/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

#game-container {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

/* Screen Management */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s ease-in-out;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

/* Loading Screen */
#loading-screen {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.loading-content {
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.loading-content h1 {
    font-size: 3rem;
    margin-bottom: 2rem;
    animation: pulse 2s infinite;
}

.loading-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
    margin: 1rem 0;
}

.loading-progress {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    width: 0%;
    transition: width 0.3s ease;
    animation: shimmer 2s infinite;
}



@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes shimmer {
    0% { background-position: -200px 0; }
    100% { background-position: 200px 0; }
}

/* Main Menu */
#main-menu {
    position: relative;
    overflow: hidden;
}

.menu-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, #87CEEB 0%, #98FB98 50%, #228B22 100%);
}

.climate-scene {
    position: relative;
    width: 100%;
    height: 100%;
}

.clouds {
    position: absolute;
    top: 10%;
    width: 100%;
    height: 30%;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 20"><circle cx="20" cy="10" r="8" fill="white" opacity="0.8"/><circle cx="80" cy="10" r="6" fill="white" opacity="0.7"/></svg>') repeat-x;
    animation: float 20s infinite linear;
}

.trees {
    position: absolute;
    bottom: 30%;
    width: 100%;
    height: 20%;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 20"><polygon points="25,2 30,18 20,18" fill="%23228B22"/><polygon points="15,2 20,18 10,18" fill="%23228B22"/><polygon points="35,2 40,18 30,18" fill="%23228B22"/></svg>') repeat-x;
}

.city-skyline {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 30%;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 30"><rect x="10" y="10" width="8" height="20" fill="%23696969"/><rect x="25" y="5" width="10" height="25" fill="%23696969"/><rect x="40" y="15" width="6" height="15" fill="%23696969"/><rect x="60" y="8" width="12" height="22" fill="%23696969"/></svg>') repeat-x;
}

@keyframes float {
    0% { transform: translateX(-100px); }
    100% { transform: translateX(100px); }
}

.menu-content {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.game-title {
    font-size: 4rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(45deg, #FFD700, #FFA500, #FF6347);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.game-subtitle {
    font-size: 1.2rem;
    margin-bottom: 3rem;
    opacity: 0.9;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 250px;
}

/* Buttons */
.btn {
    padding: 1rem 2rem;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

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

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

.btn-secondary {
    background: linear-gradient(45deg, #2196F3, #1976D2);
    color: white;
    box-shadow: 0 4px 15px rgba(33, 150, 243, 0.4);
}

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

/* Game HUD */
.hud {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent);
    padding: 1rem;
    transition: opacity 0.3s ease;
    pointer-events: none; /* Allow clicking through HUD */
}

.hud * {
    pointer-events: auto; /* Re-enable clicking on HUD elements */
}

.hud.hidden {
    opacity: 0;
    pointer-events: none;
}

.hud-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.carbon-meter {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: white;
    font-weight: 600;
}

.carbon-bar {
    width: 200px;
    height: 10px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    overflow: hidden;
}

.carbon-progress {
    height: 100%;
    background: linear-gradient(90deg, #FF6B6B, #4ECDC4, #45B7D1, #96CEB4);
    width: 50%;
    transition: width 0.5s ease;
    position: relative;
}

.carbon-progress::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: progress-shimmer 2s infinite;
}

@keyframes progress-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.level-info {
    color: white;
    font-weight: 600;
    font-size: 1.1rem;
}

.badges {
    display: flex;
    gap: 0.5rem;
}

.badge {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(45deg, #FFD700, #FFA500);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    animation: badge-glow 2s infinite alternate;
}

@keyframes badge-glow {
    0% { box-shadow: 0 0 5px rgba(255, 215, 0, 0.5); }
    100% { box-shadow: 0 0 20px rgba(255, 215, 0, 0.8); }
}

/* Game Screen */
#game-screen {
    position: relative;
    z-index: 1;
}

#scene-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    z-index: 2;
}

/* Immediate Game Content */
.immediate-game {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 10 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.game-content {
    position: relative !important;
    z-index: 11 !important;
}

/* Scene Styles */
.scene {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.scene-home {
    background: linear-gradient(to bottom, #87CEEB 0%, #98FB98 100%);
}

.scene-rural {
    background: linear-gradient(to bottom, #90EE90 0%, #228B22 100%);
}

.scene-coastal {
    background: linear-gradient(to bottom, #4682B4 0%, #1E90FF 100%);
}

.scene-polar {
    background: linear-gradient(to bottom, #E0F6FF 0%, #B0E0E6 100%);
}

.scene-summit {
    background: linear-gradient(to bottom, #2C3E50 0%, #34495E 100%);
}

.scene-content {
    text-align: center;
    max-width: 800px;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.scene-title {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: #2C3E50;
}

.scene-description {
    font-size: 1.1rem;
    margin-bottom: 2rem;
    color: #34495E;
    line-height: 1.6;
}

.scene-choices {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.choice-btn {
    padding: 1rem;
    border: 2px solid #3498DB;
    background: white;
    color: #2C3E50;
    border-radius: 10px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.choice-btn:hover {
    background: #3498DB;
    color: white;
    transform: translateX(5px);
}

/* Dialogue System */
.dialogue-box {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.7));
    color: white;
    padding: 2rem;
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    transition: all 0.3s ease;
}

.dialogue-box.hidden {
    transform: translateY(100%);
    opacity: 0;
}

.character-portrait {
    flex-shrink: 0;
}

.character-portrait img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid #4ECDC4;
}

.dialogue-content {
    flex: 1;
}

.dialogue-content h3 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    color: #4ECDC4;
}

.dialogue-content p {
    font-size: 1.1rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.choices-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.choice-option {
    padding: 0.8rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.choice-option:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: #4ECDC4;
}

/* Quiz Battle */
.quiz-battle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(145deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    padding: 2rem;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    color: white;
    transition: all 0.3s ease;
}

.quiz-battle.hidden {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
    pointer-events: none;
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.quiz-header h2 {
    font-size: 1.8rem;
}

.timer {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
}

.timer.warning {
    background: rgba(255, 107, 107, 0.8);
    animation: timer-pulse 1s infinite;
}

@keyframes timer-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.quiz-content h3 {
    font-size: 1.3rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.quiz-options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

.quiz-option {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.quiz-option:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.quiz-option.correct {
    background: rgba(76, 175, 80, 0.8);
    border-color: #4CAF50;
}

.quiz-option.incorrect {
    background: rgba(244, 67, 54, 0.8);
    border-color: #F44336;
}

.quiz-feedback {
    text-align: center;
    font-size: 1.1rem;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Progress Overlay */
.progress-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.progress-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.progress-content {
    background: white;
    padding: 3rem;
    border-radius: 20px;
    text-align: center;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.progress-content h2 {
    color: #2C3E50;
    margin-bottom: 1rem;
    font-size: 2rem;
}

.progress-content p {
    color: #34495E;
    font-size: 1.1rem;
    margin-bottom: 2rem;
    line-height: 1.6;
}

.achievements {
    margin: 2rem 0;
}

.new-badge {
    display: inline-block;
    background: linear-gradient(45deg, #FFD700, #FFA500);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    margin: 0.5rem;
    font-weight: bold;
    animation: badge-appear 0.5s ease;
}

@keyframes badge-appear {
    0% { transform: scale(0) rotate(180deg); }
    100% { transform: scale(1) rotate(0deg); }
}

/* Info Screens */
.info-content, .settings-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    margin-top: 5%;
}

.info-content h2, .settings-content h2 {
    color: #2C3E50;
    text-align: center;
    margin-bottom: 2rem;
    font-size: 2.5rem;
}

.instructions {
    margin-bottom: 2rem;
}

.instruction-item {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: rgba(52, 152, 219, 0.1);
    border-radius: 10px;
    border-left: 4px solid #3498DB;
}

.instruction-item h3 {
    color: #2C3E50;
    margin-bottom: 0.5rem;
    font-size: 1.3rem;
}

.instruction-item p {
    color: #34495E;
    line-height: 1.6;
}

/* Settings */
.setting-item {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(52, 152, 219, 0.1);
    border-radius: 10px;
}

.setting-item label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #2C3E50;
}

.setting-item input, .setting-item select {
    width: 100%;
    padding: 0.5rem;
    border: 2px solid #BDC3C7;
    border-radius: 5px;
    font-size: 1rem;
}

.setting-item input:focus, .setting-item select:focus {
    outline: none;
    border-color: #3498DB;
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-title {
        font-size: 2.5rem;
    }
    
    .hud-top {
        flex-direction: column;
        gap: 1rem;
    }
    
    .carbon-bar {
        width: 150px;
    }
    
    .dialogue-box {
        flex-direction: column;
        gap: 1rem;
    }
    
    .character-portrait img {
        width: 60px;
        height: 60px;
    }
    
    .quiz-battle {
        margin: 1rem;
        width: calc(100% - 2rem);
    }
    
    .quiz-options {
        grid-template-columns: 1fr;
    }
    
    .scene-content {
        margin: 1rem;
        padding: 1.5rem;
    }
    
    .scene-title {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .btn {
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
    }
    
    .menu-buttons {
        min-width: 200px;
    }
    
    .carbon-meter {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }
    
    .info-content, .settings-content {
        margin: 1rem;
        padding: 1rem;
    }
}

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

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn-primary {
        background: #000;
        color: #fff;
        border: 2px solid #fff;
    }
    
    .btn-secondary {
        background: #fff;
        color: #000;
        border: 2px solid #000;
    }
}

/* Colorblind friendly palette */
.colorblind-mode {
    --primary-color: #0173B2;
    --secondary-color: #DE8F05;
    --success-color: #029E73;
    --warning-color: #CC78BC;
    --error-color: #D55E00;
}

.colorblind-mode .carbon-progress {
    background: linear-gradient(90deg, var(--error-color), var(--warning-color), var(--primary-color), var(--success-color));
}

.colorblind-mode .btn-primary {
    background: linear-gradient(45deg, var(--success-color), var(--primary-color));
}

.colorblind-mode .btn-secondary {
    background: linear-gradient(45deg, var(--secondary-color), var(--warning-color));
}