/* Import pixel font from Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

html, body {
    height: 100%;
    height: calc(var(--vh, 1vh) * 100);
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    font-family: 'Press Start 2P', monospace;
    background: #1a1a2e;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 8px;
}

.game-container {
    background: linear-gradient(135deg, #1e3a5f 0%, #2a4a7c 50%, #1e3a5f 100%);
    padding: 12px;
    border: 4px solid #0a0f1e;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    width: 100%;
    max-width: 520px;
    /* Don't set explicit height, let content determine it */
    /* This allows proper padding on desktop while still working on mobile */
}

h1 {
    color: #00ff88;
    font-size: clamp(1em, 4vw, 1.5em);
    text-shadow: 2px 2px 0 #004422;
}

/* Header - single responsive version */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: wrap;
    padding: 0 12px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.score {
    color: #00ff88;
    font-size: 0.7em;
    padding: 6px 12px;
    white-space: nowrap;
}

.speed-meter-container {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 100px;
    max-width: 200px;
}

.speed-meter {
    flex: 1;
    height: 16px;
    background: #1a1a1a;
    border: 2px solid #333;
    overflow: hidden;
    position: relative;
}

.speed-bar {
    height: 100%;
    width: 50%;
    background: linear-gradient(90deg, #4CAF50 0%, #FFC107 50%, #FF5722 100%);
    transition: width 0.3s ease;
}


.speed-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 12px;
    background: #0a0a0a;
    border-radius: 0;
    width: 100%;
    border: 2px solid #333;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
}

.speed-label {
    font-weight: bold;
    color: #00ff88;
    font-size: 0.5em;
    text-shadow: 1px 1px 0 #002211;
}

.speed-meter {
    width: clamp(140px, 45vw, 180px);
    height: 20px;
    background: #1a1a1a;
    border-radius: 0;
    overflow: hidden;
    border: 2px solid #333;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.9);
    position: relative;
}

.speed-bar {
    height: 100%;
    /* Chunky segmented arcade gauge */
    background:
        repeating-linear-gradient(
            90deg,
            #4CAF50 0px,
            #4CAF50 10px,
            #2e7d32 10px,
            #2e7d32 11px,
            #FFC107 11px,
            #FFC107 21px,
            #ff9800 21px,
            #ff9800 22px,
            #FF5722 22px,
            #FF5722 32px,
            #d32f2f 32px,
            #d32f2f 33px
        );
    transition: width 0.3s ease;
    border-radius: 0;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.3),
        0 0 10px rgba(255, 87, 34, 0.5);
}

.info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
    width: 100%;
    gap: 12px;
    flex-wrap: wrap;
}

.score {
    font-size: 0.8em;
    font-weight: bold;
    color: #00ff88;
    padding: 8px 16px;
}


.options-btn {
    /* Chunky 3D arcade button */
    background: linear-gradient(180deg, #ff6b6b 0%, #ee5a52 50%, #d63447 100%);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 0;
    cursor: pointer;
    font-size: 0.55em;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    transition: all 0.1s;
    white-space: nowrap;
    text-shadow: 2px 2px 0 #000;
    /* 3D button effect */
    box-shadow:
        inset 0 2px 0 0 rgba(255, 255, 255, 0.3),
        inset 0 -2px 0 0 rgba(0, 0, 0, 0.3),
        0 4px 0 0 #8b1e3f,
        0 6px 8px rgba(0, 0, 0, 0.4);
    position: relative;
    top: 0;
}

.options-btn:hover {
    background: linear-gradient(180deg, #ff7b7b 0%, #fe6a62 50%, #e64457 100%);
    box-shadow:
        inset 0 2px 0 0 rgba(255, 255, 255, 0.4),
        inset 0 -2px 0 0 rgba(0, 0, 0, 0.2),
        0 4px 0 0 #8b1e3f,
        0 6px 12px rgba(0, 0, 0, 0.5);
}

.options-btn:active {
    top: 4px;
    box-shadow:
        inset 0 2px 0 0 rgba(0, 0, 0, 0.2),
        inset 0 -2px 0 0 rgba(255, 255, 255, 0.1),
        0 0 0 0 #8b1e3f,
        0 2px 4px rgba(0, 0, 0, 0.4);
}

/* Canvas wrapper - key component for proper sizing */
.canvas-wrapper {
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1 / 1;
    position: relative;
    flex-shrink: 1;
    min-height: 0;
}

#gameCanvas {
    width: 100%;
    height: 100%;
    background: #0a0a0a;
    border: 2px solid #333;
    display: block;
    position: relative;
}

.sound-effects-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    overflow: hidden;
}

.sound-effect-sprite {
    position: absolute;
    font-size: clamp(1em, 4vw, 1.5em);
    font-weight: bold;
    animation: soundEffectPop 0.6s ease-out forwards;
    pointer-events: none;
    text-shadow:
        0 0 5px currentColor,
        2px 2px 0 #000;
}

@keyframes soundEffectPop {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.5);
    }
    50% {
        transform: translate(-50%, -60%) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -80%) scale(1);
    }
}

.score-popup {
    font-size: clamp(0.8em, 3vw, 1.2em);
    animation: scorePopup 0.8s ease-out forwards;
}

@keyframes scorePopup {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    50% {
        transform: translateY(-20px) scale(1.3);
    }
    100% {
        opacity: 0;
        transform: translateY(-40px) scale(1);
    }
}

/* Mobile canvas sizing */
@media (max-width: 600px) {
    .canvas-wrapper {
        width: min(calc(100vw - 60px), 360px);
        height: min(calc(100vw - 60px), 360px);
        max-width: 100%;
        max-height: 100%;
        display: block;
        margin: 0 auto;
        flex-shrink: 1;
        min-height: 0;
        flex: 1 1 auto;
        position: relative;
    }

    #gameCanvas {
        width: 100%;
        height: 100%;
        display: block;
    }
}

.start-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
    background: linear-gradient(135deg, #1e3a5f 0%, #2a4a7c 100%);
    padding: 20px;
    border: 4px solid #0a0f1e;
    width: min(90%, 300px);
    height: fit-content;
    max-height: 80%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    z-index: 10;
    text-align: center;
}

.start-screen.hidden {
    display: none;
}

.start-screen h2 {
    color: #00ff88;
    font-size: clamp(1em, 6vw, 1.5em);
    text-shadow: 2px 2px 0 #004422;
    text-align: center;
}

.start-screen button {
    background: linear-gradient(180deg, #00ff88 0%, #00dd77 50%, #00bb66 100%);
    color: #000;
    border: none;
    padding: 12px 30px;
    font-size: clamp(0.6em, 3vw, 0.8em);
    font-family: 'Press Start 2P', 'Courier New', monospace;
    cursor: pointer;
    transition: all 0.1s;
    font-weight: bold;
    text-shadow: 0 2px 0 rgba(255, 255, 255, 0.3);
    box-shadow:
        inset 0 3px 0 0 rgba(255, 255, 255, 0.4),
        inset 0 -3px 0 0 rgba(0, 0, 0, 0.3),
        0 6px 0 0 #006644,
        0 8px 12px rgba(0, 0, 0, 0.5);
    position: relative;
    top: 0;
}

.start-screen button:hover {
    background: linear-gradient(180deg, #00ff99 0%, #00ee88 50%, #00cc77 100%);
    box-shadow:
        inset 0 3px 0 0 rgba(255, 255, 255, 0.5),
        inset 0 -3px 0 0 rgba(0, 0, 0, 0.2),
        0 6px 0 0 #006644,
        0 8px 16px rgba(0, 255, 136, 0.4);
}

.start-screen button:active {
    top: 6px;
    box-shadow:
        inset 0 3px 0 0 rgba(0, 0, 0, 0.3),
        inset 0 -3px 0 0 rgba(255, 255, 255, 0.2),
        0 0 0 0 #006644,
        0 2px 6px rgba(0, 0, 0, 0.4);
}

.start-screen p {
    font-size: 0.5em;
    color: #fff;
    text-shadow: 1px 1px 0 #000;
}

.pause-indicator {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
    background: linear-gradient(135deg, #1e3a5f 0%, #2a4a7c 100%);
    color: white;
    padding: clamp(28px, 6vw, 40px) clamp(36px, 8vw, 60px);
    border-radius: 0;
    border: 6px solid #0a0f1e;
    box-shadow:
        inset 0 0 0 4px #4a7ba7,
        inset 0 0 0 8px #2a4a7c,
        0 8px 0 0 #0f1e3a,
        0 12px 30px rgba(0, 0, 0, 0.8);
    z-index: 10;
    text-align: center;
    width: min(90%, 360px);
    height: fit-content;
    max-height: 80%;
}

.pause-indicator.hidden {
    display: none;
}

.pause-indicator h2 {
    font-size: clamp(1.3em, 7vw, 2em);
    margin-bottom: 15px;
    color: #ffaa00;
    text-shadow: 2px 2px 0 #664400;
}

.pause-indicator p {
    font-size: 0.6em;
    color: #8ab4d5;
    text-shadow: 1px 1px 0 #000;
}

/* Options Overlay */
.options-overlay {
    position: fixed;
    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;
    padding: clamp(12px, 3vw, 20px);
}

.options-overlay.hidden {
    display: none;
}

.options-container {
    background: linear-gradient(135deg, #1e3a5f 0%, #2a4a7c 100%);
    border-radius: 0;
    width: min(100%, 500px);
    max-height: 85dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Chunky arcade window border */
    border: 6px solid #0a0f1e;
    box-shadow:
        inset 0 0 0 4px #4a7ba7,
        inset 0 0 0 8px #2a4a7c,
        0 8px 0 0 #0f1e3a,
        0 12px 30px rgba(0, 0, 0, 0.8);
}

.options-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 4px solid #0a0f1e;
    background: linear-gradient(180deg, #2a4a7c 0%, #1e3a5f 100%);
}

.options-header h2 {
    margin: 0;
    color: #00ff88;
    font-size: clamp(0.8em, 4vw, 1.2em);
    text-shadow: 2px 2px 0 #004422;
}

.close-btn {
    /* Pixel X button */
    background: linear-gradient(180deg, #ff6b6b 0%, #d63447 100%);
    border: 2px solid #000;
    font-size: 1.2em;
    color: #fff;
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    transition: all 0.1s;
    text-shadow: 1px 1px 0 #000;
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.3),
        0 3px 0 #8b1e3f,
        0 4px 6px rgba(0, 0, 0, 0.5);
    position: relative;
    top: 0;
}

.close-btn:hover {
    background: linear-gradient(180deg, #ff7b7b 0%, #e64457 100%);
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.4),
        0 3px 0 #8b1e3f,
        0 4px 8px rgba(0, 0, 0, 0.6);
}

.close-btn:active {
    top: 3px;
    box-shadow:
        inset 0 2px 0 rgba(0, 0, 0, 0.3),
        0 0 0 #8b1e3f,
        0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 4px solid #0a0f1e;
    background: #1e3a5f;
    overflow-x: auto;
}

.tab-btn {
    flex: 1;
    padding: 12px 16px;
    background: linear-gradient(180deg, #2a4a7c 0%, #1e3a5f 100%);
    border: none;
    border-bottom: 4px solid transparent;
    border-right: 2px solid #0a0f1e;
    color: #8ab4d5;
    font-size: 0.45em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    text-shadow: 1px 1px 0 #000;
    position: relative;
}

.tab-btn:hover {
    background: linear-gradient(180deg, #3a5a8c 0%, #2e4a6f 100%);
    color: #00ff88;
    text-shadow: 1px 1px 0 #000;
}

.tab-btn.active {
    color: #00ff88;
    border-bottom-color: #00ff88;
    background: linear-gradient(180deg, #1e3a5f 0%, #16304f 100%);
    text-shadow: 1px 1px 0 #000;
    box-shadow: inset 0 -3px 0 #00ff88;
}

/* Tab Content */
.tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #16304f;
    color: #fff;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Settings Tab */
.setting-item {
    margin-bottom: 16px;
    text-align: left;
}

.setting-item label {
    display: block;
    margin-bottom: 6px;
    font-weight: bold;
    color: #8ab4d5;
    font-size: 0.5em;
}

.setting-item select {
    width: 100%;
    padding: 10px;
    border-radius: 0;
    border: 3px solid #0a0f1e;
    font-size: 0.6em;
    background: #0a0a0a;
    color: #00ff88;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    box-shadow:
        inset 0 0 10px rgba(0, 0, 0, 0.8),
        0 4px 0 #004422;
    cursor: pointer;
}

.setting-item select option {
    background: #0a0a0a;
    color: #00ff88;
}

.setting-item input[type="checkbox"] {
    margin-right: 8px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Rules Content */
.rules-content {
    text-align: left;
}

.rules-content h3 {
    color: #00ff88;
    margin-top: 12px;
    margin-bottom: 8px;
    font-size: 0.65em;
    text-shadow: 1px 1px 0 #002211;
}

.rules-content p {
    margin-bottom: 10px;
    color: #8ab4d5;
    line-height: 1.8;
    font-size: 0.5em;
}

.rules-content ul {
    margin-left: 20px;
    margin-bottom: 10px;
}

.rules-content li {
    margin-bottom: 6px;
    color: #8ab4d5;
    font-size: 0.5em;
    line-height: 1.6;
}

.rules-content strong {
    color: #00ff88;
}

/* Codes Tab */
.codes-content {
    text-align: center;
}

.codes-content h3 {
    color: #00ff88;
    margin-bottom: 12px;
    font-size: 0.7em;
    text-shadow: 1px 1px 0 #002211;
}

.codes-content p {
    color: #8ab4d5;
    margin-bottom: 16px;
    font-size: 0.5em;
}

.code-input-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 300px;
    margin: 0 auto;
}

#codeInput {
    padding: 12px;
    border: 3px solid #0a0f1e;
    border-radius: 0;
    font-size: 0.6em;
    text-align: center;
    outline: none;
    transition: all 0.2s;
    background: #0a0a0a;
    color: #00ff88;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    box-shadow:
        inset 0 0 10px rgba(0, 0, 0, 0.8),
        0 0 10px rgba(0, 255, 136, 0.2);
}

#codeInput:focus {
    border-color: #00ff88;
    box-shadow:
        inset 0 0 10px rgba(0, 0, 0, 0.8),
        0 0 20px rgba(0, 255, 136, 0.5);
}

#submitCodeBtn {
    background: linear-gradient(180deg, #00ff88 0%, #00dd77 50%, #00bb66 100%);
    color: #000;
    border: none;
    padding: 12px;
    border-radius: 0;
    cursor: pointer;
    font-size: 0.6em;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-weight: 600;
    transition: all 0.1s;
    text-shadow: 0 2px 0 rgba(255, 255, 255, 0.3);
    box-shadow:
        inset 0 3px 0 0 rgba(255, 255, 255, 0.4),
        inset 0 -3px 0 0 rgba(0, 0, 0, 0.3),
        0 4px 0 0 #006644,
        0 6px 8px rgba(0, 0, 0, 0.5);
    position: relative;
    top: 0;
}

#submitCodeBtn:hover {
    background: linear-gradient(180deg, #00ff99 0%, #00ee88 50%, #00cc77 100%);
}

#submitCodeBtn:active {
    top: 4px;
    box-shadow:
        inset 0 3px 0 0 rgba(0, 0, 0, 0.3),
        0 0 0 0 #006644,
        0 2px 4px rgba(0, 0, 0, 0.5);
}

/* High Scores Tab */
.scores-content {
    text-align: center;
}

.scores-content h3 {
    color: #00ff88;
    margin-bottom: 16px;
    font-size: 0.7em;
    text-shadow: 1px 1px 0 #002211;
}

.high-scores-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-width: 300px;
    margin: 0 auto;
}

.high-scores-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 1.1em;
}

.high-scores-list .rank {
    color: #667eea;
    font-weight: bold;
}

.high-scores-list .score-value {
    color: #333;
    font-weight: bold;
    font-size: 1.2em;
}

.game-over {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
    background: linear-gradient(135deg, #1e3a5f 0%, #2a4a7c 100%);
    padding: 20px;
    border: 4px solid #0a0f1e;
    width: min(90%, 300px);
    height: fit-content;
    max-height: 80%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    z-index: 10;
    text-align: center;
}

.game-over.hidden {
    display: none;
}

.game-over h2 {
    color: #ff4444;
    margin-bottom: 15px;
    font-size: clamp(1em, 6vw, 1.5em);
    text-shadow: 2px 2px 0 #660000;
    animation: gameOverFlash 0.5s ease-in-out 3;
}

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

.game-over p {
    font-size: 0.7em;
    margin-bottom: 20px;
    color: #fff;
    text-shadow: 1px 1px 0 #000;
}

/* Game Control Buttons */
.game-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    padding: 12px 0;
    flex-shrink: 0;
    width: 100%;
    max-width: 400px;
}

.game-btn {
    flex: 1;
    min-width: 100px;
    padding: 14px 16px;
    background: linear-gradient(180deg, #ff9500 0%, #dd6600 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: clamp(0.7em, 2.8vw, 0.85em);
    font-weight: bold;
    text-transform: uppercase;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 4px 0 #aa4400;
    transition: all 0.1s ease;
    white-space: nowrap;
}

.game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #aa4400;
}

.game-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #aa4400;
}

.controls {
    color: #8ab4d5;
    font-size: 0.45em;
    text-shadow: 1px 1px 0 #000;
    display: none; /* Hide WASD text */
}

.controls strong {
    color: #00ff88;
    text-shadow: 1px 1px 0 #000;
}

@media (max-width: 600px) {
    body {
        padding: 8px;
        padding-top: max(8px, env(safe-area-inset-top));
        padding-bottom: max(8px, env(safe-area-inset-bottom));
        justify-content: flex-start;
        align-items: center;
    }

    .game-container {
        width: 100%;
        gap: 8px;
        margin: 0;
        padding: 10px;
        max-height: calc(var(--vh, 1vh) * 100 - 16px);
    }

    .speed-indicator {
        flex-direction: column;
        gap: 6px;
        width: 100%;
        flex-shrink: 0;
    }

    .info-bar {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .controls {
        text-align: center;
    }
}

@media (max-width: 400px) {
    body {
        padding: clamp(10px, 5vw, 16px);
        padding-top: max(clamp(10px, 5vw, 16px), env(safe-area-inset-top));
        padding-bottom: max(clamp(10px, 5vw, 16px), env(safe-area-inset-bottom));
    }

    .game-container {
        border-radius: 16px;
    }

    .speed-meter {
        width: 100%;
    }

    .options-header h2 {
        font-size: 1.5em;
    }

    .tab-btn {
        font-size: 0.85em;
        padding: 10px 12px;
    }
}

/* D-pad - always visible */
.dpad-container {
    width: 100%;
    max-width: 400px;
    flex-shrink: 0;
}

.dpad {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 12px;
    /* Background removed - handled by theme-specific styles */
}

.dpad-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.dpad-middle {
    display: flex;
    gap: 10px;
}

.dpad-center {
    width: 65px;
    height: 65px;
    visibility: hidden;
}

.dpad-btn {
    width: 65px;
    height: 65px;
    background: linear-gradient(180deg, #ff9500 0%, #dd6600 100%);
    color: #fff;
    border: none;
    font-size: 1.8em;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 0 #aa4400;
    transition: all 0.1s;
}

.dpad-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #aa4400;
}

/* Show mobile controls on touch devices */
@media (hover: none) and (pointer: coarse) {
    .mobile-controls {
        display: block;
    }
    .controls {
        display: none;
    }
}

/* Mobile Compact Header Layout (if needed) */
@media (max-width: 600px) {
    .header-desktop {
        display: none;
    }

    .header-mobile {
        display: flex;
        flex-direction: column;
        gap: 6px;
        width: 100%;
    }

    .mobile-row-1,
    .mobile-row-2 {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
    }

    .mobile-row-1 {
        margin-bottom: 2px;
    }

    .mobile-row-1 h1 {
        margin: 0;
        font-size: 1.3em;
        flex-shrink: 0;
    }

    .score-mobile {
        font-size: 0.7em;
        font-weight: bold;
        /* Match desktop LED display style */
        color: #00ff88;
        text-shadow: 2px 2px 0 #002211;
        background: #0a0a0a;
        padding: 6px 12px;
        border: 2px solid #004422;
        box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
    }


    .options-btn-mobile {
        background: linear-gradient(180deg, #ff6b6b 0%, #ee5a52 50%, #d63447 100%);
        color: white;
        border: none;
        padding: 6px 12px;
        border-radius: 0;
        cursor: pointer;
        font-size: 0.8em;
        font-family: 'Press Start 2P', 'Courier New', monospace;
        font-weight: 600;
        transition: all 0.1s;
        text-shadow: 1px 1px 0 #000;
        box-shadow:
            inset 0 2px 0 0 rgba(255, 255, 255, 0.3),
            inset 0 -2px 0 0 rgba(0, 0, 0, 0.3),
            0 3px 0 0 #8b1e3f,
            0 4px 6px rgba(0, 0, 0, 0.4);
        position: relative;
        top: 0;
    }

    .options-btn-mobile:hover {
        background: linear-gradient(180deg, #ff7b7b 0%, #fe6a62 50%, #e64457 100%);
    }

    .options-btn-mobile:active {
        top: 3px;
        box-shadow:
            inset 0 2px 0 0 rgba(0, 0, 0, 0.3),
            0 0 0 0 #8b1e3f,
            0 1px 3px rgba(0, 0, 0, 0.4);
    }

    .speed-indicator-mobile {
        flex: 1;
        max-width: 160px;
    }

    .speed-meter-mobile {
        width: 100%;
        height: 18px;
        background: #1a1a1a;
        border-radius: 0;
        overflow: hidden;
        border: 2px solid #333;
        box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.9);
        position: relative;
    }

    .speed-meter-mobile .speed-bar {
        height: 100%;
        /* Chunky segmented arcade gauge - match desktop style */
        background:
            repeating-linear-gradient(
                90deg,
                #4CAF50 0px,
                #4CAF50 10px,
                #2e7d32 10px,
                #2e7d32 11px,
                #FFC107 11px,
                #FFC107 21px,
                #ff9800 21px,
                #ff9800 22px,
                #FF5722 22px,
                #FF5722 32px,
                #d32f2f 32px,
                #d32f2f 33px
            );
        transition: width 0.3s ease;
        border-radius: 0;
        box-shadow:
            inset 0 2px 0 rgba(255, 255, 255, 0.3),
            0 0 10px rgba(255, 87, 34, 0.5);
    }

    .game-container {
        padding: 8px;
        gap: 4px;
        overflow: hidden;
        max-height: calc(var(--vh, 1vh) * 100 - 16px);
    }

    .mobile-controls {
        margin-top: 4px;
        margin-bottom: 0;
        padding-bottom: 0;
    }

    .dpad {
        padding: 8px 10px 10px 10px;
        gap: 6px;
        margin-bottom: 0;
    }

    .dpad-btn {
        width: clamp(44px, 13vw, 56px);
        height: clamp(44px, 13vw, 56px);
    }

    .dpad-center {
        width: clamp(44px, 13vw, 56px);
        height: clamp(44px, 13vw, 56px);
    }
}

/* Compact cross layout for small/medium height screens (iPhone SE, iPhone Air with large toolbar, etc.) */
/* Use both media query AND body class for better detection */
@media (max-width: 600px) and (max-height: 800px),
(max-width: 600px) {
    body.compact-height .game-container {
        padding: 6px;
        gap: 4px;
        overflow: hidden;
        max-height: calc(var(--vh, 1vh) * 100 - 12px);
    }

    body.compact-height .mobile-controls {
        margin-top: 4px;
        margin-bottom: 0;
        padding-bottom: max(18px, env(safe-area-inset-bottom));
    }

    /* Compact cross D-pad layout using CSS Grid */
    body.compact-height .dpad {
        padding: 6px 10px 10px 10px !important;
        gap: 5px !important;
        margin-bottom: 0 !important;
        display: grid !important;
        grid-template-columns: auto auto auto !important;
        grid-template-rows: auto auto !important;
        justify-items: center !important;
        align-items: center !important;
        justify-content: center !important;
    }

    body.compact-height .dpad-up {
        /* Up button: top center */
        grid-column: 2 !important;
        grid-row: 1 !important;
    }

    body.compact-height .dpad-middle {
        /* Middle div: bottom row, left and right positions */
        display: contents !important; /* Makes children act as grid items */
    }

    body.compact-height .dpad-left {
        /* Left button: bottom row, left */
        grid-column: 1 !important;
        grid-row: 2 !important;
    }

    body.compact-height .dpad-center {
        /* Hide center spacer */
        display: none !important;
    }

    body.compact-height .dpad-right {
        /* Right button: bottom row, right */
        grid-column: 3 !important;
        grid-row: 2 !important;
    }

    body.compact-height .dpad-down {
        /* Down button: bottom row, center */
        grid-column: 2 !important;
        grid-row: 2 !important;
    }

    /* Slightly smaller buttons for compact layout */
    body.compact-height .dpad-btn {
        width: clamp(44px, 13vw, 54px);
        height: clamp(44px, 13vw, 54px);
        font-size: clamp(1.3em, 5.5vw, 1.7em);
    }

    /* Tighter header spacing */
    body.compact-height .mobile-row-1 h1 {
        font-size: 1.3em;
    }

    body.compact-height .mobile-row-1,
    body.compact-height .mobile-row-2 {
        gap: 6px;
    }
}

/* Responsive adjustments */
@media (max-width: 600px) {
    body {
        padding: 4px;
    }

    .game-container {
        padding: 8px;
        gap: 6px;
    }

    .header {
        flex-wrap: wrap;
    }

    h1 {
        font-size: 1em;
    }

    .score {
        font-size: 0.6em;
        padding: 4px 8px;
    }

    .btn {
        font-size: 0.5em;
        padding: 4px 8px;
    }
}

/* ============================================
   ARCADE THEMES
   ============================================ */

/* Base theme transitions */
.game-container {
    transition: background 0.5s ease, border-color 0.5s ease;
}

.game-btn, .dpad-btn {
    transition: all 0.2s ease;
}

/* ============================================
   1. PAC-MAN CLASSIC THEME
   ============================================ */

.game-container.theme-pacman {
    background: #000;
    border: 8px solid #FFD700;
}

.theme-pacman .header {
    background: #FFD700;
    color: #000;
    font-family: 'Press Start 2P', cursive;
}

.theme-pacman #gameCanvas {
    background: #000;
    border: 4px solid #FFD700;
    position: relative;
}

.theme-pacman .game-btn {
    background: #FFD700;
    color: #000;
    font-weight: bold;
    box-shadow: 0 4px 0 #B8960A;
}

.theme-pacman .game-btn:hover {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #B8960A;
}

.theme-pacman .speed-meter-container {
    background: #000;
    border: 2px solid #FFD700;
}

.theme-pacman .speed-bar {
    background: linear-gradient(90deg, #FFD700 0%, #FFA500 100%);
}

.theme-pacman .dpad {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    border: 3px solid #FFD700;
    border-radius: 12px;
    padding: 12px;
}

.theme-pacman .dpad-btn {
    background: linear-gradient(180deg, #FFD700 0%, #FFA500 100%);
    color: #000;
    font-weight: bold;
    box-shadow: 0 3px 0 #B8960A;
}

/* ============================================
   2. SPACE INVADERS THEME
   ============================================ */

.game-container.theme-space-invaders {
    background: #0a0a0a;
    border: 8px solid #00ff00;
    position: relative;
}

.game-container.theme-space-invaders::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 255, 0, 0.03) 2px,
        rgba(0, 255, 0, 0.03) 4px
    );
    pointer-events: none;
    animation: scanline 8s linear infinite;
    z-index: 1;
}

@keyframes scanline {
    0% { transform: translateY(0); }
    100% { transform: translateY(20px); }
}

.theme-space-invaders .header {
    background: rgba(0, 255, 0, 0.2);
    color: #00ff00;
    font-family: 'VT323', monospace;
    font-size: 16px;
    border: 2px solid #00ff00;
    text-shadow: 0 0 10px #00ff00;
    z-index: 2;
    position: relative;
}

.theme-space-invaders #gameCanvas {
    background: #000;
    border: 2px solid #00ff00;
    box-shadow: inset 0 0 20px rgba(0, 255, 0, 0.3);
    z-index: 2;
    position: relative;
}

.theme-space-invaders .game-btn {
    background: #000;
    color: #00ff00;
    border: 2px solid #00ff00;
    font-family: 'VT323', monospace;
    font-size: 14px;
    text-shadow: 0 0 5px #00ff00;
    z-index: 2;
    position: relative;
}

.theme-space-invaders .game-btn:hover {
    background: rgba(0, 255, 0, 0.2);
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.5);
}

.theme-space-invaders .speed-meter-container {
    background: #000;
    border: 2px solid #00ff00;
    box-shadow: inset 0 0 10px rgba(0, 255, 0, 0.3);
}

.theme-space-invaders .speed-bar {
    background: #00ff00;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
}

.theme-space-invaders .dpad {
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ff00;
    border-radius: 12px;
    padding: 12px;
    z-index: 2;
    position: relative;
}

.theme-space-invaders .dpad-btn {
    background: #000;
    color: #00ff00;
    border: 2px solid #00ff00;
    font-family: 'VT323', monospace;
    font-size: 1.4em;
    text-shadow: 0 0 5px #00ff00;
}

/* ============================================
   3. DONKEY KONG THEME
   ============================================ */

.game-container.theme-donkey-kong {
    background: #1a4d8f;
    border: 12px solid #d32f2f;
}

.theme-donkey-kong .header {
    background: linear-gradient(180deg, #d32f2f 0%, #b71c1c 100%);
    color: #fff;
    font-family: 'Press Start 2P', cursive;
    border: 3px solid #000;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}

.theme-donkey-kong #gameCanvas {
    background: linear-gradient(180deg, #1976d2 0%, #0d47a1 100%);
    border: 4px solid #000;
}

.theme-donkey-kong .game-btn {
    background: linear-gradient(180deg, #ffc107 0%, #ff6f00 100%);
    color: #000;
    border: 3px solid #000;
    font-weight: bold;
    box-shadow: 0 6px 0 #5d4037;
}

.theme-donkey-kong .game-btn:hover {
    transform: translateY(3px);
    box-shadow: 0 3px 0 #5d4037;
}

.theme-donkey-kong .speed-meter-container {
    background: #0d47a1;
    border: 3px solid #d32f2f;
}

.theme-donkey-kong .speed-bar {
    background: linear-gradient(90deg, #ffc107 0%, #ff6f00 100%);
}

.theme-donkey-kong .dpad {
    background: linear-gradient(180deg, #1976d2 0%, #0d47a1 100%);
    border: 3px solid #d32f2f;
    border-radius: 12px;
    padding: 12px;
}

.theme-donkey-kong .dpad-btn {
    background: linear-gradient(180deg, #ffc107 0%, #ff6f00 100%);
    color: #000;
    border: 3px solid #000;
    font-weight: bold;
    box-shadow: 0 4px 0 #5d4037;
}

/* ============================================
   4. GALAGA COSMIC THEME (DEFAULT)
   ============================================ */

.game-container.theme-galaga {
    background: linear-gradient(180deg, #0a0a2e 0%, #16213e 100%);
    border: 8px solid #4a5568;
    position: relative;
}

.game-container.theme-galaga::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(2px 2px at 20% 30%, white, transparent),
        radial-gradient(2px 2px at 60% 70%, white, transparent),
        radial-gradient(1px 1px at 50% 50%, white, transparent),
        radial-gradient(1px 1px at 80% 10%, white, transparent),
        radial-gradient(2px 2px at 90% 60%, white, transparent),
        radial-gradient(1px 1px at 33% 75%, white, transparent),
        radial-gradient(1px 1px at 15% 85%, white, transparent);
    background-size: 200px 200px;
    background-position: 0 0, 40px 60px, 130px 270px, 70px 100px, 150px 30px, 90px 180px, 40px 220px;
    animation: stars 60s linear infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes stars {
    0% { transform: translateY(0); }
    100% { transform: translateY(200px); }
}

.theme-galaga .header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-family: 'Orbitron', sans-serif;
    border: 2px solid #9333ea;
    box-shadow: 0 0 20px rgba(147, 51, 234, 0.5);
    z-index: 2;
    position: relative;
}

.theme-galaga #gameCanvas {
    background: rgba(0, 0, 0, 0.7);
    border: 3px solid #667eea;
    box-shadow:
        0 0 20px rgba(102, 126, 234, 0.5),
        inset 0 0 30px rgba(102, 126, 234, 0.2);
    z-index: 2;
    position: relative;
}

.theme-galaga .game-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: 2px solid #9333ea;
    font-family: 'Orbitron', sans-serif;
    box-shadow: 0 4px 15px rgba(147, 51, 234, 0.4);
    z-index: 2;
    position: relative;
}

.theme-galaga .game-btn:hover {
    box-shadow: 0 6px 20px rgba(147, 51, 234, 0.6);
    transform: translateY(-2px);
}

.theme-galaga .speed-meter-container {
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #667eea;
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.4);
}

.theme-galaga .speed-bar {
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 0 10px rgba(147, 51, 234, 0.6);
}

.theme-galaga .dpad {
    background: linear-gradient(135deg, #0a0a2e 0%, #16213e 100%);
    border: 2px solid #667eea;
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.4);
    border-radius: 12px;
    padding: 12px;
    z-index: 2;
    position: relative;
}

.theme-galaga .dpad-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: 2px solid #9333ea;
    font-family: 'Orbitron', sans-serif;
    box-shadow: 0 3px 10px rgba(147, 51, 234, 0.4);
}

/* ============================================
   5. NEO GEO MVS THEME
   ============================================ */

.game-container.theme-neogeo {
    background: linear-gradient(180deg, #1a1a1a 0%, #2d2d2d 100%);
    border: 10px solid #e63946;
}

.theme-neogeo .header {
    background: linear-gradient(90deg, #e63946 0%, #f1faee 50%, #457b9d 100%);
    color: #000;
    font-family: 'Bungee', cursive;
    border: 3px solid #000;
    font-weight: 900;
    text-transform: uppercase;
}

.theme-neogeo #gameCanvas {
    background: #000;
    border: 6px solid #f1faee;
    box-shadow:
        inset 0 0 0 2px #e63946,
        inset 0 0 0 4px #457b9d;
}

.theme-neogeo .game-btn {
    background: radial-gradient(circle at 30% 30%, #ff6b6b, #e63946);
    color: #fff;
    border: 4px solid #000;
    font-family: 'Bungee', cursive;
    text-transform: uppercase;
    box-shadow:
        0 6px 0 #8b0000,
        0 8px 15px rgba(0,0,0,0.5);
}

.theme-neogeo .game-btn:hover {
    transform: translateY(3px);
    box-shadow:
        0 3px 0 #8b0000,
        0 5px 10px rgba(0,0,0,0.5);
}

.theme-neogeo .speed-meter-container {
    background: #000;
    border: 3px solid #e63946;
    box-shadow: inset 0 0 0 1px #f1faee, inset 0 0 0 2px #457b9d;
}

.theme-neogeo .speed-bar {
    background: linear-gradient(90deg, #e63946 0%, #f1faee 50%, #457b9d 100%);
}

.theme-neogeo .dpad {
    background: linear-gradient(180deg, #1a1a1a 0%, #2d2d2d 100%);
    border: 4px solid #e63946;
    border-radius: 12px;
    padding: 12px;
}

.theme-neogeo .dpad-btn {
    background: radial-gradient(circle at 30% 30%, #ff6b6b, #e63946);
    color: #fff;
    border: 4px solid #000;
    font-family: 'Bungee', cursive;
    text-transform: uppercase;
    box-shadow: 0 4px 0 #8b0000;
}

/* ============================================
   6. TRON NEON THEME
   ============================================ */

.game-container.theme-tron {
    background: #000;
    border: 6px solid #00d9ff;
    position: relative;
}

.game-container.theme-tron::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 40px,
            rgba(0, 217, 255, 0.1) 40px,
            rgba(0, 217, 255, 0.1) 41px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 40px,
            rgba(0, 217, 255, 0.1) 40px,
            rgba(0, 217, 255, 0.1) 41px
        );
    pointer-events: none;
    z-index: 1;
}

.theme-tron .header {
    background: rgba(0, 217, 255, 0.1);
    color: #00d9ff;
    font-family: 'Orbitron', sans-serif;
    border: 2px solid #00d9ff;
    text-shadow: 0 0 10px #00d9ff;
    box-shadow: 0 0 20px rgba(0, 217, 255, 0.5);
    z-index: 2;
    position: relative;
}

.theme-tron #gameCanvas {
    background: radial-gradient(circle at center, #001a33 0%, #000 100%);
    border: 2px solid #00d9ff;
    box-shadow:
        0 0 20px rgba(0, 217, 255, 0.5),
        inset 0 0 40px rgba(0, 217, 255, 0.2);
    z-index: 2;
    position: relative;
}

.theme-tron .game-btn {
    background: transparent;
    color: #00d9ff;
    border: 2px solid #00d9ff;
    font-family: 'Orbitron', sans-serif;
    text-shadow: 0 0 5px #00d9ff;
    box-shadow:
        0 0 10px rgba(0, 217, 255, 0.5),
        inset 0 0 10px rgba(0, 217, 255, 0.2);
    z-index: 2;
    position: relative;
}

.theme-tron .game-btn:hover {
    background: rgba(0, 217, 255, 0.2);
    box-shadow:
        0 0 20px rgba(0, 217, 255, 0.8),
        inset 0 0 20px rgba(0, 217, 255, 0.3);
}

.theme-tron .speed-meter-container {
    background: rgba(0, 26, 51, 0.8);
    border: 2px solid #00d9ff;
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.5), inset 0 0 15px rgba(0, 217, 255, 0.2);
}

.theme-tron .speed-bar {
    background: #00d9ff;
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.8);
    text-shadow: 0 0 10px #00d9ff;
}

.theme-tron .dpad {
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid #00d9ff;
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.5);
    border-radius: 12px;
    padding: 12px;
    z-index: 2;
    position: relative;
}

.theme-tron .dpad-btn {
    background: transparent;
    color: #00d9ff;
    border: 2px solid #00d9ff;
    font-family: 'Orbitron', sans-serif;
    text-shadow: 0 0 5px #00d9ff;
    box-shadow: 0 0 10px rgba(0, 217, 255, 0.5), inset 0 0 10px rgba(0, 217, 255, 0.2);
}

/* ============================================
   7. OUTRUN SYNTHWAVE THEME
   ============================================ */

.game-container.theme-outrun {
    background: linear-gradient(180deg, #1a0033 0%, #2d0052 50%, #0d0221 100%);
    border: 8px solid #ff006e;
    position: relative;
}

.game-container.theme-outrun::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60%;
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 20px,
            rgba(255, 0, 110, 0.3) 20px,
            rgba(255, 0, 110, 0.3) 21px
        ),
        linear-gradient(180deg, transparent 0%, rgba(13, 2, 33, 0.9) 100%);
    transform: perspective(200px) rotateX(60deg);
    transform-origin: bottom;
    pointer-events: none;
    z-index: 1;
}

.theme-outrun .header {
    background: linear-gradient(90deg, #ff006e 0%, #8338ec 50%, #00f5ff 100%);
    color: #fff;
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    border: 2px solid #ff006e;
    text-shadow:
        0 0 10px #ff006e,
        0 0 20px #8338ec;
    z-index: 2;
    position: relative;
}

.theme-outrun #gameCanvas {
    background: radial-gradient(ellipse at top, #2d0052 0%, #0d0221 100%);
    border: 3px solid #00f5ff;
    box-shadow:
        0 0 30px rgba(255, 0, 110, 0.5),
        inset 0 0 40px rgba(131, 56, 236, 0.3);
    z-index: 2;
    position: relative;
}

.theme-outrun .game-btn {
    background: linear-gradient(135deg, #ff006e 0%, #8338ec 100%);
    color: #fff;
    border: 2px solid #00f5ff;
    font-family: 'Orbitron', sans-serif;
    font-weight: bold;
    text-shadow: 0 0 5px #fff;
    box-shadow:
        0 4px 15px rgba(255, 0, 110, 0.5),
        0 0 20px rgba(131, 56, 236, 0.3);
    z-index: 2;
    position: relative;
}

.theme-outrun .game-btn:hover {
    box-shadow:
        0 6px 20px rgba(255, 0, 110, 0.7),
        0 0 30px rgba(131, 56, 236, 0.5);
    transform: translateY(-2px);
}

.theme-outrun .speed-meter-container {
    background: radial-gradient(ellipse at top, #2d0052 0%, #0d0221 100%);
    border: 2px solid #ff006e;
    box-shadow: 0 0 20px rgba(255, 0, 110, 0.5), inset 0 0 20px rgba(131, 56, 236, 0.3);
}

.theme-outrun .speed-bar {
    background: linear-gradient(90deg, #ff006e 0%, #8338ec 50%, #00f5ff 100%);
    box-shadow: 0 0 15px rgba(255, 0, 110, 0.6);
}

.theme-outrun .dpad {
    background: linear-gradient(180deg, #1a0033 0%, #0d0221 100%);
    border: 2px solid #ff006e;
    box-shadow: 0 0 20px rgba(255, 0, 110, 0.5);
    border-radius: 12px;
    padding: 12px;
    z-index: 2;
    position: relative;
}

.theme-outrun .dpad-btn {
    background: linear-gradient(135deg, #ff006e 0%, #8338ec 100%);
    color: #fff;
    border: 2px solid #00f5ff;
    font-family: 'Orbitron', sans-serif;
    font-weight: bold;
    text-shadow: 0 0 5px #fff;
    box-shadow: 0 3px 10px rgba(255, 0, 110, 0.5);
}

/* ============================================
   8. STREET FIGHTER II THEME
   ============================================ */

.game-container.theme-street-fighter {
    background: linear-gradient(135deg, #c41e3a 0%, #8b0000 100%);
    border: 10px solid #ffd700;
}

.theme-street-fighter .header {
    background: linear-gradient(180deg, #ffd700 0%, #ffed4e 100%);
    color: #8b0000;
    font-family: 'Bungee', cursive;
    font-weight: 900;
    border: 4px solid #8b0000;
    text-transform: uppercase;
    text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.5);
}

.theme-street-fighter #gameCanvas {
    background: linear-gradient(180deg, #1a1a1a 0%, #000 100%);
    border: 6px solid #ffd700;
    box-shadow:
        inset 0 0 0 3px #8b0000,
        0 10px 30px rgba(0,0,0,0.5);
}

.theme-street-fighter .game-btn {
    background: radial-gradient(circle at 30% 30%, #ff4444, #c41e3a);
    color: #fff;
    border: 4px solid #ffd700;
    font-family: 'Bungee', cursive;
    text-transform: uppercase;
    font-weight: 900;
    box-shadow:
        0 6px 0 #8b0000,
        0 8px 20px rgba(0,0,0,0.5);
}

.theme-street-fighter .game-btn:hover {
    transform: translateY(3px);
    box-shadow:
        0 3px 0 #8b0000,
        0 5px 15px rgba(0,0,0,0.5);
}

.theme-street-fighter .speed-meter-container {
    background: #000;
    border: 4px solid #ffd700;
    box-shadow: inset 0 0 0 2px #8b0000;
}

.theme-street-fighter .speed-bar {
    background: linear-gradient(90deg, #c41e3a 0%, #ffd700 100%);
}

.theme-street-fighter .dpad {
    background: linear-gradient(135deg, #c41e3a 0%, #8b0000 100%);
    border: 4px solid #ffd700;
    border-radius: 12px;
    padding: 12px;
}

.theme-street-fighter .dpad-btn {
    background: radial-gradient(circle at 30% 30%, #ff4444, #c41e3a);
    color: #fff;
    border: 4px solid #ffd700;
    font-family: 'Bungee', cursive;
    text-transform: uppercase;
    font-weight: 900;
    box-shadow: 0 4px 0 #8b0000;
}

/* ============================================
   THEME-SPECIFIC OVERLAYS
   ============================================ */

/* PAC-MAN Overlays */
.theme-pacman .start-screen,
.theme-pacman .game-over,
.theme-pacman .pause-indicator {
    background: #000;
    border: 6px solid #FFD700;
    box-shadow: inset 0 0 0 3px #000, 0 8px 0 0 #B8960A;
}

.theme-pacman .start-screen h2,
.theme-pacman .pause-indicator h2 {
    color: #FFD700;
    text-shadow: 2px 2px 0 #B8960A;
    font-family: 'Press Start 2P', cursive;
}

.theme-pacman .game-over h2 {
    color: #FFD700;
    text-shadow: 2px 2px 0 #B8960A;
    font-family: 'Press Start 2P', cursive;
}

.theme-pacman .start-screen p,
.theme-pacman .game-over p,
.theme-pacman .pause-indicator p {
    color: #FFD700;
}

/* SPACE INVADERS Overlays */
.theme-space-invaders .start-screen,
.theme-space-invaders .game-over,
.theme-space-invaders .pause-indicator {
    background: #000;
    border: 4px solid #00ff00;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.5);
}

.theme-space-invaders .start-screen h2,
.theme-space-invaders .pause-indicator h2 {
    color: #00ff00;
    text-shadow: 0 0 10px #00ff00;
    font-family: 'VT323', monospace;
    font-size: clamp(1.5em, 7vw, 2em);
}

.theme-space-invaders .game-over h2 {
    color: #00ff00;
    text-shadow: 0 0 10px #00ff00;
    font-family: 'VT323', monospace;
    font-size: clamp(1.5em, 7vw, 2em);
}

.theme-space-invaders .start-screen p,
.theme-space-invaders .game-over p,
.theme-space-invaders .pause-indicator p {
    color: #00ff00;
    font-family: 'VT323', monospace;
    font-size: 0.8em;
}

/* DONKEY KONG Overlays */
.theme-donkey-kong .start-screen,
.theme-donkey-kong .game-over,
.theme-donkey-kong .pause-indicator {
    background: linear-gradient(180deg, #d32f2f 0%, #b71c1c 100%);
    border: 6px solid #000;
    box-shadow: inset 0 0 0 3px #ffc107, 0 8px 0 0 #5d4037;
}

.theme-donkey-kong .start-screen h2,
.theme-donkey-kong .pause-indicator h2 {
    color: #ffc107;
    text-shadow: 3px 3px 0 #000;
    font-family: 'Press Start 2P', cursive;
}

.theme-donkey-kong .game-over h2 {
    color: #ffc107;
    text-shadow: 3px 3px 0 #000;
    font-family: 'Press Start 2P', cursive;
}

.theme-donkey-kong .start-screen p,
.theme-donkey-kong .game-over p,
.theme-donkey-kong .pause-indicator p {
    color: #fff;
}

/* GALAGA Overlays */
.theme-galaga .start-screen,
.theme-galaga .game-over,
.theme-galaga .pause-indicator {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 4px solid #9333ea;
    box-shadow: 0 0 30px rgba(147, 51, 234, 0.6), inset 0 0 20px rgba(0, 0, 0, 0.3);
}

.theme-galaga .start-screen h2,
.theme-galaga .pause-indicator h2 {
    color: #fff;
    text-shadow: 0 0 15px #00f5ff, 2px 2px 0 #000;
    font-family: 'Orbitron', sans-serif;
}

.theme-galaga .game-over h2 {
    color: #ff006e;
    text-shadow: 0 0 15px #ff006e, 2px 2px 0 #000;
    font-family: 'Orbitron', sans-serif;
}

.theme-galaga .start-screen p,
.theme-galaga .game-over p,
.theme-galaga .pause-indicator p {
    color: #fff;
}

/* NEO GEO Overlays */
.theme-neogeo .start-screen,
.theme-neogeo .game-over,
.theme-neogeo .pause-indicator {
    background: linear-gradient(90deg, #e63946 0%, #f1faee 50%, #457b9d 100%);
    border: 6px solid #000;
    box-shadow: 0 8px 0 0 #8b0000;
}

.theme-neogeo .start-screen h2,
.theme-neogeo .pause-indicator h2 {
    color: #000;
    text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.5);
    font-family: 'Bungee', cursive;
    text-transform: uppercase;
}

.theme-neogeo .game-over h2 {
    color: #000;
    text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.5);
    font-family: 'Bungee', cursive;
    text-transform: uppercase;
}

.theme-neogeo .start-screen p,
.theme-neogeo .game-over p,
.theme-neogeo .pause-indicator p {
    color: #000;
    font-weight: bold;
}

/* TRON Overlays */
.theme-tron .start-screen,
.theme-tron .game-over,
.theme-tron .pause-indicator {
    background: rgba(0, 26, 51, 0.95);
    border: 3px solid #00d9ff;
    box-shadow: 0 0 30px rgba(0, 217, 255, 0.8), inset 0 0 30px rgba(0, 217, 255, 0.2);
}

.theme-tron .start-screen h2,
.theme-tron .pause-indicator h2 {
    color: #00d9ff;
    text-shadow: 0 0 15px #00d9ff, 0 0 30px #00d9ff;
    font-family: 'Orbitron', sans-serif;
}

.theme-tron .game-over h2 {
    color: #ff006e;
    text-shadow: 0 0 15px #ff006e, 0 0 30px #ff006e;
    font-family: 'Orbitron', sans-serif;
}

.theme-tron .start-screen p,
.theme-tron .game-over p,
.theme-tron .pause-indicator p {
    color: #00d9ff;
    text-shadow: 0 0 5px #00d9ff;
}

/* OUTRUN Overlays */
.theme-outrun .start-screen,
.theme-outrun .game-over,
.theme-outrun .pause-indicator {
    background: linear-gradient(135deg, #ff006e 0%, #8338ec 50%, #00f5ff 100%);
    border: 4px solid #ff006e;
    box-shadow: 0 0 40px rgba(255, 0, 110, 0.8), 0 0 20px rgba(131, 56, 236, 0.5);
}

.theme-outrun .start-screen h2,
.theme-outrun .pause-indicator h2 {
    color: #fff;
    text-shadow: 0 0 15px #00f5ff, 2px 2px 0 #000;
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
}

.theme-outrun .game-over h2 {
    color: #fff;
    text-shadow: 0 0 15px #ff006e, 2px 2px 0 #000;
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
}

.theme-outrun .start-screen p,
.theme-outrun .game-over p,
.theme-outrun .pause-indicator p {
    color: #fff;
    text-shadow: 0 0 5px #000;
}

/* STREET FIGHTER Overlays */
.theme-street-fighter .start-screen,
.theme-street-fighter .game-over,
.theme-street-fighter .pause-indicator {
    background: linear-gradient(180deg, #ffd700 0%, #ffed4e 100%);
    border: 8px solid #8b0000;
    box-shadow: inset 0 0 0 4px #ffd700, 0 8px 0 0 #5d0000;
}

.theme-street-fighter .start-screen h2,
.theme-street-fighter .pause-indicator h2 {
    color: #8b0000;
    text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.5);
    font-family: 'Bungee', cursive;
    text-transform: uppercase;
    font-weight: 900;
}

.theme-street-fighter .game-over h2 {
    color: #c41e3a;
    text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.5);
    font-family: 'Bungee', cursive;
    text-transform: uppercase;
    font-weight: 900;
}

.theme-street-fighter .start-screen p,
.theme-street-fighter .game-over p,
.theme-street-fighter .pause-indicator p {
    color: #8b0000;
    font-weight: bold;
}

/* ============================================
   9. GAME BOY COLOR THEME
   ============================================ */

.game-container.theme-gameboy {
    background: linear-gradient(135deg, #7b68a6 0%, #5a4a7a 50%, #4a3a6a 100%);
    border: 12px solid #2d1f4a;
    box-shadow: inset 0 0 20px rgba(123, 104, 166, 0.3);
}

.theme-gameboy .header {
    background: linear-gradient(180deg, #9b8fc9 0%, #7b68a6 100%);
    color: #2d1f4a;
    font-family: 'Press Start 2P', cursive;
    border: 3px solid #2d1f4a;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.2);
}

.theme-gameboy #gameCanvas {
    background: linear-gradient(135deg, #e8f4f8 0%, #d0e8f0 100%);
    border: 6px solid #2d1f4a;
    box-shadow:
        inset 0 0 0 3px #7b68a6,
        inset 0 0 30px rgba(123, 104, 166, 0.15),
        0 0 40px rgba(232, 244, 248, 0.5);
    position: relative;
}

/* LCD screen scanline effect */
.theme-gameboy #gameCanvas::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.05) 2px,
        rgba(0, 0, 0, 0.05) 4px
    );
    pointer-events: none;
}

.theme-gameboy .game-btn {
    background: linear-gradient(180deg, #9b8fc9 0%, #7b68a6 50%, #5a4a7a 100%);
    color: #fff;
    border: 4px solid #2d1f4a;
    font-family: 'Press Start 2P', cursive;
    font-weight: bold;
    box-shadow:
        0 6px 0 #2d1f4a,
        0 8px 15px rgba(0,0,0,0.4);
}

.theme-gameboy .game-btn:hover {
    transform: translateY(3px);
    box-shadow:
        0 3px 0 #2d1f4a,
        0 5px 10px rgba(0,0,0,0.4);
}

.theme-gameboy .speed-meter-container {
    background: rgba(45, 31, 74, 0.8);
    border: 3px solid #2d1f4a;
    box-shadow: inset 0 0 0 1px #7b68a6;
}

.theme-gameboy .speed-bar {
    background: linear-gradient(90deg, #0f380f 0%, #306230 50%, #8bac0f 100%);
}

.theme-gameboy .dpad {
    background: linear-gradient(180deg, #7b68a6 0%, #5a4a7a 100%);
    border: 4px solid #2d1f4a;
    border-radius: 12px;
    padding: 12px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.3);
}

.theme-gameboy .dpad-btn {
    background: linear-gradient(180deg, #4a4a5a 0%, #2d2d3a 100%);
    color: #fff;
    border: 3px solid #1a1a2a;
    font-weight: bold;
    box-shadow: 0 4px 0 #1a1a2a;
}

/* ============================================
   GAME BOY THEME OVERLAYS
   ============================================ */

.theme-gameboy .start-screen,
.theme-gameboy .game-over,
.theme-gameboy .pause-indicator {
    background: linear-gradient(135deg, #7b68a6 0%, #5a4a7a 100%);
    border: 6px solid #2d1f4a;
    box-shadow: inset 0 0 0 3px #9b8fc9, 0 8px 0 0 #1a0f2a;
}

.theme-gameboy .start-screen h2,
.theme-gameboy .pause-indicator h2 {
    color: #9bbc0f;
    text-shadow: 2px 2px 0 #0f380f;
    font-family: 'Press Start 2P', cursive;
}

.theme-gameboy .game-over h2 {
    color: #9bbc0f;
    text-shadow: 2px 2px 0 #0f380f;
    font-family: 'Press Start 2P', cursive;
}

.theme-gameboy .start-screen p,
.theme-gameboy .game-over p,
.theme-gameboy .pause-indicator p {
    color: #fff;
    text-shadow: 1px 1px 0 #2d1f4a;
}

/* ============================================
   GAME BOY THEME HEADER SCORE STYLING
   ============================================ */

.theme-gameboy .score {
    color: #9bbc0f;
    font-family: 'Press Start 2P', cursive;
    text-shadow: 1px 1px 0 #0f380f;
}

/* ============================================
   GAME BOY THEME HEADER TITLE STYLING
   ============================================ */

.theme-gameboy h1 {
    font-size: 0.9em;
    color: #9bbc0f;
    font-family: 'Press Start 2P', cursive;
    text-shadow: 2px 2px 0 #0f380f;
}

/* D-pad arrow rotations for consistent rendering */
.arrow-left {
    display: inline-block;
    transform: rotate(-90deg);
}

.arrow-right {
    display: inline-block;
    transform: rotate(90deg);
}

/* ============================================
   THEME-SPECIFIC HEADER SCORE STYLING
   ============================================ */

/* PAC-MAN Score */
.theme-pacman .score {
    color: #FFD700;
}

/* SPACE INVADERS Score */
.theme-space-invaders .score {
    color: #00ff00;
    font-family: 'VT323', monospace;
    font-size: 1.1em;
    text-shadow: 0 0 5px #00ff00;
}

/* DONKEY KONG Score */
.theme-donkey-kong .score {
    color: #ffc107;
}

/* GALAGA Score */
.theme-galaga .score {
    color: #fff;
}

/* NEO GEO Score */
.theme-neogeo .score {
    color: #fff;
    font-family: 'Bungee', cursive;
}

/* TRON Score */
.theme-tron .score {
    color: #00d9ff;
    font-family: 'Orbitron', sans-serif;
    text-shadow: 0 0 10px #00d9ff;
}

/* OUTRUN Score */
.theme-outrun .score {
    color: #fff;
    font-family: 'Orbitron', sans-serif;
    text-shadow: 0 0 10px #ff006e;
}

/* STREET FIGHTER Score */
.theme-street-fighter .score {
    color: #ffd700;
    font-family: 'Bungee', cursive;
}

/* ============================================
   THEME-SPECIFIC HEADER TITLE STYLING
   ============================================ */

/* PAC-MAN Title */
.theme-pacman h1 {
    font-size: 0.9em;
    color: #FFD700;
    font-family: 'Press Start 2P', cursive;
}

/* SPACE INVADERS Title */
.theme-space-invaders h1 {
    font-size: 0.9em;
    color: #00ff00;
    font-family: 'VT323', monospace;
    font-size: 1.5em;
    text-shadow: 0 0 10px #00ff00;
}

/* DONKEY KONG Title */
.theme-donkey-kong h1 {
    font-size: 0.9em;
    color: #ffc107;
    font-family: 'Press Start 2P', cursive;
}

/* GALAGA Title */
.theme-galaga h1 {
    font-size: 0.9em;
    color: #fff;
    font-family: 'Orbitron', sans-serif;
    text-shadow: 0 0 15px #667eea;
}

/* NEO GEO Title */
.theme-neogeo h1 {
    font-size: 0.9em;
    color: #fff;
    font-family: 'Bungee', cursive;
    text-transform: uppercase;
}

/* TRON Title */
.theme-tron h1 {
    font-size: 0.9em;
    color: #00d9ff;
    font-family: 'Orbitron', sans-serif;
    text-shadow: 0 0 15px #00d9ff;
}

/* OUTRUN Title */
.theme-outrun h1 {
    font-size: 0.9em;
    color: #fff;
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    text-shadow: 0 0 15px #ff006e, 0 0 30px #8338ec;
}

/* STREET FIGHTER Title */
.theme-street-fighter h1 {
    font-size: 0.9em;
    color: #ffd700;
    font-family: 'Bungee', cursive;
    text-transform: uppercase;
    font-weight: 900;
    text-shadow: 2px 2px 0 #8b0000;
}
