/* =====================================================
   BLOCK ROYALE — Design System v3 (Cozy Cream)
   Warm cream base, pastel clay blocks, deep-purple ink,
   coral CTA. Aesthetic target: mockup series 2026-04-23.
   ===================================================== */

/* Self-hosted fonts (offline-safe) */
@font-face {
    font-family: 'Bagel Fat One';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url(fonts/bagel-fat-one.woff2) format('woff2');
}
@font-face {
    font-family: 'Fredoka';
    font-style: normal;
    font-weight: 300 700;
    font-display: swap;
    src: url(fonts/fredoka-latin.woff2) format('woff2');
}
/* Custom SVG icon base */
.icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    line-height: 1;
}

/* CSS Custom Properties — v3 Cozy Cream theme */
:root {
    /* Block colours — punchier pastels. Still pastel in character, but with
       enough chroma to read on-device. */
    --color-red:    #F08978;   /* coral-rose, more pink pop */
    --color-orange: #F09568;   /* peach, warmer */
    --color-yellow: #F2C44E;   /* butter, more saturated */
    --color-green:  #A8D67F;   /* sage, more yellow-green */
    --color-teal:   #8DD4B6;   /* mint, more chroma */
    --color-blue:   #8DBCEA;   /* sky, more blue */
    --color-purple: #B593D8;   /* lavender, more purple */

    /* Backgrounds — unified warm peach-cream across all screens.
       Leans pink/peach (not sandy yellow). Match mockup 2026-04-23. */
    --bg-cream:       #F4D8B5;
    --bg-cream-deep:  #EEC896;
    --bg-start:       var(--bg-cream);
    --bg-start-deep:  var(--bg-cream-deep);
    --bg-game:        var(--bg-cream);
    --bg-game-deep:   var(--bg-cream-deep);
    --bg-gameover:    var(--bg-cream);
    --bg-gameover-deep: var(--bg-cream-deep);

    /* Surfaces — opaque cream cards, warm drop shadow */
    --surface-card:     #FBF0DA;       /* modals, score pill, piece tray interior */
    --surface-card-soft:#F6E3C1;       /* secondary surface */
    --surface-tray:     #EBD3AD;       /* board + piece tray recess */
    --surface-tray-line:rgba(140, 95, 50, 0.14);   /* grid dividers */
    --surface-border:   rgba(140, 95, 50, 0.10);   /* subtle edges */
    --surface-border-strong: rgba(140, 95, 50, 0.20);

    --bg-board:  var(--surface-tray);
    --bg-cell:   rgba(120, 85, 45, 0.06);

    --card-bg:      var(--surface-card);
    --card-bg-soft: var(--surface-card-soft);

    /* Ink — deep cool indigo-purple (cooler than before, matches mockup) */
    --ink-deep:     #3A2352;
    --ink-soft:     #574270;
    --ink-muted:    #A396B3;
    --ink-grey:     #9188A0;

    --text-primary:       var(--ink-deep);
    --text-on-card:       var(--ink-deep);
    --text-muted:         var(--ink-muted);
    --text-muted-on-card: var(--ink-muted);

    /* Accent — coral CTA, pastel secondary pills, warm gold */
    --accent-coral:     #EC7560;
    --accent-coral-hi:  #F28D7A;
    --accent-coral-dk:  #C85A48;
    --accent-mint:      #BEDDC6;
    --accent-lavender:  #CDB8E4;
    --accent-gold:      #F5C94F;
    --accent-star:      #E26E55;

    /* Legacy accent names kept so existing selectors still resolve */
    --accent-orange: var(--accent-coral);
    --accent-teal:   var(--accent-mint);
    --accent-green:  var(--color-green);
    --accent-pink:   var(--accent-coral);

    /* Layout — board sized to match mockup proportions (not edge-to-edge) */
    --board-size: min(90vw, 390px);
    --cell-size: calc((var(--board-size) - 24px - 42px) / 8);
    --cell-gap: 5px;

    /* Clay block recipe — pillow depth. Strong bottom rim grounds the block,
       soft top highlight rounds it, warm drop shadow lifts it off the tray. */
    --shadow-rim:
        inset 0 3px 0 rgba(255, 255, 255, 0.70),
        inset 0 -6px 0 rgba(60, 30, 10, 0.28),
        inset 4px 0 0 rgba(255, 255, 255, 0.20),
        inset -4px -2px 0 rgba(60, 30, 10, 0.10);
    --shadow-block-drop: 0 4px 6px rgba(120, 60, 30, 0.35), 0 1px 2px rgba(120, 60, 30, 0.25);

    /* Card + tray shadows — warm, never grey-black */
    --shadow-card:
        0 6px 18px rgba(120, 85, 45, 0.18),
        0 2px 4px rgba(120, 85, 45, 0.10);
    --shadow-card-lg:
        0 18px 40px rgba(120, 85, 45, 0.22),
        0 4px 10px rgba(120, 85, 45, 0.12);
    --shadow-tray-inset:
        inset 0 2px 6px rgba(120, 85, 45, 0.15),
        inset 0 -1px 0 rgba(255, 255, 255, 0.60);

    /* Float shadows — consistent hovering feel across UI elements.
       Warm brown-tinted so they sit on the peach-cream bg naturally.
       Two-layer stack: tight for contact, soft for atmosphere. */
    --float-sm:
        0 3px 6px rgba(120, 60, 30, 0.16),
        0 1px 2px rgba(120, 60, 30, 0.10);
    --float-md:
        0 6px 14px rgba(120, 60, 30, 0.22),
        0 2px 4px rgba(120, 60, 30, 0.14);
    --float-lg:
        0 12px 28px rgba(120, 60, 30, 0.26),
        0 4px 8px rgba(120, 60, 30, 0.16);

    /* Coral CTA — press-down feel with hard bottom edge */
    --shadow-cta:
        inset 0 2px 0 var(--accent-coral-hi),
        inset 0 -4px 0 var(--accent-coral-dk),
        0 6px 0 rgba(200, 90, 72, 0.35),
        0 12px 24px rgba(200, 90, 72, 0.22);

    /* Font stacks — display is Bagel Fat One (inflated bubble display,
       single weight 400), UI is Fredoka (rounded sans). */
    --font-display: 'Bagel Fat One', 'Sigmar', 'Recoleta', Georgia, serif;
    --font-game:    'Fredoka', 'SF Pro Rounded', 'Nunito', -apple-system, BlinkMacSystemFont, system-ui, 'Segoe UI', sans-serif;

    /* Unified radius scale */
    --radius-cell:    10px;      /* blocks, empty grid cells (rounder = pillow look) */
    --radius-chip:    14px;
    --radius-card-sm: 22px;
    --radius-card:    26px;
    --radius-card-lg: 34px;
    --radius-pill:    999px;
    --radius-circle:  50%;

    /* Unified type scale */
    --fs-title:       64px;
    --fs-title-sm:    30px;
    --fs-score-xl:    72px;
    --fs-score:       32px;
    --fs-button:      18px;
    --fs-button-lg:   22px;
    --fs-body:        14px;
    --fs-label:       11px;

    --fw-body:        500;
    --fw-label:       700;
    --fw-strong:      700;
    --fw-display:     700;       /* Fredoka caps at 700 */
    --tracking-title: -0.5px;
    --tracking-label: 2px;

    /* Animation */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-medium: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Unified cream background across all screens. The soft radial highlight
   in the top-left gives gentle dimensionality without looking like a gradient. */
html {
    height: 100%;
    height: -webkit-fill-available;
    background:
        radial-gradient(ellipse at 28% 12%, rgba(255, 255, 255, 0.45), transparent 60%),
        var(--bg-cream);
}

html.screen-game,
html.screen-game body,
html.screen-gameover,
html.screen-gameover body {
    background:
        radial-gradient(ellipse at 28% 12%, rgba(255, 255, 255, 0.45), transparent 60%),
        var(--bg-cream) !important;
}

body {
    font-family: var(--font-game);
    background:
        radial-gradient(ellipse at 28% 12%, rgba(255, 255, 255, 0.45), transparent 60%),
        var(--bg-cream);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* =====================================================
   BACKGROUND — Clean, per-screen colours
   ===================================================== */
.cosmic-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    background:
        radial-gradient(ellipse at 28% 12%, rgba(255, 255, 255, 0.45), transparent 60%),
        var(--bg-cream);
}

.cosmic-bg.bg-game,
.cosmic-bg.bg-gameover {
    background:
        radial-gradient(ellipse at 28% 12%, rgba(255, 255, 255, 0.45), transparent 60%),
        var(--bg-cream);
}

.cosmic-bg::before,
.nebula,
.nebula::after,
.stars,
.stars-2,
.stars-2::before,
.stars-2::after {
    display: none;
}

.particles {
    display: none;
}

/* =====================================================
   GAME CONTAINER
   ===================================================== */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 12px;
    padding-top: max(6px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    width: 100%;
    max-width: 460px;
    height: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    position: relative;
    z-index: 1;
}

/* =====================================================
   HEADER
   ===================================================== */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 8px;
    padding: 0 2px;
}

.btn-icon {
    width: 52px;
    height: 52px;
    border: 1px solid var(--surface-border);
    border-radius: 50%;
    background: var(--surface-card);
    color: var(--ink-deep);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
    box-shadow:
        inset 0 -3px 0 rgba(120, 85, 45, 0.10),
        var(--float-md);
}

.btn-icon:active {
    transform: translateY(2px);
    box-shadow:
        inset 0 -1px 0 rgba(120, 85, 45, 0.10),
        var(--float-sm);
}

.btn-icon svg {
    width: 22px;
    height: 22px;
}

/* Header score — single horizontal cream pill with star to the right of the
   number. Matches mockup layout. */
.score-display {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 0;
    flex: 0 1 auto;
    padding: 10px 24px;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-pill);
    background: var(--surface-card);
    box-shadow:
        inset 0 -3px 0 rgba(140, 95, 50, 0.10),
        var(--float-md);
    position: relative;
}

.score-display::after {
    content: '★';
    color: var(--accent-star);
    font-size: 22px;
    line-height: 1;
    margin-left: 2px;
    text-shadow: 0 1px 0 rgba(200, 90, 72, 0.25);
}

.score-label {
    display: none;
}

.score-value {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 400;
    color: var(--ink-deep);
    letter-spacing: 0;
    line-height: 1;
}

/* BEST pill — smaller cream pill, "Best" label + number inline */
.high-score {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 10px 14px;
    background: var(--surface-card);
    border-radius: var(--radius-pill);
    border: 1px solid var(--surface-border);
    box-shadow:
        inset 0 -3px 0 rgba(140, 95, 50, 0.10),
        var(--float-md);
    position: static;
    margin: 0;
    flex: 0 0 auto;
}

.high-score-label {
    font-family: var(--font-game);
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-muted);
    letter-spacing: 0;
    text-transform: none;
}

.high-score-value {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 400;
    color: var(--ink-muted);
}

/* =====================================================
   GAME BOARD
   ===================================================== */
.board-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    position: relative;
}

/* Remove the old glow effect */
.board-glow {
    display: none;
}

.board-frame {
    background: var(--surface-tray);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-card-lg);
    padding: 14px;
    box-shadow:
        var(--shadow-tray-inset),
        var(--float-lg);
    position: relative;
    z-index: 1;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: var(--cell-gap);
    width: var(--board-size);
    height: var(--board-size);
    touch-action: none;
}

/* Empty cell — lighter cream well, slight inset so grid reads distinct from tray */
.cell {
    background: rgba(255, 248, 228, 0.55);
    border-radius: var(--radius-cell);
    border: 1px solid rgba(140, 95, 50, 0.08);
    box-shadow: inset 0 1px 2px rgba(140, 95, 50, 0.06);
    transition: var(--transition-fast);
    position: relative;
    overflow: hidden;
}

/* Highlight — valid placement preview (unused, kept for fallback) */
.cell.highlight {
    background: rgba(57, 255, 20, 0.3);
    box-shadow: inset 0 0 15px rgba(57, 255, 20, 0.4), 0 0 8px rgba(57, 255, 20, 0.2);
}

/* Coloured piece preview — outline only, no fill.
   Must be categorically different from placed blocks (solid fill).
   Outline = "something will go here". Fill = "something IS here". */
.cell.preview-piece {
    background: transparent !important;
    border: 2px dashed var(--preview-color, rgba(255, 255, 255, 0.5));
    box-shadow: none;
    opacity: 0.8;
    border-radius: 8px;
    animation: none;
}

.cell.preview-piece::after {
    display: none;
}

/* Map piece colours to preview border colour */
.cell.preview-piece.color-purple  { --preview-color: var(--color-purple); }
.cell.preview-piece.color-cyan    { --preview-color: var(--color-teal); }
.cell.preview-piece.color-orange  { --preview-color: var(--color-orange); }
.cell.preview-piece.color-blue    { --preview-color: var(--color-blue); }
.cell.preview-piece.color-red     { --preview-color: var(--color-red); }
.cell.preview-piece.color-green   { --preview-color: var(--color-green); }
.cell.preview-piece.color-yellow  { --preview-color: var(--color-yellow); }

[data-theme="light"] .cell.preview-piece {
    opacity: 0.9;
}

/* Line-clear preview — highlight pulse */
.cell.line-clear-preview {
    border: 2px solid rgba(45, 106, 79, 0.6) !important;
    box-shadow:
        inset 0 0 8px rgba(45, 106, 79, 0.2),
        0 0 8px rgba(45, 106, 79, 0.15) !important;
    filter: brightness(1.15);
    animation: line-clear-pulse 0.7s ease-in-out infinite;
    z-index: 1;
}
.cell.preview-piece.line-clear-preview {
    border: 2px solid var(--accent-green) !important;
    border-style: solid !important;
    filter: brightness(1.2);
}
@keyframes line-clear-pulse {
    0%, 100% {
        filter: brightness(1.1);
        border-color: rgba(45, 106, 79, 0.5);
        box-shadow:
            inset 0 0 6px rgba(45, 106, 79, 0.15),
            0 0 6px rgba(45, 106, 79, 0.1);
    }
    50% {
        filter: brightness(1.25);
        border-color: rgba(45, 106, 79, 0.8);
        box-shadow:
            inset 0 0 12px rgba(45, 106, 79, 0.25),
            0 0 10px rgba(45, 106, 79, 0.2);
    }
}

/* Invalid placement */
.cell.invalid {
    background: rgba(244, 63, 94, 0.35);
    box-shadow: inset 0 0 15px rgba(244, 63, 94, 0.4), 0 0 8px rgba(244, 63, 94, 0.2);
}

/* =====================================================
   FILLED BLOCKS — v3 Clay pillow recipe
   Soft pastel fills with a subtle top highlight, bottom shadow,
   and a warm drop shadow. No gloss, no wet-candy shine.
   ===================================================== */
.cell.filled {
    border: none;
    box-shadow:
        var(--shadow-rim),
        var(--shadow-block-drop);
    border-radius: var(--radius-cell);
    background-image: linear-gradient(180deg,
        rgba(255, 255, 255, 0.32) 0%,
        rgba(255, 255, 255, 0) 45%,
        rgba(60, 30, 10, 0.18) 100%);
}

/* Pronounced top highlight — clay pillow gloss */
.cell.filled::after {
    content: '';
    position: absolute;
    top: 12%;
    left: 14%;
    right: 14%;
    height: 22%;
    border-radius: 999px;
    background: linear-gradient(180deg,
        rgba(255, 255, 255, 0.55) 0%,
        rgba(255, 255, 255, 0) 100%);
    pointer-events: none;
    filter: blur(1.5px);
}

/* Landing bounce — block wobbles into place */
.cell.jelly-land {
    animation: jelly-land 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes jelly-land {
    0%   { transform: scale(0.3); opacity: 0.5; }
    40%  { transform: scale(1.15, 0.85); }
    60%  { transform: scale(0.9, 1.1); }
    80%  { transform: scale(1.05, 0.95); }
    100% { transform: scale(1); opacity: 1; }
}

.cell.color-purple  { background: var(--color-purple); --glow: var(--color-purple); }
.cell.color-cyan    { background: var(--color-teal);   --glow: var(--color-teal); }
.cell.color-orange  { background: var(--color-orange); --glow: var(--color-orange); }
.cell.color-blue    { background: var(--color-blue);   --glow: var(--color-blue); }
.cell.color-red     { background: var(--color-red);    --glow: var(--color-red); }
.cell.color-green   { background: var(--color-green);  --glow: var(--color-green); }
.cell.color-yellow  { background: var(--color-yellow); --glow: var(--color-yellow); }

/* Bold shadow per block — already covered in .cell.filled, kept as override safety */
.cell.filled.color-purple,
.cell.filled.color-cyan,
.cell.filled.color-orange,
.cell.filled.color-blue,
.cell.filled.color-red,
.cell.filled.color-green,
.cell.filled.color-yellow {
    box-shadow:
        var(--shadow-rim),
        var(--shadow-block-drop);
}

.cell.color-grey,
.cell.obstacle {
    background: #4b5563;
    box-shadow: var(--shadow-rim);
}

/* =====================================================
   LINE CLEAR ANIMATION — Fast flash and vanish
   ===================================================== */
.cell.clearing {
    will-change: transform, opacity;
    animation: clear-flash 0.2s ease-out forwards;
}

@keyframes clear-flash {
    0% {
        transform: scale(1);
        opacity: 1;
        background: white;
    }
    30% {
        transform: scale(1.15);
        opacity: 1;
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

.cell.flash {
    animation: cell-flash 0.25s ease-out;
}

@keyframes cell-flash {
    0% {
        background: rgba(255, 255, 255, 0.6);
        box-shadow: 0 0 20px rgba(255, 255, 255, 0.4);
    }
    100% {
        background: var(--bg-cell);
        box-shadow: none;
    }
}

/* Line clear preview */
.cell.preview-clear {
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.4), inset 0 0 8px rgba(255, 255, 255, 0.3);
    z-index: 10;
}

.cell.preview-clear::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 6px;
    animation: clear-pulse 0.8s ease-in-out infinite;
    pointer-events: none;
}

@keyframes clear-pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.7; }
}

/* =====================================================
   PIECE TRAY
   ===================================================== */
.piece-tray {
    width: 100%;
    padding: 18px 12px 20px;
    background: var(--surface-card-soft);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-card);
    box-shadow:
        var(--shadow-tray-inset),
        var(--float-md);
    position: relative;
}

/* Mockup hides the tray header entirely — piece tray is just the slots */
.piece-tray-header {
    display: none;
}

.tray-label { display: none; }
.tray-help { display: none; }
.tray-badge { display: none; }

.piece-slots {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 8px;
    min-height: 108px;
}

.piece-slots.single-piece-mode {
    justify-content: center;
}

.piece-slot {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 108px;
    max-width: none;
    border: none;
    background: transparent;
    border-radius: 16px;
    position: relative;
    touch-action: none;
}

.piece-slot.is-primary-slot {
    flex: 0 1 132px;
    max-width: 132px;
}

.piece-slot.is-hidden-slot {
    display: none;
}

/* Empty slot (piece already used) */
.piece-slot:empty {
    border: none;
    background: transparent;
}

/* Draggable Piece */
.piece {
    display: grid;
    gap: 3px;
    cursor: grab;
    transition: transform var(--transition-fast), opacity var(--transition-fast);
    touch-action: none;
    -webkit-touch-callout: none;
    animation: piece-idle 2.5s ease-in-out infinite;
    /* Group float shadow — makes the whole piece read as hovering above tray */
    filter:
        drop-shadow(0 6px 6px rgba(120, 60, 30, 0.22))
        drop-shadow(0 2px 2px rgba(120, 60, 30, 0.14));
}

/* Subtle idle wobble — makes pieces feel alive in the tray */
@keyframes piece-idle {
    0%, 100% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(-1deg) scale(1.01); }
    75% { transform: rotate(1deg) scale(0.99); }
}

/* Stagger the idle animation per slot so they don't all move together */
.piece-slot:nth-child(1) .piece { animation-delay: 0s; }
.piece-slot:nth-child(2) .piece { animation-delay: 0.8s; }
.piece-slot:nth-child(3) .piece { animation-delay: 1.6s; }

.piece:active {
    cursor: grabbing;
    animation: none;
}

/* Piece hidden while dragging — slot empties */
.piece.dragging-hidden {
    display: none;
}

.piece-cell {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    /* No drop shadow — the parent .piece has a filter drop-shadow that
       creates a unified group float. Per-cell inset rim handles the 3D. */
    box-shadow:
        inset 0 2px 0 rgba(255, 255, 255, 0.70),
        inset 0 -4px 0 rgba(60, 30, 10, 0.28);
    position: relative;
    background-image: linear-gradient(180deg,
        rgba(255, 255, 255, 0.32) 0%,
        rgba(255, 255, 255, 0) 45%,
        rgba(60, 30, 10, 0.18) 100%);
}

/* Top pillow highlight on tray pieces */
.piece-cell::after {
    content: '';
    position: absolute;
    top: 12%;
    left: 14%;
    right: 14%;
    height: 24%;
    border-radius: 999px;
    background: linear-gradient(180deg,
        rgba(255, 255, 255, 0.55) 0%,
        rgba(255, 255, 255, 0) 100%);
    pointer-events: none;
    filter: blur(1px);
}

/* =====================================================
   FLOATING DRAG CLONE — follows finger at board cell size
   ===================================================== */
.drag-clone {
    position: fixed;
    z-index: 1000;
    pointer-events: none;
    display: grid;
    gap: var(--cell-gap);
    /* Stronger lift shadow while dragging — finger is holding it above the board */
    filter:
        drop-shadow(0 10px 10px rgba(120, 60, 30, 0.30))
        drop-shadow(0 3px 4px rgba(120, 60, 30, 0.18));
}

.drag-clone .drag-cell {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-cell);
    border: none;
    /* No drop shadow — parent .drag-clone has a filter drop-shadow for group lift */
    box-shadow:
        inset 0 3px 0 rgba(255, 255, 255, 0.70),
        inset 0 -5px 0 rgba(60, 30, 10, 0.28);
    position: relative;
    opacity: 0.95;
    background-image: linear-gradient(180deg,
        rgba(255, 255, 255, 0.32) 0%,
        rgba(255, 255, 255, 0) 45%,
        rgba(60, 30, 10, 0.18) 100%);
}

/* Top pillow highlight on drag clone */
.drag-clone .drag-cell::after {
    content: '';
    position: absolute;
    top: 12%;
    left: 14%;
    right: 14%;
    height: 22%;
    border-radius: 999px;
    background: linear-gradient(180deg,
        rgba(255, 255, 255, 0.55) 0%,
        rgba(255, 255, 255, 0) 100%);
    pointer-events: none;
    filter: blur(1.5px);
}

/* Clone cell colours */
.drag-clone .drag-cell.color-purple  { background: var(--color-purple); }
.drag-clone .drag-cell.color-cyan    { background: var(--color-teal); }
.drag-clone .drag-cell.color-orange  { background: var(--color-orange); }
.drag-clone .drag-cell.color-blue    { background: var(--color-blue); }
.drag-clone .drag-cell.color-red     { background: var(--color-red); }
.drag-clone .drag-cell.color-green   { background: var(--color-green); }
.drag-clone .drag-cell.color-yellow  { background: var(--color-yellow); }

/* Piece cell colours — flat, matching board blocks */
.piece-cell.color-purple  { background: var(--color-purple); }
.piece-cell.color-cyan    { background: var(--color-teal); }
.piece-cell.color-orange  { background: var(--color-orange); }
.piece-cell.color-blue    { background: var(--color-blue); }
.piece-cell.color-red     { background: var(--color-red); }
.piece-cell.color-green   { background: var(--color-green); }
.piece-cell.color-yellow  { background: var(--color-yellow); }

/* Ghost preview removed — pieces show directly on grid cells */

/* =====================================================
   EFFECTS
   ===================================================== */
.effects-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1500;
}

/* Score popup */
.score-popup {
    position: absolute;
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-green);
    text-shadow: 0 2px 8px rgba(45, 106, 79, 0.3);
    animation: score-float 0.8s ease-out forwards;
    pointer-events: none;
}

@keyframes score-float {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-50px) scale(1.3);
    }
}

/* Combo text — gradient with layered glow */
.combo-text {
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-6deg);
    font-size: 64px;
    font-weight: 900;
    font-style: italic;
    background: linear-gradient(135deg, var(--accent-green), var(--accent-teal));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
    z-index: 2000;
    pointer-events: none;
    animation: combo-pop 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.2));
}

@keyframes combo-pop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5) rotate(-6deg);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2) rotate(-4deg);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -60%) scale(1) rotate(-6deg);
    }
}

/* Particle effects (uses pre-created pool — no DOM creation during gameplay) */
.clear-particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    pointer-events: none;
    animation: particle-explode 0.6s ease-out forwards;
}

@keyframes particle-explode {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
        box-shadow: 0 0 8px currentColor;
    }
    100% {
        opacity: 0;
        transform: translate(var(--tx), var(--ty)) scale(0);
        box-shadow: 0 0 0 currentColor;
    }
}

/* Flash overlay — full-screen flash for big clears */
.clear-flash-overlay {
    position: fixed;
    inset: 0;
    background: var(--flash-color, white);
    pointer-events: none;
    z-index: 1500;
    animation: flash-fade var(--flash-duration, 300ms) ease-out forwards;
}

@keyframes flash-fade {
    0% { opacity: 0.4; }
    100% { opacity: 0; }
}

.sparkle {
    position: absolute;
    width: 3px;
    height: 3px;
    background: white;
    border-radius: 50%;
    pointer-events: none;
    box-shadow: 0 0 8px 2px currentColor;
    animation: sparkle-fade 0.5s ease-out forwards;
}

@keyframes sparkle-fade {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.8); }
    100% { opacity: 0; transform: scale(0); }
}

/* =====================================================
   MODALS
   ===================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(120, 85, 45, 0.28);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-medium);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--surface-card);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-card-lg);
    position: relative;
    overflow: visible;
    padding: 40px 32px 32px;
    text-align: center;
    transform: scale(0.9) translateY(20px);
    transition: var(--transition-medium);
    box-shadow: var(--shadow-card-lg);
    min-width: 320px;
    max-width: 90vw;
}

/* .modal-content::before is defined earlier as the liquid-glass specular shine — do not override */

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
}

.modal-title {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 400;
    color: var(--ink-deep);
    margin-bottom: 20px;
    letter-spacing: 0;
}

/* "Nice run!" — game over title, 3D clay extruded */
.modal-title.neon-pink {
    font-family: var(--font-display);
    font-weight: 400;
    font-style: normal;
    font-size: 36px;
    line-height: 1;
    background: linear-gradient(180deg,
        #8E66C2 0%,
        #6E48A0 25%,
        #4A2A72 65%,
        #3A2352 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    text-shadow:
        0 1px 0 #2F1B45,
        0 2px 0 #2C1940,
        0 3px 0 #29173D,
        0 4px 0 #261538,
        0 8px 12px rgba(60, 25, 90, 0.35);
    margin-bottom: 18px;
    text-transform: none;
    letter-spacing: 0.5px;
    transform: none;
}

/* Game over modal — cream card (overlay stays separate) */
.game-over-style {
    background: var(--surface-card);
    border-color: var(--surface-border);
}

#gameOverModal .modal-content {
    background: var(--surface-card);
}

/* Star decorations on game over modal */
.star-decoration {
    position: absolute;
    color: white;
    opacity: 0.8;
    filter: none;
    animation: pulse-star 2s ease-in-out infinite;
}

.star-tl {
    top: -12px;
    left: -8px;
    font-size: 24px;
}

.star-tr {
    top: 40px;
    right: -16px;
    font-size: 20px;
    animation-delay: 0.5s;
    color: var(--accent-pink);
}

.star-br {
    bottom: -12px;
    right: 32px;
    font-size: 22px;
    color: var(--accent-pink);
    animation-delay: 1s;
}

@keyframes pulse-star {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.15); }
}

.final-score-container {
    margin-bottom: 20px;
}

.score-label-small {
    display: none;
}

.modal-score-large {
    font-family: var(--font-display);
    font-size: 80px;
    font-weight: 400;
    background: linear-gradient(180deg,
        #8E66C2 0%,
        #6E48A0 25%,
        #4A2A72 65%,
        #3A2352 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    text-shadow:
        0 1px 0 #2F1B45,
        0 2px 0 #2C1940,
        0 3px 0 #29173D,
        0 4px 0 #261538,
        0 5px 0 #231333,
        0 6px 0 #20112C,
        0 7px 0 #1D0F28,
        0 8px 0 #1A0D23,
        0 16px 22px rgba(60, 25, 90, 0.40);
    line-height: 1;
    letter-spacing: 0;
    margin-bottom: 6px;
}

.best-score-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--ink-muted);
    margin-bottom: 28px;
}

.best-score-pill svg {
    display: none;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

/* Coral primary CTA — cream text, pillowy press-down */
.btn-retry {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 18px 28px 20px;
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 400;
    color: #FFF6E8;
    background: var(--accent-coral);
    border: none;
    border-radius: var(--radius-pill);
    cursor: pointer;
    box-shadow: var(--shadow-cta);
    transition: transform 0.08s ease, box-shadow 0.08s ease;
    text-transform: none;
    letter-spacing: 0;
}

.btn-retry:active {
    transform: translateY(4px);
    box-shadow:
        inset 0 2px 0 var(--accent-coral-hi),
        inset 0 -2px 0 var(--accent-coral-dk),
        0 2px 0 rgba(200, 90, 72, 0.35),
        0 4px 10px rgba(200, 90, 72, 0.18);
}

.btn-retry svg {
    color: #FFF6E8;
}

/* Secondary "Home" button — cream-filled outlined pill, purple text */
.btn-home {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px;
    font-family: inherit;
    font-size: var(--fs-button);
    font-weight: var(--fw-strong);
    color: var(--ink-deep);
    background: var(--surface-card);
    border: 2px solid var(--ink-deep);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: background 0.15s ease, transform 0.08s ease, box-shadow 0.08s ease;
    text-transform: none;
    box-shadow: var(--float-sm);
}

.btn-home:active {
    background: rgba(63, 36, 96, 0.06);
    transform: scale(0.98);
}

.btn-home svg { color: var(--ink-deep); }

.new-high-score {
    position: absolute;
    top: 40px;
    left: 20px;
    font-size: 14px;
    color: white;
    animation: spin-star 3s linear infinite;
    display: none;
}

.new-high-score.show {
    display: block;
}

@keyframes spin-star {
    to { transform: rotate(360deg); }
}

.btn-primary,
.btn-secondary {
    display: block;
    width: 100%;
    padding: 16px 28px;
    font-family: inherit;
    font-size: 18px;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
    border: none;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: var(--transition-fast);
    margin-bottom: 12px;
}

.btn-primary {
    background: var(--accent-coral);
    color: #FFF6E8;
    box-shadow: var(--shadow-cta);
    font-weight: var(--fw-display);
}

.btn-primary:active {
    transform: translateY(3px);
}

.btn-secondary {
    background: var(--surface-card);
    border: 2px solid var(--ink-deep);
    color: var(--ink-deep);
    font-weight: var(--fw-strong);
    box-shadow: var(--float-sm);
}

.settings-link-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.btn-secondary:active {
    background: rgba(63, 36, 96, 0.06);
    transform: scale(0.98);
}

/* =====================================================
   LEADERBOARD
   ===================================================== */
.leaderboard-modal {
    min-width: 300px;
    max-width: 350px;
}

.leaderboard-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 20px;
    padding: 8px 0;
}

.leaderboard-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    margin: 6px 0;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.leaderboard-row.top-score {
    background: rgba(45, 106, 79, 0.08);
    border-color: rgba(45, 106, 79, 0.2);
}

.leaderboard-rank {
    font-size: 16px;
    font-weight: 700;
    min-width: 40px;
    color: #8A8580;
}

.top-score .leaderboard-rank {
    color: var(--accent-green);
}

.leaderboard-score {
    font-size: 18px;
    font-weight: 800;
    flex: 1;
    text-align: center;
}

.leaderboard-date {
    font-size: 12px;
    color: #8A8580;
}

.leaderboard-empty {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

.btn-theme {
    display: block;
    width: 100%;
    padding: 12px 20px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.03);
    color: var(--text-muted);
    transition: var(--transition-fast);
    margin-top: 8px;
}

.btn-theme:active {
    background: rgba(0, 0, 0, 0.06);
}

/* =====================================================
   SPLASH SCREEN
   ===================================================== */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    background: transparent;
    transition: opacity 0.5s ease-out, visibility 0.5s;
}

.splash-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.splash-content {
    text-align: center;
    color: white;
    padding: 20px;
}

.splash-title {
    font-family: var(--font-game);
    font-size: var(--fs-title);
    font-weight: var(--fw-display);
    letter-spacing: -1px;
    line-height: 1;
    margin-bottom: 40px;
    color: var(--ink-deep);
    opacity: 0;
    transform: scale(0.8);
    animation: titleIn 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.splash-loader {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    margin: 0 auto 30px;
    overflow: hidden;
    opacity: 0;
    animation: fadeIn 0.5s ease 0.5s forwards;
}

.loader-bar {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, rgba(255,255,255,0.6), white);
    border-radius: 2px;
    transform: translateX(-100%);
    animation: loadProgress 2s ease-out 0.5s forwards;
}

.tap-to-start {
    font-size: 18px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    opacity: 0;
    animation: pulseFade 1.5s infinite 2.5s;
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
}

@keyframes titleIn {
    to { opacity: 1; transform: scale(1); }
}

@keyframes fadeIn {
    to { opacity: 1; }
}

@keyframes loadProgress {
    to { transform: translateX(0); }
}

@keyframes pulseFade {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-height: 680px) {
    .game-container {
        gap: 8px;
        padding: 8px;
    }

    :root {
        --board-size: min(90vw, 360px);
    }

    .piece-tray {
        padding: 10px 8px 14px;
    }

    .piece-slots {
        min-height: 100px;
    }

    .piece-cell {
        width: 30px;
        height: 30px;
    }

    .score-value {
        font-size: 28px;
    }

    .start-content {
        gap: 14px;
        padding: 24px 20px;
    }

    .start-title {
        font-size: 64px;
    }
}

@media (min-width: 500px) and (min-height: 800px) {
    :root {
        --board-size: 440px;
    }

    .piece-cell {
        width: 42px;
        height: 42px;
    }
}

@supports (padding: max(0px)) {
    .game-container {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }
}

/* =====================================================
   START SCREEN
   ===================================================== */
.start-screen {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
}

/* Let body cream show through — the game container is just a layout wrapper */
.game-container {
    background: transparent;
}

.start-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 24px;
    width: 100%;
    max-width: 430px;
    height: 100%;
    max-height: 100dvh;
    padding-top: max(40px, env(safe-area-inset-top, 40px));
    padding-bottom: max(20px, env(safe-area-inset-bottom, 20px));
    gap: 14px;
}

.start-bottom {
    gap: 12px;
}

/* Start console — on the cream-on-cream mockup this is just the title crown
   over open background, no card. Kill the glass panel. */
.start-console {
    width: 100%;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    margin-top: auto;
    margin-bottom: auto;
    position: relative;
}

/* Glass specular-shine disabled in v3 — cream surfaces are opaque, no glass */
.start-console::before,
.score-display::before,
.piece-tray::before,
.modal-content::before {
    display: none;
}

.start-tagline {
    display: none;
}

.start-kicker {
    display: none;
}

/* Custom SVG logo (inline in HTML) — replaces the old text-rendered title.
   The SVG contains crown, sparkles, and the 3D extruded "Block Royale"
   wordmark. We just size it and handle the reveal animation. */
.start-logo {
    display: block;
    width: min(78vw, 340px);
    height: auto;
    margin: 0 auto;
    opacity: 0;
    transform: scale(0.75) translateY(16px);
    animation: title-reveal 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.2s forwards;
}

@keyframes title-reveal {
    0% {
        opacity: 0;
        transform: scale(0.7) translateY(20px);
    }
    60% {
        opacity: 1;
        transform: scale(1.05) translateY(-4px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes title-flash {
    0%, 100% {
        text-shadow: none;
    }
    50% {
        text-shadow: 0 0 20px rgba(255, 255, 255, 0.8), 0 0 40px rgba(255, 255, 255, 0.4);
    }
}

.start-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
    opacity: 0;
    transform: translateY(16px);
    animation: bottom-fade-in 0.5s ease-out 0.7s forwards;
}

@keyframes bottom-fade-in {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mockup has no best-score pill on the start screen — hide */
.start-best-score { display: none; }

/* ======================================================
   START-SCREEN BOARD PREVIEW — decorative, not interactive
   ====================================================== */
.start-board-preview {
    width: min(84vw, 320px);
    flex: 0 1 auto;
    margin: 0 auto;
    pointer-events: none;
}

.preview-frame {
    background: var(--surface-tray);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-card);
    padding: 10px;
    box-shadow:
        var(--shadow-tray-inset),
        var(--float-lg);
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 4px;
    aspect-ratio: 1 / 1;
    width: 100%;
}

.preview-grid .cell {
    aspect-ratio: 1 / 1;
}

.start-buttons-row {
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 12px;
    width: 84%;
    max-width: 320px;
    margin: 0 auto;
}

/* Coral Play pill — hero CTA. Uses display font. */
.btn-play {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 0 18px;
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 400;
    color: #FFF6E8;
    background: var(--accent-coral);
    border: none;
    border-radius: var(--radius-pill);
    cursor: pointer;
    box-shadow: var(--shadow-cta);
    transition: transform 0.08s ease, box-shadow 0.08s ease;
    text-transform: none;
    letter-spacing: 0;
    flex: 0 0 auto;
    width: 84%;
    max-width: 320px;
}

.btn-play .icon { display: none; }

.btn-play:active {
    transform: translateY(4px);
    box-shadow:
        inset 0 2px 0 var(--accent-coral-hi),
        inset 0 -2px 0 var(--accent-coral-dk),
        0 2px 0 rgba(200, 90, 72, 0.35),
        0 4px 10px rgba(200, 90, 72, 0.18);
}

/* Pastel pill side buttons — Settings (mint) + Leaderboard (lavender) */
.btn-start-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 26px;
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    height: auto;
    padding: 14px 16px 18px;
    background: var(--accent-mint);
    border: 1px solid rgba(140, 95, 50, 0.10);
    color: var(--ink-deep);
    cursor: pointer;
    transition: var(--transition-fast);
    font-family: var(--font-game);
    font-size: 14px;
    font-weight: var(--fw-strong);
    box-shadow:
        inset 0 -4px 0 rgba(140, 95, 50, 0.14),
        var(--float-md);
    flex-direction: column;
    gap: 6px;
}

.btn-start-icon .icon svg {
    color: var(--ink-deep);
    width: 26px;
    height: 26px;
}

#startLeaderboardBtn { background: var(--accent-lavender); }

.btn-start-icon:active {
    transform: translateY(3px);
    box-shadow:
        inset 0 -1px 0 rgba(120, 85, 45, 0.10),
        var(--float-sm);
}

.privacy-modal {
    max-width: 420px;
}

.privacy-summary {
    color: #2C2C2C;
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 16px;
}

.privacy-points {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 18px;
    text-align: left;
}

.privacy-point {
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    background: rgba(0, 0, 0, 0.03);
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.45;
}

.privacy-point strong {
    color: #2C2C2C;
}

.btn-start-secondary:active {
    background: rgba(255, 255, 255, 0.1);
}

.start-screen.hidden {
    display: none;
}

/* =====================================================
   SETTINGS MODAL
   ===================================================== */
.modal-header-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 24px;
}

.settings-modal {
    min-width: 300px;
    max-width: 350px;
}

.settings-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 24px;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.settings-row-detail {
    align-items: flex-start;
}

.settings-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
    color: #2C2C2C;
}

.settings-label .icon {
    color: #8A8580;
}

.settings-label-detail {
    align-items: flex-start;
}

.settings-copy {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.settings-title {
    font-size: 16px;
    font-weight: 600;
    color: #2C2C2C;
}

.settings-caption {
    max-width: 180px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-muted);
}

/* Toggle switch */
.toggle-btn {
    position: relative;
    width: 52px;
    height: 30px;
    border: none;
    border-radius: 15px;
    background: rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: background 0.2s;
    padding: 0;
}

.toggle-btn.active {
    background: var(--accent-green);
}

.toggle-knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s;
}

.toggle-btn.active .toggle-knob {
    transform: translateX(22px);
}

.btn-danger {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    color: #f43f5e;
    background: rgba(244, 63, 94, 0.1);
    border: 1px solid rgba(244, 63, 94, 0.25);
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-danger:active {
    background: rgba(244, 63, 94, 0.2);
}

/* =====================================================
   TUTORIAL OVERLAY — ANIMATED HAND
   ===================================================== */
.tutorial-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: rgba(245, 243, 240, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
    cursor: pointer;
}

.tutorial-overlay.visible {
    opacity: 1;
}

.tutorial-hand {
    font-size: 64px;
    animation: hand-drag 2.4s ease-in-out infinite;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
}

@keyframes hand-drag {
    0%   { transform: translate(0, 60px) scale(1); opacity: 0.4; }
    15%  { transform: translate(0, 60px) scale(1.1); opacity: 1; }
    60%  { transform: translate(0, -80px) scale(1.1); opacity: 1; }
    75%  { transform: translate(0, -80px) scale(1); opacity: 0.6; }
    85%  { transform: translate(0, -80px) scale(1); opacity: 0; }
    100% { transform: translate(0, 60px) scale(1); opacity: 0; }
}

.tutorial-hint {
    margin-top: 24px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.tutorial-tap-hint {
    position: absolute;
    bottom: 48px;
    font-size: 13px;
    color: var(--text-muted);
}

/* Light mode is now default — no theme toggle needed */

/* =====================================================
   COIN BADGE — Phase 1, Chunk 1.1
   Gold pill rendered on Start screen (top-right) + Game header (right).
   Single component, two variants via .coin-badge--start and .coin-badge--hud.
   ===================================================== */
.coin-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-card, #FFF8EA);
    border: 1px solid rgba(166, 125, 22, 0.32);
    border-radius: 999px;
    padding: 5px 12px 5px 5px;
    font-family: 'Nunito', system-ui, -apple-system, sans-serif;
    font-weight: 900;
    font-size: 14px;
    color: #5A3D0C;
    line-height: 1;
    box-shadow:
        0 2px 0 rgba(166, 125, 22, 0.22),
        0 6px 14px rgba(166, 125, 22, 0.14);
    user-select: none;
}

.coin-badge-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.coin-badge-icon svg {
    display: block;
    filter: drop-shadow(0 1px 0 rgba(154, 109, 16, 0.4));
}

.coin-badge-value {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.3px;
}

/* Start-screen variant — pinned top-right, safe-area aware */
.coin-badge--start {
    position: absolute;
    top: max(env(safe-area-inset-top, 0px), 16px);
    right: max(env(safe-area-inset-right, 0px), 16px);
    z-index: 5;
    padding: 6px 14px 6px 6px;
    font-size: 15px;
}

/* Game-header variant — inline with score + best, slightly smaller */
.coin-badge--hud {
    padding: 4px 10px 4px 4px;
    font-size: 13px;
}

/* =====================================================
   POWER-UP TRAY — Phase 1, Chunk 1.2
   Row of 4 power-up slots above the board. Greyed when count is 0.
   ===================================================== */
.powerup-tray {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    width: 100%;
    max-width: 360px;
    margin: 8px auto 4px;
    padding: 8px;
    background: var(--surface-card, #FFF8EA);
    border: 1px solid var(--surface-border, rgba(166, 125, 22, 0.18));
    border-radius: 18px;
    box-shadow:
        inset 0 -2px 0 rgba(120, 85, 45, 0.08),
        0 4px 10px rgba(143, 119, 88, 0.10);
}

.powerup-slot {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 56px;
    padding: 6px 4px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(166, 125, 22, 0.18);
    border-radius: 12px;
    color: var(--royale-purple, #5A2873);
    font-family: 'Nunito', system-ui, -apple-system, sans-serif;
    font-weight: 900;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 90ms ease-out, box-shadow 120ms ease-out;
}

.powerup-slot:active {
    transform: translateY(1px);
}

.powerup-slot.is-empty {
    color: rgba(90, 40, 115, 0.35);
    background: rgba(255, 255, 255, 0.35);
}

.powerup-slot.is-empty .powerup-count {
    background: rgba(166, 125, 22, 0.25);
    color: rgba(90, 40, 115, 0.5);
}

.powerup-icon svg { display: block; }

.powerup-count {
    position: absolute;
    top: -6px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--coral, #FF6B5E);
    color: white;
    font-size: 11px;
    font-weight: 900;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 2px 0 rgba(60, 29, 82, 0.25);
    font-variant-numeric: tabular-nums;
}

/* =====================================================
   STORE SCREEN — Phase 1, Chunk 1.3
   ===================================================== */
.store-screen {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100vh;
    padding: max(env(safe-area-inset-top, 0px), 12px) 18px 18px;
    gap: 12px;
    background: var(--cream-bg, #FFF4DF);
    color: var(--royale-purple-dark, #3C1D52);
}

.store-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.store-back {
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
}

.store-title-wrap {
    flex: 1 1 auto;
    min-width: 0;
}

.store-title {
    font-family: 'Bagel Fat One', 'Sigmar', 'Fredoka', sans-serif;
    font-weight: 700;
    color: var(--royale-purple, #5A2873);
    font-size: 26px;
    line-height: 1;
    letter-spacing: -0.5px;
    margin: 0 0 2px;
}

.store-subtitle {
    font-size: 12px;
    font-weight: 800;
    opacity: 0.55;
    margin: 0;
    letter-spacing: 0.3px;
}

.coin-badge--store {
    flex: 0 0 auto;
    padding: 5px 12px 5px 5px;
    font-size: 14px;
}

.store-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px 0;
}

.store-tab {
    flex: 0 0 auto;
    padding: 7px 14px;
    border: none;
    background: transparent;
    color: var(--royale-purple-dark, #3C1D52);
    opacity: 0.55;
    font-family: 'Nunito', system-ui, sans-serif;
    font-weight: 900;
    font-size: 13px;
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 120ms ease-out, background 120ms ease-out, color 120ms ease-out;
}

.store-tab.is-active {
    background: var(--royale-purple, #5A2873);
    color: white;
    opacity: 1;
    box-shadow: 0 3px 0 rgba(60, 29, 82, 0.4);
}

.store-body {
    flex: 1 1 auto;
    overflow-y: auto;
}

.store-pane { display: none; }
.store-pane.is-active { display: flex; flex-direction: column; gap: 10px; }

.store-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--royale-purple-dark, #3C1D52);
    opacity: 0.5;
    font-weight: 800;
}

.store-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--surface-card, #FFF8EA);
    border: 1px solid var(--surface-border, rgba(166, 125, 22, 0.18));
    border-radius: 18px;
    box-shadow:
        inset 0 -2px 0 rgba(120, 85, 45, 0.06),
        0 3px 8px rgba(143, 119, 88, 0.10);
}

.store-row-icon {
    display: inline-flex;
    width: 46px;
    height: 46px;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.6);
    color: var(--royale-purple, #5A2873);
    border: 1px solid var(--surface-border, rgba(166, 125, 22, 0.18));
    flex: 0 0 auto;
}

.store-row-info {
    flex: 1 1 auto;
    min-width: 0;
}

.store-row-name {
    font-family: 'Nunito', system-ui, sans-serif;
    font-weight: 900;
    font-size: 14px;
    color: var(--royale-purple-dark, #3C1D52);
}

.store-row-desc {
    font-size: 11px;
    opacity: 0.55;
    font-weight: 800;
    margin-top: 1px;
}

.store-buy {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px 6px 5px;
    background: var(--yellow, #FFD23F);
    color: #6A4500;
    border: none;
    border-radius: 999px;
    font-family: 'Nunito', system-ui, sans-serif;
    font-weight: 900;
    font-size: 13px;
    box-shadow: 0 3px 0 #C9A332;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    font-variant-numeric: tabular-nums;
}

.store-buy[disabled],
.store-buy.is-disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.store-buy:active:not([disabled]):not(.is-disabled) {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #C9A332;
}

.store-buy-coin {
    display: inline-flex;
    width: 22px;
    height: 22px;
    align-items: center;
    justify-content: center;
}

.royale-pass-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--royale-purple, #5A2873) 0%, var(--royale-purple-dark, #3C1D52) 100%);
    color: white;
    border: none;
    border-radius: 22px;
    text-align: left;
    box-shadow: 0 6px 0 rgba(60, 29, 82, 0.4), 0 10px 20px rgba(90, 40, 115, 0.25);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    font-family: 'Nunito', system-ui, sans-serif;
    flex: 0 0 auto;
}

.royale-pass-card:active {
    transform: translateY(2px);
    box-shadow: 0 3px 0 rgba(60, 29, 82, 0.4), 0 6px 14px rgba(90, 40, 115, 0.25);
}

.royale-pass-crown {
    display: inline-flex;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    background: var(--yellow, #FFD23F);
    color: #6A4500;
    border-radius: 14px;
    flex: 0 0 auto;
}

.royale-pass-text {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.royale-pass-eyebrow {
    font-size: 10px;
    opacity: 0.8;
    font-weight: 900;
    letter-spacing: 0.5px;
}

.royale-pass-title {
    font-family: 'Bagel Fat One', 'Sigmar', sans-serif;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
}

.royale-pass-cta {
    background: var(--yellow, #FFD23F);
    color: #6A4500;
    padding: 7px 14px;
    border-radius: 999px;
    font-weight: 900;
    font-size: 13px;
    box-shadow: 0 3px 0 #C9A332;
    flex: 0 0 auto;
}

/* Buy-button feedback states — Chunk 1.4 */
.store-buy.is-disabled {
    opacity: 0.5;
    filter: grayscale(0.4);
    cursor: not-allowed;
}

@keyframes store-buy-nope {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(2px); }
}
.store-buy--nope { animation: store-buy-nope 320ms ease-out; }

@keyframes store-buy-pop {
    0% { transform: scale(1); }
    40% { transform: scale(1.12); }
    100% { transform: scale(1); }
}
.store-buy--success { animation: store-buy-pop 320ms ease-out; }

/* Power-up active state — Chunk 1.5 */
.powerup-slot.is-active {
    background: var(--royale-purple, #5A2873);
    color: white;
    border-color: var(--royale-purple-dark, #3C1D52);
    box-shadow: 0 4px 0 rgba(60, 29, 82, 0.4), 0 6px 14px rgba(90, 40, 115, 0.28);
}

.game-board.powerup-active {
    cursor: crosshair;
    box-shadow: inset 0 0 0 2px var(--coral, #FF6B5E), 0 0 0 4px rgba(255, 107, 94, 0.25);
    border-radius: 18px;
}

.game-board.powerup-active .cell {
    cursor: crosshair;
}

body[data-powerup-mode] .powerup-tray {
    box-shadow:
        inset 0 -2px 0 rgba(120, 85, 45, 0.08),
        0 0 0 2px var(--coral, #FF6B5E),
        0 4px 12px rgba(255, 107, 94, 0.25);
}

/* =====================================================
   DAILY CHALLENGE SCREEN — Phase 2, Chunk 2.1
   ===================================================== */
.daily-screen {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100vh;
    padding: max(env(safe-area-inset-top, 0px), 12px) 18px 18px;
    gap: 12px;
    background: var(--cream-bg, #FFF4DF);
    color: var(--royale-purple-dark, #3C1D52);
}

.daily-body {
    flex: 1 1 auto;
    overflow-y: auto;
}

.daily-objective {
    display: flex;
    align-items: stretch;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--royale-purple, #5A2873) 0%, var(--royale-purple-dark, #3C1D52) 100%);
    color: white;
    border: none;
    border-radius: 22px;
    text-align: left;
    box-shadow: 0 6px 0 rgba(60, 29, 82, 0.4), 0 10px 20px rgba(90, 40, 115, 0.25);
    font-family: 'Nunito', system-ui, sans-serif;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.daily-objective::after {
    content: "";
    position: absolute; inset: 0;
    background: radial-gradient(120px 120px at 100% 0%, rgba(255, 107, 94, 0.28), transparent 70%);
    pointer-events: none;
}

.daily-objective-icon {
    display: inline-flex;
    width: 50px;
    height: 50px;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.12);
    color: white;
    border-radius: 16px;
    flex: 0 0 auto;
}

.daily-objective-text {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.daily-objective-eyebrow {
    font-size: 10px;
    opacity: 0.8;
    font-weight: 900;
    letter-spacing: 0.5px;
}

.daily-objective-title {
    font-family: 'Bagel Fat One', 'Sigmar', sans-serif;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.05;
}

.daily-progress-track {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
    margin-top: 4px;
}

.daily-progress-fill {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--coral, #FF6B5E) 0%, var(--yellow, #FFD23F) 100%);
    border-radius: 999px;
    transition: width 220ms ease-out;
}

.daily-progress-text {
    font-size: 11px;
    font-weight: 900;
    opacity: 0.85;
}

.daily-section-title {
    margin: 14px 0 6px;
    font-weight: 900;
    font-size: 11px;
    color: var(--royale-purple-dark, #3C1D52);
    opacity: 0.55;
    letter-spacing: 0.5px;
}

.daily-rewards-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.daily-reward-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    background: var(--surface-card, #FFF8EA);
    border: 1px solid var(--surface-border, rgba(166, 125, 22, 0.18));
    border-radius: 18px;
    box-shadow: inset 0 -2px 0 rgba(120, 85, 45, 0.06);
}

.daily-reward-icon { display: inline-flex; }

.daily-reward-amount {
    font-family: 'Nunito', sans-serif;
    font-weight: 900;
    font-size: 14px;
    color: var(--royale-purple-dark, #3C1D52);
    font-variant-numeric: tabular-nums;
}

.daily-challenges {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.daily-challenge-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--surface-card, #FFF8EA);
    border: 1px solid var(--surface-border, rgba(166, 125, 22, 0.18));
    border-radius: 18px;
    box-shadow: inset 0 -2px 0 rgba(120, 85, 45, 0.06);
}

.daily-challenge-info {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.daily-challenge-name {
    font-family: 'Nunito', sans-serif;
    font-weight: 900;
    font-size: 13px;
    color: var(--royale-purple-dark, #3C1D52);
}

.daily-challenge-progress-track {
    background: rgba(166, 125, 22, 0.18);
    border-radius: 999px;
    height: 6px;
    overflow: hidden;
}

.daily-challenge-progress-fill {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--coral, #FF6B5E) 0%, var(--yellow, #FFD23F) 100%);
    border-radius: 999px;
    transition: width 220ms ease-out;
}

.daily-challenge-progress-text {
    font-size: 10px;
    font-weight: 800;
    opacity: 0.55;
}

.daily-claim {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px 6px 5px;
    background: var(--green, #6DDB98);
    color: #134d2c;
    border: none;
    border-radius: 999px;
    font-family: 'Nunito', sans-serif;
    font-weight: 900;
    font-size: 12px;
    box-shadow: 0 3px 0 #2e9658;
    cursor: pointer;
    font-variant-numeric: tabular-nums;
}

.daily-claim:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #2e9658;
}

.daily-claim.is-disabled {
    background: rgba(166, 125, 22, 0.16);
    color: rgba(60, 29, 82, 0.45);
    box-shadow: none;
    cursor: not-allowed;
}

.daily-claim-icon { display: inline-flex; }

/* =====================================================
   ROYALE PASS MODAL — Phase 4, Chunk 4.1
   ===================================================== */
.royale-pass-modal { max-width: 360px; }

.royale-pass-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.royale-pass-modal-crown {
    flex: 0 0 auto;
    display: inline-flex;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--royale-purple, #5A2873);
    align-items: center;
    justify-content: center;
}
.royale-pass-tagline {
    margin: 4px 0 0;
    font-size: 12px;
    font-weight: 800;
    opacity: 0.6;
}

.royale-pass-tiers {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 260px;
    overflow-y: auto;
    padding: 4px;
    margin-bottom: 12px;
}

.royale-pass-tier {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 12px;
    background: var(--surface-card, #FFF8EA);
    border: 1px solid var(--surface-border, rgba(166, 125, 22, 0.18));
    font-family: 'Nunito', system-ui, sans-serif;
    font-weight: 800;
    font-size: 13px;
}
.royale-pass-tier.is-premium {
    background: linear-gradient(135deg, rgba(90, 40, 115, 0.08) 0%, rgba(255, 210, 63, 0.12) 100%);
    border-color: rgba(166, 125, 22, 0.4);
}
.royale-pass-tier.is-locked {
    opacity: 0.45;
}
.royale-pass-tier-num {
    text-align: center;
    color: var(--royale-purple, #5A2873);
    font-weight: 900;
}
.royale-pass-tier-label {
    color: var(--royale-purple-dark, #3C1D52);
}
.royale-pass-tier-track {
    font-size: 9px;
    letter-spacing: 0.6px;
    color: var(--royale-purple, #5A2873);
    opacity: 0.7;
}
.royale-pass-tier.is-premium .royale-pass-tier-track {
    color: #6A4500;
    opacity: 1;
}

.royale-pass-status {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.05);
    margin-bottom: 10px;
    font-weight: 900;
    font-size: 12px;
    color: rgba(60, 29, 82, 0.6);
}
.royale-pass-status.is-active {
    background: var(--green, #6DDB98);
    color: #134d2c;
}

.royale-pass-activate.is-active {
    background: rgba(166, 125, 22, 0.18);
    color: #6A4500;
}

/* =====================================================
   THEMES — Phase 4, Chunk 4.2
   Theme cards in Store + per-theme palette overrides on [data-theme] on <html>.
   ===================================================== */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.theme-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    background: var(--surface-card, #FFF8EA);
    border: 1px solid var(--surface-border, rgba(166, 125, 22, 0.18));
    border-radius: 18px;
    box-shadow: inset 0 -2px 0 rgba(120, 85, 45, 0.06);
}
.theme-card.is-active {
    border-color: var(--royale-purple, #5A2873);
    box-shadow: 0 0 0 2px var(--coral, #FF6B5E);
}
.theme-card.is-locked .theme-card-preview { opacity: 0.55; filter: grayscale(0.3); }

.theme-card-preview {
    display: flex;
    height: 56px;
    border-radius: 12px;
    overflow: hidden;
}
.theme-swatch { flex: 1; }

.theme-card-name {
    font-family: 'Nunito', system-ui, sans-serif;
    font-weight: 900;
    font-size: 13px;
    color: var(--royale-purple-dark, #3C1D52);
}

.theme-card-cta {
    padding: 6px 12px;
    border-radius: 999px;
    border: none;
    background: var(--royale-purple, #5A2873);
    color: white;
    font-family: 'Nunito', sans-serif;
    font-weight: 900;
    font-size: 12px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.theme-card-cta.is-active { background: var(--green, #6DDB98); color: #134d2c; box-shadow: 0 3px 0 #2e9658; }
.theme-card-cta.is-locked { background: rgba(166, 125, 22, 0.16); color: rgba(60, 29, 82, 0.5); }
.theme-card-cta:active:not(.is-locked):not(.is-active) { transform: translateY(1px); }

/* ---------- Theme palettes ---------- */
/* Default = cream (already in :root). Themes override the same variables. */

html[data-theme="dark"] {
    --cream-bg: #1A0D23;
    --cream-card: #2A1538;
    --cream-cell: #3A1E4F;
    --cream-edge: #4A2A66;
    --royale-purple: #C4A4F0;
    --royale-purple-dark: #E9D9FB;
    --coral: #F472B6;
    --yellow: #FFD23F;
    --blue: #60A5FA;
    --green: #6DDB98;
    --surface-card: #2A1538;
    --surface-border: rgba(196, 164, 240, 0.18);
}

html[data-theme="pastel-dream"] {
    --cream-bg: #FCE7F3;
    --cream-card: #F5D0E5;
    --cream-cell: #FBCFE8;
    --cream-edge: #F0ABFC;
    --royale-purple: #9333EA;
    --royale-purple-dark: #6B21A8;
    --coral: #F87171;
    --yellow: #FCD34D;
    --blue: #93C5FD;
    --green: #A7F3D0;
    --surface-card: #FFE4F1;
    --surface-border: rgba(147, 51, 234, 0.18);
}

html[data-theme="neon-arcade"] {
    --cream-bg: #0B0F1A;
    --cream-card: #131A2C;
    --cream-cell: #1A2240;
    --cream-edge: #2A335C;
    --royale-purple: #A78BFA;
    --royale-purple-dark: #E0E7FF;
    --coral: #F472B6;
    --yellow: #FDE047;
    --blue: #22D3EE;
    --green: #4ADE80;
    --surface-card: #131A2C;
    --surface-border: rgba(167, 139, 250, 0.32);
}

/* =====================================================
   ACHIEVEMENTS + TROPHY — Phase 4, Chunk 4.3
   ===================================================== */
.trophy-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--surface-card, #FFF8EA);
    border: 1px solid var(--surface-border, rgba(166, 125, 22, 0.18));
    border-radius: 999px;
    padding: 4px 10px 4px 6px;
    color: var(--royale-purple-dark, #3C1D52);
    font-family: 'Nunito', system-ui, sans-serif;
    font-weight: 900;
    font-size: 11px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 2px 0 rgba(166, 125, 22, 0.16);
}
.trophy-badge-icon { font-size: 14px; line-height: 1; }
.trophy-badge-value { font-variant-numeric: tabular-nums; }

.achievements-modal { max-width: 360px; }
.achievements-sub {
    font-size: 12px;
    font-weight: 800;
    opacity: 0.6;
    margin: 0 0 12px;
}

.achievements-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 360px;
    overflow-y: auto;
    padding-right: 4px;
    margin-bottom: 12px;
}

.achievement-row {
    display: grid;
    grid-template-columns: 36px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 14px;
    background: var(--surface-card, #FFF8EA);
    border: 1px solid var(--surface-border, rgba(166, 125, 22, 0.18));
    opacity: 0.55;
}
.achievement-row.is-unlocked { opacity: 1; }
.achievement-icon { font-size: 22px; line-height: 1; text-align: center; }
.achievement-name {
    font-family: 'Nunito', sans-serif;
    font-weight: 900;
    font-size: 13px;
    color: var(--royale-purple-dark, #3C1D52);
}
.achievement-desc {
    font-size: 11px;
    font-weight: 800;
    opacity: 0.55;
    margin-top: 1px;
}
.achievement-reward {
    background: var(--yellow, #FFD23F);
    color: #6A4500;
    border-radius: 999px;
    padding: 4px 8px;
    font-weight: 900;
    font-size: 11px;
    box-shadow: 0 2px 0 #C9A332;
}

/* Toast container floats top-centre */
#achievementToast {
    position: fixed;
    top: max(env(safe-area-inset-top, 0px), 18px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.achievement-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--royale-purple, #5A2873) 0%, var(--royale-purple-dark, #3C1D52) 100%);
    color: white;
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(60, 29, 82, 0.4);
    opacity: 0;
    transform: translateY(-12px) scale(0.95);
    transition: opacity 220ms ease-out, transform 260ms cubic-bezier(0.18, 0.89, 0.32, 1.27);
    pointer-events: auto;
    min-width: 240px;
}
.achievement-toast.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.achievement-toast-trophy { font-size: 28px; }
.achievement-toast-eyebrow {
    font-size: 9px;
    opacity: 0.7;
    font-weight: 900;
    letter-spacing: 0.5px;
}
.achievement-toast-name {
    font-family: 'Bagel Fat One', 'Sigmar', sans-serif;
    font-size: 16px;
    font-weight: 700;
}
.achievement-toast-reward {
    font-size: 11px;
    font-weight: 900;
    color: var(--yellow, #FFD23F);
}

/* =====================================================
   TASKS (Daily Archive) — Phase 4, Chunk 4.4
   ===================================================== */
.tasks-screen {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100vh;
    padding: max(env(safe-area-inset-top, 0px), 12px) 18px 18px;
    gap: 12px;
    background: var(--cream-bg, #FFF4DF);
    color: var(--royale-purple-dark, #3C1D52);
}

.tasks-body {
    flex: 1 1 auto;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tasks-card {
    padding: 12px 14px;
    background: var(--surface-card, #FFF8EA);
    border: 1px solid var(--surface-border, rgba(166, 125, 22, 0.18));
    border-radius: 16px;
    box-shadow: inset 0 -2px 0 rgba(120, 85, 45, 0.06);
}
.tasks-card.is-today { border-color: var(--royale-purple, #5A2873); }
.tasks-card.is-complete {
    background: linear-gradient(135deg, rgba(109, 219, 152, 0.18) 0%, var(--surface-card, #FFF8EA) 100%);
}

.tasks-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    font-weight: 900;
    opacity: 0.55;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.tasks-card-medal { font-size: 16px; opacity: 1; }

.tasks-card-goal {
    font-family: 'Nunito', sans-serif;
    font-weight: 900;
    font-size: 14px;
    color: var(--royale-purple-dark, #3C1D52);
}

.tasks-card-progress {
    font-size: 12px;
    font-weight: 800;
    opacity: 0.65;
    margin-top: 4px;
}

.tasks-card-challenges {
    font-size: 11px;
    font-weight: 800;
    opacity: 0.55;
    margin-top: 2px;
}
