@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Inter:wght@400;600;700&display=swap');

:root {
    --primary-color: #d07335;
    --secondary-color: #4a90e2;
    --success-color: #2ecc71;
    --danger-color: #e74c3c;
    --dark-bg: #1a1a2e;
    --darker-bg: #0f0f1e;
    --text-light: #ffffff;
    --text-dim: #a0a0a0;
    --glow-orange: 0 0 20px rgba(208, 115, 53, 0.6);
    --glow-blue: 0 0 20px rgba(74, 144, 226, 0.6);
}

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

body {
    font-family: 'Inter', sans-serif;
    background: #000000 !important;
    color: var(--text-light);
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 0;
}

#game-container {
    position: relative;
    width: 1280px;
    max-width: 95vw;
    background: var(--darker-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8),
                0 0 40px rgba(74, 144, 226, 0.3);
    display: flex;
    flex-direction: column;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 720px;
    flex-shrink: 0;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* HUD Bar - Between header and game canvas */
.hud-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px 20px;
    background: linear-gradient(135deg, rgba(15, 15, 30, 0.95) 0%, rgba(26, 26, 46, 0.95) 100%);
    border-bottom: 2px solid rgba(208, 115, 53, 0.3);
    flex-shrink: 0;
    z-index: 15;
    position: relative;
}

.hud-bar .stats {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

/* UI Overlay */
#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
    /* Overlay is positioned relative to canvas, which is below header */
}

.level-info h2 {
    font-family: 'Press Start 2P', cursive;
    font-size: 20px;
    color: var(--primary-color);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8),
                 var(--glow-orange);
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.era-year {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: #ffd700;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2) 0%, rgba(255, 140, 0, 0.2) 100%);
    padding: 6px 12px;
    border-radius: 6px;
    display: inline-block;
    border: 2px solid #ffd700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
    animation: yearPulse 2s ease-in-out infinite;
}

@keyframes yearPulse {
    0%, 100% {
        box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
    }
    50% {
        box-shadow: 0 0 25px rgba(255, 215, 0, 0.8);
    }
}

.stats {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 14px;
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.stat-label {
    color: var(--text-light);
    font-size: 13px;
}

.stat-total {
    color: var(--text-dim);
    font-size: 14px;
}

.health-bar {
    width: 150px;
    height: 20px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.5),
        0 0 10px rgba(0, 0, 0, 0.3);
    /* Glass effect */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.health-bar.low-health {
    animation: healthShake 0.5s ease-in-out infinite;
}

.health-bar.critical-health {
    animation: healthShake 0.3s ease-in-out infinite;
    border-color: rgba(231, 76, 60, 0.8);
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.5),
        0 0 15px rgba(231, 76, 60, 0.6);
}

@keyframes healthShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

.health-ghost {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background: rgba(255, 255, 255, 0.3);
    transition: width 1s ease-out, opacity 1s ease-out;
    opacity: 0;
    pointer-events: none;
    z-index: 1;
}

.health-ghost.show {
    opacity: 1;
}

.health-fill {
    position: relative;
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #2ecc71 0%, #27ae60 100%);
    transition: width 0.3s ease, background 0.3s ease;
    box-shadow: 
        0 0 10px rgba(46, 204, 113, 0.6),
        inset 0 -2px 4px rgba(0, 0, 0, 0.2);
    z-index: 2;
    border-radius: 4px 0 0 4px;
}

.health-fill.health-yellow {
    background: linear-gradient(90deg, #f39c12 0%, #e67e22 100%);
    box-shadow: 
        0 0 10px rgba(243, 156, 18, 0.6),
        inset 0 -2px 4px rgba(0, 0, 0, 0.2);
}

.health-fill.health-red {
    background: linear-gradient(90deg, #e74c3c 0%, #c0392b 100%);
    box-shadow: 
        0 0 15px rgba(231, 76, 60, 0.8),
        inset 0 -2px 4px rgba(0, 0, 0, 0.2);
    animation: healthPulse 1s ease-in-out infinite;
}

@keyframes healthPulse {
    0%, 100% { 
        box-shadow: 
            0 0 15px rgba(231, 76, 60, 0.8),
            inset 0 -2px 4px rgba(0, 0, 0, 0.2);
    }
    50% { 
        box-shadow: 
            0 0 25px rgba(231, 76, 60, 1),
            inset 0 -2px 4px rgba(0, 0, 0, 0.2);
    }
}

.health-glass {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.3) 0%,
        rgba(255, 255, 255, 0.1) 50%,
        transparent 100%
    );
    pointer-events: none;
    z-index: 3;
    border-radius: 4px 4px 0 0;
}

#health-value {
    color: var(--success-color);
    min-width: 40px;
}

#spice-count {
    color: var(--primary-color);
    text-shadow: var(--glow-orange);
    font-weight: 700;
    font-size: 16px;
}

#enemy-count {
    color: var(--danger-color);
    font-weight: 700;
    font-size: 16px;
}

#enemy-total {
    color: var(--text-dim);
}

#lives-count {
    color: var(--success-color);
    font-weight: 700;
    font-size: 16px;
}

.controls-hint {
    position: relative;
    margin: 20px auto;
    max-width: 1280px;
    text-align: center;
    background: rgba(15, 15, 30, 0.9);
    padding: 12px 24px;
    border-radius: 8px;
    border: 2px solid var(--secondary-color);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-light);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.controls-hint kbd {
    display: inline-block;
    padding: 4px 8px;
    background: rgba(74, 144, 226, 0.2);
    border: 2px solid var(--secondary-color);
    border-radius: 4px;
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    color: var(--secondary-color);
    margin: 0 3px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

/* Screens */
.screen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: #000000 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

/* Intro Screen */
.intro-screen {
    background: #000000;
    padding: 0;
    overflow: hidden;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 1000 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.intro-screen.hidden {
    display: none !important;
}

/* Hide controls hint when intro screen is visible */
body:has(#intro-screen:not(.hidden)) .controls-hint {
    display: none;
}

/* Loading Screen */
.loading-screen {
    background: #000000;
    padding: 0;
    overflow: hidden;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 1000 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.loading-screen.hidden {
    display: none !important;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.loading-spinner {
    width: 80px;
    height: 80px;
    border: 8px solid rgba(208, 115, 53, 0.2);
    border-top: 8px solid #ffd700;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-family: 'Press Start 2P', cursive;
    font-size: 24px;
    color: #ffd700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
    animation: loadingPulse 1.5s ease-in-out infinite;
}

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

.loading-bar {
    width: 400px;
    max-width: 80vw;
    height: 20px;
    background: rgba(208, 115, 53, 0.2);
    border: 2px solid #ffd700;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.loading-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #ffd700 0%, #ffaa00 100%);
    width: 0%;
    animation: loadingBar 3s ease-in-out forwards;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
}

@keyframes loadingBar {
    0% { width: 0%; }
    100% { width: 100%; }
}


.intro-content {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 60px;
    overflow: hidden;
}

.intro-poster {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: auto;
    height: auto;
    max-width: 95vw;
    max-height: 95vh;
    min-width: 80vw;
    min-height: 80vh;
    object-fit: contain;
    object-position: center center;
    z-index: 1;
}


.btn-lets-play {
    font-family: 'Press Start 2P', cursive;
    font-size: 20px;
    padding: 20px 50px;
    background: linear-gradient(135deg, #ffd700 0%, #ffaa00 100%);
    color: #000000;
    border: 4px solid #ffffff;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow:
        0 0 20px rgba(255, 215, 0, 0.8),
        0 0 40px rgba(255, 215, 0, 0.4),
        inset 0 -6px 0 rgba(0, 0, 0, 0.3),
        inset 0 6px 0 rgba(255, 255, 255, 0.3);
    pointer-events: all;
    z-index: 3;
    position: relative;
    text-transform: uppercase;
    letter-spacing: 3px;
    animation: buttonHighlight 2s ease-in-out infinite;
    transform: perspective(500px) rotateX(5deg);
}

@keyframes buttonHighlight {
    0%, 100% {
        box-shadow: 
            0 0 20px rgba(255, 215, 0, 0.8),
            0 0 40px rgba(255, 215, 0, 0.4),
            inset 0 -6px 0 rgba(0, 0, 0, 0.3),
            inset 0 6px 0 rgba(255, 255, 255, 0.3);
        border-color: #ffffff;
    }
    25% {
        box-shadow: 
            0 0 30px rgba(255, 215, 0, 1),
            0 0 60px rgba(255, 215, 0, 0.6),
            0 0 80px rgba(255, 215, 0, 0.3),
            inset 0 -6px 0 rgba(0, 0, 0, 0.3),
            inset 0 6px 0 rgba(255, 255, 255, 0.4);
        border-color: #ffd700;
    }
    50% {
        box-shadow: 
            0 0 40px rgba(255, 215, 0, 1),
            0 0 80px rgba(255, 215, 0, 0.8),
            0 0 120px rgba(255, 215, 0, 0.4),
            inset 0 -6px 0 rgba(0, 0, 0, 0.3),
            inset 0 6px 0 rgba(255, 255, 255, 0.5);
        border-color: #ffed4e;
        background: linear-gradient(135deg, #ffed4e 0%, #ffd700 100%);
    }
    75% {
        box-shadow: 
            0 0 30px rgba(255, 215, 0, 1),
            0 0 60px rgba(255, 215, 0, 0.6),
            0 0 80px rgba(255, 215, 0, 0.3),
            inset 0 -6px 0 rgba(0, 0, 0, 0.3),
            inset 0 6px 0 rgba(255, 255, 255, 0.4);
        border-color: #ffd700;
    }
}

.btn-lets-play:hover {
    transform: perspective(500px) rotateX(0deg) translateY(-5px) scale(1.05);
    background: linear-gradient(135deg, #ffed4e 0%, #ffd700 100%);
    box-shadow: 
        0 0 40px rgba(255, 215, 0, 1),
        0 0 80px rgba(255, 215, 0, 0.6),
        inset 0 -6px 0 rgba(0, 0, 0, 0.3),
        inset 0 6px 0 rgba(255, 255, 255, 0.5);
    animation: none;
}

.btn-lets-play:active {
    transform: perspective(500px) rotateX(5deg) translateY(0) scale(0.98);
    box-shadow: 
        0 0 15px rgba(255, 215, 0, 0.6),
        0 0 30px rgba(255, 215, 0, 0.3),
        inset 0 2px 0 rgba(0, 0, 0, 0.3),
        inset 0 -2px 0 rgba(255, 255, 255, 0.2);
}

#game-over-screen.win-screen {
    background: #000000 !important;
    pointer-events: all;
    animation: fadeIn 0.5s ease;
}

.screen.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.screen-content {
    text-align: center;
    max-width: 800px;
    padding: 40px;
    background: rgba(26, 26, 46, 0.8);
    border-radius: 16px;
    border: 3px solid var(--primary-color);
    box-shadow: 0 0 40px rgba(208, 115, 53, 0.4),
                inset 0 0 20px rgba(0, 0, 0, 0.3);
}

.game-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 36px;
    color: var(--primary-color);
    text-shadow: 4px 4px 8px rgba(0, 0, 0, 0.8),
                 var(--glow-orange);
    margin-bottom: 20px;
    animation: pulse 2s ease-in-out infinite;
}

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

.game-subtitle {
    font-size: 16px;
    color: var(--text-dim);
    margin-bottom: 30px;
}

.btn-primary {
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
    padding: 16px 32px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #b85f28 100%);
    color: var(--text-light);
    border: 3px solid #f08040;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(208, 115, 53, 0.4),
                inset 0 -4px 0 rgba(0, 0, 0, 0.2);
    pointer-events: all;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(208, 115, 53, 0.6),
                inset 0 -4px 0 rgba(0, 0, 0, 0.2);
    background: linear-gradient(135deg, #e08040 0%, #d07335 100%);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(208, 115, 53, 0.4),
                inset 0 2px 0 rgba(0, 0, 0, 0.2);
}

.btn-leaderboard-small {
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    font-weight: 600;
    padding: 12px 16px;
    min-width: 50px;
    background: linear-gradient(135deg, rgba(74, 144, 226, 0.9) 0%, rgba(58, 114, 196, 0.9) 100%);
    color: var(--text-light);
    border: 2px solid var(--secondary-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(74, 144, 226, 0.3);
    pointer-events: all;
}

.btn-leaderboard-small:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(74, 144, 226, 0.5);
    background: linear-gradient(135deg, rgba(94, 164, 246, 0.95) 0%, rgba(74, 144, 226, 0.95) 100%);
}

.btn-leaderboard-small:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.3);
}

/* Pagination Buttons */
.btn-pagination {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 12px;
    min-width: 40px;
    background: #2d2d44;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-pagination:hover {
    background: #b85f2a;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(208, 115, 53, 0.4);
}

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

.btn-pagination-active {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: bold;
    padding: 8px 12px;
    min-width: 40px;
    background: #d07335;
    color: white;
    border: 2px solid #ffd700;
    border-radius: 4px;
    cursor: default;
}

.btn-pagination-disabled {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 15px;
    background: #555;
    color: #888;
    border: none;
    border-radius: 4px;
    cursor: not-allowed;
    opacity: 0.6;
}

#pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

#pagination-controls button {
    transition: all 0.2s ease;
}

#pagination-controls span {
    color: #a0a0a0;
    padding: 0 5px;
    user-select: none;
}

.game-info {
    margin-top: 40px;
    text-align: left;
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid var(--secondary-color);
}

.game-info h3 {
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
    color: var(--secondary-color);
    margin-bottom: 15px;
}

.game-info p {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-light);
}

#level-stats {
    font-size: 18px;
    margin: 20px 0;
    color: var(--success-color);
}

#game-over-message {
    font-size: 18px;
    margin: 20px 0;
    color: var(--danger-color);
}

/* Game Over Background Images - Newspaper Style */
.game-over-background-images {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1; /* Background layer - behind dialog */
    pointer-events: none;
    overflow: hidden;
    background: transparent;
}

.game-over-background-images.newspaper-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 30px;
    padding: 50px;
}

.newspaper-image-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 8px;
    background: rgba(20, 20, 30, 0.6);
}

.newspaper-image {
    max-width: 95%;
    max-height: 95%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
    opacity: 0;
    filter: brightness(0.8);
    transition: opacity 1.5s ease-in, transform 1.5s ease-in, filter 1.5s ease-in;
    transform: scale(0.9);
}

@keyframes fadeInNewspaper {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
        filter: blur(5px);
    }
    100% {
        opacity: 0.6;
        transform: scale(1) translateY(0);
        filter: blur(0);
    }
}

/* Securitize Logo - appears above the congrats dialog */
.securitize-logo-wrapper {
    position: absolute;
    top: 3%; /* Positioned above the dialog */
    left: 50%;
    transform: translateX(-50%);
    z-index: 200; /* Highest layer - above dialog */
    text-align: center;
    opacity: 0;
    pointer-events: none;
}

.securitize-logo {
    max-width: 200px; /* Smaller logo to avoid overlap */
    width: 25vw; /* Reduced from 50vw */
    height: auto;
    filter: 
        drop-shadow(0 0 20px rgba(255, 215, 0, 0.9)) 
        drop-shadow(0 0 40px rgba(255, 215, 0, 0.6))
        drop-shadow(0 0 60px rgba(255, 215, 0, 0.3));
}

@keyframes emergeLogo {
    0% {
        opacity: 0;
        transform: translateX(-50%) scale(0.5);
        filter: blur(20px);
    }
    50% {
        opacity: 0.7;
        filter: blur(5px);
    }
    100% {
        opacity: 1;
        transform: translateX(-50%) scale(1);
        filter: blur(0);
    }
}

#game-over-screen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: #000000 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000 !important;
}

#game-over-screen.win-screen {
    background: #000000 !important;
}

#game-over-screen.win-screen .screen-content {
    margin-top: 180px; /* Push down more to make room for logo above */
    margin-bottom: 50px; /* Add bottom margin for spacing */
}

#game-over-screen .screen-content {
    position: relative;
    z-index: 100; /* Middle layer - above background images */
    background: rgba(0, 0, 0, 0.95) !important; /* Stronger background for visibility */
    border: 3px solid rgba(255, 215, 0, 0.6) !important; /* More visible border */
    box-shadow: 
        0 0 60px rgba(0, 0, 0, 1),
        0 0 80px rgba(255, 215, 0, 0.3),
        inset 0 0 30px rgba(0, 0, 0, 0.5) !important; /* Stronger shadow */
    border-radius: 12px;
    padding: 30px 40px;
    max-width: 600px;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    backdrop-filter: blur(10px); /* Additional blur for clarity */
}

/* Responsive Design */

/* 14-inch laptops (1366x768 - 1920x1080) */
@media (max-width: 1440px) and (max-height: 900px) {
    #game-container {
        width: 95vw;
        max-width: 95vw;
    }

    #gameCanvas {
        height: calc(95vw * 0.5625);
        max-height: 70vh;
    }

    .level-header {
        padding: 10px 20px;
    }

    #level-name-top {
        font-size: 16px;
    }

    .era-year-top {
        font-size: 11px;
        padding: 4px 10px;
    }

    .hud-bar {
        padding: 8px 15px;
    }

    .hud-bar .stats {
        gap: 15px;
    }

    .stat-item {
        padding: 6px 12px;
        font-size: 12px;
    }

    .stat-label {
        font-size: 11px;
    }

    .health-bar {
        width: 120px;
        height: 18px;
    }

    #health-value,
    #spice-count,
    #enemy-count,
    #lives-count {
        font-size: 14px;
    }

    .controls-hint {
        font-size: 12px;
        padding: 10px 20px;
        margin: 15px auto;
    }

    .controls-hint kbd {
        font-size: 9px;
        padding: 3px 6px;
    }

    .btn-menu {
        font-size: 12px;
        padding: 8px 16px;
    }
}

/* Extra small 14-inch laptops (1366x768) */
@media (max-width: 1400px) and (max-height: 800px) {
    #game-container {
        width: 98vw;
        max-width: 98vw;
    }

    #gameCanvas {
        height: calc(98vw * 0.5625);
        max-height: 65vh;
    }

    .level-header {
        padding: 8px 15px;
    }

    #level-name-top {
        font-size: 14px;
    }

    .hud-bar {
        padding: 6px 12px;
    }

    .hud-bar .stats {
        gap: 12px;
    }

    .stat-item {
        padding: 5px 10px;
        font-size: 11px;
    }

    .health-bar {
        width: 100px;
        height: 16px;
    }

    #win-condition-indicator {
        margin-top: 8px !important;
        padding: 6px !important;
    }

    #win-condition-indicator > div:first-child {
        font-size: 10px !important;
        margin-bottom: 2px !important;
    }

    #win-condition-text {
        font-size: 9px !important;
    }

    .controls-hint {
        font-size: 11px;
        padding: 8px 16px;
        margin: 10px auto;
    }

    .controls-hint kbd {
        font-size: 8px;
        padding: 2px 5px;
    }
}

@media (max-width: 1400px) {
    #game-container {
        width: 90vw;
    }

    #gameCanvas {
        height: calc(90vw * 0.5625);
    }
}

@media (max-width: 768px) {
    .game-title {
        font-size: 24px;
    }

    .ui-top {
        flex-direction: column;
        gap: 15px;
    }

    .stats {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .controls-hint {
        font-size: 8px;
        padding: 8px 16px;
    }
}

/* Progress Indicators */
.progress-indicator {
    display: inline-block;
    width: 80px;
    height: 8px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
    vertical-align: middle;
    margin: 0 5px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color) 0%, #f08040 100%);
    transition: width 0.3s ease;
    box-shadow: 0 0 8px rgba(208, 115, 53, 0.6);
}

/* Objective Completion Animation */
@keyframes completeFlash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.objective-complete {
    animation: completeFlash 0.5s ease 3;
}

/* Boss Health Bar Enhancement */
.boss-health-indicator {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 15, 30, 0.9);
    padding: 12px 24px;
    border-radius: 8px;
    border: 2px solid var(--danger-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    display: none;
}

.boss-health-indicator.active {
    display: block;
}

.boss-name {
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    color: var(--danger-color);
    text-align: center;
    margin-bottom: 8px;
}

.boss-health-bar {
    width: 300px;
    height: 20px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid var(--danger-color);
    border-radius: 4px;
    overflow: hidden;
}

.boss-health-fill {
    height: 100%;
    background: linear-gradient(90deg, #e74c3c 0%, #c0392b 100%);
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.6);
}

/* Secondary Button */
.btn-secondary {
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
    padding: 16px 32px;
    background: linear-gradient(135deg, #708090 0%, #556677 100%);
    color: var(--text-light);
    border: 3px solid #a9a9a9;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(112, 128, 144, 0.4),
                inset 0 -4px 0 rgba(0, 0, 0, 0.2);
    pointer-events: all;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(112, 128, 144, 0.6),
                inset 0 -4px 0 rgba(0, 0, 0, 0.2);
    background: linear-gradient(135deg, #8090a0 0%, #708090 100%);
}

.btn-secondary:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(112, 128, 144, 0.4),
                inset 0 2px 0 rgba(0, 0, 0, 0.2);
}

.btn-fastforward {
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #b85f28 100%);
    color: var(--text-light);
    border: 3px solid #f08040;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(208, 115, 53, 0.4),
                inset 0 -4px 0 rgba(0, 0, 0, 0.2);
    pointer-events: all;
    position: relative;
    overflow: hidden;
}

.btn-fastforward::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.btn-fastforward:hover::before {
    left: 100%;
}

.btn-fastforward:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(208, 115, 53, 0.6),
                inset 0 -4px 0 rgba(0, 0, 0, 0.2);
    background: linear-gradient(135deg, #e08040 0%, #d07335 100%);
}

.btn-fastforward:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(208, 115, 53, 0.4),
                inset 0 2px 0 rgba(0, 0, 0, 0.2);
}

.btn-fastforward.active {
    background: linear-gradient(135deg, #ffd700 0%, #ffa500 100%);
    border-color: #ffb520;
    box-shadow: 0 6px 25px rgba(255, 215, 0, 0.8),
                inset 0 -4px 0 rgba(0, 0, 0, 0.2);
    animation: pulse-glow 1s ease-in-out infinite;
}

.btn-fastforward.active:hover {
    background: linear-gradient(135deg, #ffd700 0%, #ffa500 100%);
    box-shadow: 0 8px 30px rgba(255, 215, 0, 1),
                inset 0 -4px 0 rgba(0, 0, 0, 0.2);
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 6px 25px rgba(255, 215, 0, 0.6),
                    inset 0 -4px 0 rgba(0, 0, 0, 0.2);
    }
    50% {
        box-shadow: 0 8px 35px rgba(255, 215, 0, 1),
                    inset 0 -4px 0 rgba(0, 0, 0, 0.2);
    }
}

/* Level Header Above Game */
.level-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background: linear-gradient(135deg, rgba(15, 15, 30, 0.95) 0%, rgba(26, 26, 46, 0.95) 100%);
    border-bottom: 3px solid var(--primary-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    flex-shrink: 0;
    z-index: 20;
    position: relative;
}

.level-title-section {
    display: flex;
    align-items: center;
    gap: 20px;
}

#level-name-top {
    font-family: 'Press Start 2P', cursive;
    font-size: 20px;
    color: var(--primary-color);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8),
                 var(--glow-orange);
    margin: 0;
    letter-spacing: 1px;
}

.era-year-top {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: #ffd700;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2) 0%, rgba(255, 140, 0, 0.2) 100%);
    padding: 6px 12px;
    border-radius: 6px;
    border: 2px solid #ffd700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
    animation: yearPulse 2s ease-in-out infinite;
}

/* Back to Menu Button */
.btn-menu {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 20px;
    background: linear-gradient(135deg, rgba(74, 144, 226, 0.8) 0%, rgba(58, 114, 196, 0.8) 100%);
    color: var(--text-light);
    border: 2px solid var(--secondary-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(74, 144, 226, 0.3);
    pointer-events: all;
}

.btn-menu:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(74, 144, 226, 0.5);
    background: linear-gradient(135deg, rgba(94, 164, 246, 0.9) 0%, rgba(74, 144, 226, 0.9) 100%);
}

.btn-menu:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.3);
}

/* UI overlay is now empty, kept for potential future overlays */

/* Briefing Screen */
#briefing-screen {
    background: linear-gradient(135deg, rgba(15, 15, 30, 0.98) 0%, rgba(26, 26, 46, 0.98) 100%);
}

.briefing-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.briefing-content {
    display: flex;
    gap: 40px;
    max-width: 1000px;
    width: 100%;
    align-items: center;
    background: rgba(26, 26, 46, 0.9);
    border-radius: 16px;
    border: 3px solid var(--primary-color);
    box-shadow: 0 0 40px rgba(208, 115, 53, 0.4),
                inset 0 0 20px rgba(0, 0, 0, 0.3);
    padding: 40px;
}

.carlos-container {
    flex-shrink: 0;
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#carlos-canvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    width: 200px;
    height: 200px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
}

.dialogue-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.dialogue-header {
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 15px;
    margin-bottom: 15px;
}

#briefing-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 18px;
    color: var(--primary-color);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8),
                 var(--glow-orange);
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.briefing-meta {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

#briefing-time-period {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: #ffd700;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2) 0%, rgba(255, 140, 0, 0.2) 100%);
    padding: 6px 12px;
    border-radius: 6px;
    border: 2px solid #ffd700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

#briefing-mission {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--secondary-color);
    background: rgba(74, 144, 226, 0.2);
    padding: 6px 12px;
    border-radius: 6px;
    border: 2px solid var(--secondary-color);
}

.dialogue-text {
    min-height: 200px;
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    line-height: 1.8;
    color: var(--text-light);
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid var(--secondary-color);
    position: relative;
}

#briefing-text {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.typing-cursor {
    display: inline-block;
    color: var(--primary-color);
    font-weight: bold;
    animation: blink 1s infinite;
    margin-left: 2px;
}

@keyframes blink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0;
    }
}

/* Responsive briefing screen */
@media (max-width: 768px) {
    .briefing-content {
        flex-direction: column;
        padding: 20px;
    }
    
    .carlos-container {
        width: 150px;
        height: 150px;
    }
    
    #carlos-canvas {
        width: 150px;
        height: 150px;
    }
    
    #briefing-title {
        font-size: 14px;
    }
    
    .dialogue-text {
        font-size: 14px;
        min-height: 150px;
    }
}

/* Floating Audio Controls (Music & SFX) */
.audio-controls {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 10000;
    display: flex;
    flex-direction: row;
    gap: 15px;
}

.audio-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    border: 3px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.audio-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(74, 144, 226, 0.6);
    border-color: rgba(255, 255, 255, 0.6);
}

.audio-toggle:active {
    transform: scale(0.95);
}

.audio-icon {
    display: block;
    line-height: 1;
}

/* SFX Toggle - Text Style */
.sfx-toggle .audio-icon {
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    font-weight: bold;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.sfx-toggle .audio-icon.paused {
    opacity: 0.5;
    text-decoration: line-through;
}


/* Game Over Dialog - Professional UI */
.game-over-dialog {
    background: linear-gradient(145deg, rgba(20, 20, 35, 0.95) 0%, rgba(10, 10, 20, 0.98) 100%) !important;
    border: 2px solid rgba(255, 100, 100, 0.4) !important;
    border-radius: 16px !important;
    padding: 35px 45px !important;
    max-width: 450px !important;
    box-shadow: 
        0 0 60px rgba(0, 0, 0, 0.9),
        0 0 30px rgba(255, 100, 100, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(10px);
}

.game-over-score-section {
    margin: 25px 0;
    text-align: center;
}

.score-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.score-label {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #a0a0a0;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.score-value {
    font-family: 'Press Start 2P', cursive;
    font-size: 32px;
    color: #ffd700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
}

.save-score-section {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.name-input {
    padding: 12px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    border: 2px solid rgba(255, 215, 0, 0.3);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    width: 180px;
    transition: all 0.3s ease;
    outline: none;
}

.name-input:focus {
    border-color: #ffd700;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.5), 
                0 0 40px rgba(255, 215, 0, 0.2);
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.02);
}

.name-input:hover {
    border-color: rgba(255, 215, 0, 0.5);
}

.name-input::placeholder {
    color: #666;
}

.btn-save-score {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 700;
    padding: 12px 20px;
    background: linear-gradient(135deg, #ffd700 0%, #ffaa00 100%);
    color: #000;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
}

.btn-save-score:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.5);
    background: linear-gradient(135deg, #ffed4e 0%, #ffd700 100%);
}

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

.game-over-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 25px;
}

.btn-game-over-primary {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 700;
    padding: 14px 28px;
    background: linear-gradient(135deg, #d07335 0%, #b85f28 100%);
    color: white;
    border: 2px solid #f08040;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(208, 115, 53, 0.4);
}

.btn-game-over-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(208, 115, 53, 0.6);
    background: linear-gradient(135deg, #e08040 0%, #d07335 100%);
}

.btn-game-over-primary:active {
    transform: translateY(0);
}

.btn-game-over-secondary {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 700;
    padding: 14px 28px;
    background: linear-gradient(135deg, rgba(80, 90, 100, 0.8) 0%, rgba(60, 70, 80, 0.8) 100%);
    color: white;
    border: 2px solid rgba(150, 160, 170, 0.5);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.btn-game-over-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(100, 110, 120, 0.4);
    background: linear-gradient(135deg, rgba(100, 110, 120, 0.9) 0%, rgba(80, 90, 100, 0.9) 100%);
    border-color: rgba(180, 190, 200, 0.6);
}

.btn-game-over-secondary:active {
    transform: translateY(0);
}


/* Test Game Over Button */
.btn-test-game-over {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    padding: 12px 24px;
    background: linear-gradient(135deg, rgba(255, 100, 100, 0.8) 0%, rgba(200, 50, 50, 0.8) 100%);
    color: white;
    border: 2px solid rgba(255, 100, 100, 0.5);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 100, 100, 0.3);
    pointer-events: all;
    z-index: 3;
    position: relative;
    margin-top: 15px;
}

.btn-test-game-over:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 100, 100, 0.5);
    background: linear-gradient(135deg, rgba(255, 120, 120, 0.9) 0%, rgba(220, 70, 70, 0.9) 100%);
}

.btn-test-game-over:active {
    transform: translateY(0);
}

/* Death Dialog - Professional UI */
.death-dialog {
    background: linear-gradient(145deg, rgba(20, 20, 35, 0.95) 0%, rgba(10, 10, 20, 0.98) 100%) !important;
    border: 2px solid rgba(255, 100, 100, 0.4) !important;
    border-radius: 16px !important;
    padding: 35px 45px !important;
    max-width: 550px !important;
    box-shadow: 
        0 0 60px rgba(0, 0, 0, 0.9),
        0 0 30px rgba(255, 100, 100, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(10px);
}

.death-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 32px;
    color: #ff4444;
    text-shadow: 0 0 20px rgba(255, 68, 68, 0.6);
    margin-bottom: 20px;
}

#death-message {
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    line-height: 1.8;
    color: #e0e0e0;
    margin: 20px 0;
}

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

/* Game Over Text Styles */
.game-over-main-text {
    font-family: 'Press Start 2P', cursive;
    font-size: 28px;
    font-weight: bold;
    line-height: 1.4;
    color: #ff6666;
    margin-bottom: 15px;
    text-shadow: 0 0 20px rgba(255, 100, 100, 0.6);
}

.game-over-sub-text {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: #a0a0a0;
    margin-top: 10px;
}


/* Music Toggle Highlight on Intro Screen */
.music-toggle-hint {
    position: fixed;
    bottom: 110px;
    right: 60px;
    z-index: 10001;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    animation: bounceHint 1.5s ease-in-out infinite;
}

.music-toggle-hint.show {
    display: flex;
}

.hint-text {
    background: linear-gradient(135deg, #ffd700 0%, #ffaa00 100%);
    color: #000;
    padding: 8px 16px;
    border-radius: 20px;
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.6);
    border: 2px solid #fff;
    white-space: nowrap;
}

.hint-arrow {
    font-size: 32px;
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
    animation: arrowBounce 1s ease-in-out infinite;
}

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

@keyframes arrowBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(5px);
    }
}
