:root {
    --bg-dark: #0c0d12;
    --bg-mid: #151822;
    --panel-bg: #1a1e28;
    --panel-bg-lit: #222836;
    --panel-border: #0a0b0f;
    --panel-highlight: #2e3544;
    --wood-light: #a35f2e;
    --wood-mid: #7a4320;
    --wood-dark: #4a2712;
    --wood-grain: #3a1d0c;
    --desk-mat-bg: #2a5540;
    --desk-mat-mid: #234836;
    --desk-mat-border: #163024;
    --desk-mat-stitch: #3d6e52;
    --accent-yellow: #f4b41b;
    --accent-yellow-lite: #fedb6d;
    --accent-red: #de3c3c;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --text-white: #f3f4f6;
    --text-muted: #9ca3af;
    --pixel-border-color: #000000;
    --ui-scale: 1;
    --side-panel-width: 300px;
    --header-height: calc(72px * var(--ui-scale));
    --mobile-nav-height: 54px;
    --bottom-dock-height: calc(64px * var(--ui-scale));
    --menu-sheet-max: min(58vh, calc(520px * var(--ui-scale)));
    --ui-gap: calc(10px * var(--ui-scale));
    --ui-pad: calc(10px * var(--ui-scale));
    --hud-coin-size: calc(22px * var(--ui-scale));
    --hud-stat-size: calc(22px * var(--ui-scale));
    --hud-level-size: calc(18px * var(--ui-scale));
    --hud-pad-y: calc(5px * var(--ui-scale));
    --hud-pad-x: calc(12px * var(--ui-scale));
    --hud-icon: 1em;
    --dock-font: max(12px, calc(10px * var(--ui-scale)));
    --dock-icon-size: calc(22px * var(--ui-scale));
    --dock-btn-min: calc(48px * var(--ui-scale));
    --sheet-title-size: max(12px, calc(12px * var(--ui-scale)));
    --panel-item-pad: calc(10px * var(--ui-scale));
    --panel-name-size: max(12px, calc(11px * var(--ui-scale)));
    --panel-desc-size: max(12px, calc(12px * var(--ui-scale)));
    --panel-cost-size: max(12px, calc(11px * var(--ui-scale)));
    --panel-claim-size: max(12px, calc(11px * var(--ui-scale)));
    --panel-icon-size: calc(18px * var(--ui-scale));
    /* Modal / overlay scale tokens (menus, dialogs, tutorial) */
    --modal-width: min(94vw, calc(500px * var(--ui-scale)));
    --modal-max-height: min(92dvh, calc(680px * var(--ui-scale)));
    --modal-border: calc(5px * var(--ui-scale));
    --modal-header-pad: calc(12px * var(--ui-scale));
    --modal-title-size: max(14px, calc(13px * var(--ui-scale)));
    --modal-body-size: max(14px, calc(18px * var(--ui-scale)));
    --modal-body-pad: calc(15px * var(--ui-scale));
    --modal-footer-pad: calc(12px * var(--ui-scale));
    --modal-footer-gap: calc(10px * var(--ui-scale));
    --modal-close-size: calc(32px * var(--ui-scale));
    --modal-close-hit: max(44px, calc(44px * var(--ui-scale)));
    --modal-action-font: max(12px, calc(12px * var(--ui-scale)));
    --modal-action-pad-y: calc(12px * var(--ui-scale));
    --modal-action-pad-x: calc(20px * var(--ui-scale));
    --modal-action-min-h: max(44px, calc(46px * var(--ui-scale)));
    --modal-footnote-size: max(12px, calc(12px * var(--ui-scale)));
    --stats-modal-width: min(94vw, calc(440px * var(--ui-scale)));
    --ad-confirm-width: min(94vw, calc(420px * var(--ui-scale)));
    --daily-spin-width: min(94vw, calc(400px * var(--ui-scale)));
    --daily-spin-wheel-size: min(calc(252px * var(--ui-scale)), 78vw, 44dvh);
    --tutorial-banner-width: min(94vw, calc(340px * var(--ui-scale)));
    --tutorial-banner-font: calc(18px * var(--ui-scale));
    --ad-break-pad-y: calc(22px * var(--ui-scale));
    --ad-break-pad-x: calc(28px * var(--ui-scale));
    --focused-card-width: 320px;
    --focused-card-height: 420px;
    --font-pixel: 'Pixelify Sans', 'Segoe UI', system-ui, sans-serif;
    /* VT323 retired for EN: two player reports called the font unreadable ("impossible to tell
       what number is displayed"). Mirror the TR setup — Pixelify for retro flavour text, a clean
       system stack for digits/body — so EN gets the same legible numerals TR always had. */
    --font-retro: 'Pixelify Sans', 'Segoe UI', system-ui, sans-serif;
    --font-tr: 'Pixelify Sans', 'Segoe UI', system-ui, sans-serif;
    --font-digits: 'Segoe UI', system-ui, -apple-system, 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    --ui-cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 16 16'%3E%3Cpath d='M0 0 L0 11 L3 8 L6 14 L8 13 L5 7 L9 7 Z' fill='%23f4b41b' stroke='%23000' stroke-width='1'/%3E%3Cpath d='M1 2 L1 9 L3 7 L6 12 L7 11 L4 6 L7 6 Z' fill='%23fedb6d'/%3E%3C/svg%3E") 0 0, default;
    --coin-cursor: url("../assets/ui/para-cursor.png?v=restore1") 16 16, auto;
    --coin-cursor-pressed: url("../assets/ui/para2-cursor.png?v=restore1") 16 16, auto;
}

/* TR: Press Start 2P / VT323 have no dotted/dotless i (ı/İ) — mixed fallback looked broken */
html[lang="tr"] {
    --font-pixel: var(--font-tr);
    --font-retro: var(--font-tr);
    --font-digits: 'Segoe UI', system-ui, -apple-system, 'Roboto', 'Helvetica Neue', Arial, sans-serif;
}

html[lang="tr"] body {
    font-size: clamp(19px, 2.6vw, 23px);
}

html[lang="tr"] .pixel-btn,
html[lang="tr"] .task-name,
html[lang="tr"] .ticket-name,
html[lang="tr"] .upgrade-name,
html[lang="tr"] .game-title,
html[lang="tr"] .modal-header h3,
html[lang="tr"] .menu-sheet-title,
html[lang="tr"] .panel-header h2,
html[lang="tr"] .dock-btn-label {
    letter-spacing: 0.02em;
    font-weight: 600;
}

html[lang="tr"] .pixel-btn.menu-text-btn {
    font-size: max(11px, calc(10px * var(--ui-scale)));
}

html[lang="tr"] .task-desc,
html[lang="tr"] .tutorial-body,
html[lang="tr"] .modal-body {
    font-weight: 400;
}

/* TR: Pixelify Sans glyphs are weak for 0-9 — use a clear digit stack */
html[lang="tr"] .coin-stat .value,
html[lang="tr"] .diamond-stat .value,
html[lang="tr"] .crown-stat .value,
html[lang="tr"] .level-stat .value,
html[lang="tr"] .progress-text,
html[lang="tr"] .ticket-cost,
html[lang="tr"] .upgrade-cost-tag,
html[lang="tr"] .task-reward,
html[lang="tr"] .achievement-reward,
html[lang="tr"] .stats-value,
html[lang="tr"] .overlay-reward,
html[lang="tr"] .queue-display,
html[lang="tr"] .upgrade-level,
html[lang="tr"] .earn-boost-hud,
html[lang="tr"] .text-popup,
html[lang="tr"] .money-float-text,
html[lang="tr"] .buy-qty-btn,
html[lang="tr"] .daily-spin-result,
html[lang="tr"] #machine-out-count,
html[lang="tr"] #machine-out-limit,
html[lang="tr"] #machine-queue-display,
html[lang="tr"] .ticket-tier,
html[lang="tr"] .ticket-payout,
html[lang="tr"] .cooldown-timer,
html[lang="tr"] .lock-level,
html[lang="tr"] .prestige-reward-line span:last-child {
    font-family: var(--font-digits);
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    letter-spacing: 0.02em;
    image-rendering: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    user-select: none;
    -webkit-user-drag: none;
}
body {
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(ellipse 90% 70% at 50% 18%, rgba(244, 180, 27, 0.07) 0%, transparent 55%),
        radial-gradient(ellipse 70% 50% at 50% 100%, rgba(59, 130, 246, 0.05) 0%, transparent 50%),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 3px,
            rgba(0, 0, 0, 0.12) 3px,
            rgba(0, 0, 0, 0.12) 4px
        );
    color: var(--text-white);
    font-family: var(--font-digits);
    font-size: clamp(18px, 2.5vw, 22px);
    line-height: 1.4;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    position: relative;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.game-loading {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse 80% 60% at 50% 40%, #1a1520 0%, var(--bg-dark) 70%);
    transition: opacity 0.45s ease, visibility 0.45s ease;
}
.game-loading.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.game-loading-inner {
    text-align: center;
    padding: 24px;
    max-width: min(92vw, 520px);
}
.game-loading-title {
    font-family: var(--font-pixel);
    font-size: clamp(14px, 3.8vw, 22px);
    color: var(--accent-yellow);
    line-height: 1.5;
    text-shadow:
        2px 2px 0 #000,
        0 0 18px rgba(244, 180, 27, 0.35);
    animation: title-glow 2s infinite alternate;
    margin-bottom: 20px;
}
.game-loading-status {
    font-family: var(--font-digits);
    font-size: clamp(20px, 4vw, 28px);
    color: var(--text-muted);
    letter-spacing: 0.08em;
    margin-bottom: 16px;
}
.game-loading-bar {
    width: min(280px, 70vw);
    height: 14px;
    margin: 0 auto;
    background: #14161a;
    border: 3px solid #000;
    box-shadow: inset -2px -2px 0 #0a0a0c, inset 2px 2px 0 #2a2d36;
    overflow: hidden;
}
.game-loading-bar-fill {
    height: 100%;
    width: 35%;
    background: linear-gradient(90deg, #c99212, var(--accent-yellow), #fedb6d);
    animation: loading-bar-slide 1.1s ease-in-out infinite;
}
@keyframes loading-bar-slide {
    0% { transform: translateX(-120%); width: 40%; }
    50% { width: 55%; }
    100% { transform: translateX(320%); width: 40%; }
}
.crt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background:
        radial-gradient(ellipse 75% 65% at 50% 45%, rgba(255, 255, 255, 0.04) 0%, transparent 55%),
        radial-gradient(circle at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.45) 100%);
    pointer-events: none;
    z-index: 9999;
}
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: linear-gradient(
        rgba(18, 16, 16, 0) 50%,
        rgba(0, 0, 0, 0.12) 50%
    );
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 9998;
    opacity: 0.55;
}
.game-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    width: 100%;
    max-width: 1800px;
    margin-inline: auto;
    padding: 10px;
    padding-bottom: 0;
    position: relative;
}
.top-bar {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 20px;
    align-items: center;
    background-color: var(--panel-bg);
    background-image:
        linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, transparent 40%),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 7px,
            rgba(0, 0, 0, 0.08) 7px,
            rgba(0, 0, 0, 0.08) 8px
        );
    border: 4px solid var(--pixel-border-color);
    box-shadow:
        inset -3px -3px 0px #101218,
        inset 3px 3px 0px var(--panel-highlight),
        0px 4px 0px rgba(0, 0, 0, 0.45);
    padding: 8px 16px;
    margin-bottom: 10px;
    z-index: 10;
    position: relative;
}
.top-bar::after {
    content: '';
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 0;
    height: 2px;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(244, 180, 27, 0.35) 20%,
        rgba(244, 180, 27, 0.55) 50%,
        rgba(244, 180, 27, 0.35) 80%,
        transparent
    );
    pointer-events: none;
}
.stats-container {
    display: flex;
    gap: 15px;
    align-items: center;
    min-width: 0;
    flex: 1 1 auto;
}
.stat-box {
    background: #0c0e14;
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 60%);
    border: 3px solid var(--pixel-border-color);
    padding: 4px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow:
        inset 2px 2px 0px #000,
        inset -1px -1px 0px #2a2e38;
}
.coin-stat,
.diamond-stat,
.crown-stat {
    width: fit-content;
    max-width: 100%;
    min-width: 0;
    flex-shrink: 0;
    padding: var(--hud-pad-y) var(--hud-pad-x);
    gap: calc(6px * var(--ui-scale));
    overflow: visible;
    font-size: var(--hud-coin-size);
    border-width: 3px;
}
.coin-stat {
    border-color: var(--accent-yellow);
    box-shadow:
        inset 2px 2px 0px #000,
        inset -1px -1px 0px #3a3018,
        0 0 0 1px rgba(244, 180, 27, 0.25);
}
.diamond-stat {
    border-color: #60a5fa;
    box-shadow:
        inset 2px 2px 0px #000,
        inset -1px -1px 0px #1e3a5f,
        0 0 0 1px rgba(96, 165, 250, 0.3);
}
.diamond-stat .diamond-icon,
.crown-stat .crown-icon-img,
.coin-stat .coin-icon {
    width: 1em;
    height: 1em;
    flex-shrink: 0;
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    object-fit: contain;
}
.diamond-stat .value {
    color: #93c5fd;
    font-weight: bold;
    font-size: 1em;
    font-family: var(--font-digits);
    line-height: 1;
    white-space: nowrap;
}
body.mobile-layout .diamond-stat,
body.mobile-layout .crown-stat,
body.mobile-layout .coin-stat {
    font-size: calc(18px * var(--ui-scale));
    padding: calc(4px * var(--ui-scale)) calc(10px * var(--ui-scale));
}
body.mobile-layout .stats-container {
    flex-wrap: wrap;
    row-gap: 6px;
}
.crown-stat {
    border-color: #c084fc;
    box-shadow:
        inset 2px 2px 0px #000,
        inset -1px -1px 0px #4c1d95,
        0 0 0 1px rgba(192, 132, 252, 0.35);
}
.crown-stat .crown-icon-img {
    /* Match diamond crispness — no soft upscale blur */
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    filter: drop-shadow(0 0 1px rgba(233, 213, 255, 0.35));
}
.crown-stat .crown-icon {
    color: #e9d5ff;
    font-size: 0.95em;
    line-height: 1;
    text-shadow: 1px 1px 0 #000;
}
.crown-stat .value {
    color: #e9d5ff;
    font-weight: bold;
    font-size: 1em;
    font-family: var(--font-digits);
    line-height: 1;
    white-space: nowrap;
}
#prestige-btn.ready {
    color: #f3e8ff;
    border-color: #d8b4fe;
    box-shadow:
        inset -2px -2px 0px #4c1d95,
        inset 2px 2px 0px #e9d5ff,
        0 0 0 1px rgba(192, 132, 252, 0.35);
}
/* Crown costs use the same purple as the Crown counter in the top-left HUD (.crown-stat). */
.upgrade-cost-tag.crown-cost {
    border-color: #c084fc;
    color: #e9d5ff;
}
.upgrade-item.affordable:not(.maxed) .upgrade-cost-tag.crown-cost {
    color: #e9d5ff;
    border-color: #c084fc;
}
.upgrade-item.unaffordable .upgrade-cost-tag.crown-cost {
    color: #e9d5ff;
    border-color: #c084fc;
}
/* The ♛ glyph shown next to a prestige upgrade's name. */
.crown-glyph {
    color: #e9d5ff;
    text-shadow: 1px 1px 0 #000;
}

/* Sticky Diamond / Crown jump bar at the top of the Upgrades panel — Crown (prestige)
   upgrades sit far down the list and were hard to discover (CrazyGames feedback). */
/* Lives in the menu-sheet header so it is always visible and never scrolls away.
   Only shown while the Upgrades panel is open. */
.upgrade-nav { display: none; }
#menu-sheet[data-panel="upgrades"] .upgrade-nav {
    display: flex;
    gap: calc(8px * var(--ui-scale));
    margin-left: auto;
}
.upgrade-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: calc(5px * var(--ui-scale));
    min-height: max(34px, calc(34px * var(--ui-scale)));
    padding: calc(5px * var(--ui-scale)) calc(10px * var(--ui-scale));
    background: #1e2430;
    border: 2px solid #000;
    white-space: nowrap;
}
.upgrade-nav-icon { font-size: 1.05em; line-height: 1; }
.upgrade-nav-btn.diamond-nav {
    color: #93c5fd;
    box-shadow: inset -2px -2px 0 #10141c, inset 2px 2px 0 #3b5578, 0 0 0 1px rgba(96, 165, 250, 0.35);
}
.upgrade-nav-btn.crown-nav {
    color: #e9d5ff;
    box-shadow: inset -2px -2px 0 #10141c, inset 2px 2px 0 #5b3d7a, 0 0 0 1px rgba(192, 132, 252, 0.35);
}
.upgrade-nav-btn.diamond-nav:hover,
.upgrade-nav-btn.diamond-nav.active { background: #26344a; border-color: #60a5fa; }
.upgrade-nav-btn.crown-nav:hover,
.upgrade-nav-btn.crown-nav.active { background: #2f2440; border-color: #c084fc; }

/* Brief highlight on the row we jumped to, so the player sees where they landed. */
@keyframes upgrade-jump-flash {
    0%, 100% { box-shadow: none; }
    35% { box-shadow: 0 0 0 2px var(--accent-yellow), 0 0 12px rgba(244, 180, 27, 0.55); }
}
.upgrade-item.upgrade-jump-flash {
    animation: upgrade-jump-flash 1.1s ease-out 1;
}
.upgrade-item.persistent {
    border-color: #6b21a8;
}
.prestige-reward-line {
    font-family: var(--font-pixel);
    font-size: max(13px, calc(12px * var(--ui-scale)));
    color: #e9d5ff;
    margin-top: calc(10px * var(--ui-scale));
}
#confirm-prestige-btn:disabled,
#confirm-prestige-btn.unaffordable {
    opacity: 0.45;
    pointer-events: none;
}
.coin-stat .coin-icon {
    width: 1em;
    height: 1em;
    flex-shrink: 0;
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    object-fit: contain;
}
.coin-stat .value {
    color: var(--accent-yellow);
    font-weight: bold;
    font-size: 1em;
    font-family: var(--font-digits);
    line-height: 1;
    white-space: nowrap;
}
.level-stat {
    flex: 1 1 280px;
    min-width: 240px;
    max-width: 320px;
    font-size: var(--hud-level-size);
}
.level-stat .value {
    color: var(--accent-blue);
    font-weight: bold;
    flex-shrink: 0;
}
.progress-bar-container {
    flex: 1 1 120px;
    min-width: 120px;
    height: 20px;
    background: #151820;
    border: 2px solid #000;
    position: relative;
    overflow: hidden;
    box-shadow: inset 2px 2px 0 #0a0b0f;
}
.progress-bar-fill {
    height: 100%;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.25) 0%, transparent 45%),
        repeating-linear-gradient(
            90deg,
            var(--accent-blue) 0 6px,
            #2563eb 6px 8px
        );
    width: 0%;
    transition: width 0.3s ease;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25);
}
.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
    font-family: var(--font-digits);
    color: #fff;
    text-shadow: 1px 1px 0px #000;
    white-space: nowrap;
}
.level-xp-badge {
    display: flex;
    align-items: center;
    --xp-pct: 0;
    width: auto;
    height: auto;
    padding: 0;
    flex-shrink: 0;
    background: none;
    box-shadow: none;
}
.level-xp-badge-inner {
    width: auto;
    height: auto;
    background: none;
    border: none;
    display: flex;
    align-items: center;
    padding: 0;
}
.level-xp-badge .value {
    color: var(--accent-blue);
    font-weight: bold;
    font-size: 18px;
    font-family: var(--font-digits);
    line-height: 1;
}
.level-xp-badge.level-up-pulse {
    animation: level-ring-pulse 0.55s ease;
}
@keyframes level-ring-pulse {
    0%, 100% { filter: none; transform: scale(1); }
    50% { filter: drop-shadow(0 0 6px rgba(59, 130, 246, 0.9)); transform: scale(1.08); }
}
.title-container {
    text-align: center;
}
.game-title {
    font-family: var(--font-pixel);
    font-size: 18px;
    color: #fff;
    letter-spacing: 2px;
    text-shadow:
        3px 3px 0px #000,
        -1px -1px 0px #000,
        0 0 12px rgba(244, 180, 27, 0.25);
    animation: title-glow 2.4s infinite alternate;
}
@keyframes title-glow {
    from {
        color: #fff8e7;
        text-shadow:
            3px 3px 0px #000,
            0 0 6px rgba(244, 180, 27, 0.35);
    }
    to {
        color: var(--accent-yellow-lite);
        text-shadow:
            3px 3px 0px #000,
            0 0 14px rgba(244, 180, 27, 0.75);
    }
}
.menu-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.pixel-btn {
    font-family: var(--font-pixel);
    font-size: max(12px, calc(11px * var(--ui-scale)));
    padding: 8px 12px;
    background:
        linear-gradient(180deg, #4a4f5c 0%, #3a3d46 55%, #32353e 100%);
    border: 3px solid #000;
    color: #fff;
    cursor: var(--ui-cursor);
    box-shadow:
        inset -2px -2px 0px #1a1b1f,
        inset 2px 2px 0px #6a7080;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s ease, filter 0.1s ease;
    image-rendering: pixelated;
}
.pixel-btn:hover {
    background:
        linear-gradient(180deg, #575c6c 0%, #474b57 55%, #3d414c 100%);
    transform: translateY(-2px);
    box-shadow:
        inset -2px -2px 0px #1a1b1f,
        inset 2px 2px 0px #7a8194,
        0px 3px 0px rgba(0, 0, 0, 0.35);
}
.pixel-btn:active {
    transform: translateY(1px);
    box-shadow:
        inset 2px 2px 0px #1a1b1f,
        inset -2px -2px 0px #474b57;
}
.menu-text-btn {
    font-size: max(12px, calc(11px * var(--ui-scale)));
    height: 36px;
    padding: 0 10px;
}
.lang-toggle-btn {
    min-width: 40px;
    font-weight: bold;
    letter-spacing: 1px;
}
.audio-toggle-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.menu-icon-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    flex-shrink: 0;
}
body.mobile-layout .menu-icon-btn {
    width: 44px;
    height: 44px;
}
body.mobile-layout .pixel-btn.menu-text-btn {
    min-height: 44px;
}
.menu-audio-icon {
    display: block;
    width: 20px;
    height: 20px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    pointer-events: none;
}
.menu-icon-btn .audio-icon {
    display: block;
    pointer-events: none;
}
.menu-icon-btn.audio-muted:not(.disabled) {
    opacity: 0.55;
}
.menu-icon-btn.disabled {
    opacity: 0.35;
    cursor: var(--ui-cursor);
}
.pixel-icon {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}
.game-layout {
    display: grid;
    grid-template-columns: 1fr;
    flex: 1;
    min-height: 0;
    gap: 0;
    margin-bottom: calc(var(--bottom-dock-height) + env(safe-area-inset-bottom, 0px));
}
.game-layout.desk-only-layout {
    grid-template-columns: 1fr;
}
.game-layout.desk-only-layout .desk-area {
    width: 100%;
    min-height: 0;
}
.desk-area.menu-dimmed::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(8, 10, 14, 0.35);
    pointer-events: none;
    z-index: 40;
}
.mobile-panel-nav {
    display: none !important;
    flex-shrink: 0;
    gap: 6px;
    padding: 6px 8px;
    padding-bottom: 6px;
    background: var(--panel-bg);
    border: 3px solid var(--pixel-border-color);
    box-shadow: 0 -4px 0 rgba(0, 0, 0, 0.35);
    position: relative;
    z-index: 1500;
}
.mobile-nav-btn {
    flex: 1;
    font-family: var(--font-pixel);
    font-size: clamp(6px, 1.8vw, 8px);
    padding: 10px 4px;
    min-height: 44px;
    background: #252830;
    border: 2px solid #000;
    color: var(--text-muted);
    cursor: var(--ui-cursor);
    box-shadow: inset -2px -2px 0 #1a1b1f, inset 2px 2px 0 #474b57;
}
.mobile-nav-btn.active {
    background: #3a3d46;
    color: var(--accent-yellow);
    border-color: var(--accent-yellow);
}
.mobile-nav-btn:focus {
    outline: none;
}
.mobile-nav-btn:focus-visible {
    outline: 2px solid var(--accent-yellow);
    outline-offset: 1px;
}
.mobile-nav-btn.tutorial-locked {
    opacity: 0.35;
    pointer-events: none;
}
.panel {
    background-color: var(--panel-bg);
    background-image:
        linear-gradient(180deg, rgba(255, 255, 255, 0.035) 0%, transparent 28%),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 3px,
            rgba(0, 0, 0, 0.06) 3px,
            rgba(0, 0, 0, 0.06) 4px
        );
    border: 4px solid var(--pixel-border-color);
    box-shadow:
        inset -3px -3px 0px #101218,
        inset 3px 3px 0px var(--panel-highlight),
        0px 5px 0px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    position: relative;
}
.panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(
        90deg,
        transparent 4%,
        rgba(244, 180, 27, 0.2) 25%,
        rgba(244, 180, 27, 0.45) 50%,
        rgba(244, 180, 27, 0.2) 75%,
        transparent 96%
    );
    z-index: 2;
    pointer-events: none;
}
.panel-header {
    background:
        linear-gradient(180deg, #1a1d26 0%, #11141b 100%);
    border-bottom: 4px solid var(--pixel-border-color);
    padding: 8px 12px;
    text-align: center;
    position: relative;
    z-index: 1;
}
.panel-header h2 {
    font-family: var(--font-pixel);
    font-size: 11px;
    color: var(--accent-yellow);
    letter-spacing: 1px;
    text-shadow: 2px 2px 0 #000, 0 0 8px rgba(244, 180, 27, 0.25);
}
.panel-tabs {
    display: flex;
    background: #0f1013;
    border-bottom: 3px solid #000;
}
.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-pixel);
    font-size: max(12px, calc(11px * var(--ui-scale)));
    padding: 8px 0;
    cursor: var(--ui-cursor);
    text-align: center;
    position: relative;
}
.tab-btn.active {
    background: var(--panel-bg);
    color: #fff;
    border-bottom: 3px solid var(--accent-yellow);
    font-weight: bold;
}
.tab-btn.has-claim {
    color: #93c5fd;
}
.tasks-claim-badge {
    position: absolute;
    top: 2px;
    right: 6px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border: 2px solid #000;
    background: var(--accent-red);
    color: #fff;
    font-family: var(--font-pixel);
    font-size: max(12px, calc(10px * var(--ui-scale)));
    line-height: max(14px, calc(12px * var(--ui-scale)));
    text-align: center;
    box-shadow: 1px 1px 0 #000;
}
.tasks-claim-badge.hidden {
    display: none;
}
.upgrade-cost-tag.diamond-cost {
    border-color: #60a5fa;
    color: #93c5fd;
}
.upgrade-item.affordable:not(.maxed) .upgrade-cost-tag.diamond-cost {
    color: #93c5fd;
    border-color: #60a5fa;
}
/* Keep the diamond cost blue (matching the HUD token counter) even when unaffordable — just dimmed. */
.upgrade-item.unaffordable .upgrade-cost-tag.diamond-cost {
    color: #93c5fd;
    border-color: #60a5fa;
    opacity: 0.72;
}
.task-item {
    background: linear-gradient(180deg, #2c313c 0%, #252830 100%);
    border: 3px solid #000;
    box-shadow:
        inset -2px -2px 0px #1a1c22,
        inset 2px 2px 0px #3a4050;
    padding: var(--panel-item-pad) calc(12px * var(--ui-scale));
    display: flex;
    align-items: flex-start;
    gap: calc(10px * var(--ui-scale));
    flex-shrink: 0;
}
.task-item.claimable {
    box-shadow:
        inset -2px -2px 0px #1a1c22,
        inset 2px 2px 0px #3a4050,
        0 0 0 2px rgba(96, 165, 250, 0.55);
}
.task-item.claimed {
    opacity: 0.55;
}
.task-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: calc(4px * var(--ui-scale));
}
.task-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: calc(8px * var(--ui-scale));
}
.task-name {
    font-family: var(--font-pixel);
    font-size: var(--panel-name-size);
    color: #fff;
    line-height: 1.3;
}
.task-reward {
    font-family: var(--font-pixel);
    font-size: var(--panel-cost-size);
    color: #93c5fd;
    white-space: nowrap;
    flex-shrink: 0;
}
.task-desc {
    font-size: var(--panel-desc-size);
    color: var(--text-muted);
    line-height: 1.35;
}
.task-progress-bar {
    height: calc(8px * var(--ui-scale));
    background: #0f1013;
    border: 2px solid #000;
    overflow: hidden;
    margin-top: calc(2px * var(--ui-scale));
}
.task-progress-fill {
    height: 100%;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.25) 0%, transparent 45%),
        repeating-linear-gradient(90deg, #3b82f6 0 5px, #2563eb 5px 7px);
}
.task-claim-btn {
    flex-shrink: 0;
    font-size: var(--panel-claim-size);
    padding: calc(8px * var(--ui-scale)) calc(6px * var(--ui-scale));
    min-width: calc(72px * var(--ui-scale));
    align-self: center;
}
.task-claim-btn:disabled {
    opacity: 0.55;
    pointer-events: none;
}
.task-claim-btn.btn-on {
    background: #2563eb;
    box-shadow:
        inset -2px -2px 0px #1e40af,
        inset 2px 2px 0px #93c5fd;
}
.panel-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: #3e4452 #0f1013;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.panel-content.hidden {
    display: none !important;
}
.panel-content::-webkit-scrollbar {
    width: 10px;
}
.panel-content::-webkit-scrollbar-track {
    background: #0f1013;
    border-left: 2px solid #000;
}
.panel-content::-webkit-scrollbar-thumb {
    background: #3e4452;
    border: 2px solid #0f1013;
    box-shadow: inset -1px -1px 0 #1b1d24, inset 1px 1px 0 #5f687c;
}
.upgrade-item {
    background:
        linear-gradient(180deg, #2c313c 0%, #252830 100%);
    border: 3px solid #000;
    box-shadow:
        inset -2px -2px 0px #1a1c22,
        inset 2px 2px 0px #3a4050;
    padding: var(--panel-item-pad) calc(12px * var(--ui-scale));
    display: flex;
    align-items: flex-start;
    gap: 0;
    position: relative;
    cursor: var(--ui-cursor);
    transition: background 0.1s, box-shadow 0.1s;
    flex-shrink: 0;
}
@media (hover: hover) and (pointer: fine) {
    .upgrade-item:hover:not(.locked):not(.unaffordable) {
        background: linear-gradient(180deg, #343a48 0%, #2d313c 100%);
    }
}
.upgrade-item.locked,
.upgrade-item.unaffordable {
    opacity: 0.6;
    pointer-events: none;
}
.upgrade-item.affordable:not(.maxed) {
    opacity: 1;
    pointer-events: auto;
    box-shadow:
        inset -2px -2px 0px #1a1c22,
        inset 2px 2px 0px #3a4050,
        0 0 0 2px rgba(244, 180, 27, 0.55);
}
.upgrade-item.affordable:not(.maxed) .upgrade-cost-tag {
    color: #e5e7eb;
    border-color: #9ca3af;
}
.upgrade-icon {
    background:
        linear-gradient(180deg, #181b24 0%, #0c0e14 100%);
    border: 2px solid #000;
    width: calc(44px * var(--ui-scale));
    height: calc(44px * var(--ui-scale));
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        inset 1px 1px 0px #000,
        inset -1px -1px 0 #2a2e38;
    flex-shrink: 0;
}
.upgrade-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: calc(4px * var(--ui-scale));
}
.upgrade-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: calc(10px * var(--ui-scale));
    width: 100%;
    min-width: 0;
}
.upgrade-name {
    font-family: var(--font-pixel);
    font-size: var(--panel-name-size);
    color: #fff;
    line-height: 1.3;
    flex: 1;
    min-width: 0;
}
.upgrade-desc {
    font-size: var(--panel-desc-size);
    color: var(--text-muted);
    line-height: 1.35;
}
.upgrade-cost-tag {
    background: #111;
    border: 2px solid #9ca3af;
    color: #e5e7eb;
    font-family: var(--font-pixel);
    font-size: var(--panel-cost-size);
    padding: calc(3px * var(--ui-scale)) calc(6px * var(--ui-scale));
    margin-top: calc(2px * var(--ui-scale));
    align-self: flex-start;
}
.upgrade-item.maxed .upgrade-cost-tag {
    border-color: #9ca3af;
    color: #e5e7eb;
}
.upgrade-item.unaffordable .upgrade-cost-tag {
    border-color: #9ca3af;
    color: #e5e7eb;
}
.upgrade-item.locked-dependency {
    opacity: 0.45;
    pointer-events: none;
    background: #191b21;
    box-shadow: inset -2px -2px 0px #111216, inset 2px 2px 0px #22252c;
}
.upgrade-item.locked-dependency .upgrade-name {
    color: var(--text-muted);
}
.upgrade-item.locked-dependency .upgrade-desc {
    color: var(--accent-red);
}
.upgrade-item.locked-dependency .upgrade-cost-tag {
    border-color: var(--accent-red);
    color: var(--accent-red);
}
.upgrade-level {
    font-family: var(--font-pixel);
    font-size: max(12px, calc(10px * var(--ui-scale)));
    color: var(--accent-blue);
    line-height: 1.2;
    text-align: right;
    white-space: nowrap;
    flex-shrink: 0;
}
.ticket-item {
    background:
        linear-gradient(180deg, #2c313c 0%, #252830 100%);
    border: 3px solid #000;
    box-shadow:
        inset -2px -2px 0px #1a1c22,
        inset 2px 2px 0px #3a4050;
    padding: var(--panel-item-pad);
    display: flex;
    flex-direction: column;
    gap: calc(6px * var(--ui-scale));
    cursor: var(--ui-cursor);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    min-height: calc(92px * var(--ui-scale));
    box-sizing: border-box;
}
@media (hover: hover) and (pointer: fine) {
    .ticket-item:hover:not(.locked):not(.cooldown):not(.unaffordable) {
        background: linear-gradient(180deg, #343a48 0%, #2d313c 100%);
    }
}
.ticket-item.active {
    border-color: var(--accent-yellow);
    box-shadow:
        inset -2px -2px 0px #1a1c22,
        inset 2px 2px 0px #3a4050,
        0 0 0 1px rgba(244, 180, 27, 0.4);
}
.ticket-item.unaffordable {
    background: #17181c;
    border-color: #3e4452;
    opacity: 0.6;
    pointer-events: none;
}
.ticket-item.locked {
    background: #121316;
    border-color: #272a33;
    pointer-events: none;
}
.ticket-item.locked .ticket-main {
    opacity: 0.45;
    filter: grayscale(70%);
}
.ticket-main {
    display: flex;
    gap: calc(10px * var(--ui-scale));
    align-items: center;
}
.ticket-art {
    background: #131519;
    border: 2px solid #000;
    width: calc(50px * var(--ui-scale));
    height: calc(50px * var(--ui-scale));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.ticket-art .ticket-catalog-icon {
    width: calc(32px * var(--ui-scale));
    height: calc(32px * var(--ui-scale));
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    object-fit: contain;
}
.ticket-details {
    flex-grow: 1;
    min-width: 0;
}
.ticket-name {
    font-family: var(--font-pixel);
    font-size: var(--panel-name-size);
    color: #fff;
    margin-bottom: calc(2px * var(--ui-scale));
}
.ticket-tier {
    font-size: var(--panel-desc-size);
    color: var(--accent-yellow);
}
.ticket-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    min-height: calc(18px * var(--ui-scale));
    flex-shrink: 0;
}
.ticket-cost {
    font-family: var(--font-pixel);
    font-size: var(--panel-cost-size);
    color: #e5e7eb;
}
.ticket-item.unaffordable .ticket-cost {
    color: #e5e7eb;
}
.ticket-payout {
    font-size: var(--panel-desc-size);
    color: var(--text-muted);
}

/* ---- Tier colour-coding: the shop reads as a shelf of distinct prizes, not a grey wall.
   All driven by the single --tier-acc token set per row in createShopTicketElement(). ---- */
.ticket-item {
    --tier-acc: #7f8aa3;
    transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.ticket-item::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: calc(6px * var(--ui-scale));
    background: var(--tier-acc);
    box-shadow: inset -2px 0 0 rgba(0, 0, 0, 0.45), 0 0 12px -2px var(--tier-acc);
    z-index: 1;
    pointer-events: none;
}
.ticket-item .ticket-main { padding-left: calc(5px * var(--ui-scale)); }
.ticket-tier {
    color: var(--tier-acc);
    text-shadow: 0 0 8px color-mix(in srgb, var(--tier-acc) 40%, transparent);
}
.ticket-art {
    border-color: var(--tier-acc);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), 0 0 11px -3px var(--tier-acc);
}
.ticket-cost { color: var(--accent-yellow-lite); }
.ticket-item.free-ticket-row .ticket-cost { color: #7ee0a8; }
@media (hover: hover) and (pointer: fine) {
    .ticket-item:hover:not(.locked):not(.cooldown):not(.unaffordable) {
        transform: translateY(-2px);
        border-color: var(--tier-acc);
        box-shadow:
            inset -2px -2px 0px #1a1c22,
            inset 2px 2px 0px #3a4050,
            0 9px 20px -11px var(--tier-acc);
    }
}
.ticket-item.locked::before,
.ticket-item.unaffordable::before { background: #2a2e38; box-shadow: none; }

/* Bulk buy quantity bar (TICKETS sheet) */
.shop-pane.menu-panel-pane,
.shop-pane {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    padding: 0;
    gap: 0;
}
.shop-pane.hidden { display: none !important; }
.tickets-notice {
    position: relative;
    z-index: 2010;
    flex-shrink: 0;
    margin: calc(8px * var(--ui-scale)) calc(10px * var(--ui-scale)) 0;
    padding: calc(9px * var(--ui-scale)) calc(12px * var(--ui-scale));
    border: calc(3px * var(--ui-scale)) solid #ffcf4a;
    background: #2b1d0c;
    color: #fff2bd;
    box-shadow: inset 0 0 0 2px #6e4713, 0 4px 0 rgba(0, 0, 0, 0.45);
    font-size: calc(12px * var(--ui-scale));
    line-height: 1.35;
    text-align: center;
}
.tickets-notice.hidden { display: none !important; }
.tickets-notice.is-visible {
    animation: tickets-notice-in 160ms ease-out, tutorial-ticket-glow 0.8s ease-in-out 2 alternate;
}
@keyframes tickets-notice-in {
    from { transform: translateY(-6px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.buy-qty-bar {
    display: flex;
    align-items: center;
    gap: calc(6px * var(--ui-scale));
    padding: calc(8px * var(--ui-scale)) calc(10px * var(--ui-scale));
    border-bottom: 3px solid #000;
    background: #151820;
    flex-shrink: 0;
}
.buy-qty-label {
    font-family: var(--font-pixel);
    font-size: max(12px, calc(10px * var(--ui-scale)));
    color: var(--text-muted);
    margin-right: calc(2px * var(--ui-scale));
    flex-shrink: 0;
}
.buy-qty-btn {
    flex: 1 1 0;
    min-width: 0;
    min-height: calc(32px * var(--ui-scale));
    padding: calc(6px * var(--ui-scale)) calc(4px * var(--ui-scale));
    font-family: var(--font-pixel);
    font-size: max(12px, calc(11px * var(--ui-scale)));
    color: var(--text-muted);
    background: #252830;
    border: 2px solid #000;
    cursor: var(--ui-cursor);
    box-shadow: inset -2px -2px 0 #1a1b1f, inset 2px 2px 0 #474b57;
}
.buy-qty-btn.active {
    color: var(--accent-yellow);
    background: #3a3d46;
    border-color: var(--accent-yellow);
}
.buy-qty-btn:focus { outline: none; }
.buy-qty-btn:focus-visible {
    outline: 2px solid var(--accent-yellow);
    outline-offset: 1px;
}
.tickets-list-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--panel-item-pad);
    display: flex;
    flex-direction: column;
    gap: calc(8px * var(--ui-scale));
    -webkit-overflow-scrolling: touch;
}

.ticket-lock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.42);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: #fff;
    z-index: 10;
    box-sizing: border-box;
}
.ticket-lock-overlay .lock-level {
    font-family: var(--font-pixel);
    font-size: max(11px, calc(10px * var(--ui-scale)));
    color: #ff8c8c;
    text-align: center;
    padding: 0 4px;
    line-height: 1.2;
    text-shadow: 0 1px 2px #000, 0 0 3px #000;
}
.ticket-item.cooldown {
    pointer-events: none;
}
.ticket-item.cooldown .ticket-cost {
    color: var(--text-muted);
}
.cooldown-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #17181c;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--accent-yellow);
    font-family: var(--font-pixel);
    font-size: max(12px, calc(11px * var(--ui-scale)));
    gap: 4px;
    z-index: 5;
    padding: 8px;
    text-align: center;
    box-sizing: border-box;
}
.cooldown-title {
    font-size: max(10px, calc(8px * var(--ui-scale)));
    color: var(--text-muted);
    letter-spacing: 1px;
}
.cooldown-name {
    font-size: max(10px, calc(8px * var(--ui-scale)));
    color: #fff;
    font-weight: bold;
    margin: 1px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 90%;
}
.cooldown-timer {
    font-size: 16px;
    color: var(--accent-yellow);
    font-family: var(--font-digits);
    font-weight: bold;
}
.desk-area {
    background-color: var(--wood-dark);
    background-image:
        linear-gradient(90deg, rgba(0, 0, 0, 0.18) 1px, transparent 1px),
        linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, transparent 8%, transparent 92%, rgba(0, 0, 0, 0.2) 100%),
        repeating-linear-gradient(
            90deg,
            var(--wood-mid) 0 18px,
            var(--wood-light) 18px 22px,
            var(--wood-mid) 22px 40px,
            var(--wood-grain) 40px 42px,
            var(--wood-dark) 42px 58px,
            var(--wood-mid) 58px 72px
        );
    background-size: 8px 100%, 100% 100%, 96px 100%;
    border: 4px solid var(--pixel-border-color);
    box-shadow:
        inset 4px 4px 0px rgba(255, 220, 160, 0.12),
        inset -4px -4px 0px rgba(0, 0, 0, 0.45),
        0px 5px 0px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    position: relative;
    overflow: hidden;
}
.desk-wood-mat {
    width: 95%;
    height: 95%;
    border: 8px solid #3c200c;
    box-shadow:
        0 0 0 2px #1a0e06,
        inset 0 0 0 2px rgba(255, 200, 120, 0.08),
        0px 0px 24px rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: var(--wood-grain);
}
.desk-mat {
    width: 100%;
    height: 100%;
    background-color: var(--desk-mat-bg);
    background-image:
        linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 30%),
        radial-gradient(var(--desk-mat-border) 14%, transparent 18%),
        radial-gradient(var(--desk-mat-mid) 14%, transparent 18%);
    background-size: 100% 100%, 10px 10px, 10px 10px;
    background-position: 0 0, 0 0, 5px 5px;
    border: 4px solid var(--desk-mat-border);
    box-shadow:
        inset 4px 4px 0 rgba(0, 0, 0, 0.35),
        inset -3px -3px 0 rgba(255, 255, 255, 0.04),
        inset 0 0 0 3px var(--desk-mat-stitch);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
/* Ambient desk life — dust motes + a napping cat, behind the cards (decorative only). */
.desk-ambient {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}
.desk-ambient .mote {
    position: absolute;
    bottom: -6px;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: rgba(255, 247, 220, 0.5);
    box-shadow: 0 0 4px rgba(255, 247, 220, 0.4);
    opacity: 0;
    animation-name: desk-mote-float;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}
@keyframes desk-mote-float {
    0% { transform: translateY(0) translateX(0); opacity: 0; }
    15% { opacity: 0.8; }
    85% { opacity: 0.6; }
    100% { transform: translateY(-72%) translateX(18px); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .desk-ambient .mote { animation: none; opacity: 0; }
}
.desk-mat::before {
    content: '';
    position: absolute;
    inset: 6px;
    border: 2px dashed rgba(61, 110, 82, 0.45);
    pointer-events: none;
    z-index: 1;
    opacity: 0.7;
}
.desk-mat::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 50% 40% at 50% 45%, transparent 40%, rgba(0, 0, 0, 0.18) 100%);
    pointer-events: none;
    z-index: 2;
}
.desk-dim-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.desk-dim-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.cards-pile {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 25;
    pointer-events: none;
}
/* Desk cards stay under the bottom menu sheet / dock overlays */
body.menu-sheet-open .cards-pile,
body.menu-sheet-open .scratch-card-wrapper {
    z-index: 30;
}
.scratch-card-wrapper {
    position: absolute;
    width: 90px;
    height: 118px;
    border: 4px solid var(--pixel-border-color);
    box-shadow: 0 6px 12px rgba(0,0,0,0.6);
    background: #111;
    overflow: hidden;
    cursor: var(--ui-cursor);
    pointer-events: auto;
    touch-action: none;
    content-visibility: auto;
    contain-intrinsic-size: 90px 118px;
    contain: layout paint style;
    z-index: 30;
    transition:
        width 0.4s cubic-bezier(0.25, 0.8, 0.25, 1),
        height 0.4s cubic-bezier(0.25, 0.8, 0.25, 1),
        left 0.4s cubic-bezier(0.25, 0.8, 0.25, 1),
        top 0.4s cubic-bezier(0.25, 0.8, 0.25, 1),
        transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1),
        box-shadow 0.4s ease;
}
.scratch-card-wrapper.desk-drop-in {
    transition:
        left 0.2s cubic-bezier(0.22, 0.84, 0.32, 1),
        top 0.2s cubic-bezier(0.22, 0.84, 0.32, 1),
        transform 0.2s cubic-bezier(0.22, 0.84, 0.32, 1),
        width 0.4s cubic-bezier(0.25, 0.8, 0.25, 1),
        height 0.4s cubic-bezier(0.25, 0.8, 0.25, 1),
        box-shadow 0.4s ease;
}
.scratch-card-wrapper.custom-art-card {
    border: none;
    background: transparent;
    box-shadow: none;
    overflow: visible;
    contain: layout style;
}
.scratch-card-wrapper.custom-art-card:hover:not(.focused),
.scratch-card-wrapper.custom-art-card.focused,
.scratch-card-wrapper.custom-art-card.dragging {
    box-shadow: none;
}
.scratch-card-wrapper.custom-art-card canvas.card-scratch-canvas,
.scratch-card-wrapper.custom-art-card canvas.card-underlay-canvas {
    /* Modest vibrancy lift so the hand-drawn tickets pop instead of reading pastel/sleepy.
       Gentle on purpose — revealed symbols + value text must stay perfectly legible. Tune here. */
    filter: saturate(1.22) brightness(1.05) contrast(1.03);
}
.scratch-card-wrapper canvas.card-underlay-canvas {
    z-index: 1;
}
.scratch-card-wrapper canvas.card-scratch-canvas {
    z-index: 2;
}
/* Holographic foil sweep over a fresh, focused ticket (see foilLayer in createDOM). */
.card-foil {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    opacity: 0;
    overflow: hidden;
    transition: opacity .25s ease;
}
.card-foil::before {
    content: "";
    position: absolute;
    inset: -35%;
    background: linear-gradient(115deg,
        transparent 42%,
        rgba(255, 255, 255, 0.16) 48%,
        rgba(176, 112, 255, 0.24) 51%,
        rgba(244, 180, 27, 0.18) 54%,
        transparent 62%);
    mix-blend-mode: screen;
    transform: translateX(-62%);
}
.custom-art-card.focused:not(.has-scratch-progress):not(.is-completed-revealed):not(.in-machine-scratching):not(.in-machine-finished) .card-foil {
    opacity: 1;
}
.custom-art-card.focused:not(.has-scratch-progress):not(.is-completed-revealed):not(.in-machine-scratching):not(.in-machine-finished) .card-foil::before {
    animation: card-foil-sweep 4.2s linear infinite;
}
@keyframes card-foil-sweep {
    0% { transform: translateX(-62%); }
    100% { transform: translateX(62%); }
}
@media (prefers-reduced-motion: reduce) {
    .card-foil::before { animation: none !important; }
}
.scratch-card-wrapper.custom-art-card.in-machine-scratching,
.scratch-card-wrapper.custom-art-card.in-machine-finished {
    border: none !important;
    background: transparent;
}
.custom-art-card:not(.scratch-surface-ready):not(.focused):not(.in-machine-scratching):not(.in-machine-finished):not(.has-scratch-progress):not(.is-completed-revealed) .card-underlay-canvas {
    visibility: hidden;
}
.custom-art-card:not(.scratch-surface-ready):not(.focused):not(.in-machine-scratching):not(.in-machine-finished) .card-scratch-canvas {
    background: transparent;
}
.scratch-card-wrapper.custom-art-card:not(.focused):not(.in-machine-scratching):not(.in-machine-finished):not(.has-scratch-progress):not(.is-completed-revealed) .card-underlay-canvas {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.scratch-card-wrapper.custom-art-card.is-completed-revealed:not(.focused) .card-underlay-canvas {
    opacity: 1;
    visibility: visible;
}
.scratch-card-wrapper:hover:not(.focused):not(.dragging):not(.in-machine-scratching):not(.in-machine-finished) {
    transform: scale(1.1) rotate(0deg) !important;
    box-shadow: 0 10px 20px rgba(0,0,0,0.7);
}
.scratch-card-wrapper.ui-scatter-anim {
    z-index: 45 !important;
    transform: scale(1.08) rotate(0deg) !important;
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.75);
    transition:
        width 0.4s cubic-bezier(0.25, 0.8, 0.25, 1),
        height 0.4s cubic-bezier(0.25, 0.8, 0.25, 1),
        left 0.72s cubic-bezier(0.22, 1.05, 0.36, 1),
        top 0.72s cubic-bezier(0.22, 1.05, 0.36, 1),
        transform 0.72s cubic-bezier(0.22, 1.05, 0.36, 1),
        box-shadow 0.72s ease !important;
}
.scratch-card-wrapper.custom-art-card.ui-scatter-anim {
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.55);
}
.scratch-card-wrapper.dragging {
    transition: none !important;
    z-index: 999 !important;
    opacity: 0.9;
    box-shadow: 0 12px 24px rgba(0,0,0,0.8);
}
.scratch-card-wrapper.focused {
    content-visibility: visible;
    width: var(--focus-card-width, 320px) !important;
    height: var(--focus-card-height, 420px) !important;
    left: 50% !important;
    top: var(--focus-card-top, 8px) !important;
    transform: translateX(-50%) rotate(0deg) !important;
    z-index: 500 !important;
    box-shadow: 0 20px 40px rgba(0,0,0,0.9);
}
.desk-mat.has-focused-layout .scratch-card-wrapper.focused {
    top: var(--focus-card-top, 8px) !important;
    transform: translateX(-50%) rotate(0deg) !important;
}
.scratch-card-wrapper canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}
#card-underlay-canvas {
    z-index: 1;
}
.card-scratch-canvas {
    z-index: 2;
    filter: drop-shadow(0px 3px 5px rgba(0, 0, 0, 0.45));
}
.scratch-card-wrapper.focused .card-scratch-canvas {
    touch-action: none;
}
.card-overlay-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    padding: 20px;
    text-align: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}
.scratch-card-wrapper:not(.focused) .card-overlay-screen {
    opacity: 0 !important;
    pointer-events: none !important;
}
.card-overlay-screen.hidden {
    opacity: 0;
    pointer-events: none;
}
.overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 100%;
}
.overlay-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: calc(8px * var(--ui-scale));
    width: min(100%, calc(220px * var(--ui-scale)));
}
.overlay-actions .claim-btn,
.overlay-actions .claim-double-btn {
    width: 100%;
}
.claim-double-btn {
    background: linear-gradient(180deg, #fde047 0%, #f4b41b 55%, #ca8a04 100%);
    color: #1a1200;
    box-shadow:
        inset calc(-3px * var(--ui-scale)) calc(-3px * var(--ui-scale)) 0 #92400e,
        inset calc(3px * var(--ui-scale)) calc(3px * var(--ui-scale)) 0 #fef08a,
        0 calc(4px * var(--ui-scale)) 0 rgba(0, 0, 0, 0.35);
    font-family: var(--font-digits), sans-serif;
    font-size: calc(14px * var(--ui-scale));
    font-weight: bold;
    letter-spacing: 0.04em;
}
.claim-double-btn:hover {
    background: linear-gradient(180deg, #fef08a 0%, #facc15 55%, #eab308 100%);
}
.claim-double-btn.hidden {
    display: none !important;
}
.overlay-title {
    font-family: var(--font-pixel);
    font-size: 15px;
    color: var(--accent-yellow);
    text-shadow: 2px 2px 0px #000;
}
.overlay-desc {
    color: var(--text-muted);
    font-size: 16px;
    max-width: 90%;
}
.overlay-reward {
    font-family: var(--font-pixel);
    font-size: 20px;
    color: var(--accent-green);
    animation: reward-bounce 0.5s ease infinite alternate;
}
@keyframes reward-bounce {
    0% { transform: translateY(0); }
    100% { transform: translateY(-10px); }
}
.action-btn {
    padding: var(--modal-action-pad-y) var(--modal-action-pad-x);
    font-size: var(--modal-action-font);
    min-height: var(--modal-action-min-h);
}
.next-card-btn {
    background: var(--accent-green);
    box-shadow:
        inset -3px -3px 0px #0c885e,
        inset 3px 3px 0px #24e59f;
}
.next-card-btn:hover {
    background: #0ea775;
    box-shadow:
        inset -3px -3px 0px #0c885e,
        inset 3px 3px 0px #3bf0b2,
        0px 4px 0px rgba(0,0,0,0.3);
}
.pixel-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    padding:
        max(env(safe-area-inset-top, 0px), calc(8px * var(--ui-scale)))
        max(env(safe-area-inset-right, 0px), calc(8px * var(--ui-scale)))
        max(env(safe-area-inset-bottom, 0px), calc(8px * var(--ui-scale)))
        max(env(safe-area-inset-left, 0px), calc(8px * var(--ui-scale)));
    box-sizing: border-box;
    background:
        radial-gradient(ellipse 60% 50% at 50% 45%, rgba(24, 18, 32, 0.55), rgba(0, 0, 0, 0.78));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2100;
    opacity: 1;
    transition: opacity 0.3s;
}
.pixel-modal.hidden {
    opacity: 0;
    pointer-events: none;
}
.modal-content {
    background:
        linear-gradient(180deg, #242a38 0%, var(--panel-bg) 42%);
    border: var(--modal-border) solid #000;
    box-shadow:
        inset calc(-4px * var(--ui-scale)) calc(-4px * var(--ui-scale)) 0 #101218,
        inset calc(4px * var(--ui-scale)) calc(4px * var(--ui-scale)) 0 var(--panel-highlight),
        0 calc(10px * var(--ui-scale)) calc(30px * var(--ui-scale)) rgba(0, 0, 0, 0.7),
        0 0 0 calc(2px * var(--ui-scale)) rgba(244, 180, 27, 0.18);
    width: var(--modal-width);
    max-width: var(--modal-width);
    max-height: var(--modal-max-height);
    /* The modal itself must NOT scroll — otherwise the footer (OK button) scrolls out of view
       on short screens (Chromebook). Header + footer stay pinned and .modal-body scrolls. */
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    -webkit-overflow-scrolling: touch;
}
.modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: calc(10px * var(--ui-scale));
    right: calc(10px * var(--ui-scale));
    height: calc(3px * var(--ui-scale));
    background: linear-gradient(90deg, transparent, rgba(244, 180, 27, 0.55), transparent);
    pointer-events: none;
    z-index: 1;
}
.modal-header {
    background: linear-gradient(180deg, #1a1d26 0%, #131519 100%);
    border-bottom: calc(4px * var(--ui-scale)) solid #000;
    padding: var(--modal-header-pad);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: calc(8px * var(--ui-scale));
    flex-shrink: 0;
}
.modal-header h3 {
    font-family: var(--font-pixel);
    font-size: var(--modal-title-size);
    color: var(--accent-yellow);
    line-height: 1.35;
}
.close-modal-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: var(--modal-close-size);
    cursor: var(--ui-cursor);
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--modal-close-hit);
    min-height: var(--modal-close-hit);
    padding: 0;
    flex-shrink: 0;
}
.close-modal-btn:hover {
    color: #fff;
}
.modal-body {
    padding: var(--modal-body-pad);
    font-size: var(--modal-body-size);
    line-height: 1.45;
    /* Only the description scrolls, so the OK / action buttons are always reachable. */
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #4a5a78 #12151c;
}
.modal-body::-webkit-scrollbar { width: 8px; }
.modal-body::-webkit-scrollbar-track { background: #12151c; box-shadow: inset 1px 0 0 #000; }
.modal-body::-webkit-scrollbar-thumb { background: #3a4458; border: 1px solid #0a0d14; box-shadow: inset 1px 1px 0 #566b8f, inset -1px -1px 0 #202838; }
.modal-body::-webkit-scrollbar-thumb:hover { background: var(--accent-yellow); box-shadow: inset 1px 1px 0 #ffe08a; }
.modal-footer {
    border-top: calc(4px * var(--ui-scale)) solid #000;
    padding: var(--modal-footer-pad);
    display: flex;
    justify-content: flex-end;
    gap: var(--modal-footer-gap);
    flex-shrink: 0;
}
.accept-btn {
    background: var(--accent-blue);
    box-shadow:
        inset -3px -3px 0px #1e40af,
        inset 3px 3px 0px #60a5fa;
}
.accept-btn:hover {
    background: #2563eb;
    box-shadow:
        inset -3px -3px 0px #1e40af,
        inset 3px 3px 0px #93c5fd,
        0px 4px 0px rgba(0,0,0,0.3);
}
.tutorial-body p {
    margin-bottom: calc(10px * var(--ui-scale));
}
.currency-coin {
    color: var(--accent-yellow);
    font-weight: bold;
}
.currency-diamond {
    color: #93c5fd;
    font-weight: bold;
}
.currency-crown {
    color: #e9d5ff;
    font-weight: bold;
}
.help-footnote {
    margin-top: calc(14px * var(--ui-scale));
    font-size: var(--modal-footnote-size);
    color: var(--text-muted);
    line-height: 1.35;
}
.animated-pop {
    animation: stat-pop 0.3s ease;
}
@keyframes stat-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}
.particle {
    position: absolute;
    pointer-events: none;
    width: 6px;
    height: 6px;
    background: var(--accent-yellow-lite);
    border: 1px solid #000;
    box-shadow: 1px 1px 0 #000;
    animation: particle-rise 0.65s ease-out forwards;
    z-index: 5;
    image-rendering: pixelated;
}
@keyframes particle-rise {
    0% {
        transform: translate(-50%, -50%) scale(0.5) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translate(calc(-50% + var(--dx)), calc(-50% - 40px)) scale(1) rotate(90deg);
        opacity: 0;
    }
}
/* Bright white flecks amid the gold scratch dust. */
.particle.spark {
    width: 4px;
    height: 4px;
    background: #fff7e6;
    box-shadow: 0 0 6px #fff, 1px 1px 0 #000;
}
/* Win confetti bursting from the card centre (see spawnWinBurst). */
.confetti {
    position: absolute;
    width: 7px;
    height: 7px;
    pointer-events: none;
    z-index: 11; /* above the reveal overlay (z-index 10) so the burst reads on top of the win panel */
    border: 1px solid rgba(0, 0, 0, 0.5);
    image-rendering: pixelated;
    animation: confetti-fly 0.9s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}
@keyframes confetti-fly {
    0% { transform: translate(-50%, -50%) scale(0.3) rotate(0deg); opacity: 1; }
    70% { opacity: 1; }
    100% { transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty) + 32px)) scale(1) rotate(220deg); opacity: 0; }
}
/* Glow pulse on a winning card. */
.scratch-card-wrapper.win-glow { animation: win-glow-pulse 0.9s ease-out; }
@keyframes win-glow-pulse {
    0% { filter: drop-shadow(0 0 0 rgba(244, 180, 27, 0)); }
    30% { filter: drop-shadow(0 0 18px rgba(244, 180, 27, 0.85)) drop-shadow(0 0 32px rgba(176, 112, 255, 0.5)); }
    100% { filter: drop-shadow(0 0 0 rgba(244, 180, 27, 0)); }
}
/* Jackpot — a bigger, longer, gold+purple glow pulse. */
.scratch-card-wrapper.win-glow-mega { animation: win-glow-mega 1.1s ease-out; }
@keyframes win-glow-mega {
    0% { filter: drop-shadow(0 0 0 rgba(244, 180, 27, 0)); }
    25% { filter: drop-shadow(0 0 26px rgba(244, 180, 27, 1)) drop-shadow(0 0 48px rgba(176, 112, 255, 0.7)); }
    60% { filter: drop-shadow(0 0 20px rgba(255, 235, 130, 0.9)) drop-shadow(0 0 40px rgba(176, 112, 255, 0.5)); }
    100% { filter: drop-shadow(0 0 0 rgba(244, 180, 27, 0)); }
}
/* Jackpot coin rain over the card. */
.coin-rain {
    position: absolute;
    width: 18px; height: 18px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 11;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-pixel);
    font-size: 11px; font-weight: 600; color: #6b4a05;
    background: radial-gradient(circle at 35% 30%, #ffe9a8, #f4b41b 60%, #b9820c);
    border: 2px solid #6b4a05;
    box-shadow: 0 0 8px rgba(244, 180, 27, 0.6);
}
/* Near-miss — a quick amber shiver on a "one short" loss. */
.scratch-card-wrapper.near-miss { animation: near-miss-shiver 0.7s ease-in-out; }
@keyframes near-miss-shiver {
    0%, 100% { transform: translateX(0); filter: none; }
    10%, 30%, 50%, 70% { transform: translateX(-4px); filter: drop-shadow(0 0 14px rgba(244, 180, 27, 0.75)); }
    20%, 40%, 60%, 80% { transform: translateX(4px); filter: drop-shadow(0 0 14px rgba(244, 180, 27, 0.75)); }
}
/* Jackpot screen shake — transform only (no reflow). */
.screen-shake { animation: screen-shake 0.5s cubic-bezier(.36,.07,.19,.97); }
@keyframes screen-shake {
    10%, 90% { transform: translate(-2px, 1px); }
    20%, 80% { transform: translate(4px, -2px); }
    30%, 50%, 70% { transform: translate(-7px, 2px); }
    40%, 60% { transform: translate(7px, -1px); }
}
/* Coins flying from a claimed card up to the balance counter. */
.fly-coin {
    position: fixed;
    width: 20px; height: 20px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 12000;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-pixel);
    font-size: 11px; font-weight: 600; color: #6b4a05;
    background: radial-gradient(circle at 35% 30%, #ffe9a8, #f4b41b 60%, #b9820c);
    border: 2px solid #6b4a05;
    box-shadow: 0 0 8px rgba(244, 180, 27, 0.6);
}
.money-display.coin-catch,
#money-display-box.coin-catch { animation: coin-catch 0.32s ease; }
@keyframes coin-catch {
    50% { transform: scale(1.16); filter: brightness(1.25); }
}
@media (prefers-reduced-motion: reduce) {
    .confetti, .coin-rain, .fly-coin { display: none; }
    .scratch-card-wrapper.win-glow,
    .scratch-card-wrapper.win-glow-mega,
    .scratch-card-wrapper.near-miss,
    .screen-shake { animation: none; }
}
.text-popup {
    position: absolute;
    color: var(--accent-yellow);
    font-family: var(--font-pixel);
    font-size: 12px;
    text-shadow:
        2px 2px 0px #000,
        -1px 0 0 #000,
        0 -1px 0 #000,
        0 0 8px rgba(244, 180, 27, 0.45);
    pointer-events: none;
    animation: popup-float 1s ease-out forwards;
    z-index: 100;
}
@keyframes popup-float {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, calc(-50% - 60px)) scale(1.2);
        opacity: 0;
    }
}
html, body, button, a, .pixel-btn, .scratch-card-wrapper:not(.focused),
.ticket-item,
.upgrade-item,
.mobile-nav-btn, .tab-btn, .close-modal-btn,
.scratch-card-wrapper.in-machine-finished:hover,
.tutorial-skip-btn,
.cooldown-overlay,
.ticket-lock-overlay {
    cursor: var(--ui-cursor);
}
body.scratch-coin-mode,
body.scratch-coin-mode .scratch-card-wrapper.focused,
body.scratch-coin-mode .scratch-card-wrapper.focused * {
    cursor: var(--coin-cursor) !important;
}
body.scratch-coin-mode.scratch-coin-pressed,
body.scratch-coin-mode.scratch-coin-pressed *,
body.scratch-coin-mode .scratch-card-wrapper.focused.scratching,
body.scratch-coin-mode .scratch-card-wrapper.focused.scratching * {
    cursor: var(--coin-cursor-pressed) !important;
}
body.scratch-coin-mode.scratch-coin-pressed .scratch-card-wrapper.focused,
body.scratch-coin-mode .scratch-card-wrapper.focused.scratching {
    cursor: var(--coin-cursor-pressed) !important;
}
.scratch-card-wrapper.focused canvas.card-scratch-canvas {
    cursor: var(--coin-cursor) !important;
}
body.scratch-coin-mode.scratch-coin-pressed .scratch-card-wrapper.focused canvas.card-scratch-canvas,
body.scratch-coin-mode .scratch-card-wrapper.focused.scratching canvas.card-scratch-canvas,
.scratch-card-wrapper.focused.scratching canvas.card-scratch-canvas,
.scratch-card-wrapper.focused canvas.card-scratch-canvas:active {
    cursor: var(--coin-cursor-pressed) !important;
}
html.scratch-coin-cursor-follow .scratch-card-wrapper.focused,
html.scratch-coin-cursor-follow .scratch-card-wrapper.focused *,
html.scratch-coin-cursor-follow .desk-dim-overlay.active,
html.scratch-coin-cursor-follow #desk-paytable-overlay:not(.hidden) {
    cursor: none !important;
}
#scratch-coin-cursor {
    position: fixed;
    top: 0;
    left: 0;
    width: 32px;
    height: 32px;
    margin: 0;
    padding: 0;
    pointer-events: none;
    z-index: 10050;
    image-rendering: pixelated;
    will-change: transform;
}
#scratch-coin-cursor.hidden {
    display: none !important;
}
#scratch-coin-cursor img {
    width: 32px;
    height: 32px;
    display: block;
    image-rendering: pixelated;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}
.scratcher-machine {
    position: absolute;
    top: 15px;
    right: 15px;
    width: clamp(170px, 12vw, 220px);
    /* Never taller than the mat, so the SCRATCH toggle / FILL / CLAIM never clip at
       non-fullscreen sizes. The slot area (.machine-body) scrolls if content is tall. */
    max-height: calc(100% - 30px);
    overflow: hidden;
    background:
        linear-gradient(180deg, #252b38 0%, #1c222e 55%, #161b26 100%);
    border: 4px solid var(--pixel-border-color);
    box-shadow:
        inset -3px -3px 0px #10141c,
        inset 3px 3px 0px #3a4458,
        0px 6px 12px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(244, 180, 27, 0.15);
    display: flex;
    flex-direction: column;
    z-index: 15;
    image-rendering: pixelated;
    padding: 6px;
    gap: 6px;
    color: #fff;
    pointer-events: auto;
}
.scratcher-machine.hidden {
    display: none !important;
}
.machine-header {
    flex: 0 0 auto;
    font-family: var(--font-digits), sans-serif;
    font-size: max(11px, calc(12px * var(--ui-scale)));
    font-weight: bold;
    text-align: center;
    color: var(--accent-yellow);
    text-shadow: 1px 1px 0px #000, 0 0 6px rgba(244, 180, 27, 0.35);
    border-bottom: 2px solid #000;
    padding-bottom: 4px;
    background: linear-gradient(90deg, transparent, rgba(244, 180, 27, 0.08), transparent);
}
.machine-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #4a5a78 #0f1013;
}
/* Pixel-styled scrollbar for the machine (only appears when the slot area is too tall for the
   mat). Matches the machine's dark panel + steel highlight so it reads as part of the UI. */
.machine-body::-webkit-scrollbar { width: 7px; }
.machine-body::-webkit-scrollbar-track { background: #0f1013; box-shadow: inset 1px 0 0 #000; }
.machine-body::-webkit-scrollbar-thumb { background: #3a4458; border: 1px solid #0a0d14; box-shadow: inset 1px 1px 0 #566b8f, inset -1px -1px 0 #202838; }
.machine-body::-webkit-scrollbar-thumb:hover { background: var(--accent-yellow); box-shadow: inset 1px 1px 0 #ffe08a; }
.machine-slot {
    background: #0f1013;
    border: 2px solid #000;
    padding: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: inset 2px 2px 0px #000;
}
.slot-label {
    font-family: var(--font-digits), sans-serif;
    font-size: max(10px, calc(10px * var(--ui-scale)));
    font-weight: bold;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-align: center;
}
.queue-display {
    font-family: var(--font-pixel);
    font-size: 14px;
    color: var(--accent-blue);
    font-weight: bold;
}
.active-display {
    width: 100%;
    min-height: 86px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.output-display {
    width: 100%;
    min-height: 86px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.machine-controls {
    flex: 0 0 auto;
    display: flex;
    gap: 4px;
    justify-content: center;
    padding-top: 2px;
}
.machine-controls.machine-actions {
    flex-wrap: wrap;
}
.machine-action-btn {
    flex: 1;
    min-width: 0;
    font-family: var(--font-digits), sans-serif;
    font-size: calc(10px * var(--ui-scale));
    font-weight: bold;
    padding: 6px 4px;
    line-height: 1.35;
    background: #2a3550;
    border: 2px solid #000;
    color: #e5e7eb;
    box-shadow:
        inset -2px -2px 0 #151a28,
        inset 2px 2px 0 #4a5a78;
}
.machine-action-btn:hover:not(:disabled) {
    background: #354468;
    color: var(--accent-yellow-lite);
}
.machine-action-btn:disabled {
    opacity: 0.42;
    pointer-events: none;
}
#machine-claim-all-btn:not(:disabled) {
    background: #166534;
    box-shadow:
        inset -2px -2px 0 #0c4422,
        inset 2px 2px 0 #4ade80;
}
#machine-claim-all-btn:not(:disabled):hover {
    background: #15803d;
}
.toggle-btn {
    flex: 1;
    font-family: var(--font-digits), sans-serif;
    font-size: calc(10px * var(--ui-scale));
    font-weight: bold;
    padding: 6px 2px;
}
.toggle-btn.btn-on {
    background: #0ea775;
    box-shadow:
        inset -2px -2px 0px #0c885e,
        inset 2px 2px 0px #3bf0b2;
}
.toggle-btn.btn-on:hover {
    background: #10b981;
    box-shadow:
        inset -2px -2px 0px #0c885e,
        inset 2px 2px 0px #6ee7b7,
        0px 2px 0px rgba(0,0,0,0.3);
}
.toggle-btn.btn-on:active {
    transform: translateY(1px);
    box-shadow:
        inset 2px 2px 0px #0c885e,
        inset -2px -2px 0px #10b981;
}
.toggle-btn.btn-off {
    background: #de3c3c;
    box-shadow:
        inset -2px -2px 0px #8b1616,
        inset 2px 2px 0px #fca5a5;
}
.toggle-btn.btn-off:hover {
    background: #ef4444;
    box-shadow:
        inset -2px -2px 0px #8b1616,
        inset 2px 2px 0px #fca5a5,
        0px 2px 0px rgba(0,0,0,0.3);
}
.toggle-btn.btn-off:active {
    transform: translateY(1px);
    box-shadow:
        inset 2px 2px 0px #8b1616,
        inset -2px -2px 0px #ef4444;
}
.ants-toggle-btn {
    position: absolute;
    left: 12px;
    top: 12px;
    z-index: 55;
    font-size: 7px;
    padding: 6px 8px;
}
.ants-toggle-btn.btn-on {
    background: #0ea775;
    box-shadow:
        inset -2px -2px 0px #0c885e,
        inset 2px 2px 0px #3bf0b2;
}
.ants-toggle-btn.btn-on:hover {
    background: #10b981;
}
.ants-toggle-btn.btn-off {
    background: #de3c3c;
    box-shadow:
        inset -2px -2px 0px #8b1616,
        inset 2px 2px 0px #fca5a5;
}
.ants-toggle-btn.btn-off:hover {
    background: #ef4444;
}
.stats-modal-content {
    max-width: var(--stats-modal-width);
    width: var(--stats-modal-width);
}
.stats-body {
    display: flex;
    flex-direction: column;
    gap: calc(10px * var(--ui-scale));
}
.stats-intro {
    font-size: max(13px, calc(14px * var(--ui-scale)));
    color: var(--text-muted);
    line-height: 1.35;
}
.stats-grid {
    display: flex;
    flex-direction: column;
    gap: calc(6px * var(--ui-scale));
    background: #12151c;
    border: calc(2px * var(--ui-scale)) solid #000;
    padding: calc(10px * var(--ui-scale));
    box-shadow: inset calc(2px * var(--ui-scale)) calc(2px * var(--ui-scale)) 0 #000;
}
.stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: calc(12px * var(--ui-scale));
    font-size: max(13px, calc(15px * var(--ui-scale)));
}
.stats-label {
    color: var(--text-muted);
    font-family: var(--font-digits);
}
.stats-value {
    font-family: var(--font-pixel);
    font-size: max(13px, calc(12px * var(--ui-scale)));
    color: var(--accent-yellow);
    text-align: right;
}
.stats-subtitle {
    font-family: var(--font-pixel);
    font-size: max(12px, calc(11px * var(--ui-scale)));
    color: var(--accent-yellow);
    margin-top: calc(4px * var(--ui-scale));
}
/* Collection album grid inside the Stats modal. */
.collection-subtitle {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}
.collection-progress {
    font-family: var(--font-pixel);
    font-size: max(12px, calc(11px * var(--ui-scale)));
    color: var(--accent-yellow-lite);
}
.collection-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: calc(6px * var(--ui-scale));
    margin: calc(8px * var(--ui-scale)) 0 calc(14px * var(--ui-scale));
}
.collection-slot {
    appearance: none;
    padding: 0;
    position: relative;
    aspect-ratio: 3 / 4;
    border-radius: 4px;
    overflow: hidden;
    border: 2px solid #000;
    background: #0d1017;
    box-shadow: inset 0 0 0 1px #2a3242;
    display: flex;
    align-items: center;
    justify-content: center;
    image-rendering: pixelated;
    cursor: pointer;
}
.collection-slot:disabled {
    cursor: default;
}
.collection-slot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: pixelated;
}
.collection-slot.owned {
    border-color: #3a4560;
    box-shadow: 0 0 9px -2px rgba(244, 180, 27, 0.5), inset 0 0 0 1px #000;
}
.collection-slot.owned:hover,
.collection-slot.owned:focus-visible,
.collection-slot.owned.selected {
    transform: translateY(-1px);
    outline: none;
    border-color: var(--accent-yellow);
}
.collection-slot.mastery-bronze {
    border-color: #b56a35;
}
.collection-slot.mastery-silver {
    border-color: #b8c3d6;
}
.collection-slot.mastery-gold {
    border-color: #f4b41b;
}
.collection-slot.mastery-master {
    border-color: #b97cff;
    box-shadow: 0 0 12px rgba(185, 124, 255, 0.65), inset 0 0 0 1px #000;
}
.collection-slot.claimable {
    animation: mastery-slot-ready 1.25s steps(2, end) infinite;
}
.collection-mastery-badge {
    position: absolute;
    right: 2px;
    bottom: 2px;
    min-width: 17px;
    height: 17px;
    padding: 0 3px;
    display: grid;
    place-items: center;
    border: 1px solid #000;
    border-radius: 3px;
    background: #12151c;
    color: var(--accent-yellow);
    font-family: var(--font-pixel);
    font-size: 9px;
    line-height: 1;
}
.collection-slot.locked span {
    font-family: var(--font-pixel);
    font-size: calc(16px * var(--ui-scale));
    color: #39415a;
}
.collection-mastery-panel {
    display: flex;
    flex-direction: column;
    gap: calc(7px * var(--ui-scale));
    margin: 0 0 calc(12px * var(--ui-scale));
    padding: calc(9px * var(--ui-scale));
    border: 2px solid #000;
    background: #12151c;
    box-shadow: inset 0 0 0 1px #2a3242;
}
.collection-mastery-panel.hidden {
    display: none;
}
.collection-mastery-header {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    color: var(--accent-yellow-lite);
    font-family: var(--font-pixel);
    font-size: max(11px, calc(10px * var(--ui-scale)));
}
.collection-mastery-header span {
    color: var(--text-muted);
    font-family: var(--font-digits);
    font-size: max(12px, calc(13px * var(--ui-scale)));
}
.collection-mastery-note,
.collection-mastery-status {
    margin: 0;
    color: var(--text-muted);
    font-size: max(11px, calc(12px * var(--ui-scale)));
    line-height: 1.3;
}
.collection-mastery-status {
    min-height: 1.3em;
    color: var(--accent-yellow-lite);
    text-align: center;
}
.collection-mastery-bar {
    height: calc(8px * var(--ui-scale));
    overflow: hidden;
    border: 1px solid #000;
    background: #090b10;
}
.collection-mastery-bar > div {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, #b56a35, #f4b41b, #b97cff);
    transition: width 180ms steps(8, end);
}
.collection-mastery-milestones {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: calc(4px * var(--ui-scale));
}
.mastery-milestone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: calc(5px * var(--ui-scale)) 2px;
    border: 1px solid #000;
    background: #0b0e14;
    color: #596174;
    font-family: var(--font-pixel);
    font-size: max(9px, calc(8px * var(--ui-scale)));
}
.mastery-milestone small {
    color: inherit;
    font-family: var(--font-digits);
    font-size: max(10px, calc(11px * var(--ui-scale)));
}
.mastery-milestone.complete,
.mastery-milestone.claimable {
    color: var(--accent-yellow);
    border-color: #70591c;
}
.mastery-milestone.claimed {
    color: #70d69b;
    border-color: #256b47;
    background: #102319;
}
#collection-mastery-claim {
    align-self: center;
    min-width: 55%;
}
@keyframes mastery-slot-ready {
    50% {
        box-shadow: 0 0 14px rgba(244, 180, 27, 0.9), inset 0 0 0 1px #000;
    }
}
.stats-per-ticket-list {
    display: flex;
    flex-direction: column;
    gap: calc(4px * var(--ui-scale));
    max-height: calc(170px * var(--ui-scale));
    overflow-y: auto;
    padding-right: calc(4px * var(--ui-scale));
}
.stats-ticket-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: calc(8px * var(--ui-scale));
    padding: calc(4px * var(--ui-scale)) calc(6px * var(--ui-scale));
    background: #1a1e28;
    border: 1px solid #000;
    font-size: max(13px, calc(14px * var(--ui-scale)));
}
.stats-ticket-name {
    color: var(--text-white);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.stats-ticket-count {
    font-family: var(--font-pixel);
    font-size: max(12px, calc(11px * var(--ui-scale)));
    color: var(--accent-blue);
    flex-shrink: 0;
}
.stats-empty {
    font-size: max(13px, calc(14px * var(--ui-scale)));
    color: var(--text-muted);
    font-style: italic;
}
.ticket-item {
    position: relative;
}
.scratch-card-wrapper.carried-by-ant {
    transition: none !important;
    z-index: 50 !important;
    pointer-events: auto;
    cursor: grab;
}
.scratch-card-wrapper.carried-by-ant.dragging {
    cursor: grabbing;
    z-index: 999 !important;
}
.desk-ant {
    position: absolute;
    width: 12px;
    height: 12px;
    z-index: 8;
    pointer-events: none;
    image-rendering: pixelated;
    will-change: left, top, transform, opacity;
    transform-origin: center center;
}
.ants-toggle-btn.ants-hub-active {
    animation: ants-hub-pulse 0.45s ease;
}
@keyframes ants-hub-pulse {
    0%, 100% { transform: scale(1); }
    40% { transform: scale(1.06); box-shadow: 0 0 10px rgba(244, 180, 27, 0.45); }
}
.money-float-text {
    position: fixed;
    font-family: var(--font-pixel);
    font-size: max(12px, calc(11px * var(--ui-scale)));
    color: var(--accent-green);
    text-shadow: 1px 1px 0px #000;
    z-index: 10000;
    pointer-events: none;
    animation: float-up-fade 1.2s forwards ease-out;
}
@keyframes float-up-fade {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-40px); opacity: 0; }
}
.scratch-card-wrapper.in-machine-scratching {
    position: relative !important;
    left: 0 !important;
    top: 0 !important;
    transform: none !important;
    width: 60px !important;
    height: 78px !important;
    border-width: 2px !important;
    box-shadow: none !important;
    pointer-events: none !important;
}
.scratch-card-wrapper.in-machine-finished {
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    width: 60px !important;
    height: 78px !important;
    border-width: 2px !important;
    box-shadow: 0 4px 6px rgba(0,0,0,0.5);
    pointer-events: auto !important;
}
.scratch-card-wrapper.in-machine-finished:nth-child(1) {
    transform: translate(-50%, -50%) rotate(0deg) !important;
    z-index: 1;
}
.scratch-card-wrapper.in-machine-finished:nth-child(2) {
    transform: translate(-48%, -51%) rotate(1.5deg) !important;
    z-index: 2;
}
.scratch-card-wrapper.in-machine-finished:nth-child(3) {
    transform: translate(-51%, -49%) rotate(-2deg) !important;
    z-index: 3;
}
.scratch-card-wrapper.in-machine-finished:nth-child(4) {
    transform: translate(-49%, -52%) rotate(2deg) !important;
    z-index: 4;
}
.scratch-card-wrapper.in-machine-finished:nth-child(n+5) {
    transform: translate(-52%, -48%) rotate(-1.5deg) !important;
    z-index: 5;
}
.scratch-card-wrapper.in-machine-finished:hover {
    filter: brightness(1.15);
    box-shadow: 0 6px 12px rgba(0,0,0,0.7);
    cursor: var(--ui-cursor);
}
.scratch-card-wrapper.in-machine-finished:nth-child(1):hover {
    transform: translate(-50%, -50%) scale(1.04) rotate(0deg) !important;
}
.scratch-card-wrapper.in-machine-finished:nth-child(2):hover {
    transform: translate(-48%, -51%) scale(1.04) rotate(1.5deg) !important;
}
.scratch-card-wrapper.in-machine-finished:nth-child(3):hover {
    transform: translate(-51%, -49%) scale(1.04) rotate(-2deg) !important;
}
.scratch-card-wrapper.in-machine-finished:nth-child(4):hover {
    transform: translate(-49%, -52%) scale(1.04) rotate(2deg) !important;
}
.scratch-card-wrapper.in-machine-finished:nth-child(n+5):hover {
    transform: translate(-52%, -48%) scale(1.04) rotate(-1.5deg) !important;
}
.paytable-overlay {
    position: absolute;
    left: 50%;
    top: calc(var(--focus-card-top, 8px) + var(--focus-card-height, 420px) + 6px);
    transform: translateX(-50%);
    width: min(calc(360px * var(--ui-scale)), 94vw);
    height: fit-content;
    max-height: min(calc(220px * var(--ui-scale)), 52vh);
    background: rgba(28, 31, 38, 0.92);
    backdrop-filter: blur(4px);
    border: 2px solid var(--pixel-border-color);
    box-shadow: 0px 6px 12px rgba(0,0,0,0.5);
    padding: 4px 5px;
    z-index: 95;
    font-family: var(--font-digits);
    display: flex;
    flex-direction: column;
    gap: 2px;
    pointer-events: auto;
    overflow: hidden;
}
.desk-mat.has-focused-layout .paytable-overlay:not(.hidden) {
    top: calc(var(--focus-card-top, 8px) + var(--focus-card-height, 420px) + 6px) !important;
}
.paytable-overlay.hidden {
    display: none !important;
}
.paytable-title {
    font-family: var(--font-pixel);
    font-size: max(13px, calc(11px * var(--ui-scale)));
    color: var(--accent-yellow);
    text-align: center;
    border-bottom: 2px solid rgba(255, 255, 255, 0.15);
    padding-bottom: 4px;
    flex-shrink: 0;
}
.paytable-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(84px, calc(92px * var(--ui-scale)), 150px), 1fr));
    gap: 3px 5px;
    padding: 1px 2px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 0 0 auto;
    max-height: calc(170px * var(--ui-scale));
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.35) rgba(0, 0, 0, 0.2);
}
.paytable-list::-webkit-scrollbar {
    width: 6px;
}
.paytable-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.35);
    border-radius: 3px;
}
.paytable-row {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}
.paytable-sym-details:not(:has(.paytable-sym-name)) {
    justify-content: center;
}
.paytable-sym-details:not(:has(.paytable-sym-name)) .paytable-sym-val {
    font-size: max(13px, calc(12px * var(--ui-scale)));
    line-height: 1.2;
}
.paytable-sym-icon {
    width: max(18px, calc(18px * var(--ui-scale)));
    height: max(18px, calc(18px * var(--ui-scale)));
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.paytable-sym-icon canvas,
.paytable-sym-icon img {
    width: max(16px, calc(16px * var(--ui-scale)));
    height: max(16px, calc(16px * var(--ui-scale)));
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}
.paytable-sym-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.paytable-sym-name {
    font-size: max(11px, calc(10px * var(--ui-scale)));
    color: var(--text-white);
    font-weight: bold;
    line-height: 1.05;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.paytable-sym-val {
    font-size: max(13px, calc(12px * var(--ui-scale)));
    color: var(--accent-green);
    line-height: 1.05;
}
.paytable-rule-note {
    grid-column: 1 / -1;
    font-size: max(11px, calc(10px * var(--ui-scale)));
    color: var(--text-white);
    text-align: center;
    padding-bottom: 2px;
    margin-bottom: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    line-height: 1.15;
}
.paytable-luck-note {
    grid-column: 1 / -1;
    font-size: max(12px, calc(11px * var(--ui-scale)));
    color: var(--accent-yellow);
    text-align: center;
    padding-top: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.hidden {
    display: none !important;
}
body.mobile-layout .scratch-card-wrapper.focused {
    left: 50% !important;
    top: var(--focus-card-top, 6px) !important;
    transform: translateX(-50%) rotate(0deg) !important;
    width: var(--focus-card-width, min(94vw, 400px)) !important;
    height: var(--focus-card-height, min(72vh, 480px)) !important;
    max-height: none;
}
body.mobile-layout .paytable-overlay:not(.hidden),
body.mobile-layout .desk-mat.has-focused-layout .paytable-overlay:not(.hidden) {
    left: 50% !important;
    right: auto !important;
    top: calc(var(--focus-card-top, 6px) + var(--focus-card-height, 480px) + 4px) !important;
    transform: translateX(-50%) !important;
    width: min(94vw, max(var(--focus-card-width, 400px), 300px)) !important;
    max-width: min(94vw, 400px);
    max-height: min(150px, 32vh);
}
body.mobile-layout.mobile-landscape .scratch-card-wrapper.focused {
    height: var(--focus-card-height, min(58vh, 360px)) !important;
}
body.mobile-layout.mobile-landscape .paytable-overlay:not(.hidden),
body.mobile-layout.mobile-landscape .desk-mat.has-focused-layout .paytable-overlay:not(.hidden) {
    max-height: min(108px, 24vh);
}
body.mobile-layout.mobile-landscape .mobile-nav-btn {
    min-height: max(40px, calc(40px * var(--ui-scale)));
    padding: calc(6px * var(--ui-scale));
}
body.mobile-layout.mobile-landscape .pixel-btn.menu-text-btn {
    min-height: max(40px, calc(40px * var(--ui-scale)));
}
body.mobile-layout.mobile-landscape .menu-icon-btn {
    width: max(40px, calc(40px * var(--ui-scale)));
    height: max(40px, calc(40px * var(--ui-scale)));
}
body.mobile-layout.mobile-landscape .mobile-panel-nav {
    display: none !important;
    padding: 3px 8px;
    border-width: 2px;
}
@media (max-width: 1100px) {
    :root {
        --side-panel-width: 260px;
    }
    .game-title {
        font-size: 14px;
    }
    .stat-box .label {
        display: none;
    }
    .coin-stat {
        min-width: 0;
        font-size: calc(clamp(18px, 4.2vw, 24px) * var(--ui-scale));
    }
    .coin-stat .value {
        font-size: 1em;
    }
    .level-stat {
        max-width: 280px;
        min-width: 220px;
        font-size: 20px;
    }
    .progress-bar-container {
        min-width: 100px;
    }
    .panel-header h2 {
        font-size: 14px;
    }
    .tab-btn {
        font-size: max(12px, calc(11px * var(--ui-scale)));
    }
}
@media (max-width: 900px) {
    :root {
        --side-panel-width: 220px;
    }
    .top-bar {
        gap: 10px;
        padding: 6px 10px;
    }
    .game-title {
        font-size: 11px;
        letter-spacing: 1px;
    }
    .pixel-btn.menu-text-btn {
        font-size: max(11px, calc(10px * var(--ui-scale)));
        min-height: 42px;
        padding: 0 10px;
    }
    .scratcher-machine {
        width: 150px;
        top: 8px;
        right: 8px;
    }
    .machine-header {
        font-size: 10px;
    }
    .slot-label {
        font-size: 10px;
    }
    .toggle-btn {
        font-size: 8px;
        padding: 5px 2px;
    }
}
@media (max-width: 900px) and (orientation: landscape) and (max-height: 520px) {
    :root {
        --side-panel-width: 180px;
    }
    .game-container {
        padding: 4px;
    }
    .top-bar {
        margin-bottom: 4px;
        padding: 4px 10px;
    }
    .title-container {
        display: none;
    }
    .stats-container {
        gap: 8px;
        overflow: visible;
        flex-wrap: nowrap;
    }
    .coin-stat {
        font-size: calc(22px * var(--ui-scale));
    }
    .coin-stat .value {
        font-size: 1em;
    }
    .level-stat {
        font-size: 18px;
    }
    .progress-bar-container {
        height: 16px;
    }
    .progress-text {
        font-size: 14px;
    }
    .panel-header h2 {
        font-size: 11px;
        padding: 6px 8px;
    }
    .panel-header {
        padding: 5px 8px;
    }
    .desk-wood-mat {
        width: 98%;
        height: 98%;
        border-width: 4px;
    }
    body:not(.mobile-layout) .scratch-card-wrapper.focused {
        width: var(--focus-card-width, min(35vw, 320px)) !important;
        height: var(--focus-card-height, min(72vh, 420px)) !important;
        left: calc(50% - 130px) !important;
        top: var(--focus-card-top, 8px) !important;
        transform: translateX(-50%) rotate(0deg) !important;
    }
    body:not(.mobile-layout) .paytable-overlay {
        left: calc(50% + 140px) !important;
        top: var(--focus-card-top, 8px) !important;
        transform: translate(-50%, 0);
        width: min(35vw, 220px);
        height: fit-content;
        max-height: min(180px, 70vh);
    }
    .scratcher-machine {
        width: 140px;
        top: 6px;
        right: 6px;
    }
    .machine-controls {
        flex-direction: column;
        align-items: stretch;
    }
    .toggle-btn {
        width: 100%;
        min-height: 34px;
    }
    .machine-header {
        font-size: 10px;
    }
    .overlay-title {
        font-size: 13px;
    }
    .overlay-reward {
        font-size: 18px;
    }
    .action-btn {
        font-size: 10px;
        padding: 8px 14px;
        min-height: 36px;
    }
    .pixel-btn.menu-text-btn {
        font-size: max(11px, calc(10px * var(--ui-scale)));
        min-height: 36px;
    }
}
@media (max-width: 900px) and (orientation: landscape) and (max-height: 440px) {
    :root {
        --side-panel-width: 160px;
    }
    .top-bar {
        padding: 3px 8px;
        gap: 6px;
        margin-bottom: 3px;
        border-width: 3px;
    }
    .stat-box {
        padding: 3px 6px;
        border-width: 2px;
    }
    .coin-stat {
        font-size: calc(18px * var(--ui-scale));
    }
    .coin-stat .value {
        font-size: 1em;
    }
    .pixel-icon {
        width: 18px;
        height: 18px;
    }
    .level-stat {
        font-size: 16px;
    }
    .progress-bar-container {
        height: 14px;
    }
    .progress-text {
        font-size: 12px;
    }
    .panel {
        border-width: 3px;
    }
    .panel-header {
        padding: 4px 6px;
        border-bottom-width: 3px;
    }
    .panel-header h2 {
        font-size: 9px;
    }
    .panel-content {
        padding: 6px;
        gap: 6px;
    }
    .desk-area {
        border-width: 3px;
    }
    .desk-wood-mat {
        border-width: 3px;
    }
    .desk-mat {
        border-width: 3px;
    }
    body:not(.mobile-layout) .scratch-card-wrapper.focused {
        left: calc(50% - 110px) !important;
        top: 50% !important;
        transform: translate(-50%, -50%) rotate(0deg) !important;
        width: min(35vw, 260px) !important;
        height: min(82vh, 320px) !important;
    }
    body:not(.mobile-layout) .paytable-overlay {
        left: calc(50% + 120px) !important;
        top: 50% !important;
        bottom: auto;
        transform: translate(-50%, -50%);
        width: min(35vw, 220px) !important;
        height: min(82vh, 240px) !important;
    }
    .scratcher-machine {
        width: 130px;
        padding: 3px;
        gap: 4px;
    }
    .pixel-btn.menu-text-btn {
        font-size: max(11px, calc(9px * var(--ui-scale)));
        min-height: 30px;
        padding: 0 6px;
    }
}
@media (max-width: 1024px) and (orientation: portrait), (max-height: 520px) and (orientation: landscape) and (max-width: 1024px), (max-width: 600px) {
    .game-container {
        padding: 4px;
        gap: 0;
    }
    .top-bar {
        grid-template-columns: 1fr auto;
        grid-template-rows: auto;
        gap: 4px;
        padding: 5px 8px;
        margin-bottom: 4px;
        border-width: 3px;
    }
    .stats-container {
        grid-column: 1;
        grid-row: 1;
        gap: 8px;
        min-width: 0;
        overflow: visible;
        justify-content: flex-start;
        align-items: center;
        flex-wrap: nowrap;
    }
    .stat-box {
        padding: 3px 6px;
        gap: 4px;
        border-width: 2px;
        min-width: 0;
    }
    .stat-box .label {
        display: none;
    }
    .coin-stat,
    .diamond-stat,
    .crown-stat {
        flex: 0 0 auto;
        width: fit-content;
        max-width: none;
        min-width: 0;
        padding: calc(4px * var(--ui-scale)) calc(10px * var(--ui-scale));
        gap: calc(6px * var(--ui-scale));
        font-size: calc(clamp(16px, 4.5vw, 20px) * var(--ui-scale));
        border-width: 3px;
    }
    .coin-stat {
        border-color: var(--accent-yellow);
    }
    .diamond-stat {
        border-color: #60a5fa;
    }
    .crown-stat {
        border-color: #c084fc;
    }
    .coin-stat .coin-icon,
    .diamond-stat .diamond-icon,
    .crown-stat .crown-icon-img {
        width: 1em;
        height: 1em;
    }
    .coin-stat .value,
    .diamond-stat .value,
    .crown-stat .value {
        font-size: 1em;
    }
    .level-stat {
        flex: 1 1 auto;
        min-width: 0;
        margin-left: 0;
        padding: 2px;
        background: transparent;
        border: none;
        box-shadow: none;
    }
    .level-stat .progress-bar-container {
        display: none;
    }
    .level-xp-badge {
        display: block;
        width: 34px;
        height: 34px;
        padding: 2px;
        background: conic-gradient(
            from -90deg,
            var(--accent-blue) calc(var(--xp-pct) * 1%),
            #2a2e37 0
        );
        box-shadow: inset -1px -1px 0 #000, 1px 1px 0 #474b57;
    }
    .level-xp-badge-inner {
        width: 100%;
        height: 100%;
        background: #0f1013;
        border: 2px solid #000;
        display: grid;
        place-items: center;
        padding: 0;
    }
    .level-xp-badge .value {
        font-size: clamp(13px, 3.6vw, 16px);
    }
    .title-container {
        display: none;
    }
    .menu-buttons {
        grid-column: 2;
        grid-row: 1;
        gap: 4px;
    }
    .pixel-btn.menu-text-btn {
        font-size: clamp(11px, 2.8vw, 13px);
        min-height: 38px;
        padding: 0 8px;
        border-width: 2px;
    }
    .pixel-icon {
        width: 22px;
        height: 22px;
    }
    .game-layout {
        display: flex;
        flex-direction: column;
        gap: 4px;
        flex: 1 1 0%;
        min-height: 0;
    }
    .desk-area {
        flex: 1 1 0%;
        min-height: 0;
        height: auto;
        order: 1;
        border-width: 3px;
    }
    .desk-area.mobile-desk-full {
        flex: 1 1 0%;
        min-height: 0;
    }
    .desk-wood-mat {
        width: 100%;
        height: 100%;
    }
    .game-layout.mobile-desk-focus {
        flex: 1 1 0%;
        min-height: 0;
    }
    .game-layout.mobile-desk-focus .desk-area {
        flex: 1 1 0%;
        min-height: 0;
        height: auto;
        display: flex;
        flex-direction: column;
    }
    .game-layout.mobile-desk-focus .desk-wood-mat {
        width: 100%;
        flex: 1 1 0%;
        min-height: 0;
        height: auto;
        display: flex;
        flex-direction: column;
    }
    .game-layout.mobile-desk-focus .desk-mat.has-focused-layout {
        height: var(--focus-workspace-height, auto);
        min-height: 0;
        max-height: 100%;
        flex: 0 0 auto;
    }
    .game-layout.mobile-split .desk-area {
        flex: 0 0 auto;
        min-height: 22vh;
        max-height: 28vh;
    }
    .upgrades-panel,
    .shop-panel {
        display: none !important;
        flex: 1 1 0%;
        height: auto;
        min-height: 180px;
        order: 2;
        border-width: 3px;
        overflow: hidden;
    }
    .upgrades-panel.mobile-active,
    .shop-panel.mobile-active {
        display: none !important;
    }
    .mobile-panel-nav {
        display: none !important;
        order: 3;
        gap: 4px;
        border-width: 3px;
        margin-top: auto;
        flex-shrink: 0;
    }
    .mobile-nav-btn {
        font-size: clamp(10px, 3vw, 14px);
        padding: 10px 6px;
        min-height: 46px;
    }
    .panel-header {
        padding: 6px 10px;
        border-bottom-width: 3px;
    }
    .panel-header h2 {
        font-size: clamp(13px, 3.5vw, 16px);
    }
    .tab-btn {
        font-size: clamp(12px, 3vw, 15px);
        padding: 8px 0;
    }
    .panel-content {
        padding: var(--panel-item-pad);
        gap: calc(6px * var(--ui-scale));
    }
    .ticket-footer {
        min-height: calc(14px * var(--ui-scale));
    }
    .ticket-lock-overlay .lock-level {
        font-size: max(11px, calc(10px * var(--ui-scale)));
    }
    .cooldown-overlay {
        font-size: max(12px, calc(11px * var(--ui-scale)));
    }
    .cooldown-title {
        font-size: max(10px, calc(8px * var(--ui-scale)));
    }
    .cooldown-name {
        font-size: max(10px, calc(9px * var(--ui-scale)));
    }
    .cooldown-timer {
        font-size: calc(18px * var(--ui-scale));
    }
    .desk-wood-mat {
        width: 100%;
        height: 100%;
        border-width: 4px;
    }
    .desk-mat {
        border-width: 3px;
    }
    .scratcher-machine {
        width: 140px;
        top: 4px;
        right: 4px;
        padding: 4px;
        gap: 4px;
        border-width: 3px;
    }
    .machine-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
    }
    .machine-header {
        font-size: 10px;
    }
    .slot-label {
        font-size: 10px;
    }
    .queue-display {
        font-size: 16px;
    }
    .toggle-btn {
        flex: none;
        width: 100%;
        min-height: 40px;
        font-size: 7px;
        padding: 6px 4px;
    }
    .scratch-card-wrapper {
        width: 70px;
        height: 92px;
        border-width: 3px;
    }
    .scratch-card-wrapper.focused {
        width: var(--focus-card-width, min(94vw, 400px)) !important;
        height: var(--focus-card-height, min(72vh, 480px)) !important;
        left: 50% !important;
        top: var(--focus-card-top, 6px) !important;
        transform: translateX(-50%) rotate(0deg) !important;
        max-height: none;
    }
    .paytable-overlay {
        width: min(94vw, 400px);
        top: calc(var(--focus-card-top, 6px) + var(--focus-card-height, 72vh) + 4px) !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
        overflow: hidden;
        padding: 3px 4px;
        max-height: min(calc(210px * var(--ui-scale)), 48vh);
    }
    .paytable-list {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 3px 4px;
    }
    .paytable-sym-icon {
        width: max(17px, calc(17px * var(--ui-scale)));
        height: max(17px, calc(17px * var(--ui-scale)));
    }
    .paytable-sym-icon canvas,
    .paytable-sym-icon img {
        width: max(15px, calc(15px * var(--ui-scale)));
        height: max(15px, calc(15px * var(--ui-scale)));
    }
    .paytable-sym-name {
        font-size: max(11px, calc(10px * var(--ui-scale)));
    }
    .paytable-sym-val {
        font-size: max(12px, calc(11px * var(--ui-scale)));
    }
    .paytable-title {
        font-size: max(13px, calc(11px * var(--ui-scale)));
        padding-bottom: 3px;
    }
    .paytable-rule-note {
        font-size: max(11px, calc(10px * var(--ui-scale)));
    }
    .paytable-luck-note {
        font-size: max(12px, calc(11px * var(--ui-scale)));
    }
    .overlay-title {
        font-size: clamp(13px, 4vw, 18px);
    }
    .overlay-desc {
        font-size: clamp(16px, 4.5vw, 22px);
    }
    .overlay-reward {
        font-size: clamp(18px, 5.5vw, 26px);
    }
    .action-btn {
        min-height: 46px;
        padding: 12px 18px;
        font-size: clamp(12px, 3.2vw, 15px);
    }
    .modal-content {
        max-width: var(--modal-width);
        max-height: var(--modal-max-height);
        overflow-y: auto;
        border-width: calc(4px * var(--ui-scale));
    }
    .modal-header h3 {
        font-size: var(--modal-title-size);
    }
    .modal-body {
        font-size: var(--modal-body-size);
        padding: var(--modal-body-pad);
        line-height: 1.5;
    }
    .modal-body strong {
        font-size: inherit;
    }
    .modal-footer {
        padding: var(--modal-footer-pad);
    }
    .close-modal-btn {
        font-size: var(--modal-close-size);
    }
    .money-float-text {
        font-size: max(12px, calc(11px * var(--ui-scale)));
    }
    .text-popup {
        font-size: 14px;
    }
    .ants-toggle-btn {
        font-size: 9px;
        padding: 6px 10px;
    }
    .pixel-btn {
        font-size: max(12px, calc(11px * var(--ui-scale)));
        padding: 8px 12px;
        border-width: 2px;
    }
    .panel-content::-webkit-scrollbar {
        width: 6px;
    }
}
@media (max-width: 400px) and (orientation: portrait) {
    .mobile-nav-btn {
        font-size: clamp(8px, 2.3vw, 11px);
        padding: 8px 4px;
        min-height: 42px;
    }
    .scratch-card-wrapper.focused {
        width: var(--focus-card-width, 94vw) !important;
        height: var(--focus-card-height, min(65vh, 420px)) !important;
        top: var(--focus-card-top, 4px) !important;
        transform: translateX(-50%) rotate(0deg) !important;
    }
    .paytable-overlay {
        max-height: min(140px, 30vh);
    }
    .coin-stat {
        font-size: calc(clamp(16px, 4.5vw, 20px) * var(--ui-scale));
    }
    .coin-stat .value {
        font-size: 1em;
    }
    .level-xp-badge {
        width: 36px;
        height: 36px;
    }
    .scratcher-machine {
        width: 120px;
    }
    .machine-controls {
        flex-direction: column;
        align-items: stretch;
    }
    .toggle-btn {
        width: 100%;
        min-height: 40px;
    }
    .pixel-btn.menu-text-btn {
        font-size: max(11px, calc(10px * var(--ui-scale)));
        min-height: 34px;
        padding: 0 6px;
    }
    .panel-header h2 {
        font-size: clamp(11px, 3vw, 14px);
    }
}
@media (max-width: 768px) and (orientation: portrait) and (min-height: 700px) {
    .game-layout.mobile-split .desk-area {
        min-height: 24vh;
        max-height: 30vh;
    }
    .upgrades-panel.mobile-active,
    .shop-panel.mobile-active {
        min-height: 280px;
    }
    .panel-content {
        gap: calc(8px * var(--ui-scale));
        padding: var(--panel-item-pad);
    }
}
@media (max-width: 768px) and (orientation: portrait) and (min-height: 800px) {
    .game-layout.mobile-split .desk-area {
        min-height: 26vh;
        max-height: 32vh;
    }
    .upgrades-panel.mobile-active,
    .shop-panel.mobile-active {
        min-height: 320px;
    }
    .cooldown-timer {
        font-size: calc(20px * var(--ui-scale));
    }
    .panel-content {
        gap: calc(8px * var(--ui-scale));
        padding: var(--panel-item-pad);
    }
    .panel-header h2 {
        font-size: calc(14px * var(--ui-scale));
    }
    .mobile-nav-btn {
        font-size: calc(11px * var(--ui-scale));
        min-height: calc(50px * var(--ui-scale));
    }
    .coin-stat {
        font-size: calc(clamp(17px, 4.8vw, 22px) * var(--ui-scale));
    }
    .coin-stat .value {
        font-size: 1em;
    }
    .level-xp-badge {
        width: calc(36px * var(--ui-scale));
        height: calc(36px * var(--ui-scale));
    }
    .level-xp-badge .value {
        font-size: clamp(14px, 3.8vw, 17px);
    }
    .progress-text {
        font-size: clamp(11px, 3vw, 14px);
    }
    .progress-bar-container {
        height: 20px;
    }
    .ticket-payout {
        font-size: clamp(16px, 4.2vw, 20px);
    }
    .overlay-title {
        font-size: clamp(15px, 4.5vw, 20px);
    }
    .overlay-reward {
        font-size: clamp(20px, 6vw, 28px);
    }
    .action-btn {
        font-size: clamp(13px, 3.5vw, 16px);
        min-height: 50px;
    }
    .upgrade-item {
        padding: 10px 12px;
        gap: 10px;
    }
    .ticket-item {
        padding: 10px 12px;
    }
}
.edit-panel-overlay {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 290px;
    background: rgba(15, 15, 19, 0.92);
    border: 4px double #f4b41b;
    border-radius: 4px;
    padding: 18px;
    color: #fff;
    font-family: 'Press Start 2P', monospace;
    z-index: 10000;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.85), inset 0 0 10px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
}
.edit-panel-header {
    font-size: 11px;
    color: #f4b41b;
    text-align: center;
    border-bottom: 2px dashed #4e5564;
    padding-bottom: 12px;
    margin-bottom: 18px;
    letter-spacing: 1px;
    text-shadow: 1px 1px 0px #000;
}
.edit-control-group {
    margin-bottom: 16px;
}
.edit-control-label {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    margin-bottom: 6px;
    color: #a1a1aa;
}
.edit-control-label span.val {
    color: #facc15;
    font-family: 'VT323', monospace;
    font-size: 16px;
}
.edit-slider {
    width: 100%;
    height: 10px;
    background: #09090b;
    border: 2px solid #3f3f46;
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
    image-rendering: pixelated;
    cursor: var(--ui-cursor);
}
.edit-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: #f4b41b;
    border: 2px solid #000;
    cursor: var(--ui-cursor);
    box-shadow: inset -2px -2px 0 #c68a0c, inset 2px 2px 0 #fff;
}
.edit-checkbox-container {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 9px;
    margin-bottom: 18px;
    cursor: var(--ui-cursor);
    color: #e4e4e7;
    user-select: none;
}
.edit-checkbox {
    width: 16px;
    height: 16px;
    accent-color: #f4b41b;
    cursor: var(--ui-cursor);
    border: 2px solid #000;
}
.edit-action-btn {
    width: 100%;
    margin-top: 8px;
    padding: 10px;
    font-size: 9px;
}
.tutorial-overlay-banner {
    position: fixed;
    bottom: calc(var(--bottom-dock-height) + env(safe-area-inset-bottom, 0px) + calc(12px * var(--ui-scale)));
    left: 50%;
    transform: translateX(-50%);
    background: #0f0f13;
    border: calc(4px * var(--ui-scale)) solid #fff;
    box-shadow:
        0 0 0 calc(4px * var(--ui-scale)) #0f0f13,
        inset 0 0 0 calc(2px * var(--ui-scale)) #555,
        0 calc(8px * var(--ui-scale)) calc(16px * var(--ui-scale)) rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: calc(10px * var(--ui-scale)) calc(14px * var(--ui-scale));
    font-family: var(--font-retro), monospace;
    font-size: var(--tutorial-banner-font);
    line-height: 1.35;
    text-align: center;
    z-index: 2003;
    pointer-events: none;
    max-width: var(--tutorial-banner-width);
    width: var(--tutorial-banner-width);
    image-rendering: pixelated;
    animation: tutorial-pulse-border 1.5s infinite alternate;
}
.tutorial-overlay-banner strong {
    color: #f4b41b;
}
.tutorial-skip-btn {
    display: block;
    margin: calc(8px * var(--ui-scale)) auto 0;
    pointer-events: auto;
    font-size: calc(11px * var(--ui-scale));
    padding: calc(6px * var(--ui-scale)) calc(12px * var(--ui-scale));
    min-height: max(30px, calc(30px * var(--ui-scale)));
    cursor: var(--ui-cursor);
    white-space: nowrap;
}
.tutorial-banner-text {
    pointer-events: none;
}
html[lang="tr"] .tutorial-overlay-banner {
    line-height: 1.45;
    letter-spacing: 0.02em;
}
html[lang="tr"] body.tutorial-go-desk .tutorial-overlay-banner {
    font-size: calc(17px * var(--ui-scale));
}
.pixel-btn.menu-text-btn:disabled,
.pixel-btn.menu-text-btn.disabled {
    opacity: 0.45;
    cursor: var(--ui-cursor);
}
.tutorial-pointer {
    position: fixed;
    width: calc(32px * var(--ui-scale));
    height: calc(32px * var(--ui-scale));
    z-index: 2004;
    pointer-events: none;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 8 8" width="32" height="32" style="image-rendering: pixelated;"><path d="M 0 3 L 4 3 L 4 0 L 8 4 L 4 8 L 4 5 L 0 5 Z" fill="%23ffff00" stroke="%23000000" stroke-width="1"/></svg>');
    background-repeat: no-repeat;
    background-size: contain;
    animation: tutorial-bounce 0.5s infinite alternate;
    transform-origin: center center;
}
@keyframes tutorial-bounce {
    0% { margin-top: 0; }
    100% { margin-top: -6px; }
}
.tutorial-overlay-banner.hidden,
.tutorial-pointer.hidden {
    display: none !important;
}
@keyframes tutorial-pulse-border {
    0% { border-color: #ffffff; }
    100% { border-color: #f4b41b; }
}
@media (max-width: 768px) {
    .tutorial-overlay-banner {
        font-size: calc(16px * var(--ui-scale));
        width: var(--tutorial-banner-width);
        padding: calc(8px * var(--ui-scale)) calc(12px * var(--ui-scale));
        border-width: calc(3px * var(--ui-scale));
        box-shadow:
            0 0 0 calc(3px * var(--ui-scale)) #0f0f13,
            inset 0 0 0 calc(1px * var(--ui-scale)) #555,
            0 calc(6px * var(--ui-scale)) calc(12px * var(--ui-scale)) rgba(0, 0, 0, 0.6);
    }
    .tutorial-skip-btn {
        font-size: calc(10px * var(--ui-scale));
        padding: calc(4px * var(--ui-scale)) calc(10px * var(--ui-scale));
        min-height: max(26px, calc(26px * var(--ui-scale)));
        margin: calc(6px * var(--ui-scale)) auto 0;
    }
}
@media (max-height: 520px) {
    .tutorial-overlay-banner {
        font-size: calc(14px * var(--ui-scale));
        padding: calc(6px * var(--ui-scale)) calc(10px * var(--ui-scale));
    }
    .tutorial-skip-btn {
        font-size: calc(9px * var(--ui-scale));
        padding: calc(3px * var(--ui-scale)) calc(8px * var(--ui-scale));
        min-height: max(22px, calc(22px * var(--ui-scale)));
        margin: calc(4px * var(--ui-scale)) auto 0;
    }
}
body.mobile-layout.tutorial-scratch .tutorial-overlay-banner,
body.mobile-layout.tutorial-claim .tutorial-overlay-banner {
    left: 50%;
    transform: translateX(-50%);
    width: var(--tutorial-banner-width);
}
body.mobile-layout.tutorial-buy-free .tutorial-overlay-banner,
body.mobile-layout.tutorial-open-shop .tutorial-overlay-banner,
body.mobile-layout.tutorial-open-card .tutorial-overlay-banner {
    left: 50%;
    transform: translateX(-50%);
    width: var(--tutorial-banner-width);
}
body.mobile-layout.tutorial-go-desk .tutorial-overlay-banner {
    left: 50%;
    transform: translateX(-50%);
    width: min(92vw, calc(300px * var(--ui-scale)));
    font-size: calc(17px * var(--ui-scale));
    line-height: 1.4;
    padding: calc(8px * var(--ui-scale)) calc(12px * var(--ui-scale)) calc(6px * var(--ui-scale));
}
.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.78);
    z-index: 1999;
    pointer-events: auto;
    cursor: var(--ui-cursor);
}
body.tutorial-scratch .tutorial-overlay,
body.tutorial-claim .tutorial-overlay {
    pointer-events: none;
}
body.scratch-coin-mode.tutorial-scratch .tutorial-overlay,
body.scratch-coin-mode.tutorial-claim .tutorial-overlay {
    cursor: var(--coin-cursor) !important;
}
body.scratch-coin-mode.scratch-coin-pressed.tutorial-scratch .tutorial-overlay,
body.scratch-coin-mode.scratch-coin-pressed.tutorial-claim .tutorial-overlay {
    cursor: var(--coin-cursor-pressed) !important;
}
html.scratch-coin-cursor-follow body.scratch-coin-mode.tutorial-scratch .tutorial-overlay,
html.scratch-coin-cursor-follow body.scratch-coin-mode.tutorial-claim .tutorial-overlay,
html.scratch-coin-cursor-follow body.scratch-coin-mode.scratch-coin-pressed.tutorial-scratch .tutorial-overlay,
html.scratch-coin-cursor-follow body.scratch-coin-mode.scratch-coin-pressed.tutorial-claim .tutorial-overlay {
    cursor: none !important;
}
/* Raise dock / shop sheet above dim overlay during tutorial */
body.tutorial-open-shop #bottom-dock,
body.tutorial-buy-free #bottom-dock,
body.tutorial-go-desk #bottom-dock {
    z-index: 2005;
}
body.tutorial-open-shop .dock-btn[data-panel="shop"] {
    z-index: 2006;
}
body.tutorial-buy-free .menu-sheet,
body.tutorial-buy-free .menu-sheet[data-panel="shop"],
body.tutorial-buy-free #shop-pane,
body.tutorial-buy-free #tickets-list {
    z-index: 2004;
}
body.tutorial-buy-free .dock-btn[data-panel="shop"] {
    z-index: 2006;
}
body.tutorial-go-desk .menu-sheet,
body.tutorial-go-desk .menu-sheet[data-panel="shop"],
body.tutorial-go-desk #shop-pane,
body.tutorial-go-desk #tickets-list {
    z-index: 2004;
}
body.tutorial-go-desk .dock-btn[data-panel="desk"] {
    z-index: 2006;
}
.dock-btn.tutorial-spotlight-target {
    animation: tutorial-ticket-glow 1.1s ease-in-out infinite alternate;
    z-index: 2007 !important;
}
@media (min-width: 769px) {
    body.tutorial-buy-free .tutorial-overlay-banner,
    body.tutorial-open-shop .tutorial-overlay-banner,
    body.tutorial-go-desk .tutorial-overlay-banner {
        left: 50%;
        right: auto;
        bottom: calc(var(--bottom-dock-height, 64px) + calc(24px * var(--ui-scale)));
        top: auto;
        transform: translateX(-50%);
        width: min(calc(420px * var(--ui-scale)), 90vw);
    }
    body.tutorial-open-card .tutorial-overlay-banner,
    body.tutorial-scratch .tutorial-overlay-banner,
    body.tutorial-claim .tutorial-overlay-banner {
        top: calc(var(--header-height) + calc(16px * var(--ui-scale)));
        bottom: auto;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: min(calc(360px * var(--ui-scale)), 46vw);
        max-width: calc(400px * var(--ui-scale));
    }
}
.tutorial-spotlight-target {
    position: relative;
    z-index: 2002 !important;
}
.scratch-card-wrapper.tutorial-spotlight-target {
    animation: tutorial-card-glow 1.1s ease-in-out infinite alternate;
}
.ticket-item.tutorial-spotlight-target,
.claim-btn.tutorial-spotlight-target {
    animation: tutorial-ticket-glow 1.1s ease-in-out infinite alternate;
}
.claim-btn.tutorial-spotlight-target {
    z-index: 12;
}
@keyframes tutorial-card-glow {
    from {
        filter: drop-shadow(0 0 8px rgba(244, 180, 27, 0.9)) drop-shadow(0 0 16px rgba(255, 255, 255, 0.45));
    }
    to {
        filter: drop-shadow(0 0 14px rgba(244, 180, 27, 1)) drop-shadow(0 0 28px rgba(255, 255, 255, 0.75));
    }
}
@keyframes tutorial-ticket-glow {
    from {
        box-shadow: 0 0 0 2px #f4b41b, 0 0 14px rgba(244, 180, 27, 0.75);
    }
    to {
        box-shadow: 0 0 0 3px #fff7cc, 0 0 22px rgba(244, 180, 27, 1);
    }
}
.tutorial-overlay.hidden {
    display: none !important;
}

/* ===== Bottom dock + menu sheet (desk-first layout) ===== */
.bottom-dock {
    position: absolute;
    left: var(--ui-pad);
    right: var(--ui-pad);
    bottom: max(calc(6px * var(--ui-scale)), env(safe-area-inset-bottom, 0px));
    z-index: 1600;
    display: flex;
    gap: calc(6px * var(--ui-scale));
    padding: calc(6px * var(--ui-scale));
    min-height: var(--bottom-dock-height);
    background: var(--panel-bg);
    background-image:
        linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, transparent 40%),
        repeating-linear-gradient(90deg, transparent, transparent 7px, rgba(0, 0, 0, 0.08) 7px, rgba(0, 0, 0, 0.08) 8px);
    border: calc(3px * var(--ui-scale)) solid var(--pixel-border-color);
    box-shadow:
        inset -3px -3px 0 #101218,
        inset 3px 3px 0 var(--panel-highlight),
        0 -4px 0 rgba(0, 0, 0, 0.35);
}
.dock-btn {
    position: relative;
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: calc(4px * var(--ui-scale));
    min-width: 0;
    min-height: var(--dock-btn-min);
    padding: calc(6px * var(--ui-scale)) calc(4px * var(--ui-scale));
    font-family: var(--font-pixel);
    font-size: var(--dock-font);
    color: var(--text-muted);
    background: #252830;
    border: 2px solid #000;
    cursor: var(--ui-cursor);
    box-shadow: inset -2px -2px 0 #1a1b1f, inset 2px 2px 0 #474b57;
}
.dock-btn.active {
    color: var(--accent-yellow);
    background: #3a3d46;
    border-color: var(--accent-yellow);
}
.dock-btn.has-claim {
    color: #93c5fd;
}
.dock-btn.tutorial-locked {
    opacity: 0.35;
    pointer-events: none;
}
.dock-btn:focus { outline: none; }
.dock-btn:focus-visible {
    outline: 2px solid var(--accent-yellow);
    outline-offset: 1px;
}
.dock-icon {
    display: block;
    width: var(--dock-icon-size);
    height: var(--dock-icon-size);
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    pointer-events: none;
    flex-shrink: 0;
}
.dock-label {
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    line-height: 1.1;
}
.dock-badge {
    position: absolute;
    top: calc(2px * var(--ui-scale));
    right: calc(4px * var(--ui-scale));
    min-width: max(16px, calc(16px * var(--ui-scale)));
    height: max(16px, calc(16px * var(--ui-scale)));
    padding: 0 calc(4px * var(--ui-scale));
    border: 2px solid #000;
    background: var(--accent-red);
    color: #fff;
    font-family: var(--font-pixel);
    font-size: max(12px, calc(10px * var(--ui-scale)));
    line-height: max(14px, calc(12px * var(--ui-scale)));
    text-align: center;
    box-shadow: 1px 1px 0 #000;
}
.dock-badge.hidden { display: none; }

.menu-sheet {
    position: absolute;
    left: var(--ui-pad);
    right: var(--ui-pad);
    bottom: calc(var(--bottom-dock-height) + env(safe-area-inset-bottom, 0px) + calc(8px * var(--ui-scale)));
    z-index: 1550;
    display: flex;
    flex-direction: column;
    max-height: var(--menu-sheet-max);
    min-height: calc(180px * var(--ui-scale));
    background: var(--panel-bg);
    background-image:
        linear-gradient(180deg, rgba(255, 255, 255, 0.035) 0%, transparent 28%),
        repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(0, 0, 0, 0.06) 3px, rgba(0, 0, 0, 0.06) 4px);
    border: calc(3px * var(--ui-scale)) solid var(--pixel-border-color);
    box-shadow:
        inset -3px -3px 0 #101218,
        inset 3px 3px 0 var(--panel-highlight),
        0 -6px 0 rgba(0, 0, 0, 0.4);
}
.menu-sheet.hidden { display: none !important; }
.menu-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: calc(10px * var(--ui-scale));
    padding: calc(10px * var(--ui-scale)) calc(12px * var(--ui-scale));
    border-bottom: 3px solid #000;
    flex-shrink: 0;
}
.menu-sheet-header h2 {
    font-family: var(--font-pixel);
    font-size: var(--sheet-title-size);
    color: var(--accent-yellow);
    margin: 0;
}
.menu-sheet-close {
    width: max(44px, calc(36px * var(--ui-scale)));
    height: max(44px, calc(36px * var(--ui-scale)));
    padding: 0;
    font-size: calc(18px * var(--ui-scale));
    line-height: 1;
    flex-shrink: 0;
}
.menu-sheet-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.menu-panel-pane {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: var(--panel-item-pad);
    display: flex;
    flex-direction: column;
    gap: calc(8px * var(--ui-scale));
    -webkit-overflow-scrolling: touch;
}
.menu-panel-pane.hidden { display: none !important; }

/* Panel list items scale with UI */
.menu-panel-pane .upgrade-item,
.menu-panel-pane .ticket-item,
.menu-panel-pane .task-item,
.menu-panel-pane .achievement-item {
    padding: var(--panel-item-pad) calc(12px * var(--ui-scale));
    gap: calc(10px * var(--ui-scale));
}
.menu-panel-pane .upgrade-name,
.menu-panel-pane .ticket-name,
.menu-panel-pane .task-name,
.menu-panel-pane .achievement-name {
    font-size: var(--panel-name-size);
}
.menu-panel-pane .upgrade-desc,
.menu-panel-pane .task-desc,
.menu-panel-pane .achievement-desc,
.menu-panel-pane .ticket-tier {
    font-size: var(--panel-desc-size);
}
.menu-panel-pane .upgrade-cost-tag,
.menu-panel-pane .ticket-cost,
.menu-panel-pane .task-reward,
.menu-panel-pane .achievement-reward {
    font-size: var(--panel-cost-size);
}

.achievement-item {
    background: linear-gradient(180deg, #2c313c 0%, #252830 100%);
    border: 3px solid #000;
    box-shadow:
        inset -2px -2px 0 #1a1c22,
        inset 2px 2px 0 #3a4050;
    padding: var(--panel-item-pad) calc(12px * var(--ui-scale));
    display: flex;
    align-items: flex-start;
    gap: calc(10px * var(--ui-scale));
    flex-shrink: 0;
}
.achievement-item.claimable {
    box-shadow:
        inset -2px -2px 0 #1a1c22,
        inset 2px 2px 0 #3a4050,
        0 0 0 2px rgba(244, 180, 27, 0.55);
}
.achievement-item.claimed { opacity: 0.55; }
.achievement-icon {
    width: calc(28px * var(--ui-scale));
    text-align: center;
    font-size: var(--panel-icon-size);
    line-height: 1.2;
    flex-shrink: 0;
    padding-top: calc(2px * var(--ui-scale));
}
.achievement-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: calc(4px * var(--ui-scale));
}
.achievement-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: calc(8px * var(--ui-scale));
}
.achievement-name {
    font-family: var(--font-pixel);
    font-size: var(--panel-name-size);
    color: #fff;
    line-height: 1.3;
}
.achievement-reward {
    font-family: var(--font-pixel);
    font-size: var(--panel-cost-size);
    color: var(--accent-yellow);
    white-space: nowrap;
    flex-shrink: 0;
}
.achievement-desc {
    font-size: var(--panel-desc-size);
    color: var(--text-muted);
    line-height: 1.35;
}
.achievement-progress-bar {
    height: calc(8px * var(--ui-scale));
    background: #0f1013;
    border: 2px solid #000;
    overflow: hidden;
    margin-top: calc(2px * var(--ui-scale));
}
.achievement-progress-fill {
    height: 100%;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.25) 0%, transparent 45%),
        repeating-linear-gradient(90deg, #f4b41b 0 5px, #d97706 5px 7px);
}
.achievement-claim-btn {
    flex-shrink: 0;
    font-size: var(--panel-claim-size);
    padding: calc(8px * var(--ui-scale)) calc(6px * var(--ui-scale));
    min-width: calc(72px * var(--ui-scale));
    align-self: center;
}
.achievement-claim-btn:disabled {
    opacity: 0.55;
    pointer-events: none;
}
.achievement-claim-btn.btn-on {
    background: #b45309;
    box-shadow:
        inset -2px -2px 0 #78350f,
        inset 2px 2px 0 #fcd34d;
}

body.tutorial-buy-free #tickets-list,
body.tutorial-buy-free #shop-pane,
body.tutorial-buy-free .menu-sheet[data-panel="shop"],
body.tutorial-buy-free .menu-sheet {
    position: relative;
    z-index: 2002;
}
body.tutorial-buy-free .dock-btn[data-panel="shop"],
body.tutorial-open-shop .dock-btn[data-panel="shop"] {
    position: relative;
    z-index: 2003;
}

/* Narrow screens: keep dock/sheet proportional via --ui-scale (no fixed px overrides) */
@media (max-width: 700px) {
    :root {
        --menu-sheet-max: min(62vh, calc(480px * var(--ui-scale)));
        --dock-font: max(12px, calc(10px * var(--ui-scale)));
    }
    .bottom-dock,
    .menu-sheet {
        left: max(4px, calc(6px * var(--ui-scale)));
        right: max(4px, calc(6px * var(--ui-scale)));
    }
}

/* Very short landscape: sheet must not eat the desk */
@media (max-height: 480px) and (orientation: landscape) {
    :root {
        --menu-sheet-max: min(48vh, calc(320px * var(--ui-scale)));
        --bottom-dock-height: calc(52px * var(--ui-scale));
        --dock-btn-min: calc(40px * var(--ui-scale));
        --dock-icon-size: calc(18px * var(--ui-scale));
        --dock-font: max(12px, calc(9px * var(--ui-scale)));
    }
}

/* Large / fullscreen: roomier sheet, still one scale */
html.ui-scale-lg {
    --menu-sheet-max: min(56vh, calc(560px * var(--ui-scale)));
    --modal-max-height: min(90dvh, calc(720px * var(--ui-scale)));
}
html.ui-scale-xl {
    --menu-sheet-max: min(54vh, calc(620px * var(--ui-scale)));
    --modal-width: min(92vw, calc(540px * var(--ui-scale)));
    --stats-modal-width: min(92vw, calc(480px * var(--ui-scale)));
    --daily-spin-width: min(92vw, calc(440px * var(--ui-scale)));
    --modal-max-height: min(88dvh, calc(760px * var(--ui-scale)));
}
html.ui-scale-sm {
    --modal-action-min-h: max(44px, calc(48px * var(--ui-scale)));
    --modal-close-hit: max(44px, calc(48px * var(--ui-scale)));
    --dock-btn-min: max(48px, calc(50px * var(--ui-scale)));
}

/* Fullscreen / large viewport HUD scale + ads UI */
.top-bar {
    padding: calc(8px * var(--ui-scale)) calc(16px * var(--ui-scale));
}
.menu-text-btn {
    font-size: max(12px, calc(11px * var(--ui-scale)));
    height: calc(36px * var(--ui-scale));
    padding: 0 calc(10px * var(--ui-scale));
}
.menu-icon-btn {
    width: calc(36px * var(--ui-scale));
    height: calc(36px * var(--ui-scale));
}
.rewarded-coin-btn {
    color: var(--accent-yellow);
    border-color: #f59e0b;
    background: #3a2a10;
    box-shadow:
        inset -2px -2px 0 #1a1208,
        inset 2px 2px 0 #7a5a20;
}
.rewarded-coin-btn:disabled {
    opacity: 0.45;
}
.prestige-menu-btn {
    color: #e9d5ff;
    border-color: #c084fc;
    background: #2a1840;
    box-shadow:
        inset -2px -2px 0 #1a0f28,
        inset 2px 2px 0 #6b21a8;
}
.prestige-menu-btn.ready {
    color: #f3e8ff;
    border-color: #d8b4fe;
    box-shadow:
        inset -2px -2px 0 #4c1d95,
        inset 2px 2px 0 #e9d5ff,
        0 0 0 1px rgba(192, 132, 252, 0.35);
}
.level-up-particle {
    position: fixed;
    width: 8px;
    height: 8px;
    margin: -4px 0 0 -4px;
    background: var(--accent-yellow);
    border: 1px solid #000;
    pointer-events: none;
    z-index: 9000;
    animation: level-up-burst 0.85s ease-out forwards;
}
@keyframes level-up-burst {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--lx), var(--ly)) scale(0.2); opacity: 0; }
}
.rewarded-ad-offer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    margin-top: 4px;
    background: linear-gradient(180deg, #2f2818 0%, #1e1a12 100%);
    border: 3px solid #f59e0b;
    box-shadow:
        inset -2px -2px 0 #12100a,
        inset 2px 2px 0 #5a4820,
        0 0 0 1px rgba(245, 158, 11, 0.25);
    flex-shrink: 0;
}
.rewarded-ad-offer.hidden { display: none !important; }
.rewarded-ad-tag {
    align-self: flex-start;
    font-family: var(--font-pixel);
    font-size: 7px;
    color: #0f0f13;
    background: var(--accent-yellow);
    border: 2px solid #000;
    padding: 3px 6px;
    letter-spacing: 0.5px;
}
.rewarded-ad-title {
    font-family: var(--font-pixel);
    font-size: max(12px, calc(11px * var(--ui-scale)));
    color: var(--accent-yellow);
}
.rewarded-ad-desc {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.35;
}
.rewarded-ad-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    font-size: max(12px, calc(12px * var(--ui-scale)));
    background: #b45309;
    border-color: #000;
    box-shadow: inset -2px -2px 0 #78350f, inset 2px 2px 0 #fcd34d;
}
.rewarded-ad-btn:disabled {
    opacity: 0.55;
    pointer-events: none;
}
.rewarded-ad-icon,
.rewarded-ad-icon-img {
    display: inline-flex;
    width: 18px;
    height: 18px;
    align-items: center;
    justify-content: center;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    pointer-events: none;
    flex-shrink: 0;
}
.rewarded-ad-note {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
}
.rewarded-ad-note.hidden { display: none !important; }

.ad-confirm-content {
    max-width: var(--ad-confirm-width);
    width: var(--ad-confirm-width);
}
.ad-confirm-badge {
    display: inline-block;
    font-family: var(--font-pixel);
    font-size: max(12px, calc(9px * var(--ui-scale)));
    color: #0f0f13;
    background: var(--accent-yellow);
    border: calc(2px * var(--ui-scale)) solid #000;
    padding: calc(4px * var(--ui-scale)) calc(8px * var(--ui-scale));
    margin-bottom: calc(10px * var(--ui-scale));
    letter-spacing: 1px;
}
.ad-confirm-reward {
    font-family: var(--font-pixel);
    font-size: max(13px, calc(12px * var(--ui-scale)));
    color: var(--accent-yellow);
    margin: calc(8px * var(--ui-scale)) 0;
}
.ad-confirm-reward.hidden { display: none !important; }
.ad-confirm-watch-btn {
    background: #b45309 !important;
    box-shadow: inset -2px -2px 0 #78350f, inset 2px 2px 0 #fcd34d !important;
}

.ad-break-overlay {
    position: fixed;
    inset: 0;
    z-index: 9500;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(8, 10, 14, 0.72);
    pointer-events: none;
}
.ad-break-overlay.hidden { display: none !important; }
.ad-break-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: calc(10px * var(--ui-scale));
    padding: var(--ad-break-pad-y) var(--ad-break-pad-x);
    background: var(--panel-bg);
    border: calc(4px * var(--ui-scale)) solid var(--accent-yellow);
    box-shadow:
        inset calc(-3px * var(--ui-scale)) calc(-3px * var(--ui-scale)) 0 #101218,
        inset calc(3px * var(--ui-scale)) calc(3px * var(--ui-scale)) 0 var(--panel-highlight),
        0 calc(8px * var(--ui-scale)) 0 rgba(0, 0, 0, 0.45);
    text-align: center;
    max-width: min(94vw, calc(360px * var(--ui-scale)));
}
.ad-break-tag {
    font-family: var(--font-pixel);
    font-size: calc(8px * var(--ui-scale));
    color: #0f0f13;
    background: var(--accent-yellow);
    border: calc(2px * var(--ui-scale)) solid #000;
    padding: calc(4px * var(--ui-scale)) calc(8px * var(--ui-scale));
    letter-spacing: 1px;
}
.ad-break-label {
    font-family: var(--font-pixel);
    font-size: calc(clamp(14px, 3vw, 18px) * var(--ui-scale));
    color: #fff;
}
.ad-break-sub {
    font-size: calc(16px * var(--ui-scale));
    color: var(--text-muted);
}

body.ad-playing {
    pointer-events: none;
}
body.ad-playing .crt-overlay,
body.ad-playing .scanlines {
    opacity: 0.2;
}
/* Keep audio buttons non-interactive during ads (already disabled in JS) */
body.ad-playing .menu-buttons {
    pointer-events: none;
}

/* Ticket ad-offer highlight */
.ticket-item.ad-offer {
    box-shadow:
        inset -2px -2px 0px #1a1c22,
        inset 2px 2px 0px #3a4050,
        0 0 0 2px rgba(244, 180, 27, 0.65);
}
.ticket-item.ad-offer .ticket-cost {
    color: var(--accent-yellow);
}

/* 2x HUD chip — hidden; boost shown on focused card + paytable only */
.earn-boost-hud {
    display: none !important;
}
.earn-boost-hud.hidden { display: none !important; }

/* Flying 2x lure — green square, always moving */
.ad-lure {
    position: fixed;
    z-index: 4200;
    width: calc(48px * var(--ui-scale));
    height: calc(48px * var(--ui-scale));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: calc(3px * var(--ui-scale)) solid #052e16;
    border-radius: calc(4px * var(--ui-scale));
    background: linear-gradient(180deg, #4ade80 0%, #22c55e 55%, #16a34a 100%);
    box-shadow:
        inset calc(-2px * var(--ui-scale)) calc(-2px * var(--ui-scale)) 0 #14532d,
        inset calc(2px * var(--ui-scale)) calc(2px * var(--ui-scale)) 0 #bbf7d0,
        0 calc(4px * var(--ui-scale)) 0 rgba(0, 0, 0, 0.35),
        0 0 calc(10px * var(--ui-scale)) rgba(74, 222, 128, 0.4);
    cursor: var(--ui-cursor);
    animation: ad-lure-pulse 0.9s ease-in-out infinite;
}
.ad-lure.hidden { display: none !important; }
.ad-lure-text {
    display: block;
    font-family: var(--font-digits), sans-serif;
    font-size: calc(18px * var(--ui-scale));
    font-weight: bold;
    line-height: 1;
    color: #fff;
    text-shadow:
        0 calc(1px * var(--ui-scale)) 0 #052e16,
        0 0 calc(4px * var(--ui-scale)) rgba(0, 0, 0, 0.5);
    pointer-events: none;
    letter-spacing: 0.02em;
}
.ad-lure-clover,
.ad-lure-clover-canvas,
.ad-lure-icon,
.ad-lure-clover-svg { display: none !important; }
@keyframes ad-lure-pulse {
    0%, 100% { transform: scale(1) rotate(-3deg); }
    50% { transform: scale(1.1) rotate(3deg); }
}
@keyframes chance-boost-hud-pulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.15); }
}

/* Active 2x — badge on focused card while scratching */
body.chance-boost-active .scratch-card-wrapper.focused::after {
    content: '2x';
    position: absolute;
    top: calc(8px * var(--ui-scale));
    right: calc(8px * var(--ui-scale));
    z-index: 12;
    font-family: var(--font-pixel);
    font-size: calc(13px * var(--ui-scale));
    font-weight: 700;
    color: #052e16;
    background: linear-gradient(180deg, #86efac 0%, #22c55e 100%);
    border: 2px solid #052e16;
    padding: calc(3px * var(--ui-scale)) calc(7px * var(--ui-scale));
    line-height: 1;
    pointer-events: none;
    box-shadow: inset -1px -1px 0 #166534, inset 1px 1px 0 #bbf7d0;
    animation: chance-boost-hud-pulse 1.2s ease-in-out infinite;
}
body.chance-boost-flash::after {
    content: '2x CHANCE!';
    position: fixed;
    left: 50%;
    top: 28%;
    transform: translate(-50%, -50%);
    z-index: 5000;
    font-family: var(--font-pixel);
    font-size: calc(22px * var(--ui-scale));
    color: #052e16;
    background: linear-gradient(180deg, #86efac 0%, #22c55e 100%);
    border: 3px solid #000;
    padding: 10px 18px;
    pointer-events: none;
    animation: chance-boost-banner 0.9s ease-out forwards;
}
@keyframes chance-boost-banner {
    0% { opacity: 0; transform: translate(-50%, -40%) scale(0.7); }
    25% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
    100% { opacity: 0; transform: translate(-50%, -70%) scale(1); }
}

.paytable-chance-boost-note {
    font-family: var(--font-pixel);
    font-size: calc(9px * var(--ui-scale));
    color: #052e16;
    background: #86efac;
    border: 2px solid #166534;
    padding: 4px 6px;
    margin-top: 6px;
    text-align: center;
}

/* Rewarded coin button ready pulse */
@keyframes ad-coin-ready-pulse {
    0%, 100% {
        filter: brightness(1);
        box-shadow:
            inset -2px -2px 0 #1a1208,
            inset 2px 2px 0 #7a5a20,
            0 0 0 0 rgba(244, 180, 27, 0);
    }
    50% {
        filter: brightness(1.18);
        box-shadow:
            inset -2px -2px 0 #1a1208,
            inset 2px 2px 0 #fcd34d,
            0 0 12px 2px rgba(244, 180, 27, 0.55);
    }
}
.rewarded-coin-btn.ad-coin-ready-pulse {
    animation: ad-coin-ready-pulse 1.35s ease-in-out infinite;
}

/* Daily spin menu button */
.daily-spin-btn {
    color: #e9d5ff;
    border-color: #c084fc;
    background: linear-gradient(180deg, #3b1f6e 0%, #2a1840 100%);
    box-shadow:
        inset -2px -2px 0 #1a0f28,
        inset 2px 2px 0 #7c3aed;
}
.daily-spin-btn.hidden { display: none !important; }
.daily-spin-btn.daily-spin-ready {
    color: #fef3c7;
    border-color: #fbbf24;
    animation: daily-spin-ready-pulse 1.2s ease-in-out infinite;
}
@keyframes daily-spin-ready-pulse {
    0%, 100% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.04); filter: brightness(1.15); }
}

/* Broke emergency button — near coin HUD */
.broke-emergency-btn {
    font-family: var(--font-pixel);
    font-size: calc(8px * var(--ui-scale));
    height: calc(32px * var(--ui-scale));
    padding: 0 calc(8px * var(--ui-scale));
    flex-shrink: 0;
    color: #fecaca;
    border-color: #ef4444;
    background: linear-gradient(180deg, #7f1d1d 0%, #450a0a 100%);
    box-shadow:
        inset -2px -2px 0 #1a0505,
        inset 2px 2px 0 #f87171,
        0 0 0 1px rgba(239, 68, 68, 0.35);
    animation: broke-emergency-pulse 1.1s ease-in-out infinite;
}
.broke-emergency-btn.hidden { display: none !important; }
@keyframes broke-emergency-pulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.2); }
}

/* Daily spin modal */
.daily-spin-content {
    max-width: var(--daily-spin-width);
    width: var(--daily-spin-width);
    max-height: min(92dvh, calc(640px * var(--ui-scale)));
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.daily-spin-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: calc(10px * var(--ui-scale));
    text-align: center;
    overflow: visible;
}
.daily-spin-wheel-wrap {
    position: relative;
    width: var(--daily-spin-wheel-size);
    height: var(--daily-spin-wheel-size);
    margin: calc(8px * var(--ui-scale)) auto calc(4px * var(--ui-scale));
}
.daily-spin-pointer {
    position: absolute;
    top: calc(-12px * var(--ui-scale));
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    pointer-events: none;
    filter: drop-shadow(0 calc(2px * var(--ui-scale)) calc(3px * var(--ui-scale)) rgba(0, 0, 0, 0.5));
}
.daily-spin-wheel {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: calc(4px * var(--ui-scale)) solid #000;
    box-shadow:
        inset 0 0 0 calc(3px * var(--ui-scale)) var(--accent-yellow),
        0 calc(6px * var(--ui-scale)) 0 rgba(0, 0, 0, 0.45);
    overflow: hidden;
    transform: rotate(0deg);
    will-change: transform;
}
#daily-spin-canvas {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 50%;
}
.daily-spin-status {
    font-family: var(--font-digits);
    font-size: calc(18px * var(--ui-scale));
    color: var(--text-muted);
    margin: 0;
    line-height: 1.35;
}
.daily-spin-jackpot {
    font-family: var(--font-pixel);
    font-size: max(12px, calc(11px * var(--ui-scale)));
    color: var(--accent-yellow);
    margin: 0;
    line-height: 1.35;
}
.daily-spin-prizes-wrap {
    width: 100%;
    max-width: calc(320px * var(--ui-scale));
    text-align: left;
}
.daily-spin-prizes-title {
    font-family: var(--font-pixel);
    font-size: calc(9px * var(--ui-scale));
    color: var(--text-muted);
    margin: 0 0 calc(6px * var(--ui-scale));
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.daily-spin-prizes {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: calc(4px * var(--ui-scale));
}
.daily-spin-prize-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: calc(8px * var(--ui-scale));
    padding: calc(5px * var(--ui-scale)) calc(8px * var(--ui-scale));
    border: calc(2px * var(--ui-scale)) solid #000;
    background: rgba(0, 0, 0, 0.22);
    box-shadow: inset calc(-1px * var(--ui-scale)) calc(-1px * var(--ui-scale)) 0 rgba(0, 0, 0, 0.35);
}
.daily-spin-prize-item.is-jackpot {
    border-color: var(--accent-yellow);
    background: linear-gradient(90deg, rgba(244, 180, 27, 0.18), rgba(0, 0, 0, 0.2));
}
.daily-spin-prize-main {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.daily-spin-prize-badge {
    flex-shrink: 0;
    font-family: var(--font-pixel);
    font-size: calc(7px * var(--ui-scale));
    padding: calc(2px * var(--ui-scale)) calc(4px * var(--ui-scale));
    background: var(--accent-yellow);
    color: #000;
    border: 1px solid #000;
}
.daily-spin-prize-label {
    font-family: var(--font-digits);
    font-size: calc(16px * var(--ui-scale));
    color: var(--text-primary);
    line-height: 1.2;
}
.daily-spin-prize-pct {
    flex-shrink: 0;
    font-family: var(--font-digits);
    font-size: calc(14px * var(--ui-scale));
    color: var(--text-muted);
}
.daily-spin-result {
    font-family: var(--font-pixel);
    font-size: max(12px, calc(11px * var(--ui-scale)));
    color: var(--accent-yellow);
    margin: 0;
    min-height: 1.4em;
}
.daily-spin-footer {
    flex-wrap: wrap;
    justify-content: center;
    gap: calc(8px * var(--ui-scale));
}
.daily-spin-footer .hidden { display: none !important; }
.daily-spin-footer #daily-spin-free-btn,
.daily-spin-footer #daily-spin-ad-btn {
    flex: 1 1 auto;
    min-width: calc(120px * var(--ui-scale));
}

/* --- MOBILE PORTRAIT RESPONSIVENESS FIXES --- */
@media (max-width: 768px) and (orientation: portrait) {
    body.mobile-layout .top-bar {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 8px 10px;
        align-items: stretch;
    }
    body.mobile-layout .stats-container {
        display: flex;
        flex-wrap: nowrap !important;
        justify-content: space-between;
        width: 100%;
        gap: 6px;
    }
    body.mobile-layout .coin-stat,
    body.mobile-layout .diamond-stat,
    body.mobile-layout .crown-stat {
        flex: 1 1 0%;
        min-width: 0;
        justify-content: center;
        height: calc(34px * var(--ui-scale));
        box-sizing: border-box;
        font-size: calc(clamp(14px, 3.8vw, 17px) * var(--ui-scale));
        padding: 0 calc(6px * var(--ui-scale));
    }
    body.mobile-layout .level-stat {
        flex: 0 0 auto;
        display: flex;
        justify-content: center;
        align-items: center;
        margin-left: 0;
        padding: 0;
        background: transparent;
        border: none;
        box-shadow: none;
    }
    body.mobile-layout .level-xp-badge {
        width: calc(34px * var(--ui-scale));
        height: calc(34px * var(--ui-scale));
        box-sizing: border-box;
    }
    body.mobile-layout .menu-buttons {
        display: flex;
        justify-content: space-between;
        width: 100%;
        gap: 4px;
    }
    body.mobile-layout .menu-buttons > button {
        flex: 1 1 0%;
        min-width: 0;
        box-sizing: border-box;
        text-align: center;
    }
    body.mobile-layout .audio-toggle-group {
        flex: 0 0 auto;
        display: inline-flex;
        gap: 4px;
    }
    body.mobile-layout .menu-icon-btn {
        width: calc(38px * var(--ui-scale));
        height: calc(38px * var(--ui-scale));
    }
    body.mobile-layout .pixel-btn.menu-text-btn {
        min-height: calc(38px * var(--ui-scale));
        height: calc(38px * var(--ui-scale));
        font-size: clamp(11px, 2.8vw, 13px);
        padding: 0 calc(6px * var(--ui-scale));
    }
    body.mobile-layout .lang-toggle-btn {
        min-width: 0;
    }

/* ===== Daily streak & offline modals ===== */
.streak-body { text-align: center; }
.offline-sub { opacity: 0.85; margin-bottom: 8px; }
.streak-headline { font-size: 1.05em; margin-bottom: 6px; letter-spacing: 1px; }
.streak-flame { color: #f97316; font-weight: bold; }
#streak-count-value { font-size: 1.7em; color: #f4b41b; margin-left: 6px; }
}
/* Daily-streak progress: a clear "Day N of 7" caption over a row of day pips (was ambiguous "123456★"). */
.streak-dots { display: flex; flex-direction: column; align-items: center; gap: calc(6px * var(--ui-scale)); margin: calc(10px * var(--ui-scale)) 0; }
.streak-dots-caption { font-family: var(--font-retro), monospace; font-size: max(12px, calc(13px * var(--ui-scale))); color: var(--accent-yellow); letter-spacing: 0.04em; }
.streak-dots-row { display: flex; justify-content: center; gap: calc(6px * var(--ui-scale)); flex-wrap: wrap; }
.streak-dots-row .streak-dot { position: relative; width: calc(17px * var(--ui-scale)); height: calc(17px * var(--ui-scale)); min-width: 15px; min-height: 15px; border-radius: 50%; background: rgba(255, 255, 255, 0.14); border: 2px solid rgba(255, 255, 255, 0.28); box-sizing: border-box; }
.streak-dots-row .streak-dot.done { background: #10b981; border-color: #0a7a55; }
.streak-dots-row .streak-dot.active { background: #f4b41b; border-color: #fff; box-shadow: 0 0 8px rgba(244, 180, 27, 0.85); transform: scale(1.18); }
.streak-dots-row .streak-dot.reward { border-radius: 4px; }
.streak-dots-row .streak-dot.reward::after { content: "\2605"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: calc(10px * var(--ui-scale)); color: var(--accent-yellow); }
.streak-dots-row .streak-dot.reward.done::after,
.streak-dots-row .streak-dot.reward.active::after { color: #1a1205; }

/* CrazyGames: a rewarded-ad icon (rectangle + play symbol) on every "watch ad" button. */
.ad-confirm-watch-btn::before,
#broke-emergency-btn::before,
.claim-double-btn::before,
.task-x2-btn::before,
.achievement-x2-btn::before,
.rewarded-ad-btn::before {
    content: "";
    display: inline-block;
    vertical-align: middle;
    width: calc(15px * var(--ui-scale));
    height: calc(15px * var(--ui-scale));
    margin-right: calc(5px * var(--ui-scale));
    background-image: url('../assets/ui/icon-ad.png?v=2');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    image-rendering: pixelated;
}
.ad-lure-icon { image-rendering: pixelated; width: calc(13px * var(--ui-scale)); height: calc(13px * var(--ui-scale)); display: inline-block; vertical-align: middle; margin-right: 2px; }

/* Optional x2 rewarded-ad buttons next to Claim on Tasks & Achievements. */
.task-actions,
.achievement-actions { display: flex; flex-direction: column; gap: calc(4px * var(--ui-scale)); align-items: stretch; flex-shrink: 0; align-self: center; }
.task-x2-btn,
.achievement-x2-btn { font-size: var(--panel-claim-size); padding: calc(6px * var(--ui-scale)) calc(6px * var(--ui-scale)); min-width: calc(72px * var(--ui-scale)); white-space: nowrap; }

/* "Level Up!" popup that gates the midgame ad (natural transition, never instant). */
.levelup-content { text-align: center; }
.levelup-body { text-align: center; }
.levelup-star { font-size: calc(40px * var(--ui-scale)); line-height: 1; color: var(--accent-yellow); text-shadow: 0 0 12px rgba(244, 180, 27, 0.75); margin-bottom: calc(4px * var(--ui-scale)); animation: levelup-star-pop 0.5s ease-out; }
.levelup-reached { font-family: var(--font-retro), monospace; font-size: var(--modal-body-size); color: var(--text-white); margin: calc(4px * var(--ui-scale)) 0; }
.levelup-level { color: var(--accent-yellow); font-weight: 700; }
.levelup-reward { font-family: var(--font-retro), monospace; font-size: max(13px, calc(15px * var(--ui-scale))); color: var(--accent-green); margin: calc(6px * var(--ui-scale)) 0; }
.levelup-reward.hidden { display: none; }
.levelup-next { margin-top: calc(6px * var(--ui-scale)); }
@keyframes levelup-star-pop { 0% { transform: scale(0.3); opacity: 0; } 70% { transform: scale(1.2); } 100% { transform: scale(1); opacity: 1; } }

/* Free-ticket "already on desk" attention pulse (glow only — does not touch card transform). */
.scratch-card-wrapper.card-attention { animation: card-attention-glow 0.75s ease-out; }
@keyframes card-attention-glow {
    0% { filter: drop-shadow(0 0 0 rgba(244, 180, 27, 0)); }
    30% { filter: drop-shadow(0 0 10px rgba(244, 180, 27, 0.95)); }
    100% { filter: drop-shadow(0 0 0 rgba(244, 180, 27, 0)); }
}
.streak-reward-label { margin-top: 8px; opacity: 0.85; }
.streak-reward-line { font-size: 1.35em; margin-top: 2px; }
