@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700;800&display=swap');

/* Generic .hidden utility — must be outside @layer so it wins over any
   layered Tailwind rule and any component-level display overrides. */
.hidden { display: none !important; }

/* ===== Theme Custom Properties ===== */
:root {
    /* ── Dark theme (default) ── */
    --bg-body: #1e293b;
    --bg-viewport: radial-gradient(circle at center, #1e293b 0%, #020617 100%);
    --bg-loading: radial-gradient(circle at 50% 45%, #1e293b 0%, #020617 100%);
    --color-text: #ffffff;
    --color-text-muted: #64748b;
    --color-text-subtle: #475569;

    /* Buttons / HUD */
    --btn-bg: rgba(30, 41, 59, 0.8);
    --btn-border: #334155;
    --btn-color: #94a3b8;

    /* Modal / card surfaces */
    --modal-overlay-bg: rgba(7, 12, 26, 0.78);
    --modal-bg: linear-gradient(155deg, #0d1a2e 0%, #111827 60%, #0f1f38 100%);
    --modal-border: rgba(56, 189, 248, 0.22);
    --modal-shadow: 0 0 0 1px rgba(56, 189, 248, 0.06), 0 0 40px rgba(56, 189, 248, 0.08), 0 24px 48px rgba(0, 0, 0, 0.7);
    --modal-header-border: rgba(51, 65, 85, 0.6);

    /* Menu items */
    --menu-item-border: rgba(51, 65, 85, 0.35);
    --menu-item-color: #94a3b8;
    --menu-item-icon-bg: rgba(30, 41, 59, 0.9);

    /* Home screen */
    --home-stat-bg: rgba(15, 23, 42, 0.7);
    --home-stat-border: rgba(51, 65, 85, 0.5);
    --home-stat-label: #64748b;
    --home-stat-value: #e2e8f0;

    /* Score / HUD */
    --score-color: #38bdf8;
    --score-shadow: rgba(56, 189, 248, 0.4);

    /* Game over card */
    --gameover-bg: linear-gradient(155deg, #1f0a0a 0%, #2b0b0b 60%, #1a0505 100%);
    --gameover-border: rgba(239, 68, 68, 0.35);

    /* Settings page */
    --settings-bg: rgba(15, 23, 42, 0.6);
    --settings-border: rgba(51, 65, 85, 0.4);
    --settings-card-bg: rgba(15, 23, 42, 0.7);
    --settings-card-border: rgba(51, 65, 85, 0.4);
    --settings-card-selected-border: #38bdf8;
    --settings-card-selected-bg: rgba(56, 189, 248, 0.08);
    --settings-label: #94a3b8;

    /* Tray / hold / next */
    --tray-bg: rgba(15, 23, 42, 0.55);
    --tray-border: rgba(51, 65, 85, 0.4);
    --slot-bg: rgba(15, 23, 42, 0.6);
    --slot-border: rgba(51, 65, 85, 0.5);
    --slot-label: rgba(100, 116, 139, 0.7);

    /* Quest */
    --quest-card-bg: rgba(15, 23, 42, 0.8);
    --quest-card-border: rgba(51, 65, 85, 0.5);
    --quest-progress-track: rgba(30, 41, 59, 0.8);

    /* Canvas empty-hex colors (read by JS) */
    --canvas-empty-fill: rgba(30, 41, 59, 0.45);
    --canvas-empty-stroke: rgba(56, 130, 170, 0.35);
    --canvas-bg: #0f172a;
    --canvas-tray-bg: rgba(15, 23, 42, 0.55);
    --canvas-slot-bg: rgba(15, 23, 42, 0.6);
    --canvas-slot-border: rgba(51, 65, 85, 0.5);

    /* Ad banner */
    --ad-banner-bg: #070c1a;
    --ad-banner-border: #1e293b;
    --ad-label-color: #334155;

    /* Loading bar track */
    --loading-track-bg: #1e293b;

    /* Scrollbars */
    --scrollbar-thumb: #334155;
    --scrollbar-thumb-hover: #475569;
}

/* ===== Light Theme Overrides ===== */
body.light-theme {
    --bg-body: #dce6f5;
    --bg-viewport: radial-gradient(circle at center, #dce6f5 0%, #c8d8ee 100%);
    --bg-loading: radial-gradient(circle at 50% 45%, #dce6f5 0%, #c8d8ee 100%);
    --color-text: #0f172a;
    --color-text-muted: #475569;
    --color-text-subtle: #64748b;

    --btn-bg: rgba(255, 255, 255, 0.85);
    --btn-border: #cbd5e1;
    --btn-color: #334155;

    --modal-overlay-bg: rgba(148, 163, 184, 0.55);
    --modal-bg: linear-gradient(155deg, #f0f6ff 0%, #ffffff 60%, #eef4ff 100%);
    --modal-border: rgba(56, 189, 248, 0.35);
    --modal-shadow: 0 0 0 1px rgba(56, 189, 248, 0.1), 0 0 40px rgba(56, 189, 248, 0.08), 0 24px 48px rgba(0, 0, 0, 0.18);
    --modal-header-border: rgba(203, 213, 225, 0.8);

    --menu-item-border: rgba(203, 213, 225, 0.6);
    --menu-item-color: #475569;
    --menu-item-icon-bg: rgba(226, 232, 240, 0.9);

    --home-stat-bg: rgba(255, 255, 255, 0.75);
    --home-stat-border: rgba(203, 213, 225, 0.7);
    --home-stat-label: #64748b;
    --home-stat-value: #0f172a;

    --score-color: #0284c7;
    --score-shadow: rgba(2, 132, 199, 0.3);

    --gameover-bg: linear-gradient(155deg, #fff0f0 0%, #ffe4e4 60%, #ffd6d6 100%);
    --gameover-border: rgba(239, 68, 68, 0.4);

    --settings-bg: rgba(255, 255, 255, 0.7);
    --settings-border: rgba(203, 213, 225, 0.6);
    --settings-card-bg: rgba(255, 255, 255, 0.85);
    --settings-card-border: rgba(203, 213, 225, 0.6);
    --settings-card-selected-border: #0284c7;
    --settings-card-selected-bg: rgba(2, 132, 199, 0.08);
    --settings-label: #475569;

    --tray-bg: rgba(255, 255, 255, 0.6);
    --tray-border: rgba(203, 213, 225, 0.5);
    --slot-bg: rgba(255, 255, 255, 0.7);
    --slot-border: rgba(203, 213, 225, 0.6);
    --slot-label: rgba(100, 116, 139, 0.8);

    --quest-card-bg: rgba(255, 255, 255, 0.85);
    --quest-card-border: rgba(203, 213, 225, 0.6);
    --quest-progress-track: rgba(203, 213, 225, 0.6);

    --canvas-empty-fill: rgba(203, 213, 225, 0.45);
    --canvas-empty-stroke: #94a3b8;
    --canvas-bg: #d4e0f0;
    --canvas-tray-bg: rgba(255, 255, 255, 0.55);
    --canvas-slot-bg: rgba(255, 255, 255, 0.65);
    --canvas-slot-border: rgba(148, 163, 184, 0.5);

    --ad-banner-bg: #e2e8f0;
    --ad-banner-border: #cbd5e1;
    --ad-label-color: #94a3b8;

    --loading-track-bg: #cbd5e1;

    /* Scrollbars */
    --scrollbar-thumb: #94a3b8;
    --scrollbar-thumb-hover: #64748b;
}

/* ===== Base Reset ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===== Themed Scrollbars ===== */
.tab-content.active,
.settings-page,
.ap-col,
.ach-modal-content,
.weekly-level-cards,
.shop-modal-content {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}

.tab-content.active::-webkit-scrollbar,
.settings-page::-webkit-scrollbar,
.ap-col::-webkit-scrollbar,
.ach-modal-content::-webkit-scrollbar,
.weekly-level-cards::-webkit-scrollbar,
.shop-modal-content::-webkit-scrollbar {
    width: 6px;
}

.tab-content.active::-webkit-scrollbar-track,
.settings-page::-webkit-scrollbar-track,
.ap-col::-webkit-scrollbar-track,
.ach-modal-content::-webkit-scrollbar-track,
.weekly-level-cards::-webkit-scrollbar-track,
.shop-modal-content::-webkit-scrollbar-track {
    background: transparent;
}

.tab-content.active::-webkit-scrollbar-thumb,
.settings-page::-webkit-scrollbar-thumb,
.ap-col::-webkit-scrollbar-thumb,
.ach-modal-content::-webkit-scrollbar-thumb,
.weekly-level-cards::-webkit-scrollbar-thumb,
.shop-modal-content::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 6px;
}

.tab-content.active::-webkit-scrollbar-thumb:hover,
.settings-page::-webkit-scrollbar-thumb:hover,
.ap-col::-webkit-scrollbar-thumb:hover,
.ach-modal-content::-webkit-scrollbar-thumb:hover,
.weekly-level-cards::-webkit-scrollbar-thumb:hover,
.shop-modal-content::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

html {
    overflow: hidden;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-body);
    color: var(--color-text);
    margin: 0;
    overflow: hidden;
    touch-action: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100vw;
    height: 100vh;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    transition: background 0.3s ease;
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='32' viewBox='0 0 28 32'%3E%3Cpath d='M14 1 L25 8.5 L25 23.5 L14 31 L3 23.5 L3 8.5 Z' fill='%2338bdf8' fill-opacity='0.15' stroke='%2338bdf8' stroke-width='1.5' stroke-linejoin='round'/%3E%3Cpath d='M7 24 L14 8 L21 24' fill='white' fill-opacity='0.85' stroke='%2338bdf8' stroke-width='1' stroke-linejoin='round'/%3E%3C/svg%3E") 14 8, default;
}

/* ===== Custom cursors (desktop only) ===== */
@media (pointer: fine) {
    body.cursor-grab {
        cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='32' viewBox='0 0 28 32'%3E%3Cpath d='M14 1 L25 8.5 L25 23.5 L14 31 L3 23.5 L3 8.5 Z' fill='%23fbbf24' fill-opacity='0.25' stroke='%23fbbf24' stroke-width='1.5' stroke-linejoin='round'/%3E%3Cpath d='M9 18 L14 12 L19 18' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") 14 16, grab !important;
    }
    body.cursor-grabbing {
        cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='32' viewBox='0 0 28 32'%3E%3Cpath d='M14 1 L25 8.5 L25 23.5 L14 31 L3 23.5 L3 8.5 Z' fill='%23fbbf24' fill-opacity='0.4' stroke='%23fbbf24' stroke-width='2' stroke-linejoin='round'/%3E%3Ccircle cx='14' cy='16' r='4' fill='white' fill-opacity='0.9'/%3E%3C/svg%3E") 14 16, grabbing !important;
    }
    body.cursor-bomb {
        cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='32' viewBox='0 0 28 32'%3E%3Cpath d='M14 1 L25 8.5 L25 23.5 L14 31 L3 23.5 L3 8.5 Z' fill='%23f97316' fill-opacity='0.3' stroke='%23f97316' stroke-width='2' stroke-linejoin='round'/%3E%3Ctext x='14' y='20' text-anchor='middle' font-size='14'%3E%F0%9F%92%A3%3C/text%3E%3C/svg%3E") 14 16, crosshair !important;
    }
    body.cursor-drill {
        cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='32' viewBox='0 0 28 32'%3E%3Cpath d='M14 1 L25 8.5 L25 23.5 L14 31 L3 23.5 L3 8.5 Z' fill='%2360a5fa' fill-opacity='0.3' stroke='%2360a5fa' stroke-width='2' stroke-linejoin='round'/%3E%3Cpath d='M14 10 L14 22 M11 19 L14 22 L17 19' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") 14 16, crosshair !important;
    }
    body.cursor-scissors {
        cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='32' viewBox='0 0 28 32'%3E%3Cpath d='M14 1 L25 8.5 L25 23.5 L14 31 L3 23.5 L3 8.5 Z' fill='%23a78bfa' fill-opacity='0.3' stroke='%23a78bfa' stroke-width='2' stroke-linejoin='round'/%3E%3Cpath d='M9 11 L19 21 M19 11 L9 21' stroke='white' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") 14 16, crosshair !important;
    }
    body.cursor-hammer {
        cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='32' viewBox='0 0 28 32'%3E%3Cpath d='M14 1 L25 8.5 L25 23.5 L14 31 L3 23.5 L3 8.5 Z' fill='%2334d399' fill-opacity='0.3' stroke='%2334d399' stroke-width='2' stroke-linejoin='round'/%3E%3Cpath d='M14 22 L14 13 M10 13 L18 13 L18 10 L10 10 L10 13' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") 14 16, crosshair !important;
    }
}

/* ===== Full-screen body background canvas ===== */
#bodyBgCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
}

/* ===== 16:9 Game Viewport Container ===== */
#game-viewport {
    position: relative;
    z-index: 1;
    background: var(--bg-viewport);
    overflow: hidden;
    container-type: size;
    container-name: game-viewport;
    transition: background 0.3s ease;
}

/* ===== Loading Screen ===== */
#loadingScreen {
    position: absolute;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-loading);
    transition: opacity 0.4s ease;
}

#loadingScreen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loading-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.loading-hex-cluster {
    width: clamp(80px, 14cqw, 160px);
    margin-bottom: 2cqh;
    filter: drop-shadow(0 0 18px rgba(99, 102, 241, 0.5));
    animation: loading-float 2.4s ease-in-out infinite;
}

@keyframes loading-float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

.loading-title {
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    font-size: clamp(1.4rem, 5cqw, 3.2rem);
    letter-spacing: 0.04em;
    line-height: 1;
    margin-bottom: 0.8cqh;
}

.loading-hex-word {
    color: #e2e8f0;
}

.loading-burst-word {
    color: #38bdf8;
}

.loading-subtitle {
    font-family: 'Inter', sans-serif;
    font-size: clamp(0.5rem, 1.1cqw, 0.85rem);
    letter-spacing: 0.25em;
    color: var(--color-text-muted);
    text-transform: uppercase;
    margin-bottom: 3cqh;
}

.loading-bar-track {
    width: clamp(120px, 26cqw, 300px);
    height: 4px;
    background: var(--loading-track-bg);
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 1.2cqh;
}

.loading-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #6366f1, #38bdf8);
    border-radius: 99px;
    transition: width 0.3s ease;
}

.loading-status {
    font-family: 'Inter', sans-serif;
    font-size: clamp(0.45rem, 0.9cqw, 0.7rem);
    color: #475569;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

#app-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* ===== In-game top-left HUD row (currency + trophy) ===== */
.game-hud-currency {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 55;
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: all;
}

/* Shared pill style — matches home screen badge sizing */
.game-hud-coin,
.game-hud-energy,
.game-hud-trophy,
.game-hud-blitz {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px 8px 10px;
    background: rgba(15, 23, 42, 0.82);
    border-radius: 50px;
    backdrop-filter: blur(8px);
    font-size: 1.15rem;
    font-weight: 900;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.game-hud-coin {
    border: 1px solid rgba(251, 191, 36, 0.35);
    color: #fbbf24;
}

.game-hud-energy {
    border: 1px solid rgba(56, 189, 248, 0.35);
    color: #38bdf8;
}

.game-hud-trophy {
    border: 1px solid rgba(251, 191, 36, 0.35);
    color: #fbbf24;
    cursor: default;
    pointer-events: none;
}

.game-hud-blitz {
    border: 1px solid rgba(251, 191, 36, 0.35);
    color: #fbbf24;
    cursor: default;
    pointer-events: none;
}

.game-hud-coin:hover,
.game-hud-energy:hover {
    background: rgba(30, 41, 59, 0.92);
    border-color: rgba(56, 189, 248, 0.6);
    transform: translateY(-1px);
}

/* ===== HUD Layers (Top Left & Top Right) ===== */
.hud-top-left {
    position: absolute;
    top: 24px;
    left: 24px;
    z-index: 50;
    pointer-events: none;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    color: #fbbf24;
    /* Amber-400 */
    font-family: monospace;
    font-weight: 800;
    font-size: 1.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}


.hud-top-left svg {
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.5));
}

.hud-center {
    position: absolute;
    top: 6%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hud-top-right {
    position: absolute;
    top: 24px;
    right: 24px;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 14px;
}

/* Muted state — red accent */
.mute-quick-btn.muted {
    color: #ef4444;
    filter: drop-shadow(0 0 6px rgba(239, 68, 68, 0.4));
}

.mute-quick-btn.muted .menu-sprite {
    filter: brightness(0.8) saturate(0.3) drop-shadow(0 0 4px rgba(239, 68, 68, 0.5));
}

/* ===== Menu Button (Hex) ===== */

.menu-hex-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Hex border outline — now handled by inline SVG .hex-outline */
.menu-hex-wrap::before {
    display: none;
}

.menu-btn {
    position: relative;
    background: transparent;
    border: none;
    color: rgba(56, 189, 248, 0.5);
    width: 40px;
    height: 46px;
    padding: 0;
    border-radius: 0;
    cursor: pointer;
    transition: filter 0.18s, color 0.18s;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    z-index: 1;
    flex-shrink: 0;
    filter: drop-shadow(0 0 4px rgba(56, 189, 248, 0.25));
}

.menu-btn .hex-outline {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Per-button accent colours */
.menu-btn--sound {
    --menu-color: #38bdf8;
    --menu-glow: rgba(56, 189, 248, 0.55);
}

.menu-btn--hamburger {
    --menu-color: #94a3b8;
    --menu-glow: rgba(148, 163, 184, 0.55);
}

.menu-btn--back {
    --menu-color: #94a3b8;
    --menu-glow: rgba(148, 163, 184, 0.55);
}

.menu-btn:hover {
    color: var(--menu-color, #38bdf8);
    filter: drop-shadow(0 0 8px var(--menu-glow, rgba(56, 189, 248, 0.55)));
}

.menu-btn:active {
    transform: scale(0.92);
    transition: transform 0.08s, filter 0.08s;
}

/* Sprite icon inside menu buttons */
.menu-btn .menu-sprite {
    width: 70%;
    height: 70%;
    min-width: 16px;
    min-height: 16px;
    max-width: 56px;
    max-height: 56px;
    object-fit: contain;
    transition: filter 0.18s;
    flex-shrink: 0;
    pointer-events: none;
    position: relative;
    filter: brightness(1.3) drop-shadow(0 0 3px var(--menu-glow, rgba(56, 189, 248, 0.25)));
}

.menu-btn:hover .menu-sprite {
    filter: brightness(1.5) drop-shadow(0 0 6px var(--menu-glow, rgba(56, 189, 248, 0.55)));
}

/* Legacy SVG icons (for buttons still using SVGs like challenge-back-btn) */
.menu-btn svg:not(.hex-outline) {
    width: 55%;
    height: 55%;
    min-width: 16px;
    min-height: 16px;
    max-width: 28px;
    max-height: 28px;
    flex-shrink: 0;
}

/* ===== HUD Hamburger Dropdown ===== */

.hud-hamburger-wrap {
    position: relative;
}

.hud-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 100;
    min-width: 130px;
    background: rgba(15, 23, 42, 0.94);
    border: 1px solid rgba(51, 65, 85, 0.5);
    border-radius: 12px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    pointer-events: all;
}

.light-theme .hud-dropdown {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(203, 213, 225, 0.7);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.hud-dropdown.hidden {
    display: none;
}

.hud-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--color-text, #e2e8f0);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.hud-dropdown-btn:hover,
.hud-dropdown-btn:active {
    background: rgba(255, 255, 255, 0.08);
}

.hud-dropdown-divider {
    height: 1px;
    margin: 4px 8px;
    background: rgba(255, 255, 255, 0.12);
}

.hud-dropdown-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ===== Modal Overlay ===== */
.modal-overlay {
    position: absolute;
    inset: 0;
    background: var(--modal-overlay-bg);
    backdrop-filter: blur(10px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay.hidden {
    display: none;
    pointer-events: none;
}

/* ===== Hex-themed Menu Card ===== */
.modal-content {
    position: relative;
    overflow: hidden;
    background: var(--modal-bg);
    border: 1px solid var(--modal-border);
    border-radius: 24px;
    width: 90%;
    max-width: 290px;
    box-shadow: var(--modal-shadow);
    animation: menuAppear 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes menuAppear {
    from {
        transform: scale(0.88) translateY(12px);
        opacity: 0;
    }

    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* Decorative large faint hex outlines */
.modal-deco-hex {
    position: absolute;
    pointer-events: none;
    color: rgba(56, 189, 248, 0.07);
}

.modal-deco-hex--tl {
    width: 130px;
    top: -28px;
    left: -28px;
}

.modal-deco-hex--br {
    width: 110px;
    bottom: -24px;
    right: -24px;
    color: rgba(167, 139, 250, 0.07);
}

/* Header */
.modal-header {
    padding: 28px 24px 20px;
    text-align: center;
    border-bottom: 1px solid var(--modal-header-border);
}

/* Inline modal logo: mini cluster + text side by side */
.modal-logo-inline {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    margin-bottom: 4px;
}

.modal-logo-cluster {
    width: 56px;
    height: auto;
    margin-bottom: -4px;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
}

.modal-logo-text {
    display: flex;
    align-items: baseline;
    gap: 6px;
    line-height: 1;
}

.modal-logo-hex-word,
.modal-logo-burst-word {
    font-size: 1.45rem;
    font-weight: 900;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.modal-logo-hex-word {
    color: #b8d8f0;
    text-shadow:
        1px 1px 0 #4a7fa8,
        2px 2px 0 #2d5a7a,
        0 0 20px rgba(56, 189, 248, 0.4);
}

.modal-logo-burst-word {
    color: #5bc8f5;
    text-shadow:
        1px 1px 0 #1a7fa8,
        2px 2px 0 #0d4f6e,
        0 0 24px rgba(56, 189, 248, 0.5);
}

.modal-title {
    font-size: 1.3rem;
    font-weight: 900;
    letter-spacing: 0.18em;
    background: linear-gradient(120deg, #38bdf8 10%, #a78bfa 90%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.modal-highscore {
    font-size: 0.85rem;
    font-weight: 700;
    color: #f59e0b;
    letter-spacing: 0.04em;
}

/* Nav list */
.modal-nav {
    padding: 6px 0 8px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 13px;
    width: 100%;
    padding: 13px 20px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--menu-item-border);
    cursor: pointer;
    color: var(--menu-item-color);
    font-size: 0.92rem;
    font-weight: 600;
    text-align: left;
    transition: background 0.16s, color 0.16s, padding-left 0.16s;
    font-family: inherit;
}

.menu-item:last-child {
    border-bottom: none;
}

.menu-item:hover {
    background: rgba(56, 189, 248, 0.07);
    color: #e2e8f0;
    padding-left: 26px;
}

.menu-item-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--menu-item-icon-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.16s;
}

/* Per-item accent colours */
.menu-item--home .menu-item-icon {
    color: #38bdf8;
}

.menu-item--quest .menu-item-icon {
    color: #10b981;
}

.menu-item--lab .menu-item-icon {
    color: #a78bfa;
}

.menu-item--settings .menu-item-icon {
    color: #f59e0b;
}

.menu-item--builder .menu-item-icon {
    color: #34d399;
}

.menu-item--close .menu-item-icon {
    color: #64748b;
}

.menu-item:hover .menu-item-icon {
    background: rgba(56, 189, 248, 0.12);
}

.menu-item--quest:hover .menu-item-icon {
    background: rgba(16, 185, 129, 0.12);
}

.menu-item--lab:hover .menu-item-icon {
    background: rgba(167, 139, 250, 0.12);
}

.menu-item--settings:hover .menu-item-icon {
    background: rgba(245, 158, 11, 0.12);
}

.menu-item--builder:hover .menu-item-icon {
    background: rgba(52, 211, 153, 0.12);
}

.menu-item--close:hover .menu-item-icon {
    background: rgba(100, 116, 139, 0.15);
}

.menu-item-label {
    flex: 1;
}

.menu-item-arrow {
    font-size: 1.1rem;
    color: #334155;
    transition: transform 0.16s, color 0.16s;
    line-height: 1;
}

.menu-item:hover .menu-item-arrow {
    transform: translateX(4px);
    color: #38bdf8;
}

.menu-item--close .menu-item-arrow {
    display: none;
}


/* ===== Tab Content ===== */
.tab-content {
    flex: 1;
    position: relative;
    display: none;
    overflow: hidden;
    min-height: 0;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
}

/* ── Animated background canvas shared by menu tabs + settings ── */
.menu-bg-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* ===== Game UI ===== */
/* .ui-header removed as score is now absolute positioned */


.score-display {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
    color: var(--score-color);
    text-shadow: 0 0 15px var(--score-shadow);
}

.combo-display {
    display: none;
}

#gameCanvas {
    display: block;
    touch-action: none;
    position: relative;
    z-index: 10;
}

/* ===== Game Over Overlay ===== */
.game-over-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, rgba(0,0,0,0.3) 0%, rgba(0,0,0,0.6) 100%);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

/* Inner card — glassmorphism with red accent glow */
.game-over-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow: hidden;
    background: linear-gradient(165deg,
        rgba(15, 23, 42, 0.92) 0%,
        rgba(30, 20, 30, 0.95) 50%,
        rgba(15, 23, 42, 0.92) 100%);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(239, 68, 68, 0.15);
    border-radius: 28px;
    padding: 24px 40px 20px;
    min-width: 260px;
    max-width: 320px;
    box-shadow:
        0 0 0 1px rgba(239, 68, 68, 0.06),
        0 0 60px rgba(239, 68, 68, 0.15),
        0 0 120px rgba(239, 68, 68, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.05),
        0 24px 48px rgba(0, 0, 0, 0.7);
    animation: gameOverAppear 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes gameOverAppear {
    from { transform: scale(0.5) translateY(20px); opacity: 0; }
    to   { transform: scale(1) translateY(0); opacity: 1; }
}

/* Skull icon container */
.go-skull-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(239, 68, 68, 0.08));
    border: 1px solid rgba(239, 68, 68, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    color: #ef4444;
    animation: skullPulse 2s ease-in-out infinite;
}

@keyframes skullPulse {
    0%, 100% { box-shadow: 0 0 12px rgba(239, 68, 68, 0.2); }
    50%      { box-shadow: 0 0 24px rgba(239, 68, 68, 0.4); }
}

.game-over-overlay h2 {
    font-size: 2rem;
    color: #ffffff;
    text-shadow: 0 0 24px rgba(239, 68, 68, 0.8), 0 2px 10px rgba(0, 0, 0, 1);
    letter-spacing: 0.04em;
}

.go-score-line {
    font-size: 0.95rem;
    color: #94a3b8;
    margin: 0;
}
.go-score-value {
    color: #fff;
    font-weight: 800;
    font-size: 1.2rem;
}

/* Dividers */
.go-divider {
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(239, 68, 68, 0.2), rgba(100, 116, 139, 0.15), transparent);
    margin: 12px 0;
}
.go-divider--thin {
    margin: 8px 0;
    background: linear-gradient(90deg, transparent, rgba(100, 116, 139, 0.12), transparent);
}

/* ===== Watch-Ad rescue section ===== */
.go-ad-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
}
.go-ad-label {
    font-size: 0.72rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    margin: 0;
}
.go-rescue-canvas {
    width: 200px;
    height: 60px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(100, 116, 139, 0.15);
}

/* ===== Game-over icon button row ===== */
.go-icon-row {
    display: flex;
    gap: 14px;
    justify-content: center;
    margin-top: 8px;
}

.btn-icon {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.18s, background 0.18s, box-shadow 0.18s;
    flex-shrink: 0;
}

.btn-icon:hover {
    transform: scale(1.12);
}

/* Play / retry — sky blue accent */
.btn-icon--play {
    background: #38bdf8;
    color: #0f172a;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.45);
}

.btn-icon--play:hover {
    background: #7dd3fc;
    box-shadow: 0 0 18px rgba(56, 189, 248, 0.65);
}

/* Text label inside icon button (used for blitz "Play Again") */
.btn-icon-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    margin-left: 4px;
    white-space: nowrap;
}
.btn-icon:has(.btn-icon-label:not(.hidden)) {
    width: auto;
    border-radius: 22px;
    padding: 0 14px;
    gap: 4px;
}

/* Home / levels — subtle slate */
.btn-icon--home {
    background: rgba(51, 65, 85, 0.85);
    color: #cbd5e1;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.4);
}

.btn-icon--home:hover {
    background: #475569;
    color: #f1f5f9;
}

/* ===== Buttons ===== */
.btn {
    background: #38bdf8;
    color: #0f172a;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: transform 0.2s, background 0.2s;
    margin-top: 16px;
    font-size: 1rem;
    touch-action: manipulation;
    /* removes 300ms tap delay on mobile */
    -webkit-tap-highlight-color: transparent;
}

.btn:hover {
    transform: scale(1.05);
    background: #7dd3fc;
}

.btn:active {
    transform: scale(0.96);
    background: #7dd3fc;
    transition: transform 0.08s, background 0.08s;
}

/* ===== Lab UI ===== */
#lab-tab {
    padding: 16px;
    background: #0f172a;
}

.lab-grid-container {
    background: #1e293b;
    border-radius: 16px;
    padding: 16px;
    width: 100%;
    max-width: 450px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid #334155;
}

.code-output {
    background: #020617;
    padding: 12px;
    border-radius: 10px;
    font-family: monospace;
    width: 100%;
    word-break: break-all;
    color: #38bdf8;
    border: 1px solid #334155;
    margin-top: 8px;
    font-size: 0.8rem;
    min-height: 2.5rem;
}

/* ===== Piece Card Style ===== */
.piece-card {
    background: #1e293b;
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid #334155;
    transition: border-color 0.2s;
    position: relative;
}

.piece-card:hover {
    border-color: #38bdf8;
}

.piece-preview-canvas {
    background: #0f172a;
    border-radius: 8px;
    margin-bottom: 8px;
}

.piece-size-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: #334155;
    color: #94a3b8;
    font-size: 0.6rem;
    padding: 2px 5px;
    border-radius: 4px;
    font-weight: 800;
}

/* ===== Settings Tab ===== */
#settings-tab {
    overflow: hidden;
}

/* ===== Settings Page ===== */
.settings-page {
    position: relative;
    z-index: 1;
    padding: 20px 16px 40px;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 600px;
    /* standard tab width */
    margin: 0 auto;
    overflow-y: auto;
    min-height: 0;
    transition: max-width 0.2s ease;
}

/* ── Settings header ── */
.settings-header {
    text-align: center;
    margin-bottom: 22px;
    margin-top: 8px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-back-wrap {
    position: absolute;
    left: 24px;
    top: 24px;
    transform: none;
    z-index: 50;
}

.settings-title {
    font-size: 1.75rem;
    font-weight: 900;
    color: #f8fafc;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.settings-subtitle {
    font-size: 0.78rem;
    color: rgba(148, 163, 184, 0.75);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

/* ── Settings sub-tab pill nav ── */
.stab-nav {
    display: flex;
    gap: 6px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(51, 65, 85, 0.5);
    border-radius: 14px;
    padding: 5px;
    margin-bottom: 20px;
    width: 100%;
    max-width: 360px;
    backdrop-filter: blur(8px);
}

.stab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(148, 163, 184, 0.75);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.18s, color 0.18s, box-shadow 0.18s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
}

.stab-btn:hover {
    color: #e2e8f0;
    background: rgba(51, 65, 85, 0.4);
}

.stab-btn.stab-active {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.2);
    border: 1px solid rgba(56, 189, 248, 0.25);
}

/* ── Settings sub-tab panes ── */
.stab-pane {
    display: none;
    width: 100%;
    animation: stab-fade-in 0.2s ease;
}

.stab-pane-active {
    display: block;
}

@keyframes stab-fade-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Glass panel that wraps each pane's content ── */
.settings-card-panel {
    width: 100%;
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid rgba(51, 65, 85, 0.5);
    border-radius: 18px;
    padding: 20px 18px 22px;
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

/* ── Player pane ── */
.stab-player-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px 0 24px;
    text-align: center;
}

.stab-player-desc {
    font-size: 0.82rem;
    color: rgba(148, 163, 184, 0.8);
    line-height: 1.55;
    max-width: 280px;
}

.stab-danger-zone {
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 12px;
    padding: 16px;
    background: rgba(239, 68, 68, 0.05);
}

.stab-danger-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.75rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #ef4444;
    margin-bottom: 8px;
}

.stab-danger-desc {
    font-size: 0.78rem;
    color: rgba(148, 163, 184, 0.7);
    margin-bottom: 14px;
    line-height: 1.5;
}

.stab-delete-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.35);
    cursor: pointer;
    transition: background 0.18s, border-color 0.18s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.stab-delete-btn:hover {
    background: rgba(239, 68, 68, 0.22);
    border-color: rgba(239, 68, 68, 0.6);
}

/* ── Appearance pane extras ── */
.settings-preview-label {
    font-size: 0.62rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(100, 116, 139, 0.7);
    margin-top: 8px;
    text-align: center;
}

.stab-reset-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(251, 191, 36, 0.8);
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.25);
    cursor: pointer;
    margin-top: 16px;
    transition: background 0.18s, border-color 0.18s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.stab-reset-btn:hover {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.45);
}

/* ── Appearance pane — three-column layout ── */
.ap-panel {
    padding: 0;
    overflow: hidden;
    /* clip scroll columns to rounded corners */
}

/* The appearance pane fills the full settings-page width */
#stab-pane-appearance {
    max-width: none;
    width: 100%;
}

/* Let the settings page expand fully when appearance tab is active */
.settings-page:has(#stab-pane-appearance.stab-pane-active) {
    max-width: 1000px;
}

.ap-split {
    display: flex;
    align-items: stretch;
    /* fill the full panel height without setting an explicit height —
       each column scrolls independently */
    max-height: calc(100vh - 200px);
    /* viewport minus header + tabs */
    min-height: 260px;
}

/* ── Column 1: preview + reset ── */
.ap-left {
    flex: 0 0 360px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 20px 20px 20px 24px;
    border-right: 1px solid rgba(51, 65, 85, 0.4);
    background: rgba(8, 15, 30, 0.4);
    overflow: hidden;
}

.ap-left .settings-preview-container {
    margin-bottom: 0;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.ap-left .settings-preview-container canvas {
    width: 100%;
    height: auto;
    max-width: 300px;
    max-height: 300px;
    border-radius: 8px;
}

.ap-reset {
    margin-top: 0;
    padding: 10px 16px;
    font-size: 0.8rem;
    width: 100%;
    flex-shrink: 0;
}

/* ── Columns 2 & 3: scrollable picker columns ── */
.ap-col {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    padding: 10px 8px 14px 10px;
    display: flex;
    flex-direction: column;
}

.ap-col+.ap-col {
    border-left: 1px solid rgba(51, 65, 85, 0.4);
}


.ap-col-title {
    font-size: 0.6rem;
    font-weight: 900;
    color: rgba(148, 163, 184, 0.65);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: 0 0 8px 2px;
    flex-shrink: 0;
}

/* Grid fills the column width, exactly 3 cards per row */
.ap-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px !important;
    padding: 0 !important;
    margin-bottom: 0 !important;
    max-width: none !important;
    width: 100% !important;
}

.ap-grid .settings-card {
    padding: 5px;
}

.ap-grid .settings-card canvas {
    width: 100%;
    aspect-ratio: 1;
}

/* ── Colorblind mode toggle row ─────────────────────────── */

.ap-cb-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    margin-top: 12px;
    border-top: 1px solid rgba(51, 65, 85, 0.3);
}

.ap-cb-info {
    flex: 1;
    min-width: 0;
}

.ap-cb-title {
    font-size: 0.72rem;
    font-weight: 800;
    color: #e2e8f0;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0 0 2px;
}

.ap-cb-desc {
    font-size: 0.62rem;
    color: rgba(148, 163, 184, 0.7);
    margin: 0;
    line-height: 1.3;
}

.ap-cb-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: rgba(148, 163, 184, 0.7);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.ap-cb-track {
    position: relative;
    width: 36px;
    height: 20px;
    border-radius: 10px;
    background: rgba(51, 65, 85, 0.5);
    border: 1.5px solid rgba(100, 116, 139, 0.4);
    transition: background 0.2s, border-color 0.2s;
}

.ap-cb-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #94a3b8;
    transition: transform 0.2s, background 0.2s;
}

.ap-cb-toggle.active .ap-cb-track {
    background: rgba(56, 189, 248, 0.25);
    border-color: #38bdf8;
}

.ap-cb-toggle.active .ap-cb-thumb {
    transform: translateX(16px);
    background: #38bdf8;
}

.ap-cb-toggle.active .cb-toggle-label {
    color: #38bdf8;
}

/* Light theme */
.light-theme .ap-cb-row {
    border-top-color: rgba(203, 213, 225, 0.5);
}

.light-theme .ap-cb-title {
    color: #334155;
}

.light-theme .ap-cb-desc {
    color: rgba(100, 116, 139, 0.8);
}

.light-theme .ap-cb-track {
    background: rgba(203, 213, 225, 0.5);
    border-color: rgba(148, 163, 184, 0.5);
}

.light-theme .ap-cb-thumb {
    background: #94a3b8;
}

.light-theme .ap-cb-toggle.active .ap-cb-track {
    background: rgba(14, 165, 233, 0.2);
    border-color: #0ea5e9;
}

.light-theme .ap-cb-toggle.active .ap-cb-thumb {
    background: #0ea5e9;
}


.settings-panel {
    width: 100%;
    max-width: 700px;
    background: var(--settings-bg);
    border: 1px solid var(--settings-border);
    border-radius: 16px;
    padding: 18px 20px 22px;
    margin-bottom: 18px;
}


.settings-panel-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-panel-title svg {
    flex-shrink: 0;
}

/* ── Volume sliders ── */
.sound-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.sound-row:last-child {
    margin-bottom: 0;
}

.sound-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sound-row-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-text);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sound-row-value {
    font-size: 0.75rem;
    font-weight: 800;
    font-family: monospace;
    color: #fbbf24;
    min-width: 38px;
    text-align: right;
}

/* ── Music Track Selector ── */
.music-track-select {
    width: 100%;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(15, 23, 42, 0.6);
    color: var(--color-text);
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.music-track-select:hover,
.music-track-select:focus {
    border-color: rgba(251, 191, 36, 0.5);
    background: rgba(15, 23, 42, 0.8);
}

.music-track-select option {
    background: #1e293b;
    color: #f8fafc;
    padding: 8px;
}

body.light-theme .music-track-select {
    background: rgba(255, 255, 255, 0.7);
    border-color: rgba(100, 116, 139, 0.3);
}

body.light-theme .music-track-select:hover,
body.light-theme .music-track-select:focus {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(251, 191, 36, 0.6);
}

body.light-theme .music-track-select option {
    background: #f1f5f9;
    color: #1e293b;
}

.volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 6px;
    background: var(--settings-border);
    outline: none;
    cursor: pointer;
    touch-action: pan-x;
    /* allow horizontal drag on mobile without triggering scroll */
    -webkit-tap-highlight-color: transparent;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 28px;
    /* larger for easier finger-tap on mobile */
    height: 28px;
    border-radius: 50%;
    background: #f59e0b;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
    transition: transform 0.15s;
}

.volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.volume-slider::-webkit-slider-thumb:active {
    transform: scale(1.05);
}

.volume-slider::-moz-range-thumb {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #f59e0b;
    border: none;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
}

.volume-slider.disabled {
    opacity: 0.35;
    pointer-events: none;
}

/* ── Mute button ── */
.mute-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    cursor: pointer;
    border: 2px solid #475569;
    background: #1e293b;
    color: #94a3b8;
    transition: all 0.2s;
    margin-bottom: 18px;
    width: 100%;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.mute-btn:active {
    transform: scale(0.96);
    transition: transform 0.08s;
}

.mute-btn:hover {
    border-color: #ef4444;
    color: #fca5a5;
    background: #2d1a1a;
}

.mute-btn.active {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

/* ── Sound section divider ───────────────────────────────── */
.sound-divider {
    height: 1px;
    background: rgba(51, 65, 85, 0.4);
    margin: 14px 0;
}

.light-theme .sound-divider {
    background: rgba(203, 213, 225, 0.5);
}

/* ── Voices toggle button (mirrors mute-btn style) ──────── */
.voices-toggle-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    cursor: pointer;
    border: 2px solid #475569;
    background: #1e293b;
    color: #94a3b8;
    transition: all 0.2s;
    margin-bottom: 12px;
    width: 100%;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.voices-toggle-btn:active {
    transform: scale(0.96);
    transition: transform 0.08s;
}

.voices-toggle-btn:hover {
    border-color: #38bdf8;
    color: #7dd3fc;
    background: #172554;
}

.voices-toggle-btn.active {
    border-color: #38bdf8;
    background: rgba(56, 189, 248, 0.15);
    color: #7dd3fc;
}

.light-theme .voices-toggle-btn {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #64748b;
}

.light-theme .voices-toggle-btn.active {
    border-color: #0ea5e9;
    background: rgba(14, 165, 233, 0.1);
    color: #0284c7;
}

.settings-section-title {
    font-size: 1rem;
    font-weight: 800;
    color: #e2e8f0;
    margin-top: 16px;
    margin-bottom: 8px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.settings-preview-container {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 16px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 8px;
}

.settings-preview-container canvas {
    border-radius: 10px;
    max-width: 100%;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    width: 100%;
    margin-bottom: 8px;
    padding: 0 8px;
}

.settings-card {
    background: var(--settings-card-bg);
    border: 2px solid var(--settings-card-border);
    border-radius: 10px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
    position: relative;
    min-width: 0;
    min-height: 0;
}

.settings-card:hover {
    border-color: #f59e0b;
    transform: scale(1.03);
}

.settings-card.selected {
    border-color: var(--settings-card-selected-border);
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.3);
}

.settings-card canvas {
    border-radius: 6px;
    background: transparent;
    width: 100%;
    aspect-ratio: 1;
    min-width: 0;
    min-height: 0;
    display: block;
}

.settings-card-label {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--settings-label);
    margin-top: 4px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.2;
}

.settings-selected-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: #f59e0b;
    color: #0f172a;
    font-size: 0.5rem;
    font-weight: 800;
    padding: 1px 5px;
    border-radius: 4px;
    text-transform: uppercase;
}

.settings-card--locked {
    opacity: 0.5;
    filter: grayscale(0.4);
}

.settings-card--locked:hover {
    border-color: #64748b;
}

.settings-locked-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 23, 42, 0.85);
    color: #94a3b8;
    font-size: 0.58rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
}

/* ===== Design Test Page ===== */
.design-test-page {
    padding: 20px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.design-section-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: #e2e8f0;
    margin-bottom: 4px;
    text-align: center;
}

.design-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 900px;
    margin-bottom: 16px;
    padding: 0 8px;
}

.design-card {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.15s;
}

.design-card:hover {
    border-color: #a78bfa;
    transform: scale(1.02);
}

.design-card canvas {
    border-radius: 8px;
    background: transparent;
    width: 100%;
    aspect-ratio: 1;
}

.design-card-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: #94a3b8;
    margin-top: 6px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.design-preview-modal {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.92);
    backdrop-filter: blur(10px);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
}

.design-preview-modal.hidden {
    display: none;
}

.design-preview-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 90%;
}

.design-preview-inner canvas {
    border-radius: 12px;
    max-width: 100%;
    max-height: 65vh;
}

/* ===== Home Screen ===== */
#home-tab {
    position: relative;
    overflow: hidden;
}

.home-bg-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.home-content {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: safe center;
    flex: 1;
    width: 100%;
    gap: 6px;
    padding: 10px 32px 32px;
    overflow-y: auto;
    overflow-x: hidden;
}

.home-logo-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
    gap: 0;
}

/* SVG hex cluster above the text */
.home-logo-hexcluster {
    width: clamp(180px, 30vw, 300px);
    height: auto;
    margin-bottom: -18px;
    filter: drop-shadow(0 4px 20px rgba(0, 0, 0, 0.4));
}

/* Pulse animation on the background glow ring */
.logo-pulse-ring {
    animation: logo-pulse 3s ease-in-out infinite;
    transform-origin: center;
}

@keyframes logo-pulse {

    0%,
    100% {
        opacity: 0.6;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.08);
    }
}

/* Sparkle twinkle */
.logo-sparkles circle {
    animation: sparkle-twinkle 2.5s ease-in-out infinite;
}

.logo-sparkles circle:nth-child(odd) {
    animation-delay: 0.3s;
}

.logo-sparkles circle:nth-child(3n) {
    animation-delay: 0.8s;
}

.logo-sparkles circle:nth-child(4n+1) {
    animation-delay: 1.4s;
}

@keyframes sparkle-twinkle {

    0%,
    100% {
        opacity: 0.5;
        r: 2;
    }

    50% {
        opacity: 1;
        r: 3.5;
    }
}

/* Ray rotation — very subtle */
.logo-rays {
    animation: rays-spin 40s linear infinite;
    transform-origin: 140px 100px;
}

@keyframes rays-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Text wrap */
.home-logo-text-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

/* The big HONEYCOMB text */
.home-logo-text {
    display: flex;
    align-items: baseline;
    gap: 0;
    line-height: 1;
}

.home-logo-text--sub {
    margin-top: -4px;
}

.home-logo-hex-word,
.home-logo-burst-word,
.home-logo-blast-word {
    font-size: clamp(2.4rem, 6vw, 4.5rem);
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* HONEY — warm amber/gold */
.home-logo-hex-word {
    color: #fbbf24;
    text-shadow:
        1px 1px 0 #b45309,
        2px 2px 0 #78350f,
        0 0 30px rgba(251, 191, 36, 0.5),
        0 0 60px rgba(245, 158, 11, 0.25),
        0 2px 6px rgba(0, 0, 0, 0.5);
    -webkit-text-stroke: 0.5px rgba(255, 255, 255, 0.2);
}

/* COMB — bright cyan */
.home-logo-burst-word {
    color: #38bdf8;
    text-shadow:
        1px 1px 0 #0369a1,
        2px 2px 0 #0c4a6e,
        0 0 30px rgba(56, 189, 248, 0.5),
        0 0 60px rgba(56, 189, 248, 0.2),
        0 2px 6px rgba(0, 0, 0, 0.5);
    -webkit-text-stroke: 0.5px rgba(255, 255, 255, 0.2);
}

/* BLAST — fiery gradient via background-clip */
.home-logo-blast-word {
    font-size: clamp(2rem, 5vw, 3.8rem);
    letter-spacing: 0.22em;
    background: linear-gradient(90deg, #f87171, #fb923c, #fbbf24, #34d399, #38bdf8, #a78bfa);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: blast-shimmer 4s ease-in-out infinite;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

@keyframes blast-shimmer {

    0%,
    100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

/* ── Light theme logo adjustments ── */
.light-theme .home-logo-hexcluster {
    filter: drop-shadow(0 4px 20px rgba(0, 0, 0, 0.15));
}

.light-theme .home-logo-hex-word {
    color: #d97706;
    text-shadow:
        1px 1px 0 #92400e,
        2px 2px 0 #78350f,
        0 0 20px rgba(217, 119, 6, 0.3),
        0 2px 4px rgba(0, 0, 0, 0.2);
    -webkit-text-stroke: 0.5px rgba(0, 0, 0, 0.1);
}

.light-theme .home-logo-burst-word {
    color: #0284c7;
    text-shadow:
        1px 1px 0 #075985,
        2px 2px 0 #0c4a6e,
        0 0 20px rgba(2, 132, 199, 0.25),
        0 2px 4px rgba(0, 0, 0, 0.2);
    -webkit-text-stroke: 0.5px rgba(0, 0, 0, 0.1);
}

.light-theme .home-logo-blast-word {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.light-theme .logo-pulse-ring {
    opacity: 0.3;
}

.light-theme .logo-rays {
    opacity: 0.25;
}

.home-subtitle {
    font-size: 0.78rem;
    font-weight: 600;
    color: #64748b;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    margin-top: 6px;
    margin-bottom: 14px;
}

/* ── Home stats — vertical strip along left edge ───────────────────────── */
.home-stats-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 15;
    pointer-events: none;
    gap: 2px;
}

.home-stats-heading {
    font-size: 0.5rem;
    font-weight: 800;
    color: var(--home-stat-label);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 2px;
    text-align: center;
    width: 100%;
}

.home-stats-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.home-stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    background: var(--home-stat-bg);
    border: 1px solid var(--home-stat-border);
    border-radius: 8px;
    padding: 4px 8px;
    min-width: 52px;
}

.home-stat-label {
    font-size: 0.5rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--home-stat-label);
}

.home-stat-value {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--home-stat-value);
    font-family: monospace;
    text-align: center;
}

.home-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    width: 100%;
    max-width: 320px;
}

/* ── Group button containers ── */
.home-btn-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

/* Chevron rotates when open */
.home-btn-chevron {
    margin-left: auto;
    transition: transform 0.22s ease;
    flex-shrink: 0;
}

.home-btn-chevron.flipped {
    transform: rotate(180deg);
}

/* Submenu — collapsed by default, expands smoothly */
.home-btn-submenu {
    width: 100%;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.28s ease, opacity 0.22s ease, padding 0.22s ease;
    opacity: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 8px;
    box-sizing: border-box;
}

.home-btn-submenu.open {
    max-height: 200px;
    opacity: 1;
    padding: 8px 8px 0;
}

/* Sub-buttons (smaller, indented) */
.home-sub-btn {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    width: 100%;
    padding: 10px 18px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s, filter 0.15s;
    position: relative;
    overflow: hidden;
}

.home-sub-btn:hover {
    transform: translateX(3px);
    filter: brightness(1.15);
}

.home-sub-btn:active {
    transform: scale(0.97);
}

.home-sub-btn-status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    font-size: 0.7rem;
    font-weight: 700;
}

.home-sub-btn-status .status-check {
    color: #34d399;
    font-size: 0.85rem;
}

.home-sub-btn-status .status-streak {
    display: flex;
    align-items: center;
    gap: 2px;
    color: #fbbf24;
    font-size: 0.7rem;
}

.home-sub-btn-status .status-progress {
    color: #94a3b8;
    font-size: 0.65rem;
    opacity: 0.8;
}

.home-sub-btn-timer {
    margin-left: 8px;
    font-size: 0.75rem;
    opacity: 0.65;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.home-sub-btn-quest {
    background: linear-gradient(135deg, rgba(52, 211, 153, 0.2) 0%, rgba(16, 185, 129, 0.25) 100%);
    color: #34d399;
    border-color: rgba(52, 211, 153, 0.3);
}

.home-sub-btn-daily {
    background: linear-gradient(135deg, rgba(167, 139, 250, 0.2) 0%, rgba(124, 58, 237, 0.25) 100%);
    color: #c4b5fd;
    border-color: rgba(167, 139, 250, 0.3);
}

.home-sub-btn-weekly {
    background: linear-gradient(135deg, rgba(34, 211, 238, 0.2) 0%, rgba(109, 40, 217, 0.2) 100%);
    color: #67e8f9;
    border-color: rgba(34, 211, 238, 0.3);
}

.home-sub-btn-endless {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.2) 0%, rgba(14, 165, 233, 0.25) 100%);
    color: #7dd3fc;
    border-color: rgba(56, 189, 248, 0.3);
}

.home-sub-btn-blitz {
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.2) 0%, rgba(239, 68, 68, 0.2) 100%);
    color: #fb923c;
    border-color: rgba(249, 115, 22, 0.3);
}

/* Light theme */
.light-theme .home-sub-btn-quest {
    color: #059669;
    border-color: rgba(5, 150, 105, 0.4);
}

.light-theme .home-sub-btn-daily {
    color: #7c3aed;
    border-color: rgba(124, 58, 237, 0.4);
}

.light-theme .home-sub-btn-weekly {
    color: #0891b2;
    border-color: rgba(8, 145, 178, 0.4);
}

.light-theme .home-sub-btn-endless {
    color: #0369a1;
    border-color: rgba(3, 105, 161, 0.4);
}

.light-theme .home-sub-btn-blitz {
    color: #ea580c;
    border-color: rgba(234, 88, 12, 0.4);
}

@keyframes home-btn-shimmer {
    0% {
        transform: translateX(-120%) skewX(-20deg);
    }

    100% {
        transform: translateX(220%) skewX(-20deg);
    }
}

@keyframes home-btn-glow-pulse {

    0%,
    100% {
        opacity: 0.55;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.06);
    }
}

@keyframes home-btn-icon-bounce {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    30% {
        transform: translateY(-4px) rotate(-8deg);
    }

    60% {
        transform: translateY(2px) rotate(4deg);
    }
}

.home-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px 28px;
    border-radius: 14px;
    font-size: 1.15rem;
    font-weight: 800;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.18);
    transition: transform 0.18s cubic-bezier(.34, 1.56, .64, 1), box-shadow 0.2s, background 0.2s, border-color 0.2s;
    position: relative;
    letter-spacing: 0.02em;
    overflow: hidden;
    isolation: isolate;
}

/* Shimmer sweep */
.home-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg,
            transparent 35%,
            rgba(255, 255, 255, 0.28) 50%,
            transparent 65%);
    transform: translateX(-120%) skewX(-20deg);
    animation: home-btn-shimmer 3.2s ease-in-out infinite;
    pointer-events: none;
    z-index: 1;
}

/* Glow ring behind button */
.home-btn::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 18px;
    background: inherit;
    filter: blur(14px);
    opacity: 0.45;
    z-index: -1;
    animation: home-btn-glow-pulse 2.4s ease-in-out infinite;
    pointer-events: none;
}

.home-btn:hover {
    transform: scale(1.07) translateY(-2px);
    border-color: rgba(255, 255, 255, 0.35);
}

.home-btn:active {
    transform: scale(0.96) translateY(1px);
    transition-duration: 0.08s;
}

/* Icon bounce on hover */
.home-btn:hover svg {
    animation: home-btn-icon-bounce 0.55s ease forwards;
}

/* Stagger shimmer so buttons don't all flash at once */
.home-btn-quest-active::before {
    animation-delay: -0.8s;
}

.home-btn-arcade::before {
    animation-delay: -1.6s;
}

.home-btn-blitz::before {
    animation-delay: -2.4s;
}

.home-btn-quest-active::after {
    animation-delay: -0.4s;
}

.home-btn-arcade::after {
    animation-delay: -1.2s;
}

.home-btn-blitz::after {
    animation-delay: -2.0s;
}

/* ===== Resume Game Button ===== */
.home-btn-resume {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #0f172a;
    box-shadow:
        0 4px 15px rgba(245, 158, 11, 0.5),
        0 0 40px rgba(245, 158, 11, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
    animation: resume-pulse 2s ease-in-out infinite;
}

.home-btn-resume:hover {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    box-shadow:
        0 8px 28px rgba(245, 158, 11, 0.65),
        0 0 80px rgba(245, 158, 11, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.home-btn-resume::before {
    animation-delay: -0.4s;
}

.home-btn-resume::after {
    animation-delay: 0s;
}

@keyframes resume-pulse {
    0%, 100% { box-shadow: 0 4px 15px rgba(245, 158, 11, 0.5), 0 0 40px rgba(245, 158, 11, 0.2), inset 0 1px 0 rgba(255,255,255,0.25); }
    50% { box-shadow: 0 4px 20px rgba(245, 158, 11, 0.7), 0 0 60px rgba(245, 158, 11, 0.35), inset 0 1px 0 rgba(255,255,255,0.25); }
}

.home-btn-arcade {
    background: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 100%);
    color: #0f172a;
    box-shadow:
        0 4px 15px rgba(56, 189, 248, 0.4),
        0 0 40px rgba(56, 189, 248, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.home-btn-arcade:hover {
    background: linear-gradient(135deg, #7dd3fc 0%, #38bdf8 100%);
    box-shadow:
        0 8px 28px rgba(56, 189, 248, 0.65),
        0 0 80px rgba(56, 189, 248, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.home-btn-badge {
    position: absolute;
    top: -8px;
    right: -4px;
    background: #f59e0b;
    color: #0f172a;
    font-size: 0.55rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 6px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

/* ===== Quest Mode — Level Select ===== */
.quest-select-page {
    padding: 12px 12px 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
}

.quest-pyramid-wrap {
    position: relative;
    flex: 1;
    width: 100%;
    min-height: 0;
}

.quest-pyramid-wrap canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Tooltip that appears on hover */
.quest-tooltip {
    display: none;
    position: absolute;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 8px 12px;
    pointer-events: none;
    z-index: 100;
    font-size: 0.75rem;
    color: #e2e8f0;
    max-width: 180px;
    line-height: 1.4;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.quest-tooltip strong {
    color: #34d399;
    font-size: 0.8rem;
}

.quest-tip-desc {
    color: #94a3b8;
    font-size: 0.65rem;
}

.quest-tip-complete {
    color: #34d399;
    font-weight: 700;
    font-size: 0.65rem;
}

.quest-tip-lock {
    color: #64748b;
    font-style: italic;
    font-size: 0.65rem;
}

/* ===== Quest HUD (in-game progress bar) ===== */
.quest-hud {
    position: absolute;
    /* top is set dynamically by layout.js for both portrait and landscape */
    left: 50%;
    transform: translateX(-50%);
    z-index: 55;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--quest-card-bg);
    backdrop-filter: blur(6px);
    border: 1px solid var(--quest-card-border);
    border-radius: 10px;
    padding: 4px 14px;
    min-width: 240px;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.quest-hud.hidden {
    display: none;
}

.quest-hud-level {
    font-weight: 800;
    font-size: 0.7rem;
    color: #34d399;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.quest-progress-track {
    flex: 1;
    height: 10px;
    background: var(--quest-progress-track);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--quest-card-border);
}

.quest-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #34d399, #fbbf24);
    border-radius: 6px;
    transition: width 0.4s ease;
}

.quest-progress-label {
    font-weight: 700;
    font-size: 0.65rem;
    color: #94a3b8;
    font-family: monospace;
    white-space: nowrap;
}

/* ===== Quest Complete Overlay ===== */
.quest-complete-overlay {
    position: absolute;
    inset: 0;
    background: transparent;
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quest-complete-card {
    position: relative;
    /* Contain absolute decorative SVGs */
    overflow: hidden;
    /* Clip SVGs */
    background: var(--quest-card-bg);
    backdrop-filter: blur(8px);
    border: 1px solid var(--quest-card-border);
    border-radius: 24px;
    padding: 32px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    box-shadow:
        0 0 0 1px rgba(52, 211, 153, 0.08),
        0 0 40px rgba(52, 211, 153, 0.15),
        0 24px 48px rgba(0, 0, 0, 0.8);
    max-width: 360px;
    width: 90%;
    animation: gameOverAppear 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.quest-complete-title {
    font-size: 1.8rem;
    font-weight: 800;
    color: #34d399;
    text-shadow: 0 0 20px rgba(52, 211, 153, 0.4);
}

.quest-complete-level-name {
    font-size: 0.9rem;
    color: #94a3b8;
    font-weight: 600;
}

.quest-complete-score {
    font-size: 1.1rem;
    color: #e2e8f0;
    font-weight: 800;
    font-family: monospace;
}

.quest-complete-check {
    font-size: 3rem;
    color: #34d399;
    line-height: 1;
    text-shadow: 0 0 20px rgba(52, 211, 153, 0.5);
    animation: checkPop 0.5s ease-out;
}

@keyframes checkPop {
    0% {
        transform: scale(0.2);
        opacity: 0;
    }

    60% {
        transform: scale(1.3);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ===== Home Quest Button (active style) ===== */
.home-btn-quest-active {
    background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
    color: #0f172a;
    box-shadow:
        0 4px 15px rgba(52, 211, 153, 0.4),
        0 0 40px rgba(52, 211, 153, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.home-btn-quest-active:hover {
    background: linear-gradient(135deg, #6ee7b7 0%, #34d399 100%);
    box-shadow:
        0 8px 28px rgba(52, 211, 153, 0.65),
        0 0 80px rgba(52, 211, 153, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* ===== Responsive Scaling for Text/UI inside viewport ===== */

/* Home screen responsive */
#game-viewport.size-mobile .home-logo-hexcluster {
    width: clamp(120px, 38vw, 180px);
}

#game-viewport.size-mobile .home-logo-hex-word,
#game-viewport.size-mobile .home-logo-burst-word {
    font-size: 2.2rem;
}

#game-viewport.size-mobile .home-subtitle {
    font-size: 0.62rem;
    letter-spacing: 0.22em;
}

#game-viewport.size-mobile .home-highscore {
    font-size: 0.9rem;
    margin-bottom: 8px;
}

/* Only move stats to bottom-center in portrait (mobile phones).
   On landscape desktops — even small/non-maximized windows — keep the
   left-side vertical strip so it doesn't overlap the menu buttons. */
.portrait-mode #game-viewport.size-mobile .home-stats-section {
    left: auto;
    right: 50%;
    top: auto;
    bottom: 12px;
    transform: translateX(50%);
}

.portrait-mode #game-viewport.size-mobile .home-stats-row {
    flex-direction: row;
    gap: 5px;
}

.portrait-mode #game-viewport.size-mobile .home-stats-heading {
    font-size: 0.52rem;
    text-align: center;
}

#game-viewport.size-mobile .home-stat-card {
    padding: 4px 8px;
    min-width: 56px;
}

#game-viewport.size-mobile .home-stat-label {
    font-size: 0.52rem;
}

#game-viewport.size-mobile .home-stat-value {
    font-size: 0.72rem;
}

#game-viewport.size-mobile .home-btn {
    padding: 12px 20px;
    font-size: 0.95rem;
    border-radius: 12px;
}

#game-viewport.size-mobile .home-buttons {
    gap: 10px;
    max-width: 260px;
}

#game-viewport.size-mobile .home-content {
    padding: 20px;
}

#game-viewport.size-mobile .home-currency-row {
    top: 12px;
    left: 12px;
    gap: 6px;
}

#game-viewport.size-mobile .home-credits-badge,
#game-viewport.size-mobile .home-energy-badge {
    font-size: 0.95rem;
    padding: 6px 12px 6px 8px;
    gap: 6px;
}

#game-viewport.size-mobile .home-hex-nav {
    gap: 8px;
}

#game-viewport.size-mobile .home-hex-btn {
    width: 36px;
    height: 42px;
}

#game-viewport.size-mobile .home-credits-badge img {
    width: 22px;
    height: 22px;
}

#game-viewport.size-mobile .home-energy-badge svg {
    width: 14px;
    height: 14px;
}

#game-viewport.size-tablet .home-logo-hexcluster {
    width: clamp(140px, 22vw, 210px);
}

/* Small / non-maximized windows (Chromebooks, small laptops) */
@media (max-height: 620px) {
    .home-logo-hexcluster { width: clamp(100px, 18vw, 160px); margin-bottom: -10px; }
    .home-logo-text { font-size: clamp(1.4rem, 4vw, 2rem) !important; }
    .home-subtitle { font-size: 0.55rem !important; margin-bottom: 0 !important; }
    .home-stat-card { padding: 3px 4px; }
    .home-buttons { gap: 8px; }
    .home-btn { padding: 10px 18px; font-size: 0.9rem; }
    .home-content { gap: 2px; padding-top: 4px; }
}

#game-viewport.size-tablet .home-logo-hex-word,
#game-viewport.size-tablet .home-logo-burst-word {
    font-size: 3.8rem;
}

#game-viewport.size-tablet .home-btn {
    padding: 14px 24px;
    font-size: 1.05rem;
}

/* Quest responsive */
#game-viewport.size-mobile .quest-select-page {
    padding: 8px 8px 0;
}

#game-viewport.size-mobile .quest-select-page h1 {
    font-size: 1.3rem;
    margin-bottom: 2px;
}

#game-viewport.size-mobile .quest-select-page p {
    font-size: 0.7rem;
    margin-bottom: 4px;
}

/* Portrait mobile: compact quest HUD styling (position set by layout.js) */
.portrait-mode #game-viewport.size-mobile .quest-hud {
    min-width: 180px;
    padding: 3px 10px;
    gap: 6px;
}

.portrait-mode #game-viewport.size-mobile .quest-hud-level {
    font-size: 0.6rem;
}

.portrait-mode #game-viewport.size-mobile .quest-progress-label {
    font-size: 0.55rem;
}

#game-viewport.size-mobile .quest-complete-title {
    font-size: 1.4rem;
}

/* ===== Responsive Scaling for Text/UI inside viewport ===== */
/* Mobile (800x450) */
#game-viewport.size-mobile .score-display {
    font-size: 1.8rem;
}

#game-viewport.size-mobile .combo-display {
    font-size: 0.8rem;
    height: 1rem;
}

#game-viewport.size-mobile .game-hud-currency {
    top: 10px;
    left: 10px;
    gap: 5px;
}

#game-viewport.size-mobile .game-hud-coin,
#game-viewport.size-mobile .game-hud-energy,
#game-viewport.size-mobile .game-hud-trophy,
#game-viewport.size-mobile .game-hud-blitz {
    font-size: 0.88rem;
    padding: 5px 10px 5px 7px;
    gap: 5px;
}

#game-viewport.size-mobile .game-hud-coin svg,
#game-viewport.size-mobile .game-hud-trophy svg,
#game-viewport.size-mobile .game-hud-blitz svg {
    width: 20px;
    height: 20px;
}

#game-viewport.size-mobile .game-hud-energy svg {
    width: 14px;
    height: 14px;
}

#game-viewport.size-mobile .hud-top-left {
    top: 12px;
    left: 12px;
    font-size: 1.2rem;
}

/* ── Mobile portrait powerup strip — compact horizontal bar ── */

#game-viewport.size-mobile .powerup-hud:not(.powerup-hud--landscape) .pu-badge {
    min-width: 16px;
    height: 16px;
    padding: 0 3px;
    font-size: 0.6rem;
    bottom: -4px;
    right: -4px;
}

#game-viewport.size-mobile .powerup-hud:not(.powerup-hud--landscape) .act-wrap:has(.act-locked)::after {
    width: 16px;
    height: 16px;
    font-size: 0.5rem;
    right: -8px;
    top: -4px;
    padding-left: 1px;
}

#game-viewport.size-mobile .powerup-hud:not(.powerup-hud--landscape) .act-lock-badge {
    width: 16px;
    height: 16px;
    left: -8px;
    top: -4px;
}

#game-viewport.size-mobile .powerup-hud:not(.powerup-hud--landscape) .act-lock-badge svg {
    width: 9px;
    height: 9px;
}

/* Tighter border outline for compact buttons in fan mode */
#game-viewport.size-mobile .powerup-hud:not(.powerup-hud--landscape) .pu-wrap::before,
#game-viewport.size-mobile .powerup-hud:not(.powerup-hud--landscape) .act-wrap::before,
.powerup-hud--landscape .pu-wrap::before,
.powerup-hud--landscape .act-wrap::before {
    left: -2px;
    top: -2px;
    right: -2px;
    bottom: -2px;
}

/* ── Powerup Fan Menu (portrait mobile only) ── */

/* Toggle button — hidden by default, shown only in portrait mobile */
/* ── Shared hex-toggle base ────────────────────────────────────── */
.pu-fan-toggle,
.act-fan-toggle {
    display: none;
    position: absolute;
    z-index: 25;
    pointer-events: all;
    width: 52px;
    height: 60px; /* pointy-top hex ratio */
    border: none;
    padding: 0;
    background: transparent;
    cursor: pointer;
    color: rgba(56, 189, 248, 0.6);
    filter: drop-shadow(0 0 5px rgba(56, 189, 248, 0.3));
    transition: transform 0.25s cubic-bezier(.4, 0, .2, 1), filter 0.25s ease, color 0.25s ease;
    -webkit-tap-highlight-color: transparent;
}

/* SVG hex outline — positioned behind the icon */
.pu-fan-toggle .hex-outline,
.act-fan-toggle .hex-outline {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Icon sits centered on top of the hex outline */
.pu-fan-toggle .pu-fan-icon {
    position: relative;
    width: 65%;
    height: 65%;
    object-fit: contain;
    filter: brightness(1.3) drop-shadow(0 0 4px rgba(56, 189, 248, 0.5));
    transition: filter 0.2s ease, transform 0.35s cubic-bezier(.4, 0, .2, 1);
}

.pu-fan-toggle:active,
.act-fan-toggle:active {
    transform: translate(-50%, -50%) scale(0.9);
}

/* When fan is open — hex outline turns orange */
.pu-fan-toggle.pu-fan-open {
    color: rgba(249, 115, 22, 0.7);
    filter: drop-shadow(0 0 6px rgba(249, 115, 22, 0.4));
}

.pu-fan-toggle.pu-fan-open .pu-fan-icon {
    filter: brightness(1.5) drop-shadow(0 0 8px rgba(249, 115, 22, 0.7));
    transform: rotate(180deg) scale(1.05);
    transition: filter 0.2s ease, transform 0.35s cubic-bezier(.4, 0, .2, 1);
}

/* Show the fan toggle in both portrait and landscape */
.powerup-hud .pu-fan-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Powerup wraps always visible (no toggle) */
.powerup-hud .pu-wrap {
    opacity: 1;
    pointer-events: all !important;
    transform: translate(-50%, -50%) scale(1) !important;
}

/* Stagger the fan items */
.powerup-hud.pu-fan-active .pu-wrap:nth-child(2) {
    transition-delay: 0s;
}

.powerup-hud.pu-fan-active .pu-wrap:nth-child(3) {
    transition-delay: 0.04s;
}

.powerup-hud.pu-fan-active .pu-wrap:nth-child(4) {
    transition-delay: 0.08s;
}

.powerup-hud.pu-fan-active .pu-wrap:nth-child(5) {
    transition-delay: 0.12s;
}

/* ── Action Fan Menu (portrait mobile only, bottom-right) ── */

.act-fan-toggle .act-fan-icon {
    position: relative;
    width: 65%;
    height: 65%;
    object-fit: contain;
    filter: brightness(1.3) drop-shadow(0 0 4px rgba(52, 211, 153, 0.5));
    transition: filter 0.2s ease, transform 0.35s cubic-bezier(.4, 0, .2, 1);
}

.act-fan-toggle.act-fan-open {
    color: rgba(249, 115, 22, 0.7);
    filter: drop-shadow(0 0 6px rgba(249, 115, 22, 0.4));
}

.act-fan-toggle.act-fan-open .act-fan-icon {
    filter: brightness(1.5) drop-shadow(0 0 8px rgba(249, 115, 22, 0.7));
    transform: rotate(90deg) scale(1.05);
    transition: filter 0.2s ease, transform 0.35s cubic-bezier(.4, 0, .2, 1);
}

/* Show the action fan toggle in both portrait and landscape */
.powerup-hud .act-fan-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Action wraps always visible (no toggle) */
.powerup-hud .act-wrap {
    opacity: 1;
    pointer-events: all !important;
    transform: translate(-50%, -50%) scale(1) !important;
}

/* Stagger the action fan items */
.powerup-hud.act-fan-active .act-wrap:nth-of-type(1) {
    transition-delay: 0s;
}

.powerup-hud.act-fan-active .act-wrap:nth-of-type(2) {
    transition-delay: 0.04s;
}

.powerup-hud.act-fan-active .act-wrap:nth-of-type(3) {
    transition-delay: 0.08s;
}

.powerup-hud.act-fan-active .act-wrap:nth-of-type(4) {
    transition-delay: 0.12s;
}

/* Scrim overlay behind fan menus when open */
.fan-scrim {
    display: none;
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.25);
    z-index: 19;
    pointer-events: all;
}

.fan-scrim.visible {
    display: block;
}

/* ── Hold & Next panels (portrait mobile, below tray) ── */

.hold-next-strip {
    display: none;
    position: absolute;
    z-index: 15;
    pointer-events: none;
    gap: 18px;
}

.hold-next-strip.hn-visible {
    display: flex;
}

/* Drop behind the canvas (z-index: 10) while a piece is being dragged */
.hold-next-strip.hn-behind {
    z-index: 5;
}

.hn-panel {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    border: 1.5px solid rgba(100, 116, 139, 0.3);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.45);
    overflow: visible;
    pointer-events: all;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.15s ease, transform 0.1s ease;
    user-select: none;
}

.hn-panel:hover {
    border-color: rgba(99, 179, 237, 0.6);
    box-shadow: 0 0 10px rgba(99, 179, 237, 0.2);
    background: rgba(15, 23, 42, 0.65);
}

.hn-panel:active {
    transform: scale(0.96);
    border-color: rgba(99, 179, 237, 0.9);
    box-shadow: 0 0 14px rgba(99, 179, 237, 0.35);
}

/* Unlocked state — green border to indicate ready */
.hn-panel.hn-unlocked {
    border-color: rgba(52, 211, 153, 0.5);
}

.hn-panel.hn-unlocked:hover {
    border-color: rgba(52, 211, 153, 0.85);
    box-shadow: 0 0 10px rgba(52, 211, 153, 0.2);
}

.hn-label {
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.5rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(148, 163, 184, 0.5);
    padding: 0 6px;
    white-space: nowrap;
    pointer-events: none;
}

.hn-preview {
    flex: 1;
    height: 100%;
    pointer-events: none;
}

/* Lock overlay — large lock centered, ad play icon pinned to right */
.hn-lock-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.55);
    border-radius: 8px;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.hn-lock-overlay .hn-lock-icon {
    width: 28px;
    height: 28px;
    color: rgba(148, 163, 184, 0.7);
}

.hn-lock-overlay .hn-ad-icon {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 26px;
    height: 26px;
    color: rgba(251, 191, 36, 0.9);
}

/* When unlocked, hide the overlay */
.hn-panel.hn-unlocked .hn-lock-overlay {
    opacity: 0;
}

/* Subtle glow when holding a piece */
.hn-panel.hn-holding {
    border-color: rgba(56, 189, 248, 0.35);
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.15);
}

/* Pulsing hint glow — shown when dragged piece can't fit and hold is available */
.hn-panel.hn-hint {
    border-color: rgba(251, 191, 36, 0.6);
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.35), 0 0 24px rgba(251, 191, 36, 0.15);
    animation: hnHintPulse 1s ease-in-out infinite;
}

@keyframes hnHintPulse {
    0%, 100% { box-shadow: 0 0 12px rgba(251, 191, 36, 0.35), 0 0 24px rgba(251, 191, 36, 0.15); }
    50%      { box-shadow: 0 0 18px rgba(251, 191, 36, 0.55), 0 0 36px rgba(251, 191, 36, 0.25); }
}

/* Light theme adjustments */
.light-theme .hn-panel {
    background: rgba(241, 245, 249, 0.85);
    border-color: rgba(100, 116, 139, 0.3);
}

.light-theme .hn-label {
    color: rgba(71, 85, 105, 0.8);
}

.light-theme .hn-lock-overlay {
    background: rgba(241, 245, 249, 0.5);
}

.light-theme .hn-lock-overlay svg {
    color: rgba(100, 116, 139, 0.5);
}

#game-viewport.size-mobile .hud-center {
    top: 4%;
    max-width: 95vw;
}

#game-viewport.size-mobile .hud-top-right {
    top: 12px;
    right: 12px;
}

#game-viewport.size-mobile .menu-btn {
    width: 34px;
    height: 39px;
}

#game-viewport.size-mobile .menu-btn svg:not(.hex-outline) {
    width: 55%;
    height: 55%;
}

#game-viewport.size-mobile .btn {
    padding: 8px 16px;
    font-size: 0.85rem;
    margin-top: 10px;
}

#game-viewport.size-mobile .modal-header {
    padding: 20px 18px 14px;
}

#game-viewport.size-mobile .menu-item {
    padding: 11px 16px;
    font-size: 0.85rem;
}

#game-viewport.size-mobile .menu-item-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
}

#game-viewport.size-mobile .game-over-overlay h2 {
    font-size: 1.8rem;
}

#game-viewport.size-mobile .game-over-overlay p {
    font-size: 0.9rem;
}

#game-viewport.size-mobile .game-over-content {
    padding: 20px 28px 18px;
    border-radius: 14px;
}

#game-viewport.size-mobile .btn-icon {
    width: 38px;
    height: 38px;
}

#game-viewport.size-mobile .btn-icon svg {
    width: 15px;
    height: 15px;
}

/* Tablet (1080x607) */
#game-viewport.size-tablet .score-display {
    font-size: 2.2rem;
}

#game-viewport.size-tablet .combo-display {
    font-size: 0.9rem;
    height: 1.2rem;
}

/* ============================================================
   PORTRAIT MOBILE LAYOUT
   Applied when vw < vh (phone held upright).
   JS adds .portrait-mode to <body> and sizes the viewport to
   fill the full screen width × (vh - adBannerH).
   ============================================================ */

/* Body becomes a vertical stack: viewport on top, ad banner below */
body.portrait-mode {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
}

/* Ad banner slot — hidden by default, shown in portrait */
#adBanner {
    display: none;
    flex-shrink: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: var(--ad-banner-bg);
    border-top: 1px solid var(--ad-banner-border);
    width: 100%;
}

body.portrait-mode #adBanner {
    display: flex;
    height: var(--ad-banner-h, 60px);
}

/* Landscape banner strip — sits below the game viewport when vertical space
   allows it. Hidden by default; JS adds .visible when there is enough room.
   In landscape the body switches to a column stack so the banner appears
   directly under the 16:9 viewport. */
#adBannerLandscape {
    display: none;
    flex-shrink: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: var(--ad-banner-bg);
    border-top: 1px solid var(--ad-banner-border);
    overflow: hidden;
}

#adBannerLandscape.visible {
    display: flex;
    width: var(--ad-banner-landscape-w, 320px);
    height: var(--ad-banner-landscape-h, 60px);
}

/* When the landscape banner is visible, stack the viewport + banner vertically */
body.landscape-banner #game-viewport {
    aspect-ratio: unset;
}

body.landscape-banner {
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Shared label for both banner slots */
.ad-banner-label {
    font-size: 0.6rem;
    letter-spacing: 0.15em;
    color: var(--ad-label-color);
    font-weight: 700;
    text-transform: uppercase;
    line-height: 1;
}

/* Viewport fills all remaining space above the banner */
body.portrait-mode #game-viewport {
    /* aspect-ratio is overridden by the explicit JS dimensions;
       remove it here too so it can't fight flex sizing */
    aspect-ratio: unset;
    flex: 1 1 auto;
}

/* Portrait HUD tweaks — tighter spacing on a narrow screen */
/* Use body.portrait-mode #game-viewport as the selector so the ID gives
   enough specificity to override the size-mobile rules above. */
body.portrait-mode #game-viewport .hud-top-left {
    top: 14px;
    left: 16px;
    font-size: 1.7rem;
    gap: 7px;
}

body.portrait-mode #game-viewport .hud-top-left svg {
    width: 26px;
    height: 26px;
}

body.portrait-mode #game-viewport .hud-top-right {
    top: 10px;
    right: 14px;
    gap: 8px;
}

/* Score sits in the score zone below the chrome (top: 46px). */
body.portrait-mode #game-viewport .hud-center {
    top: 45px;
    height: 80px;
    justify-content: center;
}

body.portrait-mode #game-viewport .score-display {
    font-size: 3rem;
    line-height: 1;
}

body.portrait-mode #game-viewport .combo-display {
    font-size: 0.82rem;
    height: 1rem;
    margin-top: 3px;
}

body.portrait-mode .menu-btn {
    width: 34px;
    height: 39px;
}

body.portrait-mode .menu-btn svg:not(.hex-outline) {
    width: 55%;
    height: 55%;
}

/* Game-over card is slightly narrower in portrait */
body.portrait-mode .game-over-content {
    padding: 22px 32px 20px;
}

body.portrait-mode .game-over-overlay h2 {
    font-size: 2rem;
}

/* Quest HUD bar — full width in portrait; JS sets exact top position */
body.portrait-mode .quest-hud {
    width: 70%;
    bottom: auto !important;
    /* JS sets top dynamically after tray is laid out */
    font-size: 0.78rem;
}

/* ============================================================
   TEST LEVEL MODAL
   ============================================================ */
.test-level-modal {
    position: absolute;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(2, 6, 23, 0.88);
    backdrop-filter: blur(4px);
}

.test-level-modal.hidden {
    display: none;
}

.test-level-inner {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
    overflow: hidden;
    width: min(98%, 900px);
    max-height: 96%;
}

.test-level-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 14px;
    background: #1e293b;
    border-bottom: 1px solid #334155;
    flex-shrink: 0;
}

.test-level-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 0.95rem;
    color: #e2e8f0;
    letter-spacing: 0.03em;
}

.test-level-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid #475569;
    color: #94a3b8;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.test-level-close:hover {
    background: #ef4444;
    border-color: #ef4444;
    color: #fff;
}

.test-level-hud {
    width: 100%;
    flex-shrink: 0;
}

#testCanvas {
    display: block;
    width: 100%;
    flex-shrink: 0;
    /* height is set by JS via inline style */
}

.test-level-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(2, 6, 23, 0.82);
    z-index: 10;
}

.test-level-overlay.hidden {
    display: none;
}

.test-overlay-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 16px;
    padding: 28px 32px 24px;
    text-align: center;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
}

/* ===== Blitz Mode ===== */
.home-btn-blitz {
    background: linear-gradient(135deg, #f97316 0%, #ef4444 100%);
    color: #fff;
    box-shadow:
        0 4px 15px rgba(249, 115, 22, 0.4),
        0 0 40px rgba(249, 115, 22, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.home-btn-blitz:hover {
    background: linear-gradient(135deg, #fb923c 0%, #f97316 100%);
    box-shadow:
        0 8px 28px rgba(249, 115, 22, 0.65),
        0 0 80px rgba(249, 115, 22, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.home-btn-daily {
    background: linear-gradient(135deg, #a78bfa 0%, #7c3aed 100%);
    color: #fff;
    box-shadow:
        0 4px 15px rgba(167, 139, 250, 0.4),
        0 0 40px rgba(167, 139, 250, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.home-btn-daily:hover {
    background: linear-gradient(135deg, #c4b5fd 0%, #a78bfa 100%);
    box-shadow:
        0 8px 28px rgba(167, 139, 250, 0.65),
        0 0 80px rgba(167, 139, 250, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.blitz-timer-hud {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: monospace;
    font-weight: 800;
    font-size: 1.15rem;
    color: #fb923c;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    transition: color 0.3s;
}

.blitz-timer-hud.critical {
    color: #ef4444;
    animation: blitzPulse 0.4s ease-in-out infinite;
}

.blitz-timer-hud.frozen {
    color: #67e8f9;
    text-shadow: 0 0 12px rgba(103, 232, 249, 0.6), 0 2px 4px rgba(0, 0, 0, 0.5);
    animation: none;
}

@keyframes blitzPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

#game-viewport.size-mobile .blitz-timer-hud {
    font-size: 0.88rem;
}

body.portrait-mode #game-viewport .game-hud-currency {
    flex-wrap: wrap;
}

body.portrait-mode #game-viewport .blitz-timer-hud {
    font-size: 0.88rem;
}

/* ===== First-Run Tutorial Overlay ===== */
/* ===== Tutorial overlay — landscape two-column layout ===== */

#tutorialOverlay {
    position: absolute;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(2, 6, 23, 0.88);
    backdrop-filter: blur(2px);
    animation: tutorialFadeIn 0.35s ease;
    padding: 8px;
}

#tutorialOverlay.hidden {
    display: none;
}

@keyframes tutorialFadeIn {
    from { opacity: 0; transform: scale(0.97); }
    to   { opacity: 1; transform: scale(1); }
}

.tutorial-card {
    background: linear-gradient(160deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: 16px;
    padding: 20px 28px 18px;
    max-width: 760px;
    width: 92%;
    max-height: 96%;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(56, 189, 248, 0.08);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.tutorial-card::before {
    content: '';
    position: absolute;
    top: -60px;
    right: -60px;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(56, 189, 248, 0.07) 0%, transparent 70%);
    pointer-events: none;
}

.tutorial-header {
    text-align: center;
    margin-bottom: 14px;
}

.tutorial-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: #38bdf8;
    margin-bottom: 2px;
    letter-spacing: 0.01em;
}

.tutorial-subtitle {
    font-size: 0.7rem;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Two-column step grid */
.tutorial-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 24px;
    margin-bottom: 14px;
}

.tutorial-col {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tutorial-step {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.tutorial-step-icon {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.2);
}

.tutorial-step-text {
    flex: 1;
}

.tutorial-step-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: #e2e8f0;
    margin-bottom: 1px;
}

.tutorial-step-desc {
    font-size: 0.7rem;
    color: #94a3b8;
    line-height: 1.4;
}

.tutorial-step-desc strong {
    color: #cbd5e1;
}

.tutorial-tip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: 8px;
    padding: 8px 10px;
    margin-top: auto;
    font-size: 0.7rem;
    color: #fbbf24;
    line-height: 1.35;
}

.tutorial-tip svg {
    flex-shrink: 0;
    color: #f59e0b;
}

.tutorial-btn {
    width: 100%;
    padding: 10px 20px;
    background: linear-gradient(135deg, #0ea5e9 0%, #6366f1 100%);
    color: #fff;
    font-weight: 800;
    font-size: 0.85rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    letter-spacing: 0.03em;
    transition: opacity 0.15s, transform 0.1s;
    box-shadow: 0 4px 16px rgba(14, 165, 233, 0.35);
}

.tutorial-btn:hover {
    opacity: 0.92;
    transform: translateY(-1px);
}

.tutorial-btn:active {
    transform: translateY(0);
}

/* ── Portrait: stack columns vertically, allow scroll ── */
body.portrait-mode .tutorial-card {
    max-width: 420px;
    padding: 18px 18px 16px;
    max-height: 94%;
    overflow-y: auto;
}

body.portrait-mode .tutorial-body {
    grid-template-columns: 1fr;
    gap: 10px;
}

body.portrait-mode .tutorial-tip {
    margin-top: 0;
}

/* ============================================================
   ECONOMY — Credits, Energy, Shop, Power-ups
   ============================================================ */

/* ── Home Economy Bar ─────────────────────────────────────── */

.home-currency-row {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    z-index: 20;
}

.home-credits-badge,
.home-energy-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px 8px 10px;
    background: rgba(15, 23, 42, 0.82);
    border-radius: 50px;
    backdrop-filter: blur(8px);
    font-size: 1.15rem;
    font-weight: 900;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.home-credits-badge {
    border: 1px solid rgba(251, 191, 36, 0.35);
    color: #fbbf24;
}

.home-energy-badge {
    border: 1px solid rgba(56, 189, 248, 0.35);
    color: #38bdf8;
}

.home-credits-badge:hover,
.home-energy-badge:hover {
    background: rgba(30, 41, 59, 0.92);
    transform: translateY(-1px);
}

.home-credits-badge:hover {
    border-color: rgba(251, 191, 36, 0.6);
}

.home-energy-badge:hover {
    border-color: rgba(56, 189, 248, 0.6);
}

.home-economy-bar {
    display: none;
    /* replaced by .home-hex-nav */
}

/* ── Home Hex Nav (Shop / Achievements / Leaderboard) ─────── */

.home-hex-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    z-index: 20;
    margin-top: 4px;
    margin-bottom: 4px;
}

.home-hex-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0;
}

/* Hex border outline — now handled by inline SVG .hex-outline */
.home-hex-wrap::before {
    display: none;
}

.home-hex-btn {
    position: relative;
    width: 36px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    cursor: pointer;
    transition: filter 0.18s, color 0.18s;
    z-index: 1;
    color: rgba(56, 189, 248, 0.5);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
    filter: drop-shadow(0 0 4px var(--hex-glow, rgba(56, 189, 248, 0.25)));
}

.home-hex-btn .hex-outline {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Sprite icon inside home hex buttons */
.home-hex-sprite {
    width: 70%;
    height: 70%;
    min-width: 16px;
    min-height: 16px;
    max-width: 56px;
    max-height: 56px;
    object-fit: contain;
    transition: filter 0.18s;
    flex-shrink: 0;
    pointer-events: none;
    position: relative;
    filter: brightness(1.3) drop-shadow(0 0 3px var(--hex-glow, rgba(56, 189, 248, 0.25)));
}

/* Per-button accent colours */
.home-hex--shop {
    --hex-color: #8b5cf6;
    --hex-glow: rgba(139, 92, 246, 0.55);
}

.home-hex--ach {
    --hex-color: #f59e0b;
    --hex-glow: rgba(245, 158, 11, 0.55);
}

.home-hex--lb {
    --hex-color: #0ea5e9;
    --hex-glow: rgba(14, 165, 233, 0.55);
}

/* Hover — brighten outline + glow */
.home-hex-btn:hover {
    color: var(--hex-color);
    filter: drop-shadow(0 0 8px var(--hex-glow));
}

.home-hex-btn:hover .home-hex-sprite {
    filter: brightness(1.5) drop-shadow(0 0 6px var(--hex-glow));
}

.home-hex-btn:active {
    transform: scale(0.92);
    transition: transform 0.08s, filter 0.08s;
}

/* Tooltip — hidden by default, slides out below on hover */
.home-hex-tooltip {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 6px);
    transform: translateX(-50%) translateY(4px);
    background: rgba(15, 23, 42, 0.88);
    border: 1px solid var(--btn-border);
    border-radius: 8px;
    padding: 3px 10px;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #e2e8f0;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    backdrop-filter: blur(6px);
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 10;
}

.home-hex-wrap:hover .home-hex-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Tooltip accent color on hover */
.home-hex--shop:hover~.home-hex-tooltip {
    color: #8b5cf6;
    border-color: #8b5cf6;
}

.home-hex--ach:hover~.home-hex-tooltip {
    color: #f59e0b;
    border-color: #f59e0b;
}

.home-hex--lb:hover~.home-hex-tooltip {
    color: #0ea5e9;
    border-color: #0ea5e9;
}

.economy-credits {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #fbbf24;
    min-width: 44px;
}

.economy-energy {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #38bdf8;
}

.energy-pips {
    display: flex;
    gap: 3px;
    align-items: center;
}

.energy-pip {
    width: 9px;
    height: 9px;
    border-radius: 2px;
    background: rgba(148, 163, 184, 0.25);
    border: 1px solid rgba(148, 163, 184, 0.35);
    transition: background 0.2s;
}

.energy-pip.filled {
    background: #0ea5e9;
    border-color: #38bdf8;
    box-shadow: 0 0 4px rgba(14, 165, 233, 0.7);
}

/* Legacy — hidden, replaced by .home-hex-nav */
.shop-open-btn {
    display: none;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 800;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    letter-spacing: 0.02em;
    transition: opacity 0.15s, transform 0.1s;
    border-left: 1px solid rgba(148, 163, 184, 0.2);
    margin-left: 4px;
}

.shop-open-btn:hover {
    opacity: 0.88;
    transform: translateY(-1px);
}

/* ── Objective Banner ─────────────────────────────────────── */

.objective-banner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform: scale(0.7);
}

.objective-banner.hidden {
    display: none !important;
}

.objective-banner-show {
    opacity: 1 !important;
    transform: scale(1) !important;
}

.objective-banner-hide {
    opacity: 0 !important;
    transform: scale(0.85) !important;
}

.objective-banner-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 28px 40px;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.95));
    border: 2px solid rgba(251, 191, 36, 0.5);
    border-radius: 18px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6),
                0 0 30px rgba(251, 191, 36, 0.15),
                inset 0 1px 0 rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(12px);
    text-align: center;
    max-width: 85%;
}

.objective-banner-icon {
    color: #fbbf24;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    filter: drop-shadow(0 0 8px rgba(251, 191, 36, 0.5));
}

#objectiveBannerText {
    font-size: 1.3rem;
    font-weight: 900;
    color: #f1f5f9;
    letter-spacing: 0.03em;
    line-height: 1.4;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* ── Blitz Countdown ──────────────────────────────────────── */

.blitz-countdown {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 250;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.6) 0%, rgba(0, 0, 0, 0.85) 100%);
    pointer-events: all;
}

.blitz-countdown.hidden {
    display: none !important;
}

.blitz-countdown-text {
    font-size: 4rem;
    font-weight: 900;
    color: #fbbf24;
    text-shadow:
        0 0 30px rgba(251, 191, 36, 0.6),
        0 0 60px rgba(251, 191, 36, 0.3),
        0 4px 12px rgba(0, 0, 0, 0.5);
    letter-spacing: 0.05em;
    opacity: 0;
    transform: scale(0.5);
}

.blitz-countdown-pop {
    animation: countdownPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes countdownPop {
    0%   { opacity: 0; transform: scale(0.5); }
    30%  { opacity: 1; transform: scale(1.15); }
    50%  { transform: scale(0.95); }
    70%  { transform: scale(1.02); }
    100% { opacity: 1; transform: scale(1); }
}

/* ── Shop Modal ───────────────────────────────────────────── */

.shop-modal-content {
    max-width: 420px;
    max-height: calc(100% - 24px);
    overflow-y: auto;
    padding: 14px 16px 16px;
}

#game-viewport.size-tablet .shop-modal-content,
#game-viewport.size-desktop .shop-modal-content {
    max-width: 640px;
    padding: 20px 32px 28px;
}

.shop-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.shop-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 8px;
    padding: 3px;
}

.shop-tab {
    flex: 1;
    padding: 7px 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #94a3b8;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    letter-spacing: 0.03em;
}

.shop-tab:hover {
    color: #cbd5e1;
}

.shop-tab.active {
    background: rgba(99, 102, 241, 0.25);
    color: #e2e8f0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.shop-tab-panel {
    display: none;
}

.shop-tab-panel.active {
    display: block;
}

.shop-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 1.1rem;
    font-weight: 900;
    color: #e2e8f0;
    flex: 1;
    letter-spacing: 0.02em;
}

.shop-currency-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.82rem;
    font-weight: 700;
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.25);
    border-radius: 50px;
    padding: 3px 10px;
}

.shop-close-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    transition: color 0.15s, background 0.15s;
    display: flex;
    align-items: center;
}

.shop-close-btn:hover {
    color: #e2e8f0;
    background: rgba(148, 163, 184, 0.12);
}

.shop-section-label {
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
    margin: 10px 0 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(100, 116, 139, 0.2);
}

.shop-section-label:first-of-type {
    margin-top: 2px;
}

.shop-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.08);
}

.shop-row:last-of-type {
    border-bottom: none;
}

.shop-row-icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.shop-icon--gold {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}

.shop-icon--cyan {
    background: rgba(34, 211, 238, 0.12);
    color: #22d3ee;
}

.shop-icon--amber {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.shop-icon--emerald {
    background: rgba(52, 211, 153, 0.15);
    color: #34d399;
}

.shop-icon--violet {
    background: rgba(167, 139, 250, 0.15);
    color: #a78bfa;
}

.shop-row-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.shop-row-name {
    font-size: 0.82rem;
    font-weight: 700;
    color: #e2e8f0;
}

.shop-row-desc {
    font-size: 0.72rem;
    color: #94a3b8;
}

.shop-row-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
    color: #94a3b8;
    margin-top: 1px;
}

.shop-row-reward {
    font-weight: 600;
    color: #cbd5e1;
}

.shop-action-btn {
    padding: 6px 14px;
    border-radius: 10px;
    border: none;
    font-size: 0.78rem;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: opacity 0.15s, transform 0.1s;
    letter-spacing: 0.02em;
}

.shop-action-btn:hover:not(:disabled) {
    opacity: 0.85;
    transform: translateY(-1px);
}

.shop-action-btn:active:not(:disabled) {
    transform: translateY(0);
}

.shop-action-btn:disabled {
    opacity: 0.38;
    cursor: not-allowed;
}

.shop-btn--gold {
    background: linear-gradient(135deg, #d97706, #fbbf24);
    color: #1a1a2e;
}

.shop-btn--cyan {
    background: linear-gradient(135deg, #0891b2, #22d3ee);
    color: #fff;
}

.shop-btn--amber {
    background: linear-gradient(135deg, #b45309, #f59e0b);
    color: #fff;
}

.shop-btn--emerald {
    background: linear-gradient(135deg, #059669, #34d399);
    color: #fff;
}

.shop-btn--violet {
    background: linear-gradient(135deg, #7c3aed, #a78bfa);
    color: #fff;
}

.btn-claimed {
    opacity: 0.45 !important;
    cursor: not-allowed !important;
}

/* ── Shop Cosmetics Grid ──────────────────────────────────────────────── */

.shop-cosmetic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    padding: 8px 0 14px;
}

.shop-cosm-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 10px;
    padding: 8px 6px 10px;
    transition: border-color 0.15s;
}

.shop-cosm-card.active {
    border-color: #22d3ee;
    box-shadow: 0 0 8px rgba(34, 211, 238, 0.25);
}

.shop-cosm-card.locked {
    opacity: 0.72;
}

.shop-cosm-card canvas {
    width: 80px;
    height: 80px;
    border-radius: 6px;
}

.shop-cosm-name {
    font-size: 0.62rem;
    font-weight: 700;
    color: #cbd5e1;
    text-align: center;
    margin-top: 4px;
    line-height: 1.2;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shop-cosm-badge {
    font-size: 0.52rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    padding: 2px 8px;
    border-radius: 6px;
    margin-top: 4px;
}

.shop-cosm-badge--active {
    background: rgba(34, 211, 238, 0.15);
    color: #22d3ee;
}

.shop-cosm-lock {
    position: absolute;
    top: 6px;
    right: 6px;
    font-size: 0.7rem;
    opacity: 0.7;
}

.shop-cosm-actions {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    width: 100%;
}

.shop-cosm-btn {
    flex: 1;
    padding: 4px 0;
    border: none;
    border-radius: 6px;
    font-size: 0.58rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
}

.shop-cosm-btn:hover { opacity: 0.8; }

.shop-cosm-btn--buy {
    background: linear-gradient(135deg, #0f766e, #14b8a6);
    color: #f0fdfa;
}

.shop-cosm-btn--ad {
    background: linear-gradient(135deg, #0891b2, #22d3ee);
    color: #fff;
}

.shop-cosm-btn--use {
    background: linear-gradient(135deg, #059669, #34d399);
    color: #fff;
    margin-top: 4px;
    padding: 4px 12px;
}

.shop-energy-display {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0 6px;
    color: #f59e0b;
    font-size: 0.8rem;
    font-weight: 600;
}

.shop-energy-timer-wrap {
    font-size: 0.74rem;
    color: #94a3b8;
    margin-left: 4px;
}

.shop-timer-val {
    font-weight: 700;
    color: #f59e0b;
}

.shop-bonus-timer-row {
    display: none; /* legacy — replaced by .shop-row-meta */
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    margin-top: 2px;
    color: rgba(148, 163, 184, 0.8);
}

.shop-bonus-timer-label {
    font-weight: 600;
}

.shop-bonus-sep {
    opacity: 0.4;
}

.shop-bonus-claims {
    font-weight: 600;
    color: rgba(148, 163, 184, 0.6);
}

/* Power-up shop grid */
.shop-powerup-note {
    font-size: 0.74rem;
    color: #64748b;
    margin: 2px 0 8px;
}

.shop-powerup-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.shop-pu-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 6px;
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(100, 116, 139, 0.2);
    border-radius: 12px;
    text-align: center;
}

.shop-pu-icon {
    font-size: 1.4rem;
    line-height: 1;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
}

.shop-pu-name {
    font-size: 0.72rem;
    font-weight: 800;
    color: #e2e8f0;
}

.shop-pu-desc {
    font-size: 0.62rem;
    color: #64748b;
    line-height: 1.3;
}

.shop-pu-count {
    font-size: 0.72rem;
    font-weight: 700;
    color: #94a3b8;
}

.shop-pu-ad-btn {
    width: 100%;
    font-size: 0.68rem !important;
    padding: 4px 6px !important;
}

/* ── Slot Unlock Modal ────────────────────────────────────── */

.slot-unlock-content {
    max-width: 320px;
    padding: 28px 24px 24px;
    text-align: center;
}

.slot-unlock-icon {
    font-size: 2.2rem;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 8px rgba(251, 191, 36, 0.45));
}

.slot-unlock-title {
    font-size: 1.15rem;
    font-weight: 900;
    color: #fbbf24;
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

.slot-unlock-desc {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 18px;
    line-height: 1.5;
}

.slot-unlock-actions {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.slot-unlock-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 11px 16px;
    border-radius: 12px;
    border: none;
    font-size: 0.85rem;
    font-weight: 800;
    cursor: pointer;
    letter-spacing: 0.02em;
    transition: opacity 0.15s, transform 0.1s;
    font-family: inherit;
}

.slot-unlock-btn:hover {
    opacity: 0.88;
    transform: translateY(-1px);
}

.slot-unlock-btn:active {
    transform: translateY(0);
}

.slot-unlock-btn--coins {
    background: linear-gradient(135deg, #d97706, #fbbf24);
    color: #1a1200;
    box-shadow: 0 4px 14px rgba(251, 191, 36, 0.35);
    position: relative;
}

.slot-unlock-btn--coins:disabled {
    opacity: 0.38;
    cursor: not-allowed;
    transform: none;
}

.slot-unlock-balance {
    position: absolute;
    right: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    opacity: 0.7;
}

.slot-unlock-btn--ad {
    background: linear-gradient(135deg, #0891b2, #6366f1);
    color: #fff;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
}

.slot-unlock-btn--cancel {
    background: rgba(51, 65, 85, 0.7);
    color: #94a3b8;
    border: 1px solid rgba(100, 116, 139, 0.3);
}

.slot-unlock-btn--cancel:hover {
    background: rgba(71, 85, 105, 0.85);
    color: #e2e8f0;
}

/* ── Abandon Session Modal ────────────────────────────────── */

.abandon-modal-content {
    max-width: 320px;
    padding: 28px 24px 24px;
    text-align: center;
}

.abandon-icon {
    font-size: 2.2rem;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 8px rgba(234, 179, 8, 0.45));
}

.abandon-title {
    font-size: 1.15rem;
    font-weight: 900;
    color: #fbbf24;
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

.abandon-desc {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 18px;
    line-height: 1.5;
}

.abandon-desc strong {
    color: #e2e8f0;
}

.abandon-actions {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.abandon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 11px 16px;
    border-radius: 12px;
    border: none;
    font-size: 0.85rem;
    font-weight: 800;
    cursor: pointer;
    letter-spacing: 0.02em;
    transition: opacity 0.15s, transform 0.1s;
    font-family: inherit;
}

.abandon-btn:hover {
    opacity: 0.88;
    transform: translateY(-1px);
}

.abandon-btn:active {
    transform: translateY(0);
}

.abandon-btn--continue {
    background: linear-gradient(135deg, #dc2626, #f97316);
    color: #fff;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
}

.abandon-btn--cancel {
    background: rgba(51, 65, 85, 0.7);
    color: #94a3b8;
    border: 1px solid rgba(100, 116, 139, 0.3);
}

.abandon-btn--cancel:hover {
    background: rgba(71, 85, 105, 0.85);
    color: #e2e8f0;
}

/* ── Energy Gate Modal ────────────────────────────────────── */

/* ── Energy Modal ─────────────────────────────────────────── */

.energy-modal-content {
    max-width: 320px;
    padding: 24px 24px 28px;
    text-align: center;
}

.energy-modal-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
    position: relative;
}

.energy-modal-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 1.1rem;
    font-weight: 900;
    color: #38bdf8;
    letter-spacing: 0.02em;
}

.energy-modal-header .shop-close-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

.energy-pips--lg {
    justify-content: center;
    gap: 10px;
    margin-bottom: 6px;
}

.energy-pips--lg .energy-pip {
    width: 20px;
    height: 20px;
}

.energy-modal-count {
    font-size: 1rem;
    font-weight: 700;
    color: #38bdf8;
    margin-bottom: 14px;
}

/* ── Energy Gate Modal ────────────────────────────────────── */

.energy-gate-content {
    max-width: 340px;
    padding: 28px 24px;
    text-align: center;
}

.energy-gate-icon {
    font-size: 2.4rem;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.6));
}

.energy-gate-title {
    font-size: 1.2rem;
    font-weight: 900;
    color: #38bdf8;
    margin-bottom: 8px;
}

.energy-gate-desc {
    font-size: 0.82rem;
    color: #94a3b8;
    line-height: 1.5;
    margin-bottom: 12px;
}

.energy-gate-timer-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 16px;
}

.energy-gate-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.energy-gate-actions .shop-action-btn {
    width: 100%;
    padding: 10px 16px;
    font-size: 0.84rem;
}

/* ── Power-up HUD (in-game) ───────────────────────────────── */

/* ── Powerup HUD ────────────────────────────────────────────── */

.powerup-hud {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    transform: none;
    display: block;
    gap: 0;
    z-index: 20;
    pointer-events: none;
    transition: z-index 0s;
}

/* While a piece is being dragged, drop below the canvas (z-index: 10)
   so the canvas-rendered piece draws over the powerup buttons. */
.powerup-hud--behind {
    z-index: 5;
    pointer-events: none;
}

/* .powerup-hud--landscape — toggled by JS; base .powerup-hud already covers overlay styles */

/* Each row: button + the sliding tooltip beside it */
.pu-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0;
}

/* Hex border outline — rendered as a pseudo behind the clipped button.
   Unaffected by button opacity, so empty-state buttons still show the border. */
.pu-wrap::before {
    display: none; /* replaced by inline SVG hex-outline */
}

/* Each wrap is absolutely positioned by JS (both portrait and landscape) */
.powerup-hud .pu-wrap {
    position: absolute;
    pointer-events: all;
}

/* Landscape: badge pinned to the rightmost edge of each hex */
.powerup-hud--landscape .pu-badge {
    top: 50%;
    bottom: auto;
    right: -6px;
    left: auto;
    transform: translateY(-50%);
    min-width: 22px;
    height: 22px;
    font-size: 0.75rem;
}

/* Left-side tooltips: slide out to the left instead of right */
.side-left .pu-tooltip {
    left: auto;
    right: calc(100% + 8px);
    transform: translateY(-50%) translateX(6px);
}

.side-left:hover .pu-tooltip,
.side-left .pu-btn.pu-active~.pu-tooltip {
    transform: translateY(-50%) translateX(0);
}

/* Left-side action tooltips */
.side-left .act-tooltip {
    left: auto;
    right: calc(100% + 8px);
    transform: translateY(-50%) translateX(6px);
}

.side-left:hover .act-tooltip {
    transform: translateY(-50%) translateX(0);
}

/* Left-side action locked play icon: flip to left */
.side-left.act-wrap:has(.act-locked)::after {
    right: auto;
    left: -14px;
}

/* Pointy-top hex button — transparent with SVG outline */
.pu-btn {
    position: relative;
    width: 40px;
    height: 46px;
    /* pointy-top: h = w / (√3/2) ≈ w * 1.155 */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    cursor: pointer;
    transition: filter 0.18s, color 0.18s;
    z-index: 1;
    color: rgba(56, 189, 248, 0.5);
    filter: drop-shadow(0 0 4px var(--pu-glow, rgba(56, 189, 248, 0.25)));
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}

.pu-btn .hex-outline {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Per-powerup accent colours */
.pu-btn--bomb {
    --pu-color: #f97316;
    --pu-glow: rgba(249, 115, 22, 0.55);
}

.pu-btn--drill {
    --pu-color: #38bdf8;
    --pu-glow: rgba(56, 189, 248, 0.55);
}

.pu-btn--scissors {
    --pu-color: #a78bfa;
    --pu-glow: rgba(167, 139, 250, 0.55);
}

.pu-btn--hammer {
    --pu-color: #34d399;
    --pu-glow: rgba(52, 211, 153, 0.55);
}

/* Icon scales with button — ~55% of button width, clamped to a readable range */
.pu-btn .pu-svg,
.pu-btn .pu-sprite {
    width: 70%;
    height: 70%;
    min-width: 16px;
    min-height: 16px;
    max-width: 56px;
    max-height: 56px;
    object-fit: contain;
    transition: filter 0.18s;
    flex-shrink: 0;
    pointer-events: none;
}

.pu-btn .pu-sprite {
    position: relative;
    filter: brightness(1.3) drop-shadow(0 0 3px var(--pu-glow));
}

.pu-btn:hover:not(.pu-empty) .pu-sprite {
    filter: brightness(1.5) drop-shadow(0 0 6px var(--pu-glow));
}

.pu-btn.pu-active .pu-sprite {
    filter: brightness(1.6) drop-shadow(0 0 8px var(--pu-glow));
}

/* Count badge — portrait: bottom-right corner; landscape: outer midpoint (see below) */
.pu-badge {
    position: absolute;
    bottom: -5px;
    right: -5px;
    min-width: 26px;
    height: 26px;
    padding: 0 6px;
    background: rgba(15, 23, 42, 0.92);
    border: 2px solid var(--btn-border);
    border-radius: 50px;
    font-size: 0.82rem;
    font-weight: 900;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    pointer-events: none;
    z-index: 5;
    transition: background 0.18s, border-color 0.18s, color 0.18s;
}

/* Tooltip label — hidden by default, slides out to the right on hover */
.pu-tooltip {
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%) translateX(-6px);
    background: rgba(15, 23, 42, 0.88);
    border: 1px solid var(--btn-border);
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #e2e8f0;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    backdrop-filter: blur(6px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

/* Slide out on hover of the wrapper (works even if pointer is on button) */
.pu-wrap:hover .pu-tooltip {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* Tooltip also shows when button is actively selected */
.pu-btn.pu-active~.pu-tooltip {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
    color: var(--pu-color);
    border-color: var(--pu-color);
}

/* Hover state — brighten outline glow */
.pu-btn:hover:not(.pu-empty):not(:disabled) {
    color: var(--pu-color);
    filter: drop-shadow(0 0 8px var(--pu-glow));
}

.pu-wrap:hover .pu-btn:not(.pu-empty):not(:disabled)+.pu-badge {
    border-color: var(--pu-color);
    color: var(--pu-color);
}

/* Active (selected) */
.pu-btn.pu-active {
    color: var(--pu-color);
    filter: drop-shadow(0 0 10px var(--pu-glow));
    animation: pu-pulse 1.8s ease-in-out infinite;
}

.pu-btn.pu-active+.pu-badge {
    background: color-mix(in srgb, var(--pu-color) 60%, #0f172a);
    border-color: var(--pu-color);
    color: #fff;
}

@keyframes pu-pulse {

    0%,
    100% {
        filter:
            drop-shadow(1.5px 0 0 var(--pu-color)) drop-shadow(-1.5px 0 0 var(--pu-color)) drop-shadow(0 1.5px 0 var(--pu-color)) drop-shadow(0 -1.5px 0 var(--pu-color)) drop-shadow(0 0 10px var(--pu-glow));
    }

    50% {
        filter:
            drop-shadow(1.5px 0 0 var(--pu-color)) drop-shadow(-1.5px 0 0 var(--pu-color)) drop-shadow(0 1.5px 0 var(--pu-color)) drop-shadow(0 -1.5px 0 var(--pu-color)) drop-shadow(0 0 20px var(--pu-glow));
    }
}

/* Empty / Buy mode — dimmer fill, border stays full opacity via ::before pseudo */
.pu-btn.pu-empty {
    cursor: pointer;
    color: rgba(100, 116, 139, 0.3);
    filter: none;
}

.pu-btn.pu-empty::after {
    content: "+";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.2rem;
    font-weight: 700;
    color: #38bdf8;
    text-shadow: 0 0 8px rgba(0, 0, 0, 0.9);
    pointer-events: none;
    z-index: 10;
}

.pu-btn.pu-empty .pu-svg,
.pu-btn.pu-empty .pu-sprite {
    opacity: 0.2;
}

.pu-btn.pu-empty+.pu-badge {
    opacity: 0;
}

.pu-btn:disabled {
    cursor: not-allowed;
    opacity: 0.38;
}

/* ── Watch-Ad Game-Over Button ────────────────────────────── */

.go-watch-ad-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #10b981, #06b6d4);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 800;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    width: 100%;
    letter-spacing: 0.03em;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.35), 0 0 0 1px rgba(16, 185, 129, 0.15);
    text-transform: uppercase;
}

.go-watch-ad-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45), 0 0 0 1px rgba(16, 185, 129, 0.25);
}

/* ── Toast notification ───────────────────────────────────── */

.economy-toast {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 7px 18px;
    border-radius: 50px;
    font-size: 0.84rem;
    font-weight: 800;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 200;
    letter-spacing: 0.02em;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.economy-toast.toast-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.economy-toast--gold {
    background: #d97706;
    color: #fff;
}

.economy-toast--cyan {
    background: #0891b2;
    color: #fff;
}

.economy-toast--amber {
    background: #b45309;
    color: #fff;
}

.economy-toast--red {
    background: #dc2626;
    color: #fff;
}

.economy-toast--emerald {
    background: linear-gradient(135deg, #059669, #34d399);
    color: #fff;
}

.economy-toast--violet {
    background: linear-gradient(135deg, #7c3aed, #a78bfa);
    color: #fff;
}

/* ── Light theme adjustments ──────────────────────────────── */

.light-theme .home-economy-bar {
    background: rgba(241, 245, 249, 0.9);
    border-color: rgba(100, 116, 139, 0.25);
}

.light-theme .home-hex-wrap::before,
.light-theme .menu-hex-wrap::before {
    background: #94a3b8;
}

.light-theme .home-hex-tooltip {
    background: rgba(241, 245, 249, 0.92);
    border-color: rgba(100, 116, 139, 0.3);
    color: #334155;
}

.light-theme .home-credits-badge,
.light-theme .home-energy-badge {
    background: rgba(241, 245, 249, 0.92);
}

.light-theme .home-credits-badge {
    border-color: rgba(180, 130, 10, 0.4);
    color: #b45309;
}

.light-theme .home-energy-badge {
    border-color: rgba(180, 100, 10, 0.4);
    color: #b45309;
}

.light-theme .home-credits-badge:hover,
.light-theme .home-energy-badge:hover {
    background: rgba(226, 232, 240, 0.97);
}

/* Light-theme: fill hex polygons with white to match the coin/energy pill style */
.light-theme .pu-btn .hex-outline polygon,
.light-theme .act-btn .hex-outline polygon,
.light-theme .menu-btn .hex-outline polygon,
.light-theme .home-hex-btn .hex-outline polygon,
.light-theme .pu-fan-toggle .hex-outline polygon,
.light-theme .act-fan-toggle .hex-outline polygon {
    fill: rgba(241, 245, 249, 0.92);
    stroke: rgba(148, 163, 184, 0.5);
}

.light-theme .pu-btn,
.light-theme .act-btn,
.light-theme .menu-btn,
.light-theme .home-hex-btn,
.light-theme .pu-fan-toggle,
.light-theme .act-fan-toggle {
    color: #475569;
    filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.1));
}

.light-theme .pu-btn .pu-sprite,
.light-theme .act-btn .act-sprite {
    filter: none;
}

.light-theme .pu-wrap::before {
    background: rgba(100, 116, 139, 0.45);
}

.light-theme .pu-btn:hover:not(.pu-empty):not(:disabled),
.light-theme .pu-btn.pu-active {
    color: var(--pu-color);
}

.light-theme .pu-btn:hover:not(.pu-empty):not(:disabled) .hex-outline polygon,
.light-theme .act-btn:hover:not(.act-locked) .hex-outline polygon,
.light-theme .menu-btn:hover .hex-outline polygon,
.light-theme .home-hex-btn:hover .hex-outline polygon,
.light-theme .pu-fan-toggle:hover .hex-outline polygon,
.light-theme .act-fan-toggle:hover .hex-outline polygon {
    fill: rgba(255, 255, 255, 0.97);
    stroke: rgba(100, 116, 139, 0.6);
}

/* Override the rectangular gradient on act-ready/act-used in light theme */
.light-theme .act-btn.act-ready {
    background: transparent;
}
.light-theme .act-btn.act-ready .hex-outline polygon {
    fill: rgba(56, 189, 248, 0.2);
    stroke: #38bdf8;
}
.light-theme .act-btn.act-ready {
    color: #0284c7;
}
.light-theme .act-btn.act-used {
    background: transparent;
}

.light-theme .pu-label {
    color: inherit;
}

.light-theme .pu-count {
    background: rgba(100, 116, 139, 0.18);
    color: #1e293b;
}

/* ============================================================
   ACTION HUD
   ============================================================ */

/* Container — mirrors powerup-hud but on the left diagonal */
.action-hud {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 12;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
}

.action-hud--landscape {
    pointer-events: none;
}

.act-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0;
    pointer-events: all;
}

/* Hex border outline — matches pu-wrap::before exactly */
.act-wrap::before {
    display: none; /* replaced by inline SVG hex-outline */
}

.action-hud--landscape .act-wrap,
.powerup-hud--landscape .act-wrap,
.powerup-hud .act-wrap {
    position: absolute;
    pointer-events: all;
}

/* Pointy-top hex button — identical to .pu-btn / .menu-btn base */
.act-btn {
    position: relative;
    width: 40px;
    height: 46px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 0;
    cursor: pointer;
    transition: filter 0.18s, color 0.18s;
    z-index: 1;
    color: rgba(56, 189, 248, 0.5);
    filter: drop-shadow(0 0 4px var(--act-glow, rgba(56, 189, 248, 0.25)));
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}

.act-btn .hex-outline {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Per-action accent colours — matched to paired powerup icons */
.act-btn--hold {
    --act-color: #38bdf8;
    --act-glow: rgba(56, 189, 248, 0.55);
}

.act-btn--next {
    --act-color: #34d399;
    --act-glow: rgba(52, 211, 153, 0.55);
}

/* Holding indicator — piece is stored */
.act-btn.act-holding {
    color: #38bdf8;
    filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.55));
}

.act-btn .act-svg,
.act-btn .act-sprite {
    width: 70%;
    height: 70%;
    min-width: 16px;
    min-height: 16px;
    max-width: 56px;
    max-height: 56px;
    object-fit: contain;
    pointer-events: none;
    transition: opacity 0.18s, filter 0.18s;
    flex-shrink: 0;
}

.act-btn .act-sprite {
    position: relative;
    filter: brightness(1.3) drop-shadow(0 0 3px var(--act-glow));
}

.act-btn:hover:not(.act-locked) .act-sprite {
    filter: brightness(1.5) drop-shadow(0 0 6px var(--act-glow));
}

/* Tooltip — pops out to the right */
.act-tooltip {
    position: absolute;
    top: 50%;
    left: calc(100% + 6px);
    right: auto;
    transform: translateY(-50%) translateX(-6px);
    white-space: nowrap;
    font: 700 0.65rem / 1 'Inter', sans-serif;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(148, 163, 184, 0.7);
    background: rgba(15, 23, 42, 0.72);
    padding: 3px 7px;
    border-radius: 4px;
    border: 1px solid rgba(100, 116, 139, 0.25);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s, transform 0.15s;
    z-index: 5;
}

.act-wrap:hover .act-tooltip {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* ── Locked state (default on game start) ── */
.act-btn.act-locked {
    cursor: pointer;
    color: rgba(100, 116, 139, 0.3);
    filter: none;
}

/* Play icon lives on the wrap (not the btn) so clip-path doesn't cut it */
.act-wrap:has(.act-locked)::after {
    content: "▶";
    position: absolute;
    top: 50%;
    right: -14px;
    transform: translateY(-50%);
    font-size: 0.8rem;
    line-height: 1;
    color: #38bdf8;
    background: rgba(15, 23, 42, 0.92);
    border: 2px solid rgba(56, 189, 248, 0.5);
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 2px;
    pointer-events: none;
    z-index: 10;
}

.act-btn.act-locked .act-svg,
.act-btn.act-locked .act-sprite {
    opacity: 0.55;
}

/* Lock badge — padlock icon opposite the play icon */
.act-lock-badge {
    position: absolute;
    top: 50%;
    left: -14px;
    right: auto;
    transform: translateY(-50%);
    width: 26px;
    height: 26px;
    background: rgba(15, 23, 42, 0.92);
    border: 2px solid rgba(202, 163, 45, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    pointer-events: none;
    color: #e6b830;
}

.act-lock-badge svg {
    width: 14px;
    height: 14px;
}

/* Hide lock badge when unlocked */
.act-wrap:has(.act-ready) .act-lock-badge,
.act-wrap:has(.act-holding) .act-lock-badge {
    display: none;
}

/* Left side: lock badge flips to the right (play icon is on left) */
.side-left .act-lock-badge {
    left: auto;
    right: -14px;
}

/* ── Active / unlocked state — matches menu-btn:hover glow ── */
.act-btn.act-ready {
    background: linear-gradient(145deg,
            color-mix(in srgb, #38bdf8 55%, #1e293b) 0%,
            color-mix(in srgb, #38bdf8 25%, #0f172a) 100%);
    color: #fff;
    filter:
        drop-shadow(1.5px 0 0 #38bdf8) drop-shadow(-1.5px 0 0 #38bdf8) drop-shadow(0 1.5px 0 #38bdf8) drop-shadow(0 -1.5px 0 #38bdf8) drop-shadow(0 0 8px rgba(56, 189, 248, 0.55));
    animation: act-pulse 1.8s ease-in-out infinite;
}

@keyframes act-pulse {

    0%,
    100% {
        filter:
            drop-shadow(1.5px 0 0 #38bdf8) drop-shadow(-1.5px 0 0 #38bdf8) drop-shadow(0 1.5px 0 #38bdf8) drop-shadow(0 -1.5px 0 #38bdf8) drop-shadow(0 0 8px rgba(56, 189, 248, 0.55));
    }

    50% {
        filter:
            drop-shadow(1.5px 0 0 #38bdf8) drop-shadow(-1.5px 0 0 #38bdf8) drop-shadow(0 1.5px 0 #38bdf8) drop-shadow(0 -1.5px 0 #38bdf8) drop-shadow(0 0 20px rgba(56, 189, 248, 0.55));
    }
}

/* Hover when ready */
.act-btn.act-ready:hover {
    background: linear-gradient(145deg,
            color-mix(in srgb, #38bdf8 65%, #1e293b) 0%,
            color-mix(in srgb, #38bdf8 35%, #0f172a) 100%);
}

/* ── Used state (dimmed, not clickable) ── */
.act-btn.act-used {
    cursor: not-allowed;
    opacity: 0.32;
    pointer-events: none;
}

/* Light theme overrides */
.light-theme .act-wrap::before {
    background: rgba(100, 116, 139, 0.45);
}

/* ============================================================
   SHARED: Challenge back button (Daily / Weekly) — hex shape
   ============================================================ */

.challenge-back-wrap {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 55;
}

/* ============================================================
   DAILY CHALLENGE
   ============================================================ */

.daily-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
    padding: 56px 16px 12px;
    overflow-y: auto;
    box-sizing: border-box;
    gap: 12px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.daily-page::-webkit-scrollbar {
    display: none;
}

/* ── Header ── */
.daily-header {
    text-align: center;
    width: 100%;
}

.daily-header-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #f59e0b;
}

.daily-title {
    font-size: 1.5rem;
    font-weight: 900;
    color: #f59e0b;
    margin: 0;
    line-height: 1.1;
}

.daily-date {
    font-size: 0.85rem;
    color: #94a3b8;
    margin: 2px 0 0;
}

.daily-progress-text {
    font-size: 0.8rem;
    color: #64748b;
    margin: 2px 0 0;
}

/* ── Level cards ── */
.daily-level-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 480px;
}

.daily-level-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #1e293b;
    border: 2px solid #334155;
    border-radius: 14px;
    padding: 12px 36px 12px 14px;
    transition: border-color 0.15s, transform 0.1s;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.daily-level-card.daily-card--available {
    border-color: #f59e0b;
    cursor: pointer;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.2);
}

.daily-level-card.daily-card--available:hover {
    transform: translateY(-1px);
    border-color: #fbbf24;
}

.daily-level-card.daily-card--claimed {
    border-color: #059669;
    background: rgba(5, 150, 105, 0.1);
    opacity: 0.85;
}

.daily-level-card.daily-card--locked {
    opacity: 0.45;
    filter: grayscale(0.4);
}

/* Step number circle */
.daily-card-step {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #334155;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 800;
    color: #94a3b8;
}

.daily-card--available .daily-card-step {
    background: #92400e;
    color: #fef3c7;
}

.daily-card--claimed .daily-card-step {
    background: #065f46;
    color: #a7f3d0;
}

/* Card body */
.daily-card-body {
    flex: 1;
    min-width: 0;
}

.daily-card-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.daily-card--available .daily-card-name {
    color: #fef3c7;
}

.daily-card--claimed .daily-card-name {
    color: #34d399;
}

.daily-card-target {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 2px;
}

.daily-card-score {
    font-size: 0.75rem;
    color: #34d399;
    margin-top: 2px;
    font-weight: 600;
}

/* Rewards column */
.daily-card-rewards {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-end;
    flex-shrink: 0;
}

/* Claimed checkmark */
.daily-card-checkmark {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.4rem;
    color: #34d399;
    font-weight: 900;
    pointer-events: none;
}

/* Available arrow */
.daily-card-arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1rem;
    color: #f59e0b;
    pointer-events: none;
}

/* ── Reward pills ── */
.daily-reward-pill {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    white-space: nowrap;
}

.daily-reward-coins {
    background: rgba(245, 158, 11, 0.18);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.daily-reward-pu {
    background: rgba(167, 139, 250, 0.18);
    color: #c4b5fd;
    border: 1px solid rgba(167, 139, 250, 0.3);
}

.daily-reward-energy {
    background: rgba(56, 189, 248, 0.18);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.daily-reward-trophy {
    background: rgba(250, 204, 21, 0.18);
    color: #facc15;
    border: 1px solid rgba(250, 204, 21, 0.35);
    animation: trophy-pill-glow 2s ease-in-out infinite;
}

.daily-reward-trophy--earned {
    background: rgba(52, 211, 153, 0.18);
    color: #34d399;
    border: 1px solid rgba(52, 211, 153, 0.35);
    animation: none;
}

@keyframes trophy-pill-glow {
    0%, 100% { box-shadow: 0 0 4px rgba(250, 204, 21, 0.2); }
    50%      { box-shadow: 0 0 10px rgba(250, 204, 21, 0.45); }
}

/* ── Reward legend row (below cards) ── */
.daily-reward-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.daily-legend-label {
    font-size: 0.75rem;
    color: #64748b;
}

/* ── Back button ── */
.daily-back-home-btn {
    margin-top: 4px;
    background: #0f766e !important;
    color: #f0fdfa !important;
    border: 1px solid #14b8a6 !important;
    font-size: 0.85rem !important;
    padding: 8px 20px !important;
}

.daily-back-home-btn:hover {
    background: #14b8a6 !important;
    color: #fff !important;
}

/* ── Daily Level Complete overlay ── */
.daily-complete-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.daily-complete-card {
    background: linear-gradient(145deg, #1e293b, #0f172a);
    border: 2px solid #f59e0b;
    border-radius: 20px;
    padding: 28px 32px;
    max-width: 340px;
    width: 90%;
    text-align: center;
    box-shadow: 0 0 40px rgba(245, 158, 11, 0.3), 0 8px 32px rgba(0, 0, 0, 0.6);
    animation: dailyCardIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes dailyCardIn {
    from {
        transform: scale(0.7) translateY(20px);
        opacity: 0;
    }

    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.daily-complete-icon {
    font-size: 2.5rem;
    margin-bottom: 6px;
}

.daily-complete-title {
    font-size: 1.5rem;
    font-weight: 900;
    color: #f59e0b;
    margin: 0 0 4px;
}

.daily-complete-level-name {
    font-size: 0.9rem;
    color: #94a3b8;
    margin: 0 0 4px;
}

.daily-complete-score {
    font-size: 1rem;
    font-weight: 700;
    color: #e2e8f0;
    margin: 0 0 16px;
}

/* Rewards row inside complete card */
.daily-rewards-row {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 12px;
}

.daily-reward-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #0f172a;
    border-radius: 12px;
    padding: 10px 18px;
    border: 1px solid #334155;
    min-width: 90px;
}

.daily-reward-badge--coins {
    border-color: rgba(245, 158, 11, 0.5);
}

.daily-reward-badge--pu {
    border-color: rgba(167, 139, 250, 0.5);
}

.daily-reward-badge-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    margin-bottom: 4px;
}

.daily-reward-badge-value {
    font-size: 1.25rem;
    font-weight: 800;
}

.daily-reward-badge--coins .daily-reward-badge-value {
    color: #fbbf24;
}

.daily-reward-badge--pu .daily-reward-badge-value {
    color: #c4b5fd;
}

.daily-reward-badge--energy {
    border-color: rgba(56, 189, 248, 0.5);
}

.daily-reward-badge--energy .daily-reward-badge-value {
    color: #38bdf8;
}

.daily-complete-progress {
    font-size: 0.8rem;
    color: #64748b;
    margin: 0 0 16px;
}

.daily-complete-btns {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.daily-next-btn {
    background: #f59e0b !important;
    color: #0f172a !important;
    font-weight: 800 !important;
}

.daily-next-btn:hover {
    background: #fbbf24 !important;
}

/* ── Light theme overrides ── */
.light-theme .daily-page {
    color: #1e293b;
}

.light-theme .daily-title {
    color: #b45309;
}

.light-theme .daily-header-top {
    color: #b45309;
}

.light-theme .daily-level-card {
    background: rgba(241, 245, 249, 0.9);
    border-color: rgba(100, 116, 139, 0.3);
}

.light-theme .daily-card--available {
    border-color: #d97706;
}

.light-theme .daily-card--claimed {
    background: rgba(16, 185, 129, 0.08);
    border-color: #059669;
}

.light-theme .daily-card-name {
    color: #1e293b;
}

.light-theme .daily-card-target {
    color: #64748b;
}

.light-theme .daily-complete-card {
    background: linear-gradient(145deg, #f8fafc, #f1f5f9);
    border-color: #d97706;
}

.light-theme .daily-complete-title {
    color: #b45309;
}

.light-theme .daily-complete-score {
    color: #1e293b;
}

.light-theme .daily-reward-badge {
    background: #f1f5f9;
    border-color: rgba(100, 116, 139, 0.3);
}

/* ============================================================
   WEEKLY QUEST
   ============================================================ */

/* ── Home button ── */
.home-btn-weekly {
    background: linear-gradient(135deg, #0891b2 0%, #6d28d9 100%);
    color: #fff;
    font-weight: 800;
    border: none;
}

.home-btn-weekly:hover {
    background: linear-gradient(135deg, #22d3ee 0%, #8b5cf6 100%);
    box-shadow:
        0 4px 15px rgba(8, 145, 178, 0.4),
        0 0 30px rgba(109, 40, 217, 0.2);
}

/* ── Page layout ── */
.weekly-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
    padding: 56px 16px 12px;
    overflow-y: auto;
    box-sizing: border-box;
    gap: 12px;
    /* hide scrollbar everywhere */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

.weekly-page::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

/* ── Header ── */
.weekly-header {
    text-align: center;
    width: 100%;
}

.weekly-header-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #22d3ee;
}

.weekly-title {
    font-size: 1.5rem;
    font-weight: 900;
    color: #22d3ee;
    margin: 0;
    line-height: 1.1;
}

.weekly-timer {
    font-size: 0.85rem;
    color: #94a3b8;
    margin: 2px 0 0;
}

.weekly-progress-text {
    font-size: 0.8rem;
    color: #64748b;
    margin: 2px 0 0;
}

/* ── Level cards ── */
.weekly-level-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 480px;
    overflow-y: auto;
}

.weekly-level-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #1e293b;
    border: 2px solid #334155;
    border-radius: 14px;
    padding: 12px 36px 12px 14px;
    transition: border-color 0.15s, transform 0.1s;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.weekly-level-card.weekly-card--available {
    border-color: #22d3ee;
    cursor: pointer;
    box-shadow: 0 0 12px rgba(34, 211, 238, 0.2);
}

.weekly-level-card.weekly-card--available:hover {
    transform: translateY(-1px);
    border-color: #67e8f9;
}

.weekly-level-card.weekly-card--claimed {
    border-color: #059669;
    background: rgba(5, 150, 105, 0.1);
    opacity: 0.85;
}

.weekly-level-card.weekly-card--locked {
    opacity: 0.45;
    filter: grayscale(0.4);
}

/* Step icon circle */
.weekly-card-step {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #334155;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 800;
    color: #94a3b8;
}

.weekly-card--available .weekly-card-step {
    background: #164e63;
    color: #cffafe;
}

.weekly-card--claimed .weekly-card-step {
    background: #065f46;
    color: #a7f3d0;
}

/* Card body */
.weekly-card-body {
    flex: 1;
    min-width: 0;
}

.weekly-card-num {
    font-size: 0.7rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1px;
}

.weekly-card-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.weekly-card--available .weekly-card-name {
    color: #cffafe;
}

.weekly-card--claimed .weekly-card-name {
    color: #34d399;
}

.weekly-card-target {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 2px;
}

.weekly-card-score {
    font-size: 0.75rem;
    color: #34d399;
    margin-top: 2px;
    font-weight: 600;
}

/* Rewards column */
.weekly-card-rewards {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-end;
    flex-shrink: 0;
}

/* Claimed checkmark */
.weekly-card-checkmark {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.4rem;
    color: #34d399;
    font-weight: 900;
    pointer-events: none;
}

/* Available arrow */
.weekly-card-arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1rem;
    color: #22d3ee;
    pointer-events: none;
}

/* Locked icon */
.weekly-card-lock {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    opacity: 0.6;
    pointer-events: none;
}

/* ── Reward pills ── */
.weekly-reward-pill {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    white-space: nowrap;
}

.weekly-reward-coins {
    background: rgba(245, 158, 11, 0.18);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.weekly-reward-energy {
    background: rgba(56, 189, 248, 0.18);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.weekly-reward-trophy {
    background: rgba(250, 204, 21, 0.18);
    color: #facc15;
    border: 1px solid rgba(250, 204, 21, 0.35);
    animation: trophy-pill-glow 2s ease-in-out infinite;
}

.weekly-reward-trophy--earned {
    background: rgba(52, 211, 153, 0.18);
    color: #34d399;
    border: 1px solid rgba(52, 211, 153, 0.35);
    animation: none;
}

/* ── Reward legend row ── */
.weekly-reward-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.weekly-legend-label {
    font-size: 0.75rem;
    color: #64748b;
}

/* ── Back button ── */
.weekly-back-home-btn {
    margin-top: 4px;
    background: #0f766e !important;
    color: #f0fdfa !important;
    border: 1px solid #14b8a6 !important;
    font-size: 0.85rem !important;
    padding: 8px 20px !important;
}

.weekly-back-home-btn:hover {
    background: #14b8a6 !important;
    color: #fff !important;
}

/* ── Weekly Level Complete overlay ── */
.weekly-complete-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.weekly-complete-card {
    background: linear-gradient(145deg, #1e293b, #0f172a);
    border: 2px solid #22d3ee;
    border-radius: 20px;
    padding: 28px 32px;
    max-width: 340px;
    width: 90%;
    text-align: center;
    box-shadow: 0 0 40px rgba(34, 211, 238, 0.25), 0 8px 32px rgba(0, 0, 0, 0.6);
    animation: weeklyCardIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes weeklyCardIn {
    from {
        transform: scale(0.7) translateY(20px);
        opacity: 0;
    }

    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.weekly-complete-icon {
    font-size: 2.5rem;
    margin-bottom: 6px;
}

.weekly-complete-title {
    font-size: 1.5rem;
    font-weight: 900;
    color: #22d3ee;
    margin: 0 0 4px;
}

.weekly-complete-level-name {
    font-size: 0.9rem;
    color: #94a3b8;
    margin: 0 0 4px;
}

.weekly-complete-score {
    font-size: 1rem;
    font-weight: 700;
    color: #e2e8f0;
    margin: 0 0 16px;
}

.weekly-rewards-row {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 12px;
}

.weekly-reward-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #0f172a;
    border-radius: 12px;
    padding: 10px 18px;
    border: 1px solid #334155;
    min-width: 90px;
}

.weekly-reward-badge--coins {
    border-color: rgba(34, 211, 238, 0.4);
}

.weekly-reward-badge-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    margin-bottom: 4px;
}

.weekly-reward-badge-value {
    font-size: 1.25rem;
    font-weight: 800;
}

.weekly-reward-badge--coins .weekly-reward-badge-value {
    color: #22d3ee;
}

.weekly-reward-badge--energy {
    border-color: rgba(56, 189, 248, 0.5);
}

.weekly-reward-badge--energy .weekly-reward-badge-value {
    color: #38bdf8;
}

.weekly-complete-progress {
    font-size: 0.8rem;
    color: #64748b;
    margin: 0 0 16px;
}

.weekly-complete-btns {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.weekly-next-btn {
    background: #0891b2 !important;
    color: #f0fdfe !important;
    font-weight: 800 !important;
}

.weekly-next-btn:hover {
    background: #22d3ee !important;
    color: #0f172a !important;
}

/* ── Light theme overrides ── */
.light-theme .weekly-page {
    color: #1e293b;
}

.light-theme .weekly-title {
    color: #0e7490;
}

.light-theme .weekly-header-top {
    color: #0e7490;
}

.light-theme .weekly-level-card {
    background: rgba(241, 245, 249, 0.9);
    border-color: rgba(100, 116, 139, 0.3);
}

.light-theme .weekly-card--available {
    border-color: #0891b2;
}

.light-theme .weekly-card--claimed {
    background: rgba(16, 185, 129, 0.08);
    border-color: #059669;
}

.light-theme .weekly-card-name {
    color: #1e293b;
}

.light-theme .weekly-card-target {
    color: #64748b;
}

.light-theme .weekly-complete-card {
    background: linear-gradient(145deg, #f8fafc, #f1f5f9);
    border-color: #0891b2;
}

.light-theme .weekly-complete-title {
    color: #0e7490;
}

.light-theme .weekly-complete-score {
    color: #1e293b;
}

/* ============================================================
   ECONOMY: Credits, Energy, Shop, Power-ups
   ============================================================ */

/* ============================================================
   ACHIEVEMENTS — Buttons, Modal, Cards, Toast
   ============================================================ */

/* ── Home screen buttons ──────────────────────────────────── */

.achievements-open-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: opacity 0.15s, transform 0.1s;
    margin-left: 4px;
}

.achievements-open-btn:hover {
    opacity: 0.88;
    transform: translateY(-1px);
}

.leaderboard-open-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: opacity 0.15s, transform 0.1s;
    margin-left: 4px;
}

.leaderboard-open-btn:hover {
    opacity: 0.88;
    transform: translateY(-1px);
}

/* ── Modal container ──────────────────────────────────────── */

.ach-modal-content {
    max-width: 480px;
    max-height: calc(100% - 24px);
    overflow-y: auto;
    padding: 16px 20px 20px;
}

#game-viewport.size-tablet .ach-modal-content,
#game-viewport.size-desktop .ach-modal-content {
    max-width: 640px;
    padding: 20px 32px 28px;
}

.ach-modal-stats-badge {
    background: rgba(245, 158, 11, 0.15) !important;
    color: #f59e0b !important;
}

/* ── Progress bar ─────────────────────────────────────────── */

.ach-progress-track {
    height: 6px;
    background: rgba(56, 189, 248, 0.12);
    border-radius: 3px;
    margin: 10px 0 16px;
    overflow: hidden;
}

.ach-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
    border-radius: 3px;
    transition: width 0.4s ease;
}

/* ── Achievement list & sections ──────────────────────────── */

.ach-grid {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.ach-section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

/* ── Collapsible toggle ─────────────────────────────────── */

.ach-section-toggle {
    cursor: pointer;
    user-select: none;
    padding: 8px 10px;
    margin: 0 -10px 0;
    border-radius: 8px;
    transition: background 0.15s;
}

.ach-section-toggle:hover {
    background: rgba(255, 255, 255, 0.04);
}

.ach-toggle-arrow {
    font-size: 0.6rem;
    color: #64748b;
    margin-right: 6px;
    display: inline-block;
    transition: transform 0.2s ease;
}

.ach-section-toggle--open .ach-toggle-arrow {
    transform: rotate(90deg);
}

.ach-section-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: #64748b;
    flex: 1;
}

.ach-section-count {
    font-size: 0.72rem;
    font-weight: 600;
    color: #f59e0b;
}

.ach-section-count--done {
    color: #34d399;
}

.ach-cards {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.2s ease;
}

.ach-cards--collapsed {
    max-height: 0;
    opacity: 0;
    margin: 0;
}

/* ── Individual achievement card ──────────────────────────── */

.ach-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid transparent;
    transition: background 0.15s, opacity 0.15s;
}

.ach-card--unlocked {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.28);
}

.ach-card--locked {
    background: rgba(30, 41, 59, 0.5);
    border-color: rgba(56, 189, 248, 0.08);
    opacity: 0.6;
}

.ach-card-icon {
    font-size: 1.4rem;
    width: 32px;
    text-align: center;
    flex-shrink: 0;
}

.ach-card-body {
    flex: 1;
    min-width: 0;
}

.ach-card-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ach-card--locked .ach-card-name {
    color: #64748b;
}

.ach-card-desc {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ach-card--unlocked .ach-card-desc {
    color: #94a3b8;
}

.ach-card-check {
    font-size: 1rem;
    color: #f59e0b;
    font-weight: 700;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

/* ── Achievement unlock toast ─────────────────────────────── */

.achievement-toast {
    position: absolute;
    top: 56px;
    left: 50%;
    transform: translateX(-50%) translateY(-12px);
    background: linear-gradient(135deg, rgba(13, 26, 46, 0.97), rgba(15, 31, 56, 0.97));
    border: 1px solid rgba(245, 158, 11, 0.55);
    border-radius: 12px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 500;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    min-width: 220px;
    max-width: 320px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(245, 158, 11, 0.1);
    pointer-events: none;
}

.achievement-toast--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.achievement-toast-icon {
    font-size: 1.6rem;
    flex-shrink: 0;
}

.achievement-toast-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.achievement-toast-label {
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: #f59e0b;
}

.achievement-toast-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: #f1f5f9;
}

.achievement-toast-desc {
    font-size: 0.72rem;
    color: #94a3b8;
}

/* ── Light theme overrides ────────────────────────────────── */

.light-theme .achievements-open-btn {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.light-theme .leaderboard-open-btn {
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
}

.light-theme .ach-card--unlocked {
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.35);
}

.light-theme .ach-card--locked {
    background: rgba(241, 245, 249, 0.8);
    border-color: rgba(148, 163, 184, 0.3);
}

.light-theme .ach-card-name {
    color: #1e293b;
}

.light-theme .ach-card--locked .ach-card-name {
    color: #94a3b8;
}

.light-theme .ach-card-desc {
    color: #94a3b8;
}

.light-theme .ach-card--unlocked .ach-card-desc {
    color: #64748b;
}

.light-theme .ach-section-label {
    color: #94a3b8;
}

.light-theme .ach-section-toggle:hover {
    background: rgba(0, 0, 0, 0.04);
}

.light-theme .ach-toggle-arrow {
    color: #94a3b8;
}

.light-theme .achievement-toast {
    background: linear-gradient(135deg, rgba(248, 250, 252, 0.97), rgba(241, 245, 249, 0.97));
    border-color: rgba(245, 158, 11, 0.6);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(245, 158, 11, 0.15);
}

.light-theme .achievement-toast-name {
    color: #0f172a;
}

.light-theme .achievement-toast-desc {
    color: #475569;
}

/* ── Trophy Cabinet ─────────────────────────────────────────── */

.trophy-cabinet {
    margin-bottom: 8px;
}

.trophy-cabinet-heading {
    margin-bottom: 6px;
}

.trophy-sub-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.7rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 8px 0 4px 2px;
}

.trophy-shelf {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.2s ease;
}

.trophy-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 60px;
    padding: 6px 4px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(234, 179, 8, 0.06));
    border: 1px solid rgba(245, 158, 11, 0.3);
    transition: transform 0.15s, box-shadow 0.15s;
}

.trophy-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
}

.trophy-item--daily {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(96, 165, 250, 0.06));
    border-color: rgba(59, 130, 246, 0.3);
}

.trophy-item--daily:hover {
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.trophy-icon {
    font-size: 1.5rem;
    line-height: 1;
    margin-bottom: 2px;
}

.trophy-label {
    font-size: 0.55rem;
    font-weight: 600;
    color: #e2e8f0;
    text-align: center;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.trophy-week {
    font-size: 0.48rem;
    color: #94a3b8;
    margin-top: 1px;
}

.trophy-empty {
    font-size: 0.75rem;
    color: #64748b;
    text-align: center;
    padding: 12px 8px;
    font-style: italic;
}

/* ── Streak Banner ──────────────────────────────────────────── */

.streak-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin-bottom: 8px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(245, 158, 11, 0.1));
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.streak-flame {
    font-size: 1.6rem;
    line-height: 1;
    animation: streak-pulse 1.5s ease-in-out infinite;
}

@keyframes streak-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.streak-text {
    flex: 1;
}

.streak-count {
    font-size: 0.85rem;
    font-weight: 700;
    color: #f59e0b;
}

.streak-hint {
    font-size: 0.65rem;
    color: #94a3b8;
    margin-top: 1px;
}

/* ── Trophy toast accent ────────────────────────────────────── */

.trophy-toast {
    border-color: rgba(245, 158, 11, 0.8) !important;
}

/* ── Light theme trophy overrides ───────────────────────────── */

.light-theme .trophy-label {
    color: #1e293b;
}

.light-theme .trophy-week {
    color: #64748b;
}

.light-theme .trophy-empty {
    color: #94a3b8;
}

.light-theme .trophy-item {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(234, 179, 8, 0.04));
}

.light-theme .trophy-item--daily {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(96, 165, 250, 0.04));
}

.light-theme .streak-banner {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.08), rgba(245, 158, 11, 0.06));
}

.light-theme .streak-count {
    color: #d97706;
}

.light-theme .streak-hint {
    color: #64748b;
}

/* ============================================================
   LEADERBOARD MODAL
   ============================================================ */

.lb-modal-content {
    max-width: 420px;
    width: 90%;
    padding: 24px;
}

.lb-modal-body {
    margin-top: 16px;
}

.lb-stats-section {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.lb-stat-card {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
}

.lb-stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    margin-bottom: 6px;
}

.lb-stat-value {
    font-size: 22px;
    font-weight: 700;
    color: #f8fafc;
}

.lb-info-section {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 12px;
}

.lb-info-icon {
    flex-shrink: 0;
    color: #60a5fa;
    margin-top: 2px;
}

.lb-info-text {
    font-size: 12.5px;
    line-height: 1.5;
    color: #cbd5e1;
}

.lb-info-text strong {
    color: #f8fafc;
}

.lb-submit-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #94a3b8;
    padding: 8px 0 0;
}

/* Light theme overrides */
.light-theme .lb-stat-card {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.08);
}

.light-theme .lb-stat-label {
    color: #64748b;
}

.light-theme .lb-stat-value {
    color: #0f172a;
}

.light-theme .lb-info-section {
    background: rgba(59, 130, 246, 0.06);
    border-color: rgba(59, 130, 246, 0.15);
}

.light-theme .lb-info-text {
    color: #475569;
}

.light-theme .lb-info-text strong {
    color: #0f172a;
}

.light-theme .lb-submit-status {
    color: #64748b;
}

/* ============================================================
   PORTRAIT SETTINGS OVERRIDES
   ============================================================ */

/* Hide redundant HUD buttons in portrait:
   - Home button hidden on home tab (already there)
   - Home + Settings buttons hidden on settings tab (back button handles nav) */
body.on-home-tab .hud-btn-home,
body.on-settings-tab .hud-btn-home,
body.on-settings-tab .hud-btn-settings {
    display: none;
}

body.portrait-mode .settings-back-wrap {
    left: 14px;
    top: 10px;
}

/* Keep the settings page at full width on narrow screens */
body.portrait-mode .settings-page {
    max-width: 100%;
    padding: 12px 12px 40px;
}

/* Don't expand the page width for appearance on mobile */
body.portrait-mode .settings-page:has(#stab-pane-appearance.stab-pane-active) {
    max-width: 100%;
}

/* ── Appearance pane: vertical single-column layout ── */
body.portrait-mode .ap-split {
    flex-direction: column;
    max-height: none;
}

/* Preview column: full width, no border, compact height */
body.portrait-mode .ap-left {
    flex: 0 0 auto;
    border-right: none;
    border-bottom: 1px solid rgba(51, 65, 85, 0.4);
    padding: 16px;
    width: 100%;
}

body.portrait-mode .ap-left .settings-preview-container canvas {
    max-width: 200px;
    max-height: 200px;
}

/* Picker sections stack vertically, no side border */
body.portrait-mode .ap-col {
    overflow-y: visible;
    padding: 12px 12px 8px;
}

body.portrait-mode .ap-col+.ap-col {
    border-left: none;
    border-top: 1px solid rgba(51, 65, 85, 0.4);
}

/* 4 columns on narrow screens so cards are smaller */
body.portrait-mode .ap-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 6px !important;
}

/* Stack currency badges vertically so they don't collide with the HUD nav */
body.portrait-mode .home-currency-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

