body {
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100vw;
    height: 100vh;
    background: #0a3d62; /* Main game color to avoid "back background" flicker */
    background-image: url('assets/background.png');
    background-size: cover;
    background-position: center;
    overflow: hidden;
    touch-action: none;
    font-family: 'Arial', sans-serif;
    -webkit-tap-highlight-color: transparent; /* Fix stuck blue focus square */
    outline: none;
}

* {
    -webkit-tap-highlight-color: transparent;
    outline: none;
}
canvas {
    border: none;
    background-color: transparent;
    max-width: 100%;
    max-height: 100%;
    width: 100vw;
    height: 100vh;
    object-fit: fill; /* Stretches to fill sides as requested */
    image-rendering: auto;
    z-index: 10;
    opacity: 0;
    display: none;
    transition: opacity 0.5s ease-in;
    pointer-events: none;
}

canvas.game-active {
    display: block; /* Show only when playing */
    opacity: 1;
    pointer-events: auto;
}


.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none; /* Hidden by default */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 2000;
    padding: env(safe-area-inset-top, 20px) 20px max(70px, env(safe-area-inset-bottom, 20px)) 20px;
    box-sizing: border-box;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
    overflow-y: auto; /* Allow scrolling if screen is too small */
    -webkit-overflow-scrolling: touch;
}

.screen.active {
    display: flex !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    z-index: 3000 !important;
}

.screen.hidden {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}
#startScreen {
    background: rgba(12, 84, 118, 0.7) url('assets/ui/start_screen.jpeg') 0% 0%/100% 100% no-repeat;
    justify-content: center;
}



#extrasScreen {
    background: rgba(12, 84, 118, 0.85) url('assets/ui/extras_screen.jpeg') 0% 0%/100% 100% no-repeat !important;
    padding: 2vh 5vw;
    justify-content: flex-start; /* Better for tall contents */
    padding-top: max(20px, env(safe-area-inset-top));
}
#optionsScreen {
    background: rgba(0, 0, 0, 0.6) url('assets/ui/options_screen.jpeg') 0% 0%/100% 100% no-repeat !important;
    padding: 2vh 5vw;
    justify-content: flex-start;
    padding-top: max(20px, env(safe-area-inset-top));
}
#creditsScreen {
    background: rgba(0, 50, 80, 0.8) url('assets/ui/credits_screen.jpeg') 0% 0%/100% 100% no-repeat !important;
    padding: 2vh 5vw;
    justify-content: flex-start;
    padding-top: max(20px, env(safe-area-inset-top));
}
.screen h1 {
    font-size: min(10vw, 72px);
    margin: 0 0 25px 0;
    text-shadow: 0 0 20px #4da6ff, 0 0 30px #4da6ff;
    color: #4da6ff;
    text-align: center;
    z-index: 10;
    letter-spacing: 3px;
    text-transform: uppercase;
    position: relative;
}
.screen h1::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 4px;
    background: linear-gradient(90deg, transparent, #4da6ff, transparent);
    border-radius: 2px;
}
.screen p {
    font-size: 28px;
    margin: 10px 0;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}
.screen p img {
    height: 28px;
    width: auto;
}
.button {
    background: #4da6ff;
    border: none;
    padding: 15px 40px;
    font-size: 24px;
    color: white;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 0 20px rgba(77, 166, 255, 0.8);
    margin: 10px 0;
    width: 260px;
    max-width: 100%;
    touch-action: manipulation;
    pointer-events: auto !important;
    box-sizing: border-box;
}
.button:hover {
    background: #3a8bff;
    transform: scale(1.05);
}
.button.secondary {
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}
.button.secondary:hover {
    transform: scale(1.08);
}
.button.danger {
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}
.button.danger:hover {
    transform: scale(1.08);
}
/* Make ALL start screen buttons completely round (circular) and smaller */
#startScreen .button {
    background: url('assets/ui/btn_general.png') center/100% 100% no-repeat;
    color: transparent;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    width: 30vmin; /* Large bubbles */
    height: 30vmin;
    max-width: 160px;
    max-height: 160px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s ease-out;
    margin: 1vmin;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.7);
    line-height: 1;
    flex-shrink: 0;
    overflow: hidden;
    text-align: center;
    background-color: transparent !important;
    pointer-events: auto !important;
    z-index: 2500;
    touch-action: manipulation;
    box-sizing: border-box;
}
#startScreen .button:active {
    transform: scale(0.9); /* Visual feedback on touch */
}






/* Special styling for the PLAY button with new image */
#startScreen #startButton, #startGameFromInstructions {
    background-image: url('assets/ui/btn_side.png');
    background-position: center;
    background-size: 100% 100%;
    background-repeat: no-repeat;
}
#startScreen #flappyButton {
    background: url('assets/ui/btn_flappy.png') center/100% 100% no-repeat;
}
#startScreen #breakerButton {
    background: url('assets/ui/btn_breaker.png') center/100% 100% no-repeat;
}
#startScreen #froggerButton {
    background: url('assets/ui/btn_frog.png') center/100% 100% no-repeat;
}
#startScreen #marbleButton {
    background: url('assets/ui/btn_marble.png') center/100% 100% no-repeat;
}
#startScreen #optionsButton {
    background: url('assets/ui/btn_options.png') center/100% 100% no-repeat;
}
#startScreen #extrasButton {
    background: url('assets/ui/btn_extras.png') center/100% 100% no-repeat;
}
#startScreen #creditsButton {
    background: url('assets/ui/btn_credits.png') center/100% 100% no-repeat;
}
#startScreen #rankingButton {
    background: url('assets/ui/btn_ranking.png') center/100% 100% no-repeat;
}
#startScreen #donationButton {
    background: url('assets/ui/btn_coffe.png') center/100% 100% no-repeat;
}
#startScreen #rankingButton::after {
    display: none;
}
#startScreen .button:hover {
    transform: scale(1.08);
    box-shadow: 0 0 20px rgba(77, 166, 255, 0.9);
}
/* Game Over screen circular buttons - NO GLOWING RINGS */
#gameOverScreen .button {
    border: none;
    width: 28vmin;
    height: 28vmin;
    max-width: 140px;
    max-height: 140px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    margin: 10px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.7);
    line-height: 1.2;
    flex-shrink: 0;
    overflow: hidden;
    text-align: center;
    background-color: transparent;
}

#gameOverScreen .button.danger {
    background: url('assets/ui/btn_retry.png') center/100% 100% no-repeat;
}
#gameOverScreen .button.secondary {
    background: url('assets/ui/btn_menu.png') center/100% 100% no-repeat;
}
#gameOverScreen .button:hover {
    transform: scale(1.08);
}
/* Extras screen back button - circular */
#extrasScreen .button.secondary {
    border: none;
    width: 20vmin;
    height: 20vmin;
    max-width: 100px;
    max-height: 100px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    margin: 1vh;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.7);
    line-height: 1;
    flex-shrink: 0;
    overflow: hidden;
    text-align: center;
    background: url('assets/ui/btn_menu.png') center/100% 100% no-repeat;
}
#extrasScreen .button.secondary:hover {
    transform: scale(1.08);
}
/* Options screen back button - circular */
#optionsScreen .button.secondary {
    border: none;
    width: 20vmin;
    height: 20vmin;
    max-width: 100px;
    max-height: 100px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    margin: 1vh;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.7);
    line-height: 1;
    flex-shrink: 0;
    overflow: hidden;
    text-align: center;
    background: url('assets/ui/btn_menu.png') center/100% 100% no-repeat;
}
#optionsScreen .button.secondary:hover {
    transform: scale(1.08);
}
/* Credits screen back button - circular */
#creditsScreen .button.secondary {
    border: none;
    width: 20vmin;
    height: 20vmin;
    max-width: 100px;
    max-height: 100px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    margin: 1vh;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.7);
    line-height: 1;
    flex-shrink: 0;
    overflow: hidden;
    text-align: center;
    background: url('assets/ui/btn_menu.png') center/100% 100% no-repeat;
}
#creditsScreen .button.secondary:hover {
    transform: scale(1.08);
}
/* Game over buttons container */
.game-over-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}
/* Credits container cleanup */
.volume-control {
    margin: 2vh 0;
    text-align: center;
    width: 70%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1vh;
}
.volume-control label {
    font-size: 28px;
    display: block;
    margin-bottom: 15px;
}
.volume-control input[type="range"] {
    width: 100%;
    height: 30px;
    -webkit-appearance: none;
    appearance: none;
    background: #3a8bff;
    border-radius: 15px;
    outline: none;
}
.volume-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20vmin;
    height: 20vmin;
    max-width: 120px;
    max-height: 120px;
    border-radius: 50%;
    background: url('assets/ui/volume_thumb.png') center/cover no-repeat;
    cursor: pointer;
}

.volume-value {
    font-size: 48px;
    font-weight: bold;
    color: #ff6b6b;
    margin-top: 15px;
    display: flex;
    justify-content: center;
    gap: 5px;
    min-height: 48px;
}
.volume-value img {
    height: 48px;
    width: auto;
}
#gameOverScreen {
    display: none;
    background: rgba(0, 0, 0, 0.6) url('assets/ui/gameover_bg.jpg') 0% 0%/100% 100% no-repeat;
}
#gameOverScreen h2 {
    font-size: 48px;
    margin-bottom: 20px;
    text-shadow: 0 0 10px #ff6b6b;
    color: #ff6b6b;
}
#gameOverScreen p {
    font-size: 28px;
    margin: 10px 0;
}
/* Game Over title image */
.game-over-title, .extras-title, .options-title {
    max-width: 60%;
    max-height: 15vh;
    height: auto;
    margin-bottom: 2vh;
    margin-top: 1vh;
    display: block;
    object-fit: contain;
    flex-shrink: 1;
}

/* Credits screen image */
.credits-image {
    max-width: 50%;
    max-height: 40vh;
    height: auto;
    margin-top: 2vh;
    margin-bottom: 2vh;
    display: block;
    object-fit: contain;
}
#instructions {
    position: absolute;
    bottom: 20px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 18px;
    text-align: center;
    width: 100%;
}
#loadingScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #0066cc;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    pointer-events: auto;
    transition: opacity 0.5s ease-in-out;
    opacity: 1;
}

#loadingScreen.fading {
    opacity: 0;
    pointer-events: none;
}

#loadingScreen.hidden {
    display: none !important;
    pointer-events: none !important;
}

#loadingText {
    color: #fff;
    font-size: min(12vw, 48px);
    font-weight: bold;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.8), 0 0 30px rgba(255, 255, 255, 0.5);
    animation: fadeInOut 1s infinite;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    letter-spacing: 2px;
}

@keyframes fadeInOut {
    0% { opacity: 0.4; transform: scale(0.95); }
    50% { opacity: 1; transform: scale(1); }
    100% { opacity: 0.4; transform: scale(0.95); }
}

.appearance-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* 3 columns for better fit in landscape */
    gap: 1.5vmin;
    margin: 1vh 0;
    width: 90%;
    max-width: 600px;
}
@media (max-height: 500px) {
    .appearance-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        margin: 5px 0;
    }
}
.appearance-btn {
    background: #4da6ff;
    border: none;
    padding: 10px;
    font-size: 16px;
    color: white;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 0 15px rgba(77, 166, 255, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}
.appearance-btn:hover {
    background: #3a8bff;
    transform: scale(1.05);
}
.appearance-btn.selected {
    background: #ff6b6b;
    box-shadow: 0 0 20px rgba(255, 107, 107, 0.9);
}
/* Locked state for appearance buttons */
.appearance-btn.locked {
    filter: grayscale(100%) brightness(40%);
    pointer-events: none;
    opacity: 0.7;
    cursor: not-allowed;
}
.appearance-preview {
    width: 40px;
    height: 40px;
    margin-bottom: 5px;
    display: inline-block;
    vertical-align: middle;
    object-fit: contain;
    border-radius: 5px;
}
.unlock-req {
    font-size: 12px;
    margin-top: 5px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 3px #000;
}
/* lnk.bio link styling */
.lnk-bio-link {
    background: #9b51e0;
    border: none;
    border-radius: 25px;
    padding: 12px 30px;
    color: white;
    text-decoration: none;
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    transition: all 0.3s;
    margin: 1vh 0;
    display: inline-block;
    box-shadow: 0 5px 15px rgba(155, 81, 224, 0.4);
}
.lnk-bio-link:hover {
    background: #8a3bd4;
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(155, 81, 224, 0.6);
}

/* Privacy Policy styling as a button */
.privacy-link {
    background: rgba(77, 166, 255, 0.25);
    border: 3px solid #4da6ff;
    border-radius: 25px;
    padding: 12px 30px;
    color: white;
    text-decoration: none;
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    transition: all 0.3s;
    margin: 2vh 0;
    display: inline-block;
}
.privacy-link:hover {
    background: rgba(77, 166, 255, 0.45);
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(77, 166, 255, 0.6);
}
/* Pyramid layout for start screen buttons - compact and centered */
.start-buttons-container {
    display: flex;
    flex-direction: row; /* Horizontal row */
    align-items: center;
    justify-content: center;
    flex-wrap: wrap; /* Wrap if too many for narrow screens */
    width: 100%;
    max-width: 95%; /* Use more width for the row */
    padding: 0;
    box-sizing: border-box;
    gap: 1.5vmin; /* Tight but consistent gap */
}


.button-row {
    display: flex;
    justify-content: center;
    width: 100%;
    gap: 8px;
    margin: 4px 0;
}
/* Title image styling - removed box-shadow and border-radius */
.title-image {
    max-width: 80%;
    max-height: 25vh; 
    height: auto;
    width: auto;
    margin-top: 0;
    margin-bottom: 4vh; /* More space between logo and buttons */
    display: block;
    margin-left: auto;
    margin-right: auto;
    z-index: 10;
    object-fit: contain;
}




@media (max-width: 480px), (max-height: 480px) {
    #startScreen h1 {
        font-size: 24px;
        margin-bottom: 10px;
    }
    #startScreen .button {
        width: 20vmin;
        height: 20vmin;
        max-width: 90px;
        max-height: 90px;
        font-size: 10px;
    }
    .start-buttons-container {
        gap: 2vmin;
    }
    .title-image {
        max-height: 20vh;
        margin-bottom: 2vh;
    }
    .appearance-grid {
        gap: 8px;
        grid-template-columns: repeat(3, 1fr);
    }
    .appearance-btn {
        padding: 5px;
        font-size: 12px;
    }
}

/* Ranking Styles */
#rankingScreen {
    background: linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5)), url('assets/ui/record_bg.jpg') 0% 0%/100% 100% no-repeat !important;
    background-color: #0a3d62 !important;
    padding: 5vh 5vw;
    justify-content: center;
}

/* Donation Screen Styles */
#donationScreen {
    background: rgba(0, 30, 50, 0.9) url('assets/ui/options_screen.jpeg') 0% 0%/100% 100% no-repeat !important;
    padding-top: 5vh;
}
#donationScreen h2.instr-title {
    margin-bottom: 4vh;
    font-size: clamp(24px, 5vw, 36px);
}
.donation-options {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
}
.donation-btn {
    width: clamp(80px, 15vw, 120px) !important;
    height: clamp(80px, 15vw, 120px) !important;
    padding: 0 !important;
    font-weight: bold !important;
    font-size: 24px !important;
    background: #ffbd00 !important;
    color: #4a3000 !important;
    border: 4px solid #fff !important;
    border-radius: 50% !important;
    box-shadow: 0 5px 15px rgba(255, 189, 0, 0.5) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s !important;
}
.donation-btn:hover {
    transform: scale(1.1) !important;
    background: #ffcc33 !important;
}

#donationScreen .button.secondary {
    border: none !important;
    width: 20vmin !important;
    height: 20vmin !important;
    max-width: 100px !important;
    max-height: 100px !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    transition: all 0.3s !important;
    margin: 1vh !important;
    font-size: 14px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.7) !important;
    line-height: 1 !important;
    flex-shrink: 0 !important;
    overflow: hidden !important;
    text-align: center !important;
    background: url('assets/ui/btn_menu.png') center/100% 100% no-repeat !important;
}
#donationScreen .button.secondary:hover {
    transform: scale(1.1) !important;
}

#rankingScreen img {
    max-width: 70%;
    height: auto;
    margin-bottom: 2vh;
}

.ranking-tabs {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}
.ranking-tab-btn {
    background: rgba(77, 166, 255, 0.2);
    border: 2px solid #4da6ff;
    padding: 8px 20px;
    color: white;
    border-radius: 40px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 0 10px rgba(77, 166, 255, 0.4);
}
/* Ranking Menu View */
.ranking-menu-view {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* Start from top to leave space */
    padding-top: 5vh;
    background: transparent;
    z-index: 5;
}

#rankingScreen {
    background: url('assets/ui/record_bg.jpg') center/cover no-repeat !important;
}

.ranking-logo {
    max-width: 90%;
    max-height: 25vh;
    object-fit: contain;
    margin-bottom: 20px;
}

.ranking-categories {
    display: flex;
    flex-direction: row; /* Horizontal as in the image */
    flex-wrap: wrap; /* Allow wrapping on very narrow screens but try to stay in line */
    justify-content: center;
    gap: 10px;
    width: 95%;
    margin-bottom: 30px;
}

.ranking-cat-btn {
    background: rgba(0, 102, 204, 0.3);
    border: 2px solid #4da6ff;
    border-radius: 25px; /* Pill shape */
    color: white;
    font-size: clamp(14px, 3.5vw, 22px);
    font-weight: 900;
    padding: 10px 20px;
    text-shadow: 0 0 5px #000;
    box-shadow: 0 0 10px rgba(77, 166, 255, 0.4);
    cursor: pointer;
    transition: all 0.2s;
    min-width: 100px;
}

.ranking-cat-btn:active, .ranking-cat-btn.active {
    background: #007bff;
    box-shadow: 0 0 20px #4da6ff;
    transform: scale(1.05);
}

/* Fullscreen Overlay Style */
.ranking-fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 20, 40, 0.98);
    background-image: radial-gradient(circle at center, #003366 0%, #001122 100%);
    z-index: 10000; /* Over everything */
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.close-ranking-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: url('assets/ui/x.png') center/contain no-repeat;
    border: none;
    cursor: pointer;
    z-index: 10100;
    text-indent: -9999px; /* Hide text if any */
}

#rankingBoxTitle {
    color: #ffd32a;
    font-size: clamp(28px, 7vw, 42px);
    margin: 30px 0 15px 0;
    text-transform: uppercase;
    font-weight: 900;
    text-shadow: 0 0 15px rgba(255, 211, 42, 0.6);
}

.ranking-box-container {
    width: 100%;
    max-width: 900px;
    flex: 1;
    background: rgba(0, 0, 0, 0.8);
    border: 3px solid #4da6ff;
    border-radius: 20px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 30px rgba(0, 102, 204, 0.5);
    overflow: hidden;
}


.ranking-footer {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

/* Ranking screen back button - matching others */
#rankingScreen .button.secondary {
    border: none;
    width: 20vmin;
    height: 20vmin;
    max-width: 100px;
    max-height: 100px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    margin: 1vh;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.7);
    line-height: 1;
    flex-shrink: 0;
    overflow: hidden;
    text-align: center;
    background: url('assets/ui/btn_menu.png') center/100% 100% no-repeat;
    pointer-events: auto !important;
}

#rankingScreen .button.secondary:hover {
    transform: scale(1.08);
}


#leaderboardList {
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
}

#leaderboardList::-webkit-scrollbar {
    width: 10px;
}
#leaderboardList::-webkit-scrollbar-thumb {
    background: #ffd32a;
    border-radius: 5px;
}




.ranking-item {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    margin: 8px 0;
    padding: 8px 15px;
    border-radius: 15px;
    border: 1px solid rgba(77, 166, 255, 0.2);
    transition: all 0.2s;
}
.ranking-item:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.02);
}
.ranking-item .rank {
    font-size: 18px;
    font-weight: bold;
    min-width: 32px;
    color: #4da6ff;
    text-align: left;
}
.ranking-item .rank.top3 {
    color: #ffd700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
    font-size: 22px;
}
.ranking-item .entry {
    display: flex;
    align-items: center;
    flex-grow: 1;
    gap: 12px;
    overflow: hidden;
}
.ranking-item .entry-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
    filter: drop-shadow(0 0 5px rgba(255,255,255,0.3));
}
.ranking-item .name {
    flex-grow: 1;
    font-size: 16px;
    font-weight: bold;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: uppercase;
}
.ranking-item .score {
    font-size: 20px;
    font-weight: bold;
    color: #ff6b6b;
    text-shadow: 0 0 5px rgba(255, 107, 107, 0.3);
}
.loading-ranks {
    text-align: center;
    padding: 30px;
    font-size: 18px;
    color: #4da6ff;
    font-weight: bold;
    font-style: italic;
}
.instructions-box {
    background: rgba(0, 0, 50, 0.7);
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    padding: 15px;
    margin-bottom: 10px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
    box-sizing: border-box;
}

.instr-title {
    color: #fff;
    text-shadow: 2px 2px 4px #000;
    margin-bottom: 1.5vh;
    font-size: 24px;
}

.instruction-row {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 15px;
}

.instruction-row.powerups {
    flex-direction: column;
    gap: 10px;
}

.instr-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 50px;
}

.instr-item.wide {
    flex-direction: row;
    justify-content: flex-start;
    gap: 15px;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 15px;
    border-radius: 12px;
    width: 100%;
    box-sizing: border-box;
}

.instr-item img {
    height: 35px;
    width: auto;
    object-fit: contain;
}

.instr-item.wide img {
    height: 45px;
}

.instr-text {
    text-align: left;
    display: flex;
    flex-direction: column;
}

.instr-text p {
    margin: 2px 0 0 0;
    font-size: 13px;
    color: #ddd;
}

.instr-item span {
    font-size: 15px;
    margin-top: 5px;
    color: #fff;
    text-shadow: 1px 1px 2px #000;
}

.instr-item.wide span {
    margin-top: 0;
}

.instr-tip {
    font-size: 16px;
    text-align: center;
    line-height: 1.3;
    color: #fff;
    text-shadow: 2px 2px 4px #000;
    margin-top: 5px;
}


.ranking-item {
    display: flex;
    align-items: center;
    padding: 5px 4px;
    border-bottom: 1px solid rgba(77, 166, 255, 0.2);
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
}

.ranking-item:last-child {
    border-bottom: none;
}

.ranking-item .rank {
    min-width: 28px;
    color: #ffd700;
    font-weight: bold;
    font-size: 12px;
    text-align: right;
    padding-right: 6px;
    flex-shrink: 0;
}

.ranking-item .rank.top3 {
    font-size: 14px;
    color: #ffaa00;
}

.ranking-item .entry {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ranking-item .entry .entry-name {
    color: #ffffff;
    font-weight: bold;
    min-width: 140px; /* Increased to fit 15 characters */
    display: inline-block;
    overflow: visible; /* Ensure full name is visible */
}

.ranking-item .entry .entry-sep {
    color: #88c8ff;
    flex-shrink: 0;
}

.ranking-item .entry .entry-score {
    color: #4da6ff;
    font-weight: bold;
    flex-shrink: 0;
    margin-left: auto; /* Push score to the right */
    padding-right: 5px;
}

.ranking-item .entry .entry-icon {
    width: 30px;
    height: 30px;
    object-fit: contain;
    flex-shrink: 0;
    margin-right: 10px;
}

.ranking-item.empty-slot .entry {
    color: rgba(100, 150, 200, 0.4);
}

.loading-ranks {
    text-align: center;
    padding-top: 30px;
    font-style: italic;
    color: #88c8ff;
    font-size: 14px;
}

/* Custom Scrollbar */
.ranking-list::-webkit-scrollbar {
    width: 8px;
}
.ranking-list::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
}
.ranking-list::-webkit-scrollbar-thumb {
    background: #4da6ff;
    border-radius: 10px;
}

/* Ranking screen menu button */
#rankingScreen .button.secondary {
    background: url('assets/ui/btn_menu.png') center/100% 100% no-repeat;
    width: 25vmin;
    height: 25vmin;
    max-width: 110px;
    max-height: 110px;
    margin-top: 2vh;
}


/* Submit button on name entry */
#submitScoreButton {
    background: url('assets/ui/btn_submit.png') center/100% 100% no-repeat;
    color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}
#submitScoreButton::after {
    display: none !important;
}

#nameEntryScreen {
    background: linear-gradient(rgba(0,0,0,0.4), rgba(0,0,0,0.4)), url('assets/ui/record_bg.jpg') 0% 0%/100% 100% no-repeat !important;
    background-color: #0a3d62 !important;
    z-index: 1000;
    justify-content: center;
    padding: 5vh 5vw;
}

#playerNameInput {
    padding: 2vmin;
    font-size: min(6vw, 24px);
    border-radius: 15px;
    border: 3px solid #4da6ff;
    width: 60%;
    max-width: 300px;
    text-align: center;
    margin-bottom: 4vh;
    background: #0a3d62;
    color: white;
    font-family: inherit;
    box-shadow: 0 0 15px rgba(77, 166, 255, 0.4);
}

#nameEntryScreen img {
    max-width: 55%;
    max-height: 12vh;
    height: auto;
    margin-bottom: 1.5vh;
    object-fit: contain;
}

/* Back button on name entry */
#nameEntryBackButton {
    background: url('assets/ui/btn_back_alt.png') center/100% 100% no-repeat;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    width: 25vmin;
    height: 25vmin;
    max-width: 120px;
    max-height: 120px;
}

.record-buttons {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 5vmin;
    width: 100%;
    margin-top: 2vh;
}

#submitScoreButton {
    width: 30vmin;
    height: 30vmin;
    max-width: 150px;
    max-height: 150px;
}

#rankingScreen {
    background: linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5)), url('assets/ui/record_bg.jpg') 0% 0%/100% 100% no-repeat !important;
    background-color: #0a3d62 !important;
}

.instructions-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    margin-top: 10px;
}

.tap-to-continue {
    color: #fff;
    font-weight: bold;
    font-size: 22px;
    margin-top: 20px;
    margin-bottom: 10px;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.8), 2px 2px 4px #000;
    animation: pulse 1.5s infinite ease-in-out;
    pointer-events: none; /* Let clicks pass through if we listen on the parent */
}

#instructionsBackButton {
    background: url('assets/ui/btn_back.png') center/100% 100% no-repeat;
    width: 60px;
    height: 60px;
    border: none;
    cursor: pointer;
    z-index: 10; /* Make sure back button is clickable on top of tap screen */
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 0.7; }
}

#instructions {
    position: fixed;
    top: 50%;
    transform: translate(-50%, -50%);
    left: 50%;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 20px 40px;
    border-radius: 30px;
    font-size: 24px;
    font-weight: bold;
    color: #fff;
    text-shadow: 2px 2px 4px #000;
    border: 3px solid rgba(77, 166, 255, 0.5);
    z-index: 2000;
    pointer-events: none;
    display: none; /* Controlled by JS */
    width: 80%;
    max-width: 500px;
    transition: opacity 0.5s ease;
    opacity: 0;
}
.start-buttons-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2vh;
    width: 100%;
}
.menu-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 1.5vmin;
}
