/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
    user-select: none;
}

/* Main container - responsive height management */
#gameContainer {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Iframe detection and height adjustment */
@media (max-height: 500px) {
    #gameContainer {
        height: 450px;
    }
}

@media (min-height: 501px) {
    #gameContainer {
        height: 90vh;
    }
}

/* Progress bar styling */
#progressBar {
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 0 0 15px 15px;
    margin: 0 10px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

#progressFill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    border-radius: 0 0 15px 15px;
    width: 0%;
    transition: width 0.5s ease;
}

#progressText {
    position: relative;
    z-index: 2;
    font-weight: bold;
    color: #333;
    font-size: 14px;
}

/* Main game area */
#gameArea {
    flex: 1;
    position: relative;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: background-image 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Background scenarios */
.home-bg {
    background-image: linear-gradient(rgba(0,0,0,0.1), rgba(0,0,0,0.1)), 
                      url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 300"><rect fill="%23f4f4f4" width="400" height="300"/><rect fill="%23d4af37" x="50" y="200" width="300" height="100"/><rect fill="%23654321" x="180" y="120" width="40" height="80"/><circle fill="%23ffff00" cx="50" cy="50" r="30"/></svg>');
}

.school-bg {
    background-image: linear-gradient(rgba(0,0,0,0.1), rgba(0,0,0,0.1)), 
                      url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 300"><rect fill="%23e6f3ff" width="400" height="300"/><rect fill="%23ff6b6b" x="0" y="250" width="400" height="50"/><rect fill="%234ecdc4" x="50" y="100" width="300" height="150"/><rect fill="%23654321" x="190" y="150" width="20" height="100"/></svg>');
}

.classroom-bg {
    background-image: linear-gradient(rgba(0,0,0,0.1), rgba(0,0,0,0.1)), 
                      url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 300"><rect fill="%23fff8dc" width="400" height="300"/><rect fill="%23228b22" x="0" y="50" width="400" height="200"/><rect fill="%23000" x="50" y="80" width="300" height="120"/><rect fill="%23654321" x="20" y="220" width="60" height="40"/></svg>');
}

/* Character and NPC styling */
#character, #npc {
    position: absolute;
    transition: all 0.3s ease;
}

#character {
    left: 20%;
    bottom: 20%;
    transform: scale(1.2);
}

#npc {
    right: 20%;
    bottom: 20%;
    transform: scale(1.2);
}

#characterSprite, #npcSprite {
    font-size: 48px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    animation: bounce 2s infinite ease-in-out;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

/* Dialogue box styling */
#dialogueBox {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 20px;
    max-width: 80%;
    min-width: 300px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    border: 3px solid #4CAF50;
}

#dialogueText {
    font-size: 16px;
    line-height: 1.4;
    margin-bottom: 15px;
    color: #333;
    text-align: center;
}

#dialogueButtons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.dialogue-btn {
    background: linear-gradient(45deg, #4CAF50, #45a049);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
    min-height: 44px;
    white-space: nowrap;
}

.dialogue-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.dialogue-btn:active {
    transform: translateY(0);
}

/* Decision container */
#decisionContainer {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 20px;
    max-width: 90%;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    border: 3px solid #FF9800;
}

#decisionTitle {
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 15px;
    color: #333;
}

#decisionButtons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.decision-btn {
    background: linear-gradient(45deg, #2196F3, #1976D2);
    color: white;
    border: none;
    padding: 15px 20px;
    border-radius: 15px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(33, 150, 243, 0.3);
    text-align: left;
    min-height: 50px;
    display: flex;
    align-items: center;
}

.decision-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(33, 150, 243, 0.4);
}

.decision-btn.correct {
    background: linear-gradient(45deg, #4CAF50, #45a049);
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.decision-btn.incorrect {
    background: linear-gradient(45deg, #f44336, #d32f2f);
    box-shadow: 0 4px 15px rgba(244, 67, 54, 0.3);
}

/* Celebration message */
#celebrationMessage {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(45deg, #FFD700, #FFA500);
    border-radius: 20px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: celebrationPop 0.5s ease;
}

@keyframes celebrationPop {
    0% {
        transform: translate(-50%, -50%) scale(0);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
    }
}

#celebrationText {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
}

#celebrationSubtext {
    font-size: 16px;
    color: #555;
}

/* Bottom panel */
#bottomPanel {
    height: 80px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px 15px 0 0;
    margin: 0 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

/* Level indicator */
#levelIndicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.level-icon {
    font-size: 24px;
}

.level-text {
    font-size: 12px;
    font-weight: bold;
    color: #333;
}

/* Skills inventory */
#skillsInventory {
    display: flex;
    gap: 10px;
    flex: 1;
    justify-content: center;
    padding: 0 20px;
}

.skill-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 8px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 50px;
}

.skill-item:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: translateY(-2px);
}

.skill-icon {
    font-size: 20px;
}

.skill-status {
    font-size: 16px;
}

.skill-item.completed .skill-status {
    content: "✅";
}

/* Navigation buttons */
#navigationButtons {
    display: flex;
    gap: 10px;
}

.nav-btn {
    background: linear-gradient(45deg, #9C27B0, #7B1FA2);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 15px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(156, 39, 176, 0.3);
    min-height: 44px;
    white-space: nowrap;
}

.nav-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(156, 39, 176, 0.4);
}

/* Tooltip styling */
#tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    z-index: 1000;
    pointer-events: none;
    white-space: nowrap;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    #dialogueBox, #decisionContainer {
        max-width: 95%;
        min-width: auto;
    }
    
    #bottomPanel {
        padding: 0 10px;
    }
    
    #skillsInventory {
        gap: 5px;
        padding: 0 10px;
    }
    
    .skill-item {
        min-width: 40px;
        padding: 5px;
    }
    
    .skill-icon {
        font-size: 16px;
    }
    
    .skill-status {
        font-size: 14px;
    }
    
    #characterSprite, #npcSprite {
        font-size: 36px;
    }
}

/* Touch-friendly button sizing */
@media (hover: none) and (pointer: coarse) {
    .dialogue-btn, .decision-btn, .nav-btn {
        min-height: 48px;
        padding: 15px 20px;
    }
    
    .skill-item {
        min-width: 48px;
        min-height: 48px;
    }
}