/* PinPoint — styles.css */
  /* =====================================================
     DESIGN TOKENS
  ===================================================== */
  :root {
    --ff-display : 'Outfit',  sans-serif;
    --ff-body    : 'Mulish',  sans-serif;

    /* spacing scale */
    --sp-1: 4px;  --sp-2: 7px;  --sp-3: 11px;
    --sp-4: 14px; --sp-5: 18px; --sp-6: 22px;

    /* radii */
    --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-pill: 999px;

    /* transition */
    --t: 0.18s ease;
  }

  /* DARK THEME */
  [data-theme="dark"] {
    --bg          : #0b0f1a;
    --bg-dot      : rgba(255,255,255,0.04);
    --surface     : #131929;
    --surface-2   : #1b2236;
    --surface-3   : #232d44;
    --border      : rgba(255,255,255,0.08);
    --border-2    : rgba(255,255,255,0.14);
    --text-1      : #e8edf8;
    --text-2      : #7e8da8;
    --text-3      : #4a5568;
    --accent      : #38bdf8;
    --accent-2    : #34d399;
    --warn        : #fbbf24;
    --danger      : #f87171;
    --key-bg      : #1b2236;
    --key-border  : rgba(255,255,255,0.12);
    --key-text    : #e8edf8;
    --modal-bg    : #131929;
    --shadow      : 0 16px 48px rgba(0,0,0,0.6);
    --dot-used    : #38bdf8;
    --dot-wrong   : #f87171;
  }

  /* LIGHT THEME */
  [data-theme="light"] {
    --bg          : #f0f4fb;
    --bg-dot      : rgba(0,0,0,0.04);
    --surface     : #ffffff;
    --surface-2   : #e8eef8;
    --surface-3   : #dce4f2;
    --border      : rgba(0,0,0,0.07);
    --border-2    : rgba(0,0,0,0.13);
    --text-1      : #0f172a;
    --text-2      : #64748b;
    --text-3      : #94a3b8;
    --accent      : #0284c7;
    --accent-2    : #059669;
    --warn        : #d97706;
    --danger      : #dc2626;
    --key-bg      : #dce4f2;
    --key-border  : rgba(0,0,0,0.1);
    --key-text    : #0f172a;
    --modal-bg    : #ffffff;
    --shadow      : 0 16px 48px rgba(0,0,0,0.15);
    --dot-used    : #0284c7;
    --dot-wrong   : #dc2626;
  }

  /* =====================================================
     RESET
  ===================================================== */
  *, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    height: 100%;
    overflow: hidden;
  }
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    font-family: var(--ff-body);
    background: var(--bg);
    color: var(--text-1);
    height: 100dvh;
    display: flex;
    justify-content: center;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    transition: background var(--t), color var(--t);
  }
  button {
    font-family: var(--ff-body);
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
  }
  ul { list-style: none; }

  /* dot-grid background */
  body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: radial-gradient(var(--bg-dot) 1.5px, transparent 1.5px);
    background-size: 26px 26px;
    pointer-events: none;
    z-index: 0;
  }

  /* =====================================================
     LAYOUT
  ===================================================== */
  #app {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 460px;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 0 14px calc(20px + env(safe-area-inset-bottom));
  }

  /* =====================================================
     HEADER
  ===================================================== */
  #header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    padding: 12px 0 10px;
    border-bottom: 1px solid var(--border-2);
    margin-bottom: 12px;
  }

  /* header left — streak + calendar grouped together */
  #header-left {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }

  /* streak pill */
  #streak-pill {
    display: flex;
    align-items: center;
    gap: 5px;
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--r-pill);
    padding: 5px 10px 5px 8px;
    flex-shrink: 0;
  }
  #streak-flame {
    font-size: 18px;
    display: inline-block;
    animation: flicker 2s ease-in-out infinite;
  }
  #streak-count {
    font-family: var(--ff-display);
    font-weight: 700;
    font-size: 15px;
    color: var(--warn);
  }
  /* logo */
  #logo {
    font-family: var(--ff-display);
    font-weight: 900;
    font-size: 20px;
    letter-spacing: -0.5px;
    background: linear-gradient(120deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    user-select: none;
    white-space: nowrap;
  }

  /* header right */
  #header-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }

  /* calendar badge */
  #cal-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--r-sm);
    padding: 3px 9px 4px;
    min-width: 40px;
    gap: 0;
    line-height: 1;
  }
  #cal-icon   { font-size: 9px; opacity: 0.7; margin-bottom: 1px; }
  #cal-month  { font-size: 9px; font-weight: 700; letter-spacing: 1.5px; color: var(--accent); text-transform: uppercase; }
  #cal-day    { font-family: var(--ff-display); font-weight: 900; font-size: 17px; color: var(--text-1); }

  /* icon button (theme toggle) */
  .icon-btn {
    width: 36px;
    height: 36px;
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    transition: background var(--t), transform 0.1s;
  }
  .icon-btn:active { transform: scale(0.91); }

  /* =====================================================
     CLUE PANEL
  ===================================================== */
  #clue-panel {
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--r-lg);
    padding: 11px 11px 9px;
    margin-bottom: 10px;
    position: relative;
  }
  #clue-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
  }
  #clue-panel-title {
    font-family: var(--ff-display);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--text-2);
  }
  #clue-dots {
    display: flex;
    gap: 6px;
    align-items: center;
  }
  .clue-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1.5px solid var(--border-2);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: transparent;
    transition: background 0.25s, border-color 0.25s, color 0.25s, transform 0.2s;
  }
  /* wrong guess — red strike */
  .clue-dot.wrong {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
    transform: scale(1.1);
  }
  .clue-dot.wrong::after { content: '\2715'; }
  /* correct guess — green tick */
  .clue-dot.correct {
    background: var(--accent-2);
    border-color: var(--accent-2);
    color: #fff;
    transform: scale(1.15);
    animation: pop 0.35s ease;
  }
  .clue-dot.correct::after { content: '\2713'; }
  @keyframes pop {
    0%   { transform: scale(0.6); }
    60%  { transform: scale(1.3); }
    100% { transform: scale(1.15); }
  }

  /* Horizontal scroll track — one card per clue, snaps on swipe */
  #clue-list {
    display: flex;
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;           /* Firefox */
    padding-bottom: 2px;
  }
  #clue-list::-webkit-scrollbar { display: none; } /* Chrome/Safari */

  .clue-row {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    background: var(--surface-2);
    border-radius: var(--r-sm);
    padding: 10px 12px;
    /* Each card fills the full track width and snaps into place */
    flex: 0 0 100%;
    scroll-snap-align: start;
    opacity: 0;
    transform: translateX(8px);
    animation: rise-x 0.35s ease forwards;
    box-sizing: border-box;
  }
  .clue-emoji { font-size: 17px; min-width: 22px; line-height: 1.4; flex-shrink: 0; }
  .clue-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--text-2);
    margin-bottom: 2px;
  }
  .clue-text  { font-size: 13px; line-height: 1.45; color: var(--text-1); }

  /* Pagination dots below the clue carousel */
  #clue-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    margin-top: 10px;
  }
  .page-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--border-2);
    border: none;
    padding: 0;
    cursor: pointer;
    /* enlarge tap target without changing visual size */
    position: relative;
    transition: background 0.25s, transform 0.25s, width 0.25s;
    flex-shrink: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  .page-dot::before {
    content: '';
    position: absolute;
    inset: -8px;
  }
  .page-dot:hover { background: var(--text-2); }
  .page-dot.active {
    background: var(--accent);
    width: 16px;
    border-radius: 3px;
  }

  /* =====================================================
     BROWSER-ONLY LAYOUT FIX
     Scoped to html:not(.is-native) — APK completely untouched.

     #app is a flex-column at 100dvh.
     Children in play order:
       #header        — flex-shrink:0, always visible
       #middle-zone   — flex:1, fills remaining space
         #clue-panel    — flex-shrink:0, top of middle
         #history       — flex-shrink:0, margin-top:auto pushes to bottom
         #btn-see-result— flex-shrink:0, below history at game-end
         #word-section  — flex-shrink:0, above keyboard
       #keyboard-zone — flex-shrink:0, always at bottom during game

     Game-over (#app.game-over):
       keyboard-zone collapses (height:0, overflow:hidden)
       history fills the full middle zone
       btn-see-result appears below history rows
  ===================================================== */
  html:not(.is-native) #app        { gap: 0; }
  html:not(.is-native) #header     { flex-shrink: 0; }

  html:not(.is-native) #middle-zone {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
  }

  /* Clue panel sits at the top of middle-zone, never shrinks */
  html:not(.is-native) #clue-panel  { flex-shrink: 0; margin-bottom: 6px; }

  /* History: auto top-margin absorbs slack, pushing rows to the bottom.
     overflow:hidden clips oldest rows behind clue panel when full. */
  html:not(.is-native) #history {
    flex: 0 1 auto; /* Changed from flex-shrink: 0 to allow shrinking */
    margin-top: 0;
    gap: 4px;
    margin-bottom: 4px;
    overflow: hidden;
    min-height: 0; /* Important for flex-shrink to work */
  }

  /* See Result button — hidden during game, shown at game-end below history */
  html:not(.is-native) #btn-see-result {
    flex-shrink: 0;
    margin-bottom: 6px;
  }

  /* Word/dash section above keyboard */
  html:not(.is-native) #word-section { 
    flex-shrink: 0; 
    margin-bottom: 8px; /* Slightly more space */
    padding-bottom: 4px;
  }

  /* Keyboard zone always pinned at the bottom during the game */
  html:not(.is-native) #keyboard-zone {
    flex: 0 0 auto;
    margin-top: 10px;
    padding-top: 0;
    transition: none;
    max-height: none;
  }

  /* Game-over: collapse keyboard-zone so middle-zone expands to fill screen */
  html:not(.is-native) #app.game-over #keyboard-zone {
    max-height: 0;
    padding-top: 0;
  }

  /* Game-over: history fills all space between clue panel and see-result button,
     rows stay centred and anchored to the bottom */
  html:not(.is-native) #app.game-over #history {
    flex: 0 1 auto;      /* Don't force it to grow/fill the whole screen */
    margin-top: 0;       /* Remove the auto-push */
    justify-content: flex-start; 
    overflow: visible;   /* Allow seeing all guesses if they fit */
    margin-bottom: 12px;
  }

  html:not(.is-native) #app.game-over #btn-see-result {
    margin-top: 0;       /* Keep it snug against the history */
    margin-bottom: 20px;
  }
  /* On native Capacitor the wrapper divs are invisible to layout */
  html.is-native #middle-zone,
  html.is-native #keyboard-zone { display: contents; }

  /* Shrink keys on short screens */
  @media (max-height: 680px) {
    html:not(.is-native) .key           { height: 42px; font-size: 14px; }
    html:not(.is-native) #keyboard      { gap: 3px; margin-bottom: 7px; }
    html:not(.is-native) #clue-panel    { padding: 7px 11px 6px; margin-bottom: 4px; }
    html:not(.is-native) #history       { gap: 3px; }
    html:not(.is-native) #word-section  { margin-bottom: 2px; }
    html:not(.is-native) #keyboard-zone { max-height: 240px; }
  }
  @media (max-height: 600px) {
    html:not(.is-native) .key           { height: 40px; font-size: 13px; }
    html:not(.is-native) #keyboard      { gap: 2px; margin-bottom: 6px; }
    html:not(.is-native) #keyboard-zone { max-height: 200px; }
  }

  /* =====================================================
     WRONG GUESS HISTORY

  ===================================================== */
  #history {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 8px;
  }
  .history-row {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 3px;
    padding: 0 3px;
    opacity: 0;
    animation: rise 0.28s ease forwards;
  }
  /* spacer between words in a history row */
  .history-gap { width: clamp(6px, var(--tile-w, 26px) * 0.35, 10px); }
  /* individual letter tile in history */
  .history-tile {
    width: var(--tile-w, 26px);
    height: var(--tile-h, 32px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 3px;
    border-bottom: 2.5px solid var(--border-2);
  }
  .history-tile span {
    font-family: var(--ff-display);
    font-weight: 700;
    font-size: var(--tile-font, 15px);
    text-transform: uppercase;
    line-height: 1;
  }
  /* correct position — green */
  .history-tile.tile-correct {
    border-bottom-color: var(--accent-2);
  }
  .history-tile.tile-correct span { color: var(--accent-2); }
  /* letter present but wrong position — orange */
  .history-tile.tile-present {
    border-bottom-color: var(--warn);
  }
  .history-tile.tile-present span { color: var(--warn); }
  /* letter not in answer — muted */
  .history-tile.tile-absent span { color: var(--text-2); }

  /* Progressive shrinking — oldest guesses appear smaller.
     :nth-last-child(1) = newest (full size, no change needed)
     Each step back shrinks tiles and font by a small increment. */
  #history .history-row:nth-last-child(n+2) .history-tile {
    width: 23px;
    height: 28px;
  }
  #history .history-row:nth-last-child(n+2) .history-tile span {
    font-size: 13px;
  }
  #history .history-row:nth-last-child(n+3) .history-tile {
    width: 21px;
    height: 25px;
  }
  #history .history-row:nth-last-child(n+3) .history-tile span {
    font-size: 12px;
  }
  #history .history-row:nth-last-child(n+4) .history-tile {
    width: 19px;
    height: 22px;
  }
  #history .history-row:nth-last-child(n+4) .history-tile span {
    font-size: 11px;
  }
  #history .history-row:nth-last-child(n+5) .history-tile {
    width: 17px;
    height: 20px;
    padding-bottom: 2px;
    border-bottom-width: 2px;
  }
  #history .history-row:nth-last-child(n+5) .history-tile span {
    font-size: 10px;
  }

  /* =====================================================
     WORD / DASH DISPLAY
  ===================================================== */
  #word-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
  }
  #word-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--text-2);
  }
  #dash-row {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 4px;
    padding: 0 4px;
  }
  .letter-tile {
    width: var(--tile-w, 26px);
    height: var(--tile-h, 32px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 3px;
    border-bottom: 2.5px solid var(--border-2);
    transition: border-color 0.2s;
  }
  .letter-tile.cursor {
    border-color: var(--accent);
    animation: blink 1.1s ease-in-out infinite;
  }
  .letter-tile.hint-revealed {
    border-color: var(--accent-2);
  }
  .letter-tile.hint-revealed span {
    color: var(--accent-2);
  }
  .letter-tile span {
    font-family: var(--ff-display);
    font-weight: 700;
    font-size: var(--tile-font, 15px);
    color: var(--text-1);
    text-transform: uppercase;
    line-height: 1;
  }
  .word-spacer { width: clamp(6px, var(--tile-w, 26px) * 0.35, 10px); }

  /* =====================================================
     KEYBOARD
  ===================================================== */
  #keyboard {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 10px;
  }
  .kb-row {
    display: flex;
    justify-content: center;
    gap: 4px;
  }
  .key {
    flex: 1;
    max-width: 36px;
    height: 42px;
    background: var(--key-bg);
    border: 1px solid var(--key-border);
    border-radius: var(--r-sm);
    color: var(--key-text);
    font-family: var(--ff-body);
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    transition: background var(--t), transform 0.08s;
  }
  .key:active { transform: scale(0.88); }
  .key-del {
    max-width: 52px;
    background: var(--surface-3);
    font-size: 16px;
    color: var(--text-2);
  }

  /* =====================================================
     BOTTOM ACTIONS
  ===================================================== */
  #bottom-bar {
    display: flex;
    gap: 8px;
    align-items: stretch;
  }
  #hint-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--r-md);
    padding: 7px 14px;
    color: var(--text-2);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
    white-space: nowrap;
    transition: color var(--t), border-color var(--t), background var(--t);
    touch-action: manipulation;
  }
  #hint-btn:hover { color: var(--warn); border-color: var(--warn); background: rgba(251,191,36,0.06); }
  #hint-btn .hint-icon { font-size: 20px; }
  #submit-btn {
    flex: 1;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-radius: var(--r-md);
    color: #fff;
    font-family: var(--ff-display);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.3px;
    padding: 12px;
    touch-action: manipulation;
    transition: opacity var(--t), transform 0.1s;
  }
  #submit-btn:hover  { opacity: 0.9; }
  #submit-btn:active { transform: scale(0.97); }

  /* =====================================================
     MODAL SHARED
  ===================================================== */
  .overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(20px + env(safe-area-inset-top)) 20px calc(20px + env(safe-area-inset-bottom));
    z-index: 500;
    animation: fade-in 0.22s ease;
  }
  .overlay.hidden { display: none; }

  .modal {
    background: var(--modal-bg);
    border: 1px solid var(--border-2);
    border-radius: var(--r-lg);
    padding: 22px 20px;
    width: 100%;
    max-width: 400px;
    max-height: 90dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: var(--shadow);
    animation: slide-up 0.26s ease;
  }
  .modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
  }
  .modal-title {
    font-family: var(--ff-display);
    font-weight: 900;
    font-size: 19px;
    background: linear-gradient(120deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }
  .modal-close {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-2);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color var(--t);
  }
  .modal-close:hover { color: var(--text-1); }
  .modal-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-radius: var(--r-md);
    color: #fff;
    font-family: var(--ff-display);
    font-size: 14px;
    font-weight: 700;
    padding: 13px;
    touch-action: manipulation;
    transition: opacity var(--t);
  }
  .modal-btn:hover { opacity: 0.9; }

  /* =====================================================
     RULES MODAL
  ===================================================== */
  #rules-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
  }
  .rule-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--surface-2);
    border-radius: var(--r-sm);
    padding: 10px;
  }
  .rule-num {
    min-width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(56,189,248,0.12);
    border: 1px solid rgba(56,189,248,0.3);
    color: var(--accent);
    font-family: var(--ff-display);
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  .rule-text { font-size: 13px; line-height: 1.5; color: var(--text-1); }
  .rule-text b { color: var(--accent-2); font-weight: 600; }

  #colour-key {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
  }
  .colour-key-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface-2);
    border-radius: var(--r-sm);
    padding: 8px 11px;
  }
  .colour-key-tile {
    width: 26px;
    height: 32px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 3px;
    border-bottom: 2.5px solid var(--border-2);
    flex-shrink: 0;
  }
  .colour-key-tile span {
    font-family: var(--ff-display);
    font-weight: 700;
    font-size: 15px;
    text-transform: uppercase;
    line-height: 1;
  }
  .colour-key-tile.tile-correct { border-bottom-color: var(--accent-2); }
  .colour-key-tile.tile-correct span { color: var(--accent-2); }
  .colour-key-tile.tile-present { border-bottom-color: var(--warn); }
  .colour-key-tile.tile-present span { color: var(--warn); }
  .colour-key-tile.tile-absent span  { color: var(--text-2); }
  .colour-key-text { font-size: 12px; color: var(--text-1); }
  .colour-key-text b { font-weight: 700; }

  #score-guide {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
    margin-bottom: 16px;
  }
  .score-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    padding: 4px 10px;
    font-size: 11px;
  }
  .chip-stars { color: var(--warn); }
  .chip-clue  { color: var(--text-2); }



  /* =====================================================
     AD MODAL
  ===================================================== */
  #ad-box {
    background: var(--surface-2);
    border: 2px dashed var(--border-2);
    border-radius: var(--r-md);
    padding: 32px 16px;
    text-align: center;
    margin: 14px 0;
  }
  #ad-banner-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 8px;
  }
  #ad-countdown {
    font-family: var(--ff-display);
    font-weight: 900;
    font-size: 36px;
    color: var(--text-1);
    line-height: 1;
    margin-bottom: 4px;
  }
  #ad-sub {
    font-size: 11px;
    color: var(--text-2);
    margin-bottom: 14px;
  }
  #ad-skip-btn {
    background: none;
    border: 1px solid var(--border-2);
    border-radius: var(--r-pill);
    color: var(--text-2);
    font-size: 12px;
    font-weight: 600;
    padding: 7px 18px;
    transition: color var(--t), border-color var(--t);
  }
  #ad-skip-btn:not(:disabled):hover { color: var(--accent-2); border-color: var(--accent-2); }
  #ad-skip-btn:disabled { opacity: 0.3; cursor: not-allowed; }
  #ad-upsell {
    font-size: 11px;
    color: var(--text-2);
    text-align: center;
  }
  #ad-upsell span {
    color: var(--warn);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
  }

  /* =====================================================
     RESULT MODAL
  ===================================================== */
  #result-stars  { font-size: 28px; text-align: center; margin: 10px 0 14px; min-height: 36px; }
  #result-name   { font-family: var(--ff-display); font-weight: 900; font-size: 24px; color: var(--text-1); text-align: center; }
  #result-detail { font-size: 12px; color: var(--text-2); text-align: center; margin-bottom: 14px; }
  #result-fact {
    background: var(--surface-2);
    border-left: 3px solid var(--accent);
    border-radius: var(--r-sm);
    padding: 11px 13px;
    font-size: 13px;
    line-height: 1.55;
    color: var(--text-1);
    margin-bottom: 14px;
  }
  /* =====================================================
     RESULT STATS SECTION
  ===================================================== */
  #result-stats {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 14px 14px 12px;
    margin-bottom: 14px;
  }

  .stats-title {
    display: block;
    font-family: var(--ff-display);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--text-2);
    margin-bottom: 10px;
  }

  /* ── Top row: streak / played / win% ── */
  #stats-row {
    display: flex;
    align-items: center;
    justify-content: space-around;
    margin-bottom: 16px;
  }
  .stat-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex: 1;
  }
  .stat-num {
    font-family: var(--ff-display);
    font-weight: 900;
    font-size: 22px;
    color: var(--text-1);
    line-height: 1;
  }
  .stat-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--text-2);
    white-space: nowrap;
  }
  .stat-divider {
    width: 1px;
    height: 36px;
    background: var(--border-2);
    flex-shrink: 0;
  }

  /* ── Distribution bars ── */
  #dist-section { margin-bottom: 14px; }
  #dist-bars {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }
  .dist-row {
    display: flex;
    align-items: center;
    gap: 7px;
  }
  .dist-label {
    font-family: var(--ff-display);
    font-size: 11px;
    font-weight: 700;
    color: var(--text-2);
    width: 84px;
    flex-shrink: 0;
    white-space: nowrap;
  }
  .dist-track {
    flex: 1;
    height: 18px;
    background: var(--surface-3);
    border-radius: var(--r-pill);
    overflow: hidden;
  }
  .dist-fill {
    height: 100%;
    border-radius: var(--r-pill);
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    min-width: 0;
    transition: width 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  .dist-fill.dist-highlight {
    background: linear-gradient(90deg, var(--accent-2), #10b981);
  }
  .dist-count-outside {
    font-family: var(--ff-display);
    font-size: 11px;
    font-weight: 700;
    color: var(--text-2);
    min-width: 18px;
    text-align: right;
    flex-shrink: 0;
  }

  /* ── Countdown ── */
  #next-puzzle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface-3);
    border-radius: var(--r-sm);
    padding: 9px 12px;
  }
  .next-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-2);
  }
  #next-countdown {
    font-family: var(--ff-display);
    font-weight: 900;
    font-size: 18px;
    color: var(--accent);
    letter-spacing: 1px;
  }

  #share-btn {
    width: 100%;
    background: none;
    border: 1px solid var(--border-2);
    border-radius: var(--r-md);
    color: var(--text-1);
    font-family: var(--ff-display);
    font-size: 13px;
    font-weight: 700;
    padding: 11px;
    margin-bottom: 9px;
    touch-action: manipulation;
    transition: color var(--t), border-color var(--t);
  }
  #share-btn:hover { color: var(--accent); border-color: var(--accent); }

  /* =====================================================
     SETTINGS MODAL
  ===================================================== */
  #settings-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .settings-row {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--text-1);
    font-family: var(--ff-body);
    font-size: 15px;
    font-weight: 500;
    text-align: left;
    touch-action: manipulation;
    transition: background var(--t), border-color var(--t);
    cursor: pointer;
  }
  .settings-row:hover,
  .settings-row:active {
    background: var(--surface-3, var(--border));
    border-color: var(--border-2);
  }
  .settings-icon {
    font-size: 20px;
    flex-shrink: 0;
    width: 28px;
    text-align: center;
  }
  .settings-label {
    flex: 1;
  }
  .settings-chevron {
    color: var(--text-2);
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
  }

  /* =====================================================
     NO-ADS MODAL
  ===================================================== */
  #noads-price-block { text-align: center; margin: 12px 0 16px; }
  #noads-price {
    font-family: var(--ff-display);
    font-weight: 900;
    font-size: 42px;
    color: var(--text-1);
  }
  .hidden {
  display: none !important;
  }
  #noads-price-sub { font-size: 12px; color: var(--text-2); }
  #noads-perks { display: flex; flex-direction: column; gap: 9px; margin-bottom: 18px; }
  .perk-row { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-1); }
  .perk-check { color: var(--accent-2); font-size: 15px; flex-shrink: 0; }

  /* =====================================================
     TOAST
  ===================================================== */
  #toast {
    position: fixed;
    bottom: calc(24px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: var(--surface-3);
    border: 1px solid var(--border-2);
    color: var(--text-1);
    font-size: 13px;
    font-weight: 500;
    padding: 9px 20px;
    border-radius: var(--r-pill);
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    white-space: nowrap;
    box-shadow: var(--shadow);
    transition: opacity 0.25s ease, transform 0.25s ease;
  }
  #toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }

  /* =====================================================
     ANIMATIONS
  ===================================================== */
  @keyframes flicker {
    0%,100% { transform: rotate(-4deg) scale(1); }
    50%      { transform: rotate(4deg) scale(1.15); }
  }
  @keyframes rise {
    to { opacity: 1; transform: translateY(0); }
  }
  @keyframes rise-x {
    to { opacity: 1; transform: translateX(0); }
  }
  @keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
  }
  @keyframes slide-up {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  @keyframes blink {
    0%,100% { border-color: var(--accent); }
    50%      { border-color: var(--accent-2); }
  }
  @keyframes shake {
    0%,100% { transform: translateX(0); }
    20%     { transform: translateX(-6px); }
    40%     { transform: translateX(6px); }
    60%     { transform: translateX(-4px); }
    80%     { transform: translateX(4px); }
  }
  .shake { animation: shake 0.36s ease; }

  /* reduced-motion */
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.01ms !important;
      transition-duration: 0.01ms !important;
    }
  }