:root {
    --primary-bg: #764ba2;
    --secondary-bg: #667eea;
    --card-bg: #ffffff;
    --text-dark: #333333;
    --text-light: #ffffff;
    --btn-primary: #8a2be2;
    --btn-primary-hover: #7b24c9;
    --btn-secondary: #ff7f50;
    --btn-secondary-hover: #ff6347;
    --success: #28a745;
    --success-light: #d4edda;
    --danger: #dc3545;
    --danger-light: #f8d7da;
    --font-main: 'Outfit', sans-serif;
    --shadow: 0 8px 16px rgba(0,0,0,0.15);
    --radius: 16px;
    --anim-speed: 0.3s;
}

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

html {
    /* Prevent the browser from silently re-adjusting scroll position
       whenever content is inserted/removed above/within the viewport
       (e.g. floating score text spawning every question). */
    overflow-anchor: none;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-main);
    background: linear-gradient(135deg, var(--secondary-bg) 0%, var(--primary-bg) 100%);
    color: var(--text-dark);
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    overflow-anchor: none;
    overscroll-behavior: none;
    touch-action: none;
    position: relative;
}

/* Subtle background pattern */
body::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: radial-gradient(rgba(255,255,255,0.1) 2px, transparent 2px);
    background-size: 30px 30px;
    pointer-events: none;
    z-index: 0;
}

.app-container {
    width: 100%;
    height: 100%;
    max-width: min(100%, 820px);
    max-height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
    background: transparent;
    padding: clamp(10px, 3vh, 20px) clamp(10px, 4vw, 20px);
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    /* NOTE: this was briefly `center`, which on short screens clips the
       top of overflowing content (a known flex+overflow interaction —
       centered overflow can become unreachable by scroll) and can shift
       between frames as the box height is recalculated. flex-start
       keeps the HUD always anchored and visible; the clamp()-based
       sizing below is what actually prevents overflow now. */
    /* Content is sized to fit the Y8/CrazyGames iframe via clamp(),
       and the scrollbar below is hidden — scrolling only ever kicks
       in as a fallback on unusually short viewports. */
}

/* Hide the scrollbar everywhere it can appear, while keeping the
   element scrollable so nothing ever gets permanently cut off. */
.app-container,
#leaderboard-screen,
.modal-content {
    scrollbar-width: none;      /* Firefox */
    -ms-overflow-style: none;   /* old Edge/IE */
}
.app-container::-webkit-scrollbar,
#leaderboard-screen::-webkit-scrollbar,
.modal-content::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;              /* Chrome/Safari/new Edge */
}

.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    animation: fadeIn 0.4s ease-out;
}

.screen.active {
    display: flex;
}

/* Typography */
h1.game-title {
    font-size: clamp(1.8rem, 6vh, 3rem);
    font-weight: 800;
    color: var(--text-light);
    text-align: center;
    text-shadow: 2px 4px 6px rgba(0,0,0,0.3);
    margin-bottom: clamp(8px, 2.5vh, 20px);
    line-height: 1.1;
}

h1.game-title span {
    color: #ffd700;
}

h2 {
    font-size: 2rem;
    color: var(--text-light);
    margin-bottom: 20px;
    text-shadow: 1px 2px 4px rgba(0,0,0,0.2);
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    width: 100%;
    text-align: center;
}

/* Buttons */
button {
    font-family: var(--font-main);
    cursor: pointer;
    border: none;
    outline: none;
    transition: all var(--anim-speed) ease;
    border-radius: 30px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.8;
}

.btn-primary, .btn-secondary {
    padding: clamp(10px, 2vh, 15px) 30px;
    font-size: clamp(1rem, 3vh, 1.2rem);
    width: 100%;
    max-width: 300px;
    margin: clamp(5px, 1.4vh, 10px) 0;
    color: white;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

.btn-primary { background: var(--btn-primary); }
.btn-primary:hover { background: var(--btn-primary-hover); transform: translateY(-3px); box-shadow: 0 6px 12px rgba(0,0,0,0.3); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary { background: var(--btn-secondary); }
.btn-secondary:hover { background: var(--btn-secondary-hover); transform: translateY(-3px); box-shadow: 0 6px 12px rgba(0,0,0,0.3); }

.icon-btn {
    background: rgba(255,255,255,0.2);
    color: white;
    width: 40px; height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
}
.icon-btn:hover { background: rgba(255,255,255,0.4); transform: scale(1.1); }
#settings-btn { position: absolute; top: 10px; right: 20px; }

/* Menus */
.menu-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin-top: 10px;
}

.high-score-display {
    background: rgba(0,0,0,0.3);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: clamp(8px, 2.5vh, 20px);
}

.difficulty-selector {
    margin-top: 20px;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 1.1rem;
}
.difficulty-selector select {
    margin-top: 5px;
    padding: 10px;
    border-radius: 10px;
    border: none;
    font-family: var(--font-main);
    font-weight: 600;
    cursor: pointer;
}

/* Generic hidden utility — many JS toggles rely on this class alone */
.hidden { display: none; }

/* Modals */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    animation: fadeIn 0.3s;
}
.modal.hidden { display: none; }
.modal-content {
    background: white;
    padding: 30px;
    border-radius: var(--radius);
    max-width: 400px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}
.modal-content h2 { color: var(--text-dark); text-shadow: none; }
.modal-content ul { text-align: left; margin: 15px 0; padding-left: 20px; }
.modal-content li { margin-bottom: 8px; }

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-size: 1.2rem;
    font-weight: bold;
}
.toggle-btn {
    width: 60px; padding: 8px; font-size: 1rem; background: var(--danger); color: white;
}
.toggle-btn.on { background: var(--success); }
.btn-danger { background: var(--danger); color: white; padding: 10px; margin-bottom: 15px; width: 100%; font-size: 1.1rem; }

/* Game Screen */
.game-header {
    display: flex;
    align-items: center;
    width: 100%;
    margin-bottom: 15px;
    gap: 15px;
}
.progress-container {
    flex-grow: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,0.2);
    padding: 8px 15px;
    border-radius: 20px;
    color: white;
    font-weight: bold;
}
.progress-bar {
    flex-grow: 1;
    height: 10px;
    background: rgba(255,255,255,0.2);
    border-radius: 5px;
    overflow: hidden;
}
#progress-fill {
    height: 100%;
    width: 0%;
    background: #ffd700;
    transition: width 0.3s ease;
}

.health-container {
    display: flex;
    align-items: center;
    width: 100%;
    margin-bottom: 15px;
    gap: 15px;
    background: rgba(0,0,0,0.2);
    padding: 8px 15px;
    border-radius: 20px;
    color: white;
    font-weight: bold;
}
.health-label {
    min-width: 100px;
}
.health-bar {
    flex-grow: 1;
    height: 10px;
    background: rgba(255,255,255,0.2);
    border-radius: 5px;
    overflow: hidden;
}
#health-fill {
    height: 100%;
    width: 100%;
    background: #ff4757;
    transition: width 0.3s ease, background 0.3s ease;
}

.stats-row {
    display: flex;
    justify-content: space-between;
    width: 100%;
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: clamp(8px, 2.5vh, 20px);
}
.score-box, .streak-box {
    background: rgba(0,0,0,0.2);
    padding: 5px 15px;
    border-radius: 15px;
}

.question-container {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: clamp(10px, 3vh, 25px);
    perspective: 1000px;
}

.image-wrapper {
    width: 100%;
    max-width: clamp(200px, 42vh, 400px);
    aspect-ratio: 4/3;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    background: var(--card-bg);
    animation: slideInDown 0.5s ease-out;
}

.image-wrapper img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
    transition: opacity 0.3s;
}

.image-wrapper img.hidden {
    opacity: 0;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0,0,0,0.1);
    border-top: 4px solid var(--btn-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    position: absolute;
}
.spinner.hidden { display: none; }

/* Answers */
.answers-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(8px, 2vh, 15px);
    width: 100%;
}
@media (max-width: 500px) {
    .answers-grid { grid-template-columns: 1fr; }
}

.answer-btn {
    background: white;
    color: var(--text-dark);
    padding: clamp(8px, 1.8vh, 15px);
    font-size: clamp(0.9rem, 2.6vh, 1.1rem);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    border: 3px solid transparent;
    /* Reserve enough height for the longest realistic (2-line) country
       name so switching between short and long answers never changes
       the button/grid height between questions. Scales down on short
       viewports so two rows of answers still fit without overflow. */
    min-height: clamp(56px, 11vh, 76px);
}
.answer-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
    background: #f8f9fa;
}
.answer-btn:active:not(:disabled) { transform: scale(0.98); }

.btn-letter {
    background: var(--primary-bg);
    color: white;
    width: 35px; height: 35px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: 15px;
    font-weight: 800;
    flex-shrink: 0;
}

.btn-text { text-align: left; line-height: 1.3; }

/* Answer States */
.answer-btn.correct {
    background: var(--success-light);
    border-color: var(--success);
    color: var(--success);
    animation: pulse 0.4s;
}
.answer-btn.correct .btn-letter { background: var(--success); }

.answer-btn.wrong {
    background: var(--danger-light);
    border-color: var(--danger);
    color: var(--danger);
    animation: shake 0.4s;
}
.answer-btn.wrong .btn-letter { background: var(--danger); }

.answer-btn.hint-eliminated {
    opacity: 0.35;
    filter: grayscale(0.6);
    box-shadow: none;
    pointer-events: none;
}

/* Hint Button */
.hint-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #ffb347, #ff8c00);
    color: white;
    border: none;
    padding: 5px 14px;
    border-radius: 15px;
    font-family: var(--font-main);
    font-weight: bold;
    font-size: 1.05rem;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.2s ease;
    box-shadow: 0 3px 6px rgba(255,140,0,0.35);
}
.hint-btn .hint-icon { font-size: 1.1rem; }
.hint-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(255,140,0,0.45);
}
.hint-btn:active:not(:disabled) { transform: scale(0.96); }
.hint-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}
.hint-btn.hint-empty {
    background: linear-gradient(135deg, #999, #666);
    box-shadow: none;
}
.hint-btn.hint-pop { animation: pulse 0.4s; }

/* Hint Refill (Rewarded Ad) Modal */
.hint-ad-content { text-align: center; }
.hint-ad-icon { font-size: 3rem; margin-bottom: 10px; }
.hint-ad-desc { color: #666; margin: 10px 0 20px; font-size: 1rem; }
.hint-ad-buttons { display: flex; flex-direction: column; gap: 10px; }
.btn-hint-watch {
    background: linear-gradient(135deg, #ffb347, #ff8c00);
    color: white;
    border: none;
    padding: 12px;
    border-radius: var(--radius);
    font-family: var(--font-main);
    font-weight: bold;
    font-size: 1.1rem;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 4px 8px rgba(255,140,0,0.35);
}
.btn-hint-watch:hover { transform: translateY(-2px); box-shadow: 0 6px 12px rgba(255,140,0,0.45); }
.btn-hint-watch:active { transform: translateY(0); }
.hint-ad-spinner {
    position: static;
    margin: 10px auto;
    border-top-color: #ff8c00;
}

/* Results Screen */
.results-card {
    max-width: 400px;
    margin-bottom: 25px;
}
.result-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
    font-size: 1.2rem;
}
.result-row:last-child { border-bottom: none; }
.result-row strong { color: var(--primary-bg); font-size: 1.4rem; }

/* Offline Alert */
#offline-alert {
    position: fixed;
    top: 0; left: 0; width: 100%;
    background: var(--danger);
    color: white;
    text-align: center;
    padding: 15px;
    z-index: 9999;
    font-weight: bold;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}
#offline-alert.hidden { display: none; }
#offline-alert p { font-size: 0.9rem; font-weight: normal; margin-top: 5px; }

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes slideInDown {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
/* Additional styles to append */

.selectors-container {
    display: flex;
    gap: 20px;
    margin-top: clamp(8px, 2.5vh, 20px);
}
.selector-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: white;
    font-size: 1.1rem;
}
.selector-group select {
    margin-top: 5px;
    padding: 10px;
    border-radius: 10px;
    border: none;
    font-family: var(--font-main);
    font-weight: 600;
    cursor: pointer;
}

.hud-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: clamp(5px, 1.5vh, 10px);
    gap: 15px;
}
.hud-middle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 15px;
    margin-bottom: clamp(6px, 2vh, 15px);
}

.timer-container {
    background: rgba(0,0,0,0.2);
    padding: 8px 15px;
    border-radius: 20px;
    color: white;
    font-weight: bold;
    font-size: 1.2rem;
    min-width: 80px;
    text-align: center;
}
.timer-urgent {
    background: var(--danger);
    animation: pulseUrgent 0.5s infinite alternate;
}

.performance-rating {
    font-size: 1.5rem;
    color: #ffd700;
    margin-bottom: 15px;
    text-shadow: 1px 2px 4px rgba(0,0,0,0.3);
    font-weight: 800;
}
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }

/* Floating Text Animation */
/* This layer is a fixed, viewport-sized, clipped overlay. Floating text
   is appended into it (instead of directly onto <body>) so the particles
   can never expand the document's scrollable height — which was the
   actual cause of the page nudging up/down every question. */
#floating-text-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    z-index: 60;
}
.floating-text {
    position: absolute;
    color: white;
    font-weight: 900;
    font-size: 1.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    pointer-events: none;
    animation: floatUpFadeOut 1s ease-out forwards;
    z-index: 50;
}
.floating-text.correct { color: var(--success-light); }
.floating-text.bonus { color: #ffd700; }
.floating-text.wrong { color: var(--danger-light); }
.floating-text.streak { color: #ff7f50; font-size: 2rem; }

@keyframes pulseUrgent {
    from { transform: scale(1); }
    to { transform: scale(1.1); box-shadow: 0 0 10px var(--danger); }
}

@keyframes floatUpFadeOut {
    0% { transform: translateY(0) scale(0.5); opacity: 0; }
    20% { transform: translateY(-20px) scale(1.2); opacity: 1; }
    100% { transform: translateY(-60px) scale(1); opacity: 0; }
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .selectors-container {
        flex-direction: column;
        gap: 10px;
    }
    .hud-middle {
        flex-direction: column;
    }
    .health-container, .timer-container {
        width: 100%;
    }
}


/* =============================================================
   LEADERBOARD & SAVE SCORE STYLES
   ============================================================= */

/* Leaderboard button (gold accent) */
.btn-leaderboard {
    padding: clamp(10px, 2vh, 15px) 30px;
    font-size: clamp(1rem, 3vh, 1.2rem);
    width: 100%;
    max-width: 300px;
    margin: clamp(5px, 1.4vh, 10px) 0;
    color: #1a1a2e;
    font-family: var(--font-main);
    font-weight: 800;
    background: linear-gradient(135deg, #ffd700, #ffb300);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}
.btn-leaderboard:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(255, 215, 0, 0.6);
}
.btn-leaderboard:active { transform: translateY(0); }

/* ---- LEADERBOARD SCREEN ---- */
#leaderboard-screen {
    padding: 20px;
    max-height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior: contain;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.lb-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    color: white;
}
.lb-header h2 {
    font-size: 1.6rem;
    font-weight: 800;
    flex: 1;
    text-align: center;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.lb-filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    justify-content: center;
}
.lb-filters select {
    padding: 10px 14px;
    border-radius: 12px;
    border: none;
    font-family: var(--font-main);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    background: rgba(255,255,255,0.95);
    color: #333;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    flex: 1;
    min-width: 130px;
    max-width: 180px;
}
.btn-refresh {
    padding: 10px 16px;
    border-radius: 12px;
    border: none;
    background: rgba(255,255,255,0.25);
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    font-family: var(--font-main);
}
.btn-refresh:hover { background: rgba(255,255,255,0.4); transform: rotate(20deg); }

/* Loading */
.lb-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    color: white;
    padding: 40px;
    font-size: 1.1rem;
}
.lb-spinner {
    width: 45px; height: 45px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.lb-error {
    text-align: center;
    color: white;
    padding: 30px;
    font-size: 1.1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

/* Content */
.lb-content { width: 100%; }

/* Personal Best */
.lb-personal-best {
    background: linear-gradient(135deg, rgba(255,215,0,0.2), rgba(255,180,0,0.15));
    border: 2px solid rgba(255,215,0,0.5);
    border-radius: 16px;
    padding: 14px 18px;
    margin-bottom: 18px;
    color: white;
}
.lb-pb-label {
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: #ffd700;
    margin-bottom: 8px;
}
.lb-pb-card {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}
.lb-pb-rank {
    font-size: 1.8rem;
    font-weight: 800;
    color: #ffd700;
    min-width: 50px;
}
.lb-pb-info { flex: 1; }
.lb-pb-name { font-weight: 800; font-size: 1.1rem; }
.lb-pb-title { font-size: 0.9rem; opacity: 0.85; }
.lb-pb-stats { display: flex; gap: 14px; font-size: 0.95rem; }
.lb-pb-stats strong { font-weight: 800; }

/* Leaderboard Entries */
.lb-list { display: flex; flex-direction: column; gap: 10px; }
.lb-empty { text-align: center; color: rgba(255,255,255,0.7); padding: 40px; font-size: 1.1rem; }

.lb-entry {
    background: rgba(255,255,255,0.97);
    border-radius: 14px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 3px 12px rgba(0,0,0,0.12);
    transition: transform 0.15s, box-shadow 0.15s;
    animation: slideInUp 0.3s ease both;
    position: relative;
    overflow: hidden;
}
.lb-entry:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,0.18); }

/* Top 3 special treatment */
.lb-entry.rank-1 { background: linear-gradient(135deg, #fff8dc, #fffacd); border-left: 4px solid #ffd700; }
.lb-entry.rank-2 { background: linear-gradient(135deg, #f0f0f0, #e8e8e8); border-left: 4px solid #c0c0c0; }
.lb-entry.rank-3 { background: linear-gradient(135deg, #fff3e0, #ffe0b2); border-left: 4px solid #cd7f32; }

.lb-entry.rank-1 .lb-rank,
.lb-entry.rank-2 .lb-rank,
.lb-entry.rank-3 .lb-rank { font-size: 1.6rem; }

.lb-rank {
    font-size: 1.1rem;
    font-weight: 800;
    min-width: 42px;
    text-align: center;
    color: #333;
}
.lb-player { flex: 1; min-width: 0; }
.lb-player-name {
    font-weight: 800;
    font-size: 1rem;
    color: #1a1a2e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.lb-player-title { font-size: 0.82rem; color: #666; margin-top: 2px; }
.lb-player-meta  { font-size: 0.78rem; color: #999; margin-top: 2px; }

.lb-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    text-align: right;
    min-width: 90px;
}
.lb-score { font-size: 1.15rem; font-weight: 800; color: #6a0dad; }
.lb-streak { font-size: 0.85rem; color: #ff6347; font-weight: 700; }
.lb-accuracy { font-size: 0.85rem; color: #28a745; font-weight: 700; }

/* ---- SAVE SCORE MODAL ---- */
.leaderboard-modal-content {
    max-width: 420px;
    width: 90%;
}

.save-modal-sub {
    color: #666;
    font-size: 0.95rem;
    margin-bottom: 16px;
    text-align: center;
}

.save-score-preview {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.save-preview-item {
    background: linear-gradient(135deg, #f3e5ff, #ead6ff);
    border-radius: 12px;
    padding: 10px 18px;
    text-align: center;
    min-width: 90px;
    flex: 1;
}
.save-preview-item span { display: block; font-size: 0.75rem; color: #888; font-weight: 600; }
.save-preview-item strong { display: block; font-size: 1.1rem; font-weight: 800; color: #6a0dad; margin-top: 4px; }

.name-input-group { width: 100%; margin-bottom: 14px; }
.name-input-group label { display: block; font-weight: 700; margin-bottom: 6px; color: #444; font-size: 0.9rem; }
#player-name-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #d0a0ff;
    border-radius: 12px;
    font-family: var(--font-main);
    font-size: 1.1rem;
    font-weight: 700;
    color: #333;
    outline: none;
    transition: border-color 0.2s;
    background: #fafafa;
}
#player-name-input:focus { border-color: #8a2be2; background: white; }
.input-hint { font-size: 0.78rem; color: #aaa; margin-top: 5px; }

.save-error {
    background: #fdecea;
    color: #c0392b;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.9rem;
    margin-bottom: 10px;
    text-align: center;
    font-weight: 600;
}

.save-modal-buttons { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.btn-save-confirm {
    padding: 14px 30px;
    font-size: 1.1rem;
    background: linear-gradient(135deg, #8a2be2, #6a0dad);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-family: var(--font-main);
    font-weight: 800;
    width: 100%;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 14px rgba(138,43,226,0.4);
}
.btn-save-confirm:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(138,43,226,0.5); }
.btn-save-confirm:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* ---- SCORE SAVED SUCCESS ---- */
.score-saved-content { text-align: center; }
.saved-check {
    width: 64px; height: 64px;
    background: linear-gradient(135deg, #28a745, #20c750);
    color: white;
    border-radius: 50%;
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    box-shadow: 0 4px 20px rgba(40,167,69,0.4);
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}
.saved-rank-box {
    background: linear-gradient(135deg, #ffd700, #ffb300);
    border-radius: 16px;
    padding: 14px 24px;
    margin: 12px 0;
    display: inline-block;
    min-width: 140px;
}
.saved-rank-label { font-size: 0.8rem; font-weight: 700; color: rgba(0,0,0,0.6); letter-spacing: 1px; }
.saved-rank-number { font-size: 2.5rem; font-weight: 800; color: #1a1a2e; line-height: 1; }

/* ---- ANIMATIONS ---- */
@keyframes slideInUp {
    from { opacity: 0; transform: translateY(15px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes popIn {
    from { transform: scale(0); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

/* ---- MOBILE RESPONSIVE ---- */
@media (max-width: 600px) {
    .lb-header h2 { font-size: 1.2rem; }
    .lb-filters select { min-width: 100px; font-size: 0.85rem; }
    .lb-entry { padding: 12px; gap: 10px; }
    .lb-stats { min-width: 75px; }
    .lb-score { font-size: 1rem; }
    .lb-player-meta { display: none; }
    .save-score-preview { gap: 6px; }
    .save-preview-item { padding: 8px 12px; min-width: 75px; }
}

/* ── Y8 Menu Branding ── */
.menu-y8-branding {
    position: fixed;
    bottom: 12px;
    left: 12px;
    z-index: 9999;
}
.menu-y8-logo {
    width: 72px;
    opacity: 0.85;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.35));
    transition: opacity 0.2s, transform 0.2s;
}
.menu-y8-logo:hover {
    opacity: 1;
    transform: scale(1.1);
}



/* Midgame ad popup (start-of-game interstitial) */
.midgame-ad-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}
