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

/* GPU acceleration for smooth animations */
#gameCanvas {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Page transition - quick fade in */
body {
    animation: pageFadeIn 0.3s ease-out;
    background: radial-gradient(ellipse at center, #1a0a2e 0%, #0d0515 50%, #050208 100%);
    transition: background 0.3s ease;
}

/* Dark mode body styling */
body.dark-mode {
    background: radial-gradient(ellipse at center, #0a0a0a 0%, #050505 50%, #000000 100%);
}

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

/* Page transition out class */
.page-transitioning {
    animation: pageTransitionOut 0.2s ease-in forwards;
}

@keyframes pageTransitionOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(1.02);
    }
}

html, body {
    width: 100%;
    height: 100%;
    height: 100dvh; /* Dynamic viewport height - accounts for browser UI */
    background-color: #000000; /* Black to prevent white lines */
    overflow: hidden;
    font-family: 'Creepster', cursive;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100dvh; /* Dynamic viewport height - fills available space */
    height: 100vh; /* Fallback for older browsers */
    max-width: calc(100dvh * 0.667); /* Maintain 2:3 aspect ratio */
    background-color: #000000; /* Black to prevent white lines */
    box-shadow: none;
    overflow: hidden;
}

/* Standalone/PWA mode - fill entire screen */
@media (display-mode: standalone), (display-mode: fullscreen) {
    html, body {
        height: 100vh;
    }
    
    #game-container {
        height: 100vh;
        max-width: calc(100vh * 0.667);
    }
}

/* Dark mode game container background */
body.dark-mode #game-container {
    background-color: #0a0a0a;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    background-color: #000000; /* Black to prevent white lines */
}

/* Prevent text selection and touch callouts on mobile */
canvas {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Ensure smooth rendering on all devices */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* GPU acceleration for animations */
button, .back-btn, .nav-btn, .view-lb-btn, #sound-toggle-btn, #sound-toggle-btn-gameover {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Touch feedback for mobile buttons */
@media (hover: none) and (pointer: coarse) {
    button:active, .back-btn:active, .nav-btn:active {
        transform: scale(0.95) !important;
        transition: transform 0.1s ease !important;
    }
}

#game-over-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding-bottom: 25%;
    background: radial-gradient(ellipse at center, rgba(40, 10, 20, 0.98) 0%, rgba(15, 5, 25, 0.99) 50%, rgba(5, 2, 10, 1) 100%);
    z-index: 20;
    animation: gameOverAppear 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Vignette overlay */
#game-over-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at center, transparent 0%, transparent 40%, rgba(0, 0, 0, 0.6) 100%);
    pointer-events: none;
    z-index: 0;
}

/* Floating particles layer */
#game-over-screen::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(3px 3px at 10% 15%, rgba(255, 68, 68, 0.5), transparent),
        radial-gradient(2px 2px at 85% 25%, rgba(255, 100, 100, 0.4), transparent),
        radial-gradient(3px 3px at 20% 70%, rgba(255, 68, 68, 0.5), transparent),
        radial-gradient(4px 4px at 75% 80%, rgba(157, 78, 221, 0.4), transparent),
        radial-gradient(2px 2px at 40% 40%, rgba(255, 68, 68, 0.4), transparent),
        radial-gradient(3px 3px at 60% 60%, rgba(157, 78, 221, 0.3), transparent),
        radial-gradient(2px 2px at 90% 50%, rgba(255, 100, 100, 0.4), transparent),
        radial-gradient(3px 3px at 30% 90%, rgba(255, 68, 68, 0.5), transparent);
    background-repeat: repeat;
    background-size: 300px 300px;
    animation: deathParticles 20s linear infinite;
    opacity: 0.7;
    pointer-events: none;
    z-index: 0;
}

@keyframes deathParticles {
    0% { transform: translateY(0) translateX(0) scale(1); }
    50% { transform: translateY(-150px) translateX(20px) scale(1.1); }
    100% { transform: translateY(-300px) translateX(40px) scale(1); }
}

@keyframes gameOverAppear {
    0% {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    100% {
        opacity: 1;
        backdrop-filter: blur(12px);
    }
}

/* Fast pop animation for quick deaths */
@keyframes fastPop {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(10px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

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

/* BULLETPROOF: Ensure all game over elements are visible after animation completes */
#game-over-screen:not(.hidden) h2,
#game-over-screen:not(.hidden) p,
#game-over-screen:not(.hidden) #final-score,
#game-over-screen:not(.hidden) #restart-btn,
#game-over-screen:not(.hidden) #home-btn,
#game-over-screen:not(.hidden) #submit-score-btn,
#game-over-screen:not(.hidden) .view-lb-btn,
#game-over-screen:not(.hidden) .name-input-container,
#game-over-screen:not(.hidden) .submit-hint {
    animation-fill-mode: forwards;
}

#game-over-screen h2 {
    font-family: 'Creepster', cursive;
    font-size: 82px;
    color: #ff6b6b;
    margin-bottom: 20px;
    text-shadow: 
        0 0 10px rgba(255, 68, 68, 0.8),
        0 0 30px rgba(255, 68, 68, 0.6),
        0 0 60px rgba(255, 34, 34, 0.4),
        0 0 100px rgba(255, 0, 0, 0.2),
        0 4px 0 #8B0000;
    animation: gameOverTitle 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) forwards, gameOverPulse 3s ease-in-out 0.25s infinite;
    letter-spacing: 8px;
    position: relative;
    z-index: 1;
}

@keyframes gameOverTitle {
    0% {
        opacity: 0;
        transform: translateY(-40px) scale(1.5) rotate(-4deg);
        filter: blur(8px);
    }
    60% {
        opacity: 1;
        transform: translateY(4px) scale(0.98) rotate(1deg);
        filter: blur(0px);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1) rotate(0deg);
        filter: blur(0px);
    }
}

@keyframes gameOverPulse {
    0%, 100% { 
        transform: scale(1); 
        text-shadow: 0 0 10px rgba(255, 68, 68, 0.8), 0 0 30px rgba(255, 68, 68, 0.6), 0 0 60px rgba(255, 34, 34, 0.4), 0 0 100px rgba(255, 0, 0, 0.2), 0 4px 0 #8B0000;
    }
    50% { 
        transform: scale(1.02); 
        text-shadow: 0 0 20px rgba(255, 68, 68, 0.9), 0 0 40px rgba(255, 68, 68, 0.7), 0 0 80px rgba(255, 34, 34, 0.5), 0 0 120px rgba(255, 0, 0, 0.3), 0 4px 0 #8B0000;
    }
}


#game-over-screen p {
    font-family: 'Creepster', cursive;
    font-size: 50px;
    color: #e0aaff;
    margin-bottom: 30px;
    text-shadow: 0 0 20px rgba(224, 170, 255, 0.7), 0 0 40px rgba(224, 170, 255, 0.4);
    position: relative;
    z-index: 1;
    animation: scoreReveal 0.15s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes scoreReveal {
    0% {
        opacity: 0;
        transform: translateY(15px) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

#final-score {
    font-weight: bold;
    font-size: 64px;
    color: #FFD700;
    text-shadow: 
        0 0 15px rgba(255, 215, 0, 0.8),
        0 0 35px rgba(255, 215, 0, 0.5),
        0 0 60px rgba(255, 215, 0, 0.3),
        0 3px 0 #B8860B;
    animation: scoreGlow 2s ease-in-out infinite, scorePop 0.15s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes scorePop {
    0% {
        transform: scale(0.7);
    }
    60% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes scoreGlow {
    0%, 100% { 
        text-shadow: 0 0 15px rgba(255, 215, 0, 0.8), 0 0 35px rgba(255, 215, 0, 0.5), 0 0 60px rgba(255, 215, 0, 0.3), 0 3px 0 #B8860B;
        filter: brightness(1);
    }
    50% { 
        text-shadow: 0 0 25px rgba(255, 215, 0, 1), 0 0 50px rgba(255, 215, 0, 0.7), 0 0 80px rgba(255, 215, 0, 0.4), 0 3px 0 #B8860B;
        filter: brightness(1.2);
    }
}

/* Button container - no animation, buttons animate individually */
.game-over-buttons {
    opacity: 1;
}

/* Full-width restart bar - TALL TAP AREA at bottom, respects safe areas */
#restart-btn {
    font-family: 'Creepster', cursive;
    padding: 40px 40px;
    font-size: 32px;
    color: #FFFFFF;
    background: linear-gradient(180deg, #3a3a3a 0%, #222 30%, #1a1a1a 100%);
    background-size: 200% 200%;
    border: none;
    border-top: 3px solid rgba(255, 255, 255, 0.2);
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9), 0 0 20px rgba(255, 255, 255, 0.2);
    box-shadow: 
        0 -8px 30px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.08) inset;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    min-height: 180px;
    height: 22%;
    max-height: 25%;
    padding-bottom: max(30px, env(safe-area-inset-bottom, 30px));
    overflow: hidden;
    letter-spacing: 5px;
    animation: restartBtnIdle 4s ease infinite, restartBarSlide 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes restartBarSlide {
    0% {
        opacity: 0;
        transform: translateY(30%);
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes btnPop {
    0% {
        opacity: 0;
        transform: scale(0.85) translateY(8px);
    }
    50% {
        opacity: 1;
    }
    70% {
        opacity: 1;
        transform: scale(1.05) translateY(-2px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes restartBtnIdle {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

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

#restart-btn:hover::before {
    left: 100%;
}

#restart-btn:hover {
    background: linear-gradient(135deg, #555, #333, #444, #333, #555);
    box-shadow: 
        0 -6px 30px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    border-top-color: rgba(255, 255, 255, 0.3);
}

#restart-btn:active {
    background: linear-gradient(135deg, #333, #1a1a1a, #222, #1a1a1a, #333);
    box-shadow: 
        0 -2px 10px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    transition: all 0.08s ease;
}

#home-btn {
    font-family: 'Creepster', cursive;
    padding: 16px 28px;
    font-size: 24px;
    color: #FFFFFF;
    background: linear-gradient(135deg, #7b2cbf, #5a189a, #3c096c, #5a189a, #7b2cbf);
    background-size: 200% 200%;
    border: 3px solid rgba(157, 78, 221, 0.5);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
    box-shadow: 
        0 6px 25px rgba(90, 24, 154, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.08) inset,
        0 2px 0 rgba(255, 255, 255, 0.15) inset,
        0 0 20px rgba(157, 78, 221, 0.2);
    position: relative;
    overflow: hidden;
    letter-spacing: 1px;
    animation: homeBtnIdle 4s ease infinite, btnPop 0.15s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    flex: 0 0 auto;
}

@keyframes homeBtnIdle {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

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

#home-btn:hover::before {
    left: 100%;
}

#home-btn:hover {
    background: linear-gradient(135deg, #9d4edd, #7b2cbf, #5a189a, #7b2cbf, #9d4edd);
    transform: translateY(-4px) scale(1.05);
    box-shadow: 
        0 12px 40px rgba(123, 44, 191, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.15) inset,
        0 2px 0 rgba(255, 255, 255, 0.2) inset,
        0 0 40px rgba(157, 78, 221, 0.3);
    border-color: rgba(224, 170, 255, 0.6);
}

#home-btn:active {
    transform: translateY(2px) scale(0.96);
    box-shadow: 
        0 2px 10px rgba(90, 24, 154, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    transition: all 0.08s ease;
}

/* ============================================ */
/* WALLET CONNECT BUTTON */
/* ============================================ */

#connect-wallet-btn {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 1000;
    font-family: 'Creepster', cursive;
    padding: 14px 28px;
    font-size: 18px;
    color: #FFFFFF;
    background: linear-gradient(135deg, #7B3FE4, #9B5FFF, #7B3FE4);
    background-size: 200% 200%;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        0 4px 20px rgba(123, 63, 228, 0.5),
        0 0 30px rgba(123, 63, 228, 0.2),
        0 1px 0 rgba(255, 255, 255, 0.2) inset;
    position: relative;
    overflow: hidden;
    letter-spacing: 1px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    animation: walletBtnIdle 3s ease infinite;
}

@keyframes walletBtnIdle {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

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

#connect-wallet-btn:hover::before {
    left: 100%;
}

#connect-wallet-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 
        0 8px 30px rgba(123, 63, 228, 0.6),
        0 0 50px rgba(123, 63, 228, 0.3),
        0 1px 0 rgba(255, 255, 255, 0.3) inset;
    border-color: rgba(255, 255, 255, 0.4);
}

#connect-wallet-btn:active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 2px 15px rgba(123, 63, 228, 0.4);
    transition: all 0.1s ease;
}

/* ============================================ */
/* GAME OVER BUTTONS */
/* ============================================ */

.game-over-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-bottom: 15px;
    max-width: 90%;
    z-index: 1;
}

#submit-score-btn {
    font-family: 'Creepster', cursive;
    padding: 16px 28px;
    font-size: 24px;
    color: #FFFFFF;
    background: linear-gradient(135deg, #9B5FFF, #7B3FE4, #5a189a, #7B3FE4, #9B5FFF);
    background-size: 300% 300%;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        0 6px 30px rgba(123, 63, 228, 0.6),
        0 0 50px rgba(123, 63, 228, 0.25),
        0 2px 0 rgba(255, 255, 255, 0.25) inset,
        0 -2px 10px rgba(90, 24, 154, 0.3) inset;
    position: relative;
    overflow: hidden;
    letter-spacing: 1px;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    animation: submitBtnGlow 3s ease infinite, btnPop 0.15s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    flex: 0 0 auto;
}

@keyframes submitBtnGlow {
    0%, 100% { 
        background-position: 0% 50%;
        box-shadow: 
            0 6px 30px rgba(123, 63, 228, 0.6),
            0 0 50px rgba(123, 63, 228, 0.25),
            0 2px 0 rgba(255, 255, 255, 0.25) inset;
    }
    50% { 
        background-position: 100% 50%;
        box-shadow: 
            0 6px 35px rgba(155, 95, 255, 0.7),
            0 0 60px rgba(123, 63, 228, 0.35),
            0 2px 0 rgba(255, 255, 255, 0.3) inset;
    }
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

#submit-score-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.6s ease;
}

#submit-score-btn:hover:not(:disabled)::before {
    left: 100%;
}

#submit-score-btn:hover:not(:disabled) {
    transform: translateY(-4px) scale(1.03);
    box-shadow: 
        0 8px 35px rgba(123, 63, 228, 0.6),
        0 0 60px rgba(123, 63, 228, 0.3),
        0 1px 0 rgba(255, 255, 255, 0.3) inset;
    border-color: rgba(255, 255, 255, 0.4);
}

#submit-score-btn:active:not(:disabled) {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 2px 15px rgba(123, 63, 228, 0.4);
    transition: all 0.1s ease;
}

#submit-score-btn:disabled {
    background: #666666;
    cursor: not-allowed;
    opacity: 0.6;
}

.submit-hint {
    font-size: 16px !important;
    color: rgba(224, 170, 255, 0.6) !important;
    margin-top: 10px;
}

/* ============================================ */
/* NAME INPUT */
/* ============================================ */

.name-input-container {
    margin-bottom: 20px;
}

#player-name-input {
    font-family: 'Creepster', cursive;
    padding: 14px 24px;
    font-size: 22px;
    width: 300px;
    max-width: 90%;
    text-align: center;
    border: 3px solid #7B3FE4;
    border-radius: 14px;
    background: rgba(26, 10, 46, 0.85);
    color: #e0aaff;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.3),
        0 0 20px rgba(123, 63, 228, 0.15),
        0 1px 0 rgba(255, 255, 255, 0.05) inset;
    letter-spacing: 2px;
}

#player-name-input:focus {
    border-color: #a855f7;
    box-shadow: 
        0 0 25px rgba(123, 63, 228, 0.6),
        0 0 50px rgba(123, 63, 228, 0.3),
        0 8px 25px rgba(0, 0, 0, 0.3),
        0 1px 0 rgba(255, 255, 255, 0.1) inset;
    background: rgba(26, 10, 46, 0.95);
    transform: scale(1.02);
}

#player-name-input:hover:not(:focus) {
    border-color: #9B5FFF;
    box-shadow: 
        0 4px 20px rgba(0, 0, 0, 0.3),
        0 0 25px rgba(123, 63, 228, 0.2);
}

#player-name-input:disabled {
    background: rgba(200, 200, 200, 0.5);
    border-color: #888;
    color: #666;
}

#player-name-input::placeholder {
    color: rgba(224, 170, 255, 0.5);
    font-size: 16px;
}

/* ============================================ */
/* VIEW LEADERBOARD BUTTON */
/* ============================================ */

.view-lb-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: 'Creepster', cursive;
    padding: 14px 28px;
    font-size: 22px;
    color: #1a1a1a;
    background: linear-gradient(135deg, #FFD700, #FFC107, #FFD700);
    background-size: 200% 200%;
    border: 2px solid rgba(255, 255, 255, 0.4);
    text-decoration: none;
    border-radius: 14px;
    cursor: pointer;
    margin-top: 15px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        0 4px 20px rgba(255, 215, 0, 0.5),
        0 0 30px rgba(255, 215, 0, 0.2),
        0 1px 0 rgba(255, 255, 255, 0.5) inset;
    position: relative;
    overflow: hidden;
    text-shadow: 0 1px 2px rgba(255, 215, 0, 0.3);
    animation: goldShimmer 2s ease infinite, btnPop 0.15s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes goldShimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

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

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

.view-lb-btn:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 
        0 10px 40px rgba(255, 215, 0, 0.6),
        0 0 50px rgba(255, 215, 0, 0.4),
        0 1px 0 rgba(255, 255, 255, 0.6) inset;
    border-color: rgba(255, 255, 255, 0.6);
    color: #000;
}

.view-lb-btn:active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 2px 15px rgba(255, 215, 0, 0.4);
    transition: all 0.1s ease;
}

body.dark-mode #game-over-screen {
    background: radial-gradient(ellipse at center, rgba(25, 15, 35, 0.98) 0%, rgba(12, 8, 18, 0.99) 50%, rgba(5, 3, 8, 1) 100%) !important;
}

body.dark-mode #game-over-screen h2 {
    color: rgba(180, 142, 255, 0.9);
    text-shadow: 
        0 0 15px rgba(157, 78, 221, 0.4),
        0 0 30px rgba(123, 63, 228, 0.2);
}

body.dark-mode #game-over-screen p {
    color: rgba(180, 160, 200, 0.8);
}

body.dark-mode #final-score {
    color: rgba(200, 170, 255, 0.9) !important;
}

/* ============================================ */
/* RESPONSIVE - COMPREHENSIVE ALL DEVICES */
/* ============================================ */

/* Aspect ratio handling for game container */
@media (max-aspect-ratio: 2/3) {
    #game-container {
        width: 100vw;
        height: calc(100vw * 1.5);
        max-height: 100vh;
    }
}

@media (min-aspect-ratio: 2/3) {
    #game-container {
        height: 100vh;
        width: calc(100vh * 0.667);
        max-width: 100vw;
    }
}

/* Ultra-wide screens */
@media (min-aspect-ratio: 21/9) {
    #game-container {
        height: 100vh;
        width: calc(100vh * 0.667);
    }
}

/* Large desktop (1920px+) */
@media (min-width: 1920px) {
    #game-over-screen h2 {
        font-size: 90px;
    }
    
    #game-over-screen p {
        font-size: 56px;
    }
    
    #final-score {
        font-size: 72px;
    }
    
    #restart-btn, #home-btn, #submit-score-btn {
        padding: 20px 36px;
        font-size: 28px;
    }
    
    .view-lb-btn {
        font-size: 26px;
        padding: 18px 34px;
    }
}

/* Standard desktop (1200px - 1919px) */
@media (min-width: 1200px) and (max-width: 1919px) {
    #game-over-screen h2 {
        font-size: 82px;
    }
    
    #game-over-screen p {
        font-size: 50px;
    }
}

/* Tablet landscape (900px - 1199px) */
@media (min-width: 900px) and (max-width: 1199px) {
    #game-over-screen h2 {
        font-size: 72px;
    }
    
    #game-over-screen p {
        font-size: 44px;
    }
    
    #final-score {
        font-size: 56px;
    }
    
    #restart-btn, #home-btn, #submit-score-btn {
        padding: 14px 24px;
        font-size: 22px;
    }
}

/* Tablet portrait (600px - 899px) */
@media (min-width: 600px) and (max-width: 899px) {
    #game-over-screen h2 {
        font-size: 60px;
    }
    
    #game-over-screen p {
        font-size: 38px;
    }
    
    #final-score {
        font-size: 48px;
    }
    
    #restart-btn, #home-btn, #submit-score-btn {
        padding: 14px 22px;
        font-size: 20px;
    }
    
    .view-lb-btn {
        font-size: 18px;
        padding: 12px 22px;
    }
    
    #player-name-input {
        font-size: 18px;
        padding: 12px 20px;
        width: 260px;
    }
}

/* Mobile large (480px - 599px) */
@media (min-width: 480px) and (max-width: 599px) {
    #connect-wallet-btn {
        padding: 10px 18px;
        font-size: 14px;
        top: 10px;
        right: 10px;
    }
    
    .game-over-buttons {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    #restart-btn, #home-btn, #submit-score-btn {
        padding: 12px 18px;
        font-size: 18px;
    }
    
    #game-over-screen h2 {
        font-size: 52px;
        letter-spacing: 4px;
    }
    
    #game-over-screen p {
        font-size: 32px;
    }
    
    #final-score {
        font-size: 42px;
    }
    
    .view-lb-btn {
        font-size: 16px;
        padding: 10px 18px;
    }
    
    #player-name-input {
        font-size: 16px;
        padding: 10px 16px;
        width: 220px;
    }
    
    .submit-hint {
        font-size: 12px !important;
    }
}

/* Mobile small (320px - 479px) */
@media (max-width: 479px) {
    #connect-wallet-btn {
        padding: 8px 14px;
        font-size: 12px;
        top: 8px;
        right: 8px;
    }
    
    #game-over-screen {
        padding-bottom: 26%;
    }
    
    .game-over-buttons {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        width: 90%;
        justify-content: center;
    }
    
    #home-btn, #submit-score-btn {
        padding: 10px 16px;
        font-size: 16px;
        flex: 0 1 auto;
    }
    
    #restart-btn {
        padding: 30px 40px;
        font-size: 24px;
        min-height: 140px;
    }
    
    #game-over-screen h2 {
        font-size: 38px;
        letter-spacing: 3px;
        margin-bottom: 8px;
    }
    
    #game-over-screen p {
        font-size: 24px;
        margin-bottom: 12px;
    }
    
    #final-score {
        font-size: 32px;
    }
    
    .view-lb-btn {
        font-size: 13px;
        padding: 8px 14px;
        margin-top: 8px;
    }
    
    #player-name-input {
        font-size: 14px;
        padding: 10px 14px;
        width: 200px;
    }
    
    .submit-hint {
        font-size: 10px !important;
        margin-top: 6px;
    }
    
    .name-input-container {
        margin-bottom: 10px;
    }
    
    #sound-toggle-btn {
        width: 44px;
        height: 44px;
        font-size: 20px;
        top: 8px;
        left: 8px;
    }
    
    .dark-mode-toggle {
        width: 44px;
        height: 44px;
        font-size: 20px;
        top: 8px;
        right: 8px;
    }
}

/* Extra small devices (< 320px) */
@media (max-width: 319px) {
    #game-over-screen h2 {
        font-size: 32px;
        letter-spacing: 2px;
    }
    
    #game-over-screen p {
        font-size: 20px;
    }
    
    #final-score {
        font-size: 28px;
    }
    
    #restart-btn, #home-btn, #submit-score-btn {
        padding: 10px 16px;
        font-size: 14px;
    }
    
    .view-lb-btn {
        font-size: 12px;
        padding: 8px 12px;
    }
}

/* Landscape mobile orientation */
@media (max-height: 500px) and (orientation: landscape) {
    #game-over-screen {
        padding: 10px;
        padding-bottom: 100px;
        justify-content: center;
        overflow-y: auto;
    }
    
    #game-over-screen h2 {
        font-size: 32px;
        margin-bottom: 6px;
    }
    
    #game-over-screen p {
        font-size: 20px;
        margin-bottom: 8px;
    }
    
    .game-over-buttons {
        flex-direction: row;
        gap: 8px;
    }
    
    #home-btn, #submit-score-btn {
        padding: 8px 16px;
        font-size: 14px;
    }
    
    #restart-btn {
        min-height: 80px;
        height: 25%;
        padding: 16px 30px;
        font-size: 18px;
    }
    
    .view-lb-btn {
        font-size: 11px;
        padding: 6px 10px;
        margin-top: 6px;
    }
    
    #player-name-input {
        padding: 6px 10px;
        font-size: 12px;
        width: 160px;
    }
    
    .name-input-container {
        margin-bottom: 6px;
    }
    
    #final-score {
        font-size: 24px;
    }
    
    .submit-hint {
        display: none;
    }
}

/* High DPI / Retina displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    #gameCanvas {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Reduced motion preference - keep elements visible */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    /* Ensure game over elements are visible without animation */
    #game-over-screen h2,
    #game-over-screen p,
    #final-score,
    #restart-btn,
    #home-btn,
    #submit-score-btn,
    .view-lb-btn,
    .name-input-container,
    .submit-hint {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* Safe area insets for notched devices */
@supports (padding: max(0px)) {
    #game-container {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
    
    #sound-toggle-btn {
        left: max(15px, calc(env(safe-area-inset-left) + 15px));
        top: max(15px, calc(env(safe-area-inset-top) + 15px));
    }
    
    /* Restart button respects bottom safe area */
    #restart-btn {
        padding-bottom: max(24px, calc(env(safe-area-inset-bottom) + 16px));
    }
    
    /* Game over screen content stays above restart button */
    #game-over-screen {
        padding-bottom: max(26%, calc(env(safe-area-inset-bottom) + 22%));
    }
    
    .dark-mode-toggle {
        right: max(20px, calc(env(safe-area-inset-right) + 20px));
        top: max(20px, calc(env(safe-area-inset-top) + 20px));
    }
}
