* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: auto;
    padding: 20px;
}

#game-container {
    position: relative;
    width: 900px;
    min-height: 750px;
    background: #0f0f23;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: visible;
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 30px;
    overflow-y: auto;
}

.screen.active {
    display: flex;
}

/* Menu Screen */
#menu-screen {
    background: linear-gradient(180deg, #1e3a5f 0%, #0d1b2a 100%);
}

.game-title {
    font-size: 48px;
    color: #ffd700;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5);
    margin-bottom: 5px;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.subtitle {
    color: #87ceeb;
    font-size: 18px;
    margin-bottom: 20px;
}

.menu-section {
    margin: 15px 0;
    text-align: center;
}

.menu-section h3 {
    color: #fff;
    margin-bottom: 10px;
    font-size: 16px;
}

.menu-btn {
    background: linear-gradient(180deg, #4a90d9 0%, #357abd 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 5px;
}

.menu-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(74, 144, 217, 0.4);
}

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

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 280px;
    padding: 15px;
    background: linear-gradient(180deg, #2d4a6f 0%, #1e3a5f 100%);
    border: 2px solid transparent;
}

.mode-btn.active {
    border-color: #ffd700;
    background: linear-gradient(180deg, #3d5a7f 0%, #2e4a6f 100%);
}

.mode-icon {
    font-size: 32px;
    margin-bottom: 5px;
}

.mode-name {
    font-size: 18px;
    font-weight: bold;
}

.mode-desc {
    font-size: 12px;
    opacity: 0.8;
}

.operation-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.op-btn {
    padding: 10px 20px;
    background: linear-gradient(180deg, #2d4a6f 0%, #1e3a5f 100%);
    border: 2px solid transparent;
}

.op-btn.active {
    border-color: #ffd700;
    background: linear-gradient(180deg, #3d5a7f 0%, #2e4a6f 100%);
}

.start-btn {
    margin-top: 20px;
    padding: 15px 50px;
    font-size: 20px;
    background: linear-gradient(180deg, #4caf50 0%, #388e3c 100%);
}

.start-btn:hover {
    box-shadow: 0 5px 20px rgba(76, 175, 80, 0.4);
}

.menu-footer {
    margin-top: 20px;
    display: flex;
    gap: 15px;
}

.small-btn {
    padding: 8px 16px;
    font-size: 14px;
    background: linear-gradient(180deg, #555 0%, #333 100%);
}

.high-score {
    margin-top: 15px;
    color: #ffd700;
    font-size: 16px;
}

/* Game Screen */
#game-screen {
    padding: 0;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* HUD */
#hud {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
}

.hud-item {
    background: rgba(0, 0, 0, 0.6);
    padding: 8px 15px;
    border-radius: 8px;
    text-align: center;
    pointer-events: auto;
}

.hud-label {
    display: block;
    color: #aaa;
    font-size: 12px;
}

.hud-value {
    display: block;
    color: #fff;
    font-size: 24px;
    font-weight: bold;
}

#hud-flying .hud-value { color: #87ceeb; }
#hud-math .hud-value { color: #ffd700; }
#hud-total .hud-value { color: #4caf50; }

.hud-btn {
    background: rgba(0, 0, 0, 0.6);
    border: none;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 20px;
    cursor: pointer;
    pointer-events: auto;
    transition: background 0.2s;
}

.hud-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* Overlays */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    background: linear-gradient(180deg, #2d4a6f 0%, #1e3a5f 100%);
    padding: 30px 50px;
    border-radius: 16px;
    text-align: center;
}

.overlay-content h2 {
    color: #fff;
    margin-bottom: 20px;
}

.overlay-content p {
    color: #aaa;
    margin-bottom: 10px;
}

.mode-indicator {
    color: #ffd700;
    font-weight: bold;
}

/* Game Over Screen */
#gameover-screen {
    background: linear-gradient(180deg, #1e3a5f 0%, #0d1b2a 100%);
}

#gameover-screen h1 {
    color: #ff6b6b;
    font-size: 42px;
    margin-bottom: 20px;
}

.score-summary {
    background: rgba(0, 0, 0, 0.3);
    padding: 20px 40px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.score-row {
    display: flex;
    justify-content: space-between;
    color: #fff;
    font-size: 18px;
    padding: 8px 0;
    min-width: 250px;
}

.score-row.total {
    border-top: 2px solid #ffd700;
    margin-top: 10px;
    padding-top: 15px;
    font-size: 24px;
    color: #ffd700;
}

#new-high-score {
    justify-content: center;
    color: #4caf50;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.stats-summary {
    display: flex;
    gap: 30px;
    margin-bottom: 25px;
}

.stat-item {
    text-align: center;
    padding: 15px 25px;
    border-radius: 10px;
}

.stat-item.correct { background: rgba(76, 175, 80, 0.3); }
.stat-item.wrong { background: rgba(244, 67, 54, 0.3); }
.stat-item.passed { background: rgba(255, 193, 7, 0.3); }

.stat-value {
    display: block;
    font-size: 32px;
    font-weight: bold;
    color: #fff;
}

.stat-item.correct .stat-value { color: #4caf50; }
.stat-item.wrong .stat-value { color: #f44336; }
.stat-item.passed .stat-value { color: #ffc107; }

.stat-label {
    color: #aaa;
    font-size: 14px;
}

.gameover-buttons {
    display: flex;
    gap: 15px;
}

/* Heatmap Screen */
#heatmap-screen {
    background: linear-gradient(180deg, #1e3a5f 0%, #0d1b2a 100%);
}

#heatmap-screen h1 {
    color: #fff;
    margin-bottom: 15px;
}

.heatmap-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.tab-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 2px solid transparent;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.tab-btn.active {
    border-color: #ffd700;
    background: rgba(255, 215, 0, 0.2);
}

.heatmap-operation-toggle {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.op-toggle-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 2px solid transparent;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.op-toggle-btn.active {
    border-color: #87ceeb;
    background: rgba(135, 206, 235, 0.2);
}

.heatmap-container {
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
}

#heatmap-grid {
    display: grid;
    grid-template-columns: 35px repeat(10, 35px);
    grid-template-rows: 35px repeat(10, 35px);
    gap: 3px;
    margin-bottom: 15px;
}

.heatmap-cell {
    width: 35px;
    height: 35px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.1s;
}

.heatmap-cell:hover {
    transform: scale(1.1);
    z-index: 10;
}

.heatmap-cell.header {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: default;
}

.heatmap-cell.header:hover {
    transform: none;
}

.heatmap-cell.data {
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.heatmap-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #aaa;
    font-size: 12px;
}

.legend-gradient {
    width: 150px;
    height: 15px;
    border-radius: 4px;
    background: linear-gradient(90deg, #1a1a2e, #4caf50);
}

.legend-gradient.wrong {
    background: linear-gradient(90deg, #1a1a2e, #f44336);
}

.legend-gradient.passed {
    background: linear-gradient(90deg, #1a1a2e, #ffc107);
}

.heatmap-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 14px;
    pointer-events: none;
    z-index: 1000;
    white-space: nowrap;
}

.tooltip.hidden {
    display: none;
}

/* Feedback Overlay */
#feedback-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    transition: opacity 0.3s;
}

#feedback-overlay.hidden {
    opacity: 0;
}

#feedback-overlay.correct {
    background: rgba(76, 175, 80, 0.5);
    box-shadow: inset 0 0 100px rgba(76, 175, 80, 0.8);
}

#feedback-overlay.wrong {
    background: rgba(244, 67, 54, 0.5);
    box-shadow: inset 0 0 100px rgba(244, 67, 54, 0.8);
}

#feedback-overlay.passed {
    background: rgba(255, 193, 7, 0.4);
    box-shadow: inset 0 0 100px rgba(255, 193, 7, 0.6);
}

/* Speed Indicator */
#speed-indicator {
    position: absolute;
    top: 80px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: #ffd700;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 18px;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 50;
}

#speed-indicator.show {
    opacity: 1;
}

/* Studio Branding */
#studio-branding {
    position: fixed;
    bottom: 15px;
    right: 20px;
    text-align: right;
    z-index: 100;
}

.studio-logo {
    font-size: 18px;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 5px;
}

.copyright {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
}

/* Responsive */
@media (max-width: 850px) {
    #game-container {
        width: 100%;
        height: 100vh;
        border-radius: 0;
    }
    
    #studio-branding {
        bottom: 10px;
        right: 10px;
    }
    
    .studio-logo {
        font-size: 14px;
    }
    
    .copyright {
        font-size: 9px;
    }
}
