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

body {
    font-family: 'Comic Sans MS', cursive, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* Main game container - responsive height */
.game-container {
    width: 100%;
    height: 450px; /* Default iframe height */
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    overflow: hidden;
    position: relative;
}

/* Full screen mode detection */
@media (min-height: 500px) {
    .game-container {
        height: 90vh;
    }
}

/* Progress section */
.progress-section {
    background: linear-gradient(90deg, #4CAF50, #45a049);
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    font-weight: bold;
    font-size: 14px;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: rgba(255,255,255,0.3);
    border-radius: 4px;
    margin-right: 12px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: white;
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 4px;
}

.level-indicator {
    font-size: 12px;
    white-space: nowrap;
}

/* Main game area */
.game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Scenario backgrounds */
.scenario-background {
    flex: 1;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    transition: background-image 0.5s ease;
}

/* Default backgrounds for different scenarios */
.scenario-background.classroom {
    background: 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="%23e8f4fd" width="400" height="300"/><rect fill="%23d4e6f1" x="50" y="50" width="300" height="150" rx="10"/><rect fill="%232c3e50" x="60" y="60" width="280" height="80"/><circle fill="%23f39c12" cx="200" cy="250" r="20"/><rect fill="%238b4513" x="80" y="220" width="240" height="60" rx="5"/></svg>');
}

.scenario-background.home {
    background: 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="%23fef9e7" width="400" height="300"/><rect fill="%23d5a021" x="100" y="100" width="200" height="150"/><polygon fill="%23c0392b" points="80,100 200,50 320,100"/><rect fill="%236b4423" x="180" y="180" width="40" height="70"/><circle fill="%23f1c40f" cx="190" cy="200" r="3"/></svg>');
}

.scenario-background.school {
    background: 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="%23ecf0f1" width="400" height="300"/><rect fill="%23e74c3c" x="50" y="80" width="300" height="180"/><rect fill="%23c0392b" x="180" y="120" width="40" height="60"/><rect fill="%23f39c12" x="100" y="140" width="30" height="40"/><rect fill="%23f39c12" x="270" y="140" width="30" height="40"/></svg>');
}

/* Character area */
.character-area {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    align-items: flex-end;
}

.character {
    width: 60px;
    height: 80px;
    background: #ffeb3b;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s ease;
    border: 3px solid #fff;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.character:hover {
    transform: scale(1.1);
}

.character.selected {
    border-color: #4CAF50;
    transform: scale(1.15);
}

.character::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    background: #8d6e63;
    border-radius: 50%;
}

.character::after {
    content: attr(data-name);
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    font-weight: bold;
    color: #333;
    white-space: nowrap;
    background: rgba(255,255,255,0.9);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Skills tracker */
.skills-tracker {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(255,255,255,0.95);
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    max-width: 120px;
}

.skill-step {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px;
    border-radius: 4px;
    font-size: 10px;
    transition: all 0.3s ease;
    opacity: 0.5;
}

.skill-step.active {
    background: #e3f2fd;
    border: 2px solid #2196F3;
    opacity: 1;
}

.skill-step.completed {
    background: #e8f5e8;
    border: 2px solid #4CAF50;
    opacity: 1;
}

.step-icon {
    font-size: 12px;
    width: 16px;
    text-align: center;
}

.step-text {
    font-weight: bold;
    line-height: 1.2;
}

/* Dialogue box */
.dialogue-box {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255,255,255,0.95);
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    max-width: 90%;
    min-width: 200px;
    font-size: 14px;
    line-height: 1.4;
    position: relative;
    border: 2px solid #e0e0e0;
}

.dialogue-box::before {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid rgba(255,255,255,0.95);
}

.audio-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #2196F3;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.audio-btn:hover {
    background: #1976D2;
}

/* Decision area */
.decision-area {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: 95%;
}

.decision-btn {
    background: #2196F3;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    transition: all 0.2s ease;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    flex: 1;
    min-width: 100px;
    max-width: 150px;
}

.decision-btn:hover {
    background: #1976D2;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.decision-btn.correct {
    background: #4CAF50;
}

.decision-btn.incorrect {
    background: #f44336;
}

/* Navigation controls */
.navigation-controls {
    background: #f5f5f5;
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.nav-btn {
    background: #757575;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    transition: all 0.2s ease;
    flex: 1;
    max-width: 120px;
}

.nav-btn:hover:not(:disabled) {
    background: #616161;
    transform: translateY(-1px);
}

.nav-btn:disabled {
    background: #bdbdbd;
    cursor: not-allowed;
}

.nav-btn.primary {
    background: #4CAF50;
}

.nav-btn.primary:hover {
    background: #45a049;
}

/* Celebration overlay */
.celebration-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.celebration-overlay.show {
    display: flex;
}

.celebration-content {
    background: white;
    padding: 24px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    animation: celebrationPop 0.5s ease;
}

@keyframes celebrationPop {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.celebration-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.celebration-message {
    font-size: 18px;
    font-weight: bold;
    color: #333;
    margin-bottom: 16px;
}

.celebration-btn {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: background 0.2s ease;
}

.celebration-btn:hover {
    background: #45a049;
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1001;
    opacity: 0;
    transition: opacity 0.2s ease;
    max-width: 200px;
    text-align: center;
}

.tooltip.show {
    opacity: 1;
}

/* Mobile optimizations */
@media (max-width: 480px) {
    .skills-tracker {
        position: static;
        flex-direction: row;
        overflow-x: auto;
        max-width: none;
        margin: 8px;
        padding: 6px;
    }
    
    .skill-step {
        flex-shrink: 0;
        min-width: 80px;
    }
    
    .decision-btn {
        min-width: 80px;
        font-size: 11px;
        padding: 6px 8px;
    }
    
    .character {
        width: 50px;
        height: 70px;
    }
    
    .dialogue-box {
        font-size: 12px;
        padding: 10px 12px;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .game-container {
        border: 3px solid #000;
    }
    
    .decision-btn {
        border: 2px solid #000;
    }
    
    .skill-step.active {
        border-color: #000;
    }
}