/* Online multiplayer screen: small additions on top of the compiled design system. */
[data-screen=online] [hidden]{display:none!important}
.ol-stack{display:grid;grid-template-columns:minmax(0,1fr);min-width:0;gap:.75rem}
.ol-stack>*{min-width:0;max-width:100%;box-sizing:border-box}
.ol-stack>label,.ol-stack>p{overflow-wrap:anywhere}
.ol-center{justify-items:center;text-align:center}
.ol-players{display:grid;grid-template-columns:1fr 1fr;gap:.5rem}
.ol-conn{display:inline-flex;align-items:center;gap:.4rem;padding:.25rem .65rem;border-radius:999px;border:1px solid var(--color-border,#cbd5e1);background:var(--color-surface,#fff);font-size:.75rem;font-weight:700;color:var(--color-foreground-muted,#475569);white-space:nowrap}
.ol-conn:empty{display:none}
.ol-dot{width:.5rem;height:.5rem;border-radius:50%;background:var(--color-danger,#dc2626);flex:none}
[data-on="1"]>.ol-dot,.ol-dot[data-on="1"]{background:var(--color-success,#16a34a)}
.ol-dot[data-on="w"]{background:#d97706}
.ol-input{min-height:3rem;width:100%;border-radius:1rem;border:1px solid var(--color-border,#cbd5e1);background:var(--color-surface-strong,#fff);color:var(--color-foreground,#0f172a);padding:0 1rem;font:inherit;font-weight:700}
.ol-input:focus-visible{outline:2px solid var(--color-brand,#2563eb);outline-offset:2px}
.ol-name-display{display:flex;align-items:center;min-height:3rem;width:100%;border-radius:1rem;border:1px solid var(--lg-rim,var(--color-border,#cbd5e1));background:color-mix(in oklab,var(--surface-strong,#fff) 55%,transparent);color:var(--foreground,#0f172a);padding:0 1rem;font:inherit;font-weight:800;user-select:none}
.ol-code-input{text-transform:uppercase;letter-spacing:.3em;text-align:center}
.ol-code{font-family:var(--font-display,inherit);font-size:2.25rem;font-weight:800;letter-spacing:.3em;margin-right:-.3em}
.ol-err{border-radius:1rem;padding:.65rem 1rem;font-weight:700;color:var(--color-danger,#dc2626);border:1px solid currentColor;background:transparent}
.ol-banner{padding:.75rem 1rem;font-weight:700;text-align:center}
.ol-banner button{margin-top:.5rem}
.ol-player{display:flex;align-items:center;gap:.5rem;min-width:0;padding:.5rem .75rem}
.ol-player[data-me]{outline:2px solid var(--color-brand,#2563eb)}
.ol-player .nm{min-width:0;flex:1}
.ol-player .nm b{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ol-player .nm small{color:var(--color-foreground-muted,#475569);font-weight:600}
@keyframes ol-spin{to{transform:rotate(360deg)}}
#ol-rematch[hidden]+#ol-leave{grid-column:1/-1}
@media(max-width:520px){[data-screen=online]>header{flex-wrap:nowrap;gap:.5rem}[data-screen=online]>header>div:first-child{min-width:0;flex:1 1 auto}[data-screen=online]>header>div:last-child{flex-direction:column;align-items:flex-end;gap:.4rem}[data-screen=online]>header .screen-title{font-size:1.15rem}[data-screen=online]>header .screen-subtitle{display:none}.ol-conn{margin-left:0;padding:.15rem .5rem;font-size:.7rem}}
.pf-genders{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:.65rem}
.pf-genders>.btn{min-width:0;width:100%;padding-inline:.75rem;box-sizing:border-box}
.rv { display: flex; align-items: center; justify-content: center; gap: .75rem; }
.rv[hidden] { display: none; }
.rv .btn { min-width: 3rem; min-height: 3rem; padding: 0; }
.rv .btn:disabled { opacity: .4; cursor: not-allowed; }
.rv span { min-width: 6.5rem; text-align: center; font-weight: 700; font-size: .875rem; }

.pf-id{font-family:'Fredoka',system-ui,sans-serif;font-weight:600;font-size:1rem;letter-spacing:.04em;font-variant-numeric:tabular-nums}

.ac-pwrow{display:flex;gap:.5rem}.ac-pwrow .ol-input{flex:1;min-width:0}.ac-val{word-break:break-all;font-size:1.25rem}.ac-big{font-size:2rem;letter-spacing:.08em;font-variant-numeric:tabular-nums}
.ac-dialog{border:1px solid var(--border);border-radius:1.5rem;background:var(--surface-strong);color:var(--foreground);padding:1rem;max-width:min(94vw,30rem);margin:auto;box-shadow:0 24px 60px -20px rgb(var(--shadow-rgb)/.5)}
.ac-dialog::backdrop{background:rgb(0 0 0/.55)}.ac-dialog img{width:100%;height:auto;border-radius:1rem;margin-bottom:.75rem}.ac-actions{display:flex;gap:.5rem;margin-top:.75rem}.ac-actions .btn{flex:1}
.ac-dialog[open]{animation:screen-in 240ms var(--ease-expo) both}
.ol-err[data-bad=""]{color:var(--foreground)}
.ac-note{margin:0;padding:.75rem 1rem;border-radius:1rem;border:1px solid var(--danger);color:var(--foreground);font-size:.8125rem}
/* profile: UID number sits right under its tag; recovery pill in the bottom-right corner */
#pf-idcard .pf-id{margin-block:-.45rem 0}
/* recovery pill sits in the viewport's bottom-right corner; the screen keeps room under Log out so it never covers it */
.pf-corner{position:fixed;right:1rem;bottom:1rem;z-index:5}
[data-screen=profile]{padding-bottom:4rem}

.pf-main{position:relative}
.pf-tools{position:absolute;top:.75rem;right:.75rem;display:flex;gap:.4rem}
.pf-tools .icon-btn{width:2.25rem;height:2.25rem;min-width:0;min-height:0}
/* Themes, symbol effects, and accessible touch sizing (plain CSS, no build step) */
[data-theme="aurora"]{color-scheme:light;--page-from:#e6f1ff;--page-to:#f2ecff;--foreground:#0f1f4d;--foreground-muted:#44577f;--surface:rgb(255 255 255 / .7);--surface-strong:#ffffff;--border:rgb(37 99 235 / .2);--brand:#2563eb;--brand-strong:#1d4ed8;--brand-foreground:#ffffff;--mark-x:#2563eb;--mark-o:#a21caf;--success:#15803d;--danger:#b91c1c;--focus:#2563eb;--shadow-rgb:15 31 77}
[data-theme="midnight"]{color-scheme:dark;--page-from:#050816;--page-to:#1a1040;--foreground:#eef3ff;--foreground-muted:#b3c3e6;--surface:rgb(30 24 80 / .62);--surface-strong:#2e2470;--border:rgb(150 140 255 / .3);--brand:#5b49f5;--brand-strong:#4b38e0;--brand-foreground:#ffffff;--mark-x:#38e8ff;--mark-o:#e07bff;--success:#34d399;--danger:#ff8a8a;--focus:#5b49f5;--shadow-rgb:0 0 0}
[data-theme="ocean"]{color-scheme:dark;--page-from:#040b2e;--page-to:#0b2a7a;--foreground:#eaf6ff;--foreground-muted:#b6d0f5;--surface:rgb(10 30 110 / .6);--surface-strong:#12307f;--border:rgb(56 189 248 / .35);--brand-foreground:#ffffff;--mark-x:#38bdf8;--success:#34d399;--danger:#ff8a8a;--shadow-rgb:0 0 0}
[data-theme="sunset"]{color-scheme:light;--page-from:#ffe7d6;--page-to:#ffc4aa;--foreground:#4a1d0d;--foreground-muted:#7a3d27;--surface:rgb(255 255 255 / .6);--surface-strong:#fff6ef;--border:rgb(234 88 12 / .28);--brand:#c2410c;--brand-strong:#9a3412;--brand-foreground:#ffffff;--mark-x:#be123c;--mark-o:#9a3412;--success:#15803d;--danger:#b91c1c;--focus:#c2410c;--shadow-rgb:74 29 13}
[data-theme="forest"]{color-scheme:light;--foreground:#12361a;--foreground-muted:#355c3b;--surface:rgb(255 255 255 / .6);--surface-strong:#fbfff4;--border:rgb(47 125 50 / .28);--brand:#2f7d32;--brand-strong:#256628;--brand-foreground:#ffffff;--mark-x:#15803d;--mark-o:#b45309;--success:#15803d;--danger:#b91c1c;--focus:#2f7d32;--shadow-rgb:18 54 26}
[data-theme="lavender"]{color-scheme:light;--page-from:#f1e6ff;--page-to:#dcc8ff;--foreground:#2e1a5c;--foreground-muted:#59427f;--surface:rgb(255 255 255 / .62);--surface-strong:#fcf8ff;--border:rgb(124 58 237 / .26);--brand:#7c3aed;--brand-strong:#6d28d9;--brand-foreground:#ffffff;--mark-x:#7c3aed;--mark-o:#be185d;--success:#15803d;--danger:#b91c1c;--focus:#7c3aed;--shadow-rgb:46 26 92}
[data-theme="royal"]{color-scheme:dark;--page-from:#040b2e;--page-to:#0b2a7a;--foreground:#fff6d6;--foreground-muted:#c9d4f5;--surface:rgb(10 30 110 / .6);--surface-strong:#12307f;--border:rgb(255 201 60 / .35);--brand:#f5b800;--brand-strong:#e0a800;--brand-foreground:#1a1200;--mark-x:#ffc93c;--mark-o:#9cc2ff;--success:#34d399;--danger:#ff8a8a;--focus:#f5b800;--shadow-rgb:0 0 0}
[data-theme="minimal"]{color-scheme:light;--page-from:#fafafa;--page-to:#e8ebf0;--foreground:#111827;--foreground-muted:#4b5563;--surface:rgb(255 255 255 / .8);--surface-strong:#ffffff;--border:rgb(17 24 39 / .16);--brand:#111827;--brand-strong:#000000;--brand-foreground:#ffffff;--mark-x:#111827;--mark-o:#1d4ed8;--success:#15803d;--danger:#b91c1c;--focus:#111827;--shadow-rgb:17 24 39}
[data-theme="candy"]{color-scheme:light;--page-from:#ffd9ec;--page-to:#ffe9bd;--foreground:#5b1240;--foreground-muted:#86456a;--surface:rgb(255 255 255 / .62);--surface-strong:#fff7fb;--border:rgb(190 24 93 / .28);--brand:#be185d;--brand-strong:#9d174d;--brand-foreground:#ffffff;--mark-x:#7c3aed;--mark-o:#be185d;--success:#15803d;--danger:#b91c1c;--focus:#be185d;--shadow-rgb:91 18 64}
[data-theme="glass"]{color-scheme:light;--page-from:#d9e8ff;--page-to:#e6dcff;--foreground:#1c2c5a;--foreground-muted:#47588a;--surface:rgb(255 255 255 / .45);--surface-strong:rgb(255 255 255 / .8);--border:rgb(255 255 255 / .7);--brand:#2563eb;--brand-strong:#1d4ed8;--brand-foreground:#ffffff;--mark-x:#1d4ed8;--mark-o:#6d28d9;--success:#15803d;--danger:#b91c1c;--focus:#2563eb;--shadow-rgb:28 44 90}
[data-theme="vintage"]{color-scheme:light;--page-from:#ecd3a6;--page-to:#c99a62;--foreground:#3a1f0b;--foreground-muted:#66421f;--surface:rgb(255 248 232 / .62);--surface-strong:#fff8ea;--border:rgb(122 67 30 / .32);--brand:#8a4a1c;--brand-strong:#6f3a14;--brand-foreground:#ffffff;--mark-x:#4a2c12;--mark-o:#b91c1c;--success:#15803d;--danger:#b91c1c;--focus:#8a4a1c;--shadow-rgb:58 31 11}

/* symbol effects */
svg[data-s="3"]{filter:drop-shadow(0 3px 2px rgb(0 0 0/.28)) drop-shadow(0 0 5px color-mix(in oklab,currentColor 55%,transparent))}
svg[data-s="5"]{filter:drop-shadow(0 0 2px currentColor) drop-shadow(0 0 7px currentColor)}
svg[data-s="10"]{filter:drop-shadow(0 2px 1px rgb(0 0 0/.18))}

/* Home top bar: profile pinned left, theme toggle pinned right */
main{position:relative;z-index:1}
.home-bar{display:flex;flex-direction:row;align-items:center;justify-content:space-between;width:100%}

/* Mobile & Low-End GPU Perf: avoid full-screen bg-fixed repaints on mobile/tablet */
@media(max-width:1023px){body{background-attachment:scroll}}

/* WCAG 2.5.5 / 44x44px Touch Target Floor (45px accounts for .screen-enter scale(0.992) on entry) */
.icon-btn{min-width:45px;min-height:45px;width:45px;height:45px}
.seg>button{min-height:45px;min-width:45px;padding-inline:.875rem}
.theme-switch{min-height:45px;height:45px;width:84px}
@media(max-width:639px){.theme-switch{width:76px;height:45px;min-height:45px}.ts-slot{width:40px}.ts-knob{width:35px;height:35px;top:5px;left:5px}.theme-switch[aria-checked="true"] .ts-knob{transform:translateX(31px)}}
.switch{min-width:52px;min-height:45px;width:52px;height:45px;background-color:transparent!important;cursor:pointer}
.switch::before{content:"";position:absolute;inset-inline:0;top:8.5px;height:28px;border-radius:999px;background-color:color-mix(in oklab,var(--foreground-muted) 45%,transparent);transition:background-color .22s ease}
.switch[aria-checked="true"]::before{background-color:var(--brand)}
.switch::after{top:11.5px;left:3px}
.switch[aria-checked="true"]::after{transform:translateX(24px)}
#volume{min-height:45px;height:45px;cursor:pointer}

/* Button/card motion lives in ONE place: the "interaction system" at the end of glass.css. */

/* ==========================================================================
   REALISTIC LIQUID GLASS UI — STATISTICS DASHBOARD & MODE CARDS
   1. Authentic glass transparency first (background visible through cards)
   2. Controlled corner/edge refraction via ::before
   3. Non-button display cards (no hover lift / CTA button behavior)
   4. Dimensional UI icon medallions (no milky top glare cap, no 2D cartoon look)
   5. Responsive side-by-side layout on Canvas (639px+) and desktop (1280px+)
   ========================================================================== */

/* Expand #app container width when Statistics or Mode screen is active so side-by-side layout works on 600px+ viewports */
@media (min-width: 560px) {
  #app:has([data-screen="stats"]:not([hidden])),
  #app:has([data-screen="mode"]:not([hidden])) {
    max-width: 68rem !important;
    padding-inline: 1rem !important;
  }
}
@media (min-width: 960px) {
  #app:has([data-screen="stats"]:not([hidden])),
  #app:has([data-screen="mode"]:not([hidden])) {
    padding-inline: 2rem !important;
  }
}

/* Enhance background ambient color depth subtly when Statistics screen is shown so background refraction is clearly perceptible through the glass cards */
body:has([data-screen="stats"]:not([hidden])) {
  background-image:
    radial-gradient(46rem 28rem at 18% 28%, color-mix(in oklab, var(--brand) 22%, transparent), transparent 65%),
    radial-gradient(44rem 28rem at 82% 72%, color-mix(in oklab, var(--mark-o) 20%, transparent), transparent 65%),
    linear-gradient(160deg, var(--page-from), var(--page-to));
}

/* ---- Desktop Side-by-Side Layout (>= 560px) & Mobile Stack (< 560px) ---- */
.stats-dashboard {
  width: 100%;
}

@media (min-width: 560px) {
  .stats-dashboard {
    display: grid !important;
    grid-template-columns: minmax(0, 1.22fr) minmax(0, 0.95fr) !important;
    grid-template-rows: auto auto auto !important;
    column-gap: 0.9rem !important;
    row-gap: 1rem !important;
    align-content: center !important;
    margin-block: auto !important;
  }
  .stats-dashboard > .stats-header {
    grid-column: 1 / -1 !important;
    grid-row: 1 !important;
  }
  .stats-dashboard > .stats-cards-col {
    grid-column: 1 !important;
    grid-row: 2 !important;
    align-self: stretch !important;
  }
  .stats-dashboard > .recent-glass-panel {
    grid-column: 2 !important;
    grid-row: 2 !important;
    align-self: stretch !important;
  }
  .stats-dashboard > .stats-reset-btn {
    grid-column: 1 !important;
    grid-row: 3 !important;
    justify-self: start !important;
  }
}

@media (min-width: 960px) {
  .stats-dashboard {
  }
}

/* 3-Column x 2-Row Statistics Grid on Desktop/Canvas; 2-Column on Mobile */
.stats-cards-grid {
  display: grid;
  gap: 0.75rem;
  margin: 0;
}

@media (min-width: 960px) {
  .stats-cards-grid {
    gap: 0.9rem;
  }
}

@media (max-width: 559px) {
  .stats-cards-grid {
    gap: 0.75rem;
  }
}

/* ---- Header & Back Button (Theme Toggle Untouched!) ---- */
.stats-back-btn {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.36),
    rgba(195, 222, 252, 0.16) 50%,
    rgba(255, 255, 255, 0.24)
  ) !important;
  backdrop-filter: blur(16px) saturate(165%) !important;
  -webkit-backdrop-filter: blur(16px) saturate(165%) !important;
  border: 1px solid rgba(255, 255, 255, 0.75) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.88),
    inset 0 -1px 0 rgba(56, 189, 248, 0.28),
    0 6px 16px rgba(45, 70, 130, 0.08) !important;
}

[data-dark] .stats-back-btn {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.12),
    rgba(255, 255, 255, 0.04) 50%,
    rgba(255, 255, 255, 0.08)
  ) !important;
  border-color: rgba(255, 255, 255, 0.20) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.30),
    inset 0 -1px 0 rgba(56, 189, 248, 0.22),
    0 6px 16px rgba(0, 0, 0, 0.28) !important;
}

.stats-title-group {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.stats-heading {
  font-size: clamp(1.5rem, 2.5vw, 2.05rem) !important;
  letter-spacing: -0.02em !important;
  margin: 0;
}

/* ---- Six Statistics Cards: Authentic Transparent Liquid Glass Information Panels ---- */
.stat-card {
  --corner-bl: rgba(56, 218, 252, 0.28);
  --corner-br: rgba(59, 130, 246, 0.16);
  --corner-tr: rgba(125, 211, 252, 0.12);
  --edge-tint: rgba(56, 189, 248, 0.42);

  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 1.15rem;
  text-align: center;
  backdrop-filter: blur(16px) saturate(165%);
  -webkit-backdrop-filter: blur(16px) saturate(165%);

  border: 1px solid rgba(255, 255, 255, 0.72);
  border-bottom-color: color-mix(in oklab, var(--edge-tint) 65%, rgba(255, 255, 255, 0.75));

  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.88),
    inset 1px 0 0 rgba(255, 255, 255, 0.42),
    inset 0 -1px 0 var(--edge-tint),
    0 8px 22px -6px rgba(35, 62, 122, 0.08);
}

@media (min-width: 960px) {
  .stat-card {
    padding: 1.05rem 0.75rem 0.95rem;
    border-radius: 1.25rem;
  }
}

/* Corner & Edge Colour Transmission (Center remains transparent!) */
.stat-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background:
    radial-gradient(ellipse 72% 52% at 0% 100%, var(--corner-bl), transparent 58%),
    radial-gradient(ellipse 68% 48% at 100% 100%, var(--corner-br), transparent 56%),
    radial-gradient(ellipse 60% 42% at 100% 0%, var(--corner-tr), transparent 55%);
  z-index: -1;
}

/* Subtle diagonal glass refraction line across lower-left corner */
.stat-card::after {
  content: "";
  position: absolute;
  left: -14%;
  bottom: -22%;
  width: 65%;
  border-radius: 50%;
  pointer-events: none;
  z-index: -1;
}

/* Dark Theme Adaptation for Stat Cards */
/* Individual Corner Colour Treatments (Requirement 3) */
/* 1. Total Games: Cyan / Aqua */
.stat-card--total {
  --corner-bl: rgba(34, 211, 238, 0.30);
  --corner-br: rgba(56, 189, 248, 0.22);
  --corner-tr: rgba(103, 232, 249, 0.14);
  --edge-tint: rgba(34, 211, 238, 0.48);
}

/* 2. Wins: Violet / Purple */
.stat-card--wins {
  --corner-bl: rgba(168, 85, 247, 0.20);
  --corner-br: rgba(232, 121, 249, 0.28);
  --corner-tr: rgba(192, 132, 252, 0.14);
  --edge-tint: rgba(192, 132, 252, 0.48);
}

/* 3. Losses: Soft Pink / Rose */
.stat-card--losses {
  --corner-bl: rgba(251, 113, 133, 0.28);
  --corner-br: rgba(244, 114, 182, 0.18);
  --corner-tr: rgba(147, 197, 253, 0.14);
  --edge-tint: rgba(251, 113, 133, 0.45);
}

/* 4. Draws: Turquoise / Mint */
.stat-card--draws {
  --corner-bl: rgba(45, 212, 191, 0.30);
  --corner-br: rgba(56, 189, 248, 0.22);
  --corner-tr: rgba(110, 231, 183, 0.14);
  --edge-tint: rgba(45, 212, 191, 0.48);
}

/* 5. Win Rate: Blue / Indigo */
.stat-card--rate {
  --corner-bl: rgba(192, 132, 252, 0.24);
  --corner-br: rgba(96, 165, 250, 0.24);
  --corner-tr: rgba(129, 140, 248, 0.14);
  --edge-tint: rgba(129, 140, 248, 0.48);
}

/* 6. Win Streak: Amber / Orange */
.stat-card--streak {
  --corner-bl: rgba(251, 146, 60, 0.28);
  --corner-br: rgba(56, 189, 248, 0.22);
  --corner-tr: rgba(251, 191, 36, 0.14);
  --edge-tint: rgba(251, 146, 60, 0.48);
}

/* Stat Card Typography */
.stat-card-label {
  font-size: clamp(0.68rem, 1.12vw, 0.8125rem);
  line-height: 1.25;
  font-weight: 700;
  color: var(--foreground);
  margin-bottom: 0.16rem;
  white-space: nowrap;
}

.stat-card-value {
  font-size: clamp(1.35rem, 2vw, 1.65rem);
  line-height: 1.08;
  font-weight: 800;
  color: var(--foreground);
  margin: 0;
}

/* ---- Recent Games Panel: Matching Transparent Liquid Glass Panel (Requirement 7) ---- */
.recent-glass-panel {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 1.35rem;

  /* Genuine translucent glass matching the 6 stat cards */
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.28) 0%,
    rgba(195, 222, 252, 0.11) 48%,
    rgba(255, 255, 255, 0.18) 100%
  );
  backdrop-filter: blur(16px) saturate(165%);
  -webkit-backdrop-filter: blur(16px) saturate(165%);

  border: 1px solid rgba(255, 255, 255, 0.72);
  border-bottom-color: rgba(56, 189, 248, 0.48);

  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.88),
    inset 1px 0 0 rgba(255, 255, 255, 0.42),
    inset 0 -1px 0 rgba(56, 189, 248, 0.38),
    0 8px 24px -6px rgba(35, 62, 122, 0.08);
}

/* Subtle corner refraction on Recent Games panel */
.recent-glass-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background:
    radial-gradient(ellipse 65% 48% at 0% 100%, rgba(34, 211, 238, 0.24), transparent 58%),
    radial-gradient(ellipse 65% 48% at 100% 100%, rgba(192, 132, 252, 0.22), transparent 58%),
    radial-gradient(ellipse 55% 38% at 100% 0%, rgba(125, 211, 252, 0.12), transparent 55%);
  z-index: -1;
}

[data-dark] .recent-glass-panel {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.09) 0%,
    rgba(255, 255, 255, 0.025) 48%,
    rgba(255, 255, 255, 0.055) 100%
  );
  border-color: rgba(255, 255, 255, 0.16);
  border-bottom-color: rgba(56, 189, 248, 0.42);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 -1px 0 rgba(56, 189, 248, 0.35),
    0 8px 24px -6px rgba(0, 0, 0, 0.34);
}

.recent-glass-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 1.15rem;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.26) 0%,
    rgba(255, 255, 255, 0.06) 100%
  );
  border-bottom: 1px solid rgba(255, 255, 255, 0.58);
  border-bottom-right-radius: 1.15rem;
}

[data-dark] .recent-glass-header {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.07) 0%,
    rgba(255, 255, 255, 0.015) 100%
  );
  border-bottom-color: rgba(255, 255, 255, 0.14);
}

.recent-clock-icon {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 9999px;
  display: grid;
  place-items: center;
  color: #1d4ed8;
}

.recent-clock-icon > svg {
  width: 1.35rem;
  height: 1.35rem;
  stroke-width: 2.4px;
}

[data-dark] .recent-clock-icon {
  color: #60a5fa;
}

.recent-glass-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--foreground);
  margin: 0;
}

/* Recent Games Body: Top-aligned for populated history, centered for empty state */
.recent-glass-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.recent-history-list {
  width: 100%;
}

.recent-history-list > .row {
  padding-block: 0.45rem;
}

[data-theme="dark"] .recent-history-list > .row, [data-theme="black"] .recent-history-list > .row {
  border-color: rgba(255, 255, 255, 0.12);
}

.recent-empty-state:not([hidden]) {
  margin-block: auto;
}

.recent-empty-art {
}

.recent-empty-copy {
  font-size: 0.8125rem;
  line-height: 1.42;
  font-weight: 600;
  color: var(--foreground-muted);
  margin: 0 0 0.25rem;
}

/* Liquid Glass Pill CTA Button ("Play your first game") */
.stats-play-cta {
  min-height: 2.55rem !important;
  padding: 0.45rem 1.35rem !important;
  border-radius: 9999px !important;
  font-size: 0.84rem !important;
  font-weight: 800 !important;
  color: #0f296b !important;
  background:
    radial-gradient(60% 80% at 18% 20%, rgba(255, 255, 255, 0.68) 0%, transparent 65%),
    linear-gradient(90deg, rgba(56, 224, 255, 0.68) 0%, rgba(165, 148, 255, 0.54) 52%, rgba(244, 114, 255, 0.72) 100%) !important;
  border: 1px solid rgba(255, 255, 255, 0.88) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.92),
    inset 0 -1px 0 rgba(217, 70, 239, 0.32),
    0 6px 16px -4px rgba(56, 189, 248, 0.28) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.stats-play-cta > svg {
  color: #1d4ed8;
}

[data-dark] .stats-play-cta {
  color: #ffffff !important;
  background:
    radial-gradient(60% 80% at 18% 20%, rgba(255, 255, 255, 0.26) 0%, transparent 65%),
    linear-gradient(90deg, rgba(14, 165, 233, 0.68) 0%, rgba(124, 58, 237, 0.62) 52%, rgba(217, 70, 239, 0.72) 100%) !important;
  border-color: rgba(255, 255, 255, 0.45) !important;
}

[data-dark] .stats-play-cta > svg {
  color: #67e8f9;
}

.stats-reset-btn {
  min-height: 2.45rem !important;
  padding-inline: 1.15rem !important;
  border-radius: 9999px !important;
  font-size: 0.8125rem !important;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.28), rgba(195, 222, 252, 0.12)) !important;
  border: 1px solid rgba(255, 255, 255, 0.72) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), 0 6px 16px -4px rgba(35, 62, 122, 0.08) !important;
  backdrop-filter: blur(16px) saturate(165%) !important;
  -webkit-backdrop-filter: blur(16px) saturate(165%) !important;
}
[data-dark] .stats-reset-btn {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.03)) !important;
  border-color: rgba(255, 255, 255, 0.18) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 6px 16px -4px rgba(0, 0, 0, 0.34) !important;
}

/* ---- Mode Selection Cards (Preserved Transparent Glass + Water Wave Only) ---- */
.mode-card-v2 {
  --wave-color: #2563eb;
  --wave-rim: #38bdf8;

  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  justify-content: flex-start !important;
  gap: 0 !important;
  min-height: 15.5rem;
  padding: 1.25rem 1.3rem 1.1rem !important;
  border-radius: 1.5rem !important;
  border: 1px solid color-mix(in oklab, var(--wave-color) 24%, rgba(255, 255, 255, 0.68)) !important;
  border-bottom-color: color-mix(in oklab, var(--wave-rim) 72%, rgba(255, 255, 255, 0.8)) !important;
  text-align: left;
  text-decoration: none;
  cursor: pointer;

  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.28) 0%,
    rgba(195, 222, 252, 0.10) 48%,
    rgba(255, 255, 255, 0.18) 100%
  ) !important;
  backdrop-filter: blur(16px) saturate(165%);
  -webkit-backdrop-filter: blur(16px) saturate(165%);

  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    inset 0 -1px 0 color-mix(in oklab, var(--wave-rim) 55%, transparent),
    0 8px 22px -6px rgba(35, 62, 122, 0.08) !important;

}

.mode-ai { --wave-color: #2563eb; --wave-rim: #38bdf8; }
.mode-2p { }
.mode-series { --wave-color: #0891b2; --wave-rim: #2dd4bf; }
.mode-online { --wave-color: #d97706; --wave-rim: #fbbf24; }

.mode-wave-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 40%;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
  border-bottom-left-radius: inherit;
  border-bottom-right-radius: inherit;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.72) 22%, #000 100%);
  mask-image: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.72) 22%, #000 100%);
}

.mode-wave-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.mode-wave-main {
  d: path("M 0,14 C 66,20 108,88 192,102 C 242,110 276,108 300,104 L 300,120 L 0,120 Z");
  transition: d 650ms cubic-bezier(.22, 1, .36, 1);
}

.mode-wave-sub {
  d: path("M 0,38 C 56,48 98,98 178,110 C 232,118 272,116 300,114 L 300,120 L 0,120 Z");
  transition: d 650ms cubic-bezier(.22, 1, .36, 1);
}

@keyframes water-wave-main-flow {
  0% { d: path("M 0,14 C 66,20 108,88 192,102 C 242,110 276,108 300,104 L 300,120 L 0,120 Z"); }
  33% { d: path("M 0,24 C 52,10 122,76 202,96 C 248,106 278,98 300,96 L 300,120 L 0,120 Z"); }
  66% { d: path("M 0,8 C 78,28 96,96 182,106 C 236,112 272,112 300,108 L 300,120 L 0,120 Z"); }
  100% { d: path("M 0,18 C 60,14 114,82 196,99 C 245,108 276,103 300,100 L 300,120 L 0,120 Z"); }
}

@keyframes water-wave-sub-flow {
  0% { d: path("M 0,38 C 56,48 98,98 178,110 C 232,118 272,116 300,114 L 300,120 L 0,120 Z"); }
  50% { d: path("M 0,28 C 72,38 112,88 190,104 C 240,114 276,110 300,108 L 300,120 L 0,120 Z"); }
  100% { d: path("M 0,44 C 48,54 90,102 170,112 C 226,118 268,117 300,115 L 300,120 L 0,120 Z"); }
}

/* waves flow continuously on every device (not hover-gated); reduced-motion rule below disables */
.mode-wave-main { animation: water-wave-main-flow 4.2s ease-in-out infinite alternate; }
.mode-wave-sub { animation: water-wave-sub-flow 5.2s ease-in-out infinite alternate; }
.mode-card-v2:nth-child(2n) :is(.mode-wave-main, .mode-wave-sub) { animation-delay: -1.7s; }
.mode-card-v2:nth-child(3n) :is(.mode-wave-main, .mode-wave-sub) { animation-delay: -3.1s; }
.mode-card-v2 .mode-wave-wrap { transform: translateZ(0); }

@media (hover: hover) {
  .mode-card-v2:hover {
    border-color: color-mix(in oklab, var(--wave-rim) 55%, var(--border)) !important;
    border-bottom-color: var(--wave-rim) !important;
  }

  .mode-card-v2:hover .mode-v2-icon {
    transform: translate3d(0, -4px, 0) scale(1.04);
  }

  .mode-card-v2:hover .mode-v2-arrow {
    background: color-mix(in oklab, var(--wave-rim) 24%, var(--surface-strong));
    border-color: color-mix(in oklab, var(--wave-rim) 60%, var(--border));
    transform: translate3d(3px, 0, 0);
  }

  .mode-card-v2:hover .mode-v2-arrow-ic {
    transform: translateX(1.5px);
  }
}

.mode-v2-icon-wrap {
  position: relative;
  z-index: 2;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 0.1rem;
  margin-bottom: 0.55rem;
}

.mode-v2-icon {
  width: 5.8rem;
  height: 5.35rem;
  overflow: visible;
  transition: transform 300ms cubic-bezier(.22, 1, .36, 1);
}

.mode-v2-copy {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  margin-top: 0.1rem;
  margin-bottom: auto;
}

.mode-v2-title {
  display: block;
  font-size: 1.08rem;
  line-height: 1.22;
  font-weight: 800;
  letter-spacing: -0.015em;
  color: var(--foreground);
}

.mode-v2-sub {
  display: block;
  margin-top: 0.22rem;
  font-size: 0.79rem;
  line-height: 1.35;
  font-weight: 600;
  color: var(--foreground-muted);
}

.mode-v2-arrow {
  position: relative;
  z-index: 2;
  align-self: flex-end;
  margin-top: 0.5rem;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9999px;
  display: grid;
  place-items: center;
  background: color-mix(in oklab, var(--surface-strong) 45%, transparent);
  border: 1px solid rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--foreground);
  transition:
    transform 300ms cubic-bezier(.22, 1, .36, 1),
    background-color 300ms cubic-bezier(.22, 1, .36, 1),
    border-color 300ms cubic-bezier(.22, 1, .36, 1);
}

.mode-v2-arrow-ic {
  width: 1.05rem;
  height: 1.05rem;
  transition: transform 300ms cubic-bezier(.22, 1, .36, 1);
}

@media (max-width: 639px) {
  .mode-select-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
  }
  .mode-card-v2 {
    min-height: 13.5rem;
    padding: 1rem 1rem 0.95rem !important;
    border-radius: 1.25rem !important;
  }
  .mode-v2-icon {
    width: 4.8rem;
    height: 4.4rem;
  }
  .mode-v2-title {
    font-size: 0.96rem;
  }
  .mode-v2-sub {
    font-size: 0.73rem;
  }
  .mode-v2-arrow {
    width: 2rem;
    height: 2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mode-v2-icon,
  .mode-v2-arrow,
  .mode-v2-arrow-ic,
  .mode-wave-main,
  .mode-wave-sub {
    transition-duration: 0.01ms !important;
    animation: none !important;
  }
}

/* ==========================================================================
   STATS SCREEN v4 — original card size, glass history to the bottom,
   CSS bar-tower logo, flat (no neon) glass, high-contrast icons
   ========================================================================== */

/* ---- CSS bar logo ---- */
.stats-logo {
  display: inline-flex; align-items: flex-end; gap: .2rem;
  height: 1.9rem; flex-shrink: 0;
}
.stats-logo i {
  display: block; width: .52rem; border-radius: .3rem .3rem .14rem .14rem;
}
.stats-logo i:nth-child(1) { height: 48%;  --b1:#38bdf8; --b2:#1d6fe8; --b3:rgba(29,111,232,.55); }
.stats-logo i:nth-child(2) { height: 74%;  --b1:#5b8cff; --b2:#4338ca; --b3:rgba(67,56,202,.55); }
.stats-logo i:nth-child(3) { height: 100%; --b1:#a78bfa; --b2:#6d28d9; --b3:rgba(109,40,217,.55); }

/* ---- Cards: back to original size ---- */
.stat-card { aspect-ratio: 1.12; padding: .6rem .35rem !important; }

/* ---- Desktop: fixed-width cards left, glass history right down to the bottom ---- */
@media (min-width: 960px) {
  #app:has([data-screen="stats"]:not([hidden])) { max-width: 80rem !important; }
  .stats-dashboard {
    grid-template-columns: 36rem minmax(0, 1fr) !important;
    grid-template-rows: auto 1fr auto !important;
    column-gap: 1.5rem !important; row-gap: 1.1rem !important;
    align-content: stretch !important;
    height: calc(100dvh - 2.5rem); min-height: 0;
    margin-block: 0 !important;
  }
  .stats-dashboard > .stats-cards-col { grid-column: 1 !important; grid-row: 2 !important; align-self: start !important; gap: .9rem; }
  .stats-dashboard > .recent-glass-panel { grid-column: 2 !important; grid-row: 2 / 4 !important; align-self: stretch !important; contain: size; min-height: 0; }
  .stats-dashboard > .stats-reset-btn { grid-column: 1 !important; grid-row: 3 !important; align-self: end !important; justify-self: start !important; }
}
/* 560–959: stacked */
@media (min-width: 560px) and (max-width: 959px) {
  .stats-dashboard { display: flex !important; flex-direction: column; height: auto; }
  .stats-dashboard > .recent-glass-panel { contain: none; }
  .recent-history-list { max-height: 22rem !important; }
}

/* ---- History panel: glass like the cards, no neon/cyan tint ---- */
.recent-glass-panel::before, .recent-glass-panel::after { display: none !important; }
.recent-glass-panel, [data-theme] .recent-glass-panel {
  background: linear-gradient(135deg, rgba(255,255,255,.34), rgba(195,222,252,.12) 48%, rgba(255,255,255,.22));
  backdrop-filter: blur(16px) saturate(165%); -webkit-backdrop-filter: blur(16px) saturate(165%);
  border: 1px solid rgba(255,255,255,.72);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.88), inset 1px 0 0 rgba(255,255,255,.42), 0 8px 22px -6px rgba(35,62,122,.1);
  overflow: hidden;
}
:is([data-theme=dark],[data-theme=neon],[data-theme=cyberpunk],[data-theme=midnight],[data-theme=ocean],[data-theme=slate],[data-theme=moss],[data-theme=plum],[data-theme=deepsea],[data-theme=royal]) .recent-glass-panel {
  background: linear-gradient(135deg, rgba(255,255,255,.09), rgba(255,255,255,.025) 48%, rgba(255,255,255,.055));
  border-color: rgba(255,255,255,.16);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.28), 0 8px 24px -6px rgba(0,0,0,.34);
}
.recent-glass-header, [data-theme] .recent-glass-header {
  background: none; border-radius: 0; padding: .95rem 1.3rem;
  border-bottom: 1px solid rgba(255,255,255,.6);
}
:is([data-theme=dark],[data-theme=neon],[data-theme=cyberpunk],[data-theme=midnight],[data-theme=ocean],[data-theme=slate],[data-theme=moss],[data-theme=plum],[data-theme=deepsea],[data-theme=royal]) .recent-glass-header { border-bottom-color: rgba(255,255,255,.14); }
.recent-glass-body { min-height: 0; padding: .3rem 1.3rem .8rem; }

/* ---- History list: vertical scroll only, themed scrollbar ---- */
.recent-history-list {
  flex: 1; min-height: 0; max-height: none;
  overflow-x: hidden !important; overflow-y: auto;
  padding-right: .5rem !important;
}
@media (max-width: 559px) { .recent-history-list { max-height: 20rem; } }
.recent-history-list::-webkit-scrollbar { width: 8px; }
.recent-history-list::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
.recent-history-list::-webkit-scrollbar-track { background: color-mix(in oklab, var(--foreground) 8%, transparent); border-radius: 9999px; }
.recent-history-list::-webkit-scrollbar-thumb { background: var(--brand); border-radius: 9999px; border: 2px solid transparent; background-clip: padding-box; }
.recent-history-list > .row { flex-wrap: nowrap !important; gap: .75rem; min-height: 3.6rem; border-color: rgba(255,255,255,.6) !important; }
:is([data-theme=dark],[data-theme=neon],[data-theme=cyberpunk],[data-theme=midnight],[data-theme=ocean],[data-theme=slate],[data-theme=moss],[data-theme=plum],[data-theme=deepsea],[data-theme=royal]) .recent-history-list > .row { border-color: rgba(255,255,255,.12) !important; }
.recent-history-list > .row > span:first-child { min-width: 0; }
.recent-history-list > .row > span:last-child { white-space: nowrap; flex-shrink: 0; }

.title-img{width:min(100%,26rem);height:auto}

/* ==========================================================================
   HOW TO PLAY screen
   ========================================================================== */
.howto { width:100%; }
.ht-h, .ht-copy h2 { font-family:"Fredoka",ui-rounded,"Plus Jakarta Sans",system-ui,sans-serif; font-weight:600; }
.ht-h { font-size:1.2rem; margin-bottom:.4rem; }
.ht-goal p, .ht-copy p, .ht-list li { font-size:.9rem; line-height:1.5; color:var(--foreground-muted); }
.ht-goal b, .ht-copy b, .ht-list b { color:var(--foreground); font-weight:800; }
.ht-chips { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.5rem; margin-top:.9rem; }
.ht-chip { border:1px solid var(--border); border-radius:1rem; background:var(--surface-strong); padding:.65rem .4rem; text-align:center; font-weight:800; font-size:1.05rem; color:var(--foreground); }
.ht-chip small { display:block; margin-top:.1rem; font-size:.75rem; font-weight:600; color:var(--foreground-muted); }
.ht-steps { display:grid; gap:.9rem; list-style:none; margin:0; padding:0; }
.ht-step { display:flex; align-items:center; gap:1rem; padding:1rem; }
.ht-copy { flex:1; min-width:0; }
.ht-copy h2 { display:flex; align-items:center; gap:.6rem; font-size:1.1rem; margin-bottom:.35rem; }
.ht-num { display:grid; place-items:center; flex:none; width:1.75rem; height:1.75rem; border-radius:50%; background:var(--brand); color:var(--brand-foreground); font-size:.85rem; font-weight:800; line-height:1; }
.ht-shot { flex:none; width:8.25rem; margin:0; }
.ht-shot img { display:block; width:100%; height:auto; border:1px solid var(--border); border-radius:1.1rem; background:var(--surface-strong); box-shadow:0 1px 2px rgb(var(--shadow-rgb) / .08), 0 12px 28px -12px rgb(var(--shadow-rgb) / .3); }
.ht-more { display:grid; gap:.9rem; }
.ht-list { list-style:none; margin:0; padding:0; }
.ht-list li { position:relative; padding:.45rem 0 .45rem 1.1rem; }
.ht-list li + li { border-top:1px solid var(--border); }
.ht-list li::before { content:""; position:absolute; left:0; top:1.05rem; width:.45rem; height:.45rem; border-radius:50%; background:var(--brand); }
.ht-copy p + p, .ht-copy .ht-list { margin-top:.5rem; }
@media (min-width:480px) { .ht-chips { grid-template-columns:repeat(4,minmax(0,1fr)); } }
.howto kbd { display:inline-block; min-width:1.4em; padding:0 .35em; border:1px solid var(--border); border-bottom-width:2px; border-radius:.4rem; background:var(--surface-strong); color:var(--foreground); font:700 .78em/1.55 inherit; text-align:center; }
@media (max-width:359px) { .ht-step { flex-direction:column; align-items:flex-start; } .ht-shot { width:9rem; align-self:center; } }
@media (min-width:64rem) {
  .howto { max-width:60rem; margin-inline:auto; }
  .ht-steps, .ht-more { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .ht-shot { width:9rem; }
}

/* Statistics: offline and online sections stacked in one column, same card layout */
.stats-cards-col { display: flex; flex-direction: column; gap: 1.1rem; min-width: 0; }
.stats-section-title { margin: 0 0 .5rem .25rem; font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--foreground-muted); }
@media (min-width: 960px) { .stats-cards-col { min-height: 0; overflow-y: auto; } }
/* Liquid Glass layer (plain CSS, no build step; loaded last so it wins over styles.css/extra.css).
   Recipe: translucent fill + backdrop blur/saturate + bright specular top edge + thin rim + soft shadow,
   springy press feedback. Fill colours derive from each theme's --surface-strong, so every theme keeps working. */
:root {
  --lg-fill: color-mix(in oklab, var(--surface-strong) 40%, transparent);
  --lg-fill-hi: color-mix(in oklab, var(--surface-strong) 66%, transparent);
  --lg-rim: rgb(255 255 255 / .62);
  --lg-spec: rgb(255 255 255 / .9);
  --lg-shadow: 0 12px 32px -14px rgb(var(--shadow-rgb, 30 50 110) / .38);
  --lg-blur: blur(22px) saturate(180%);
  --lg-spring: cubic-bezier(.34, 1.4, .64, 1);
}
:is([data-theme=dark], [data-theme=neon], [data-theme=cyberpunk], [data-theme=midnight], [data-theme=royal], [data-theme=ocean],[data-theme=slate],[data-theme=moss],[data-theme=plum],[data-theme=deepsea]) {
  --lg-fill: color-mix(in oklab, var(--surface-strong) 46%, transparent);
  --lg-fill-hi: color-mix(in oklab, var(--surface-strong) 72%, transparent);
  --lg-rim: rgb(255 255 255 / .34);
  --lg-spec: rgb(255 255 255 / .55);
  --lg-shadow: 0 14px 34px -14px rgb(0 0 0 / .6);
}

/* ---- pink "Two players" card ---- */
.mode-2p { --wave-color: #ec4899; --wave-rim: #f472b6; }

/* ---- the glass material ---- */
.card, .btn-secondary, .icon-btn, .seg, .tile, .board, .mini, .ol-input, .ol-conn, .stat-card, .recent-glass-panel, .sheet-card, .grid-opts button {
  background-image: linear-gradient(150deg, var(--lg-fill-hi), var(--lg-fill) 55%, color-mix(in oklab, var(--lg-fill) 60%, transparent));
  background-color: transparent;
  border: 1px solid var(--lg-rim);
  box-shadow: inset 0 1.5px 0 var(--lg-spec), inset 0 -1px 0 rgb(255 255 255 / .14), inset 0 0 22px rgb(255 255 255 / .08), var(--lg-shadow);
  -webkit-backdrop-filter: var(--lg-blur);
  backdrop-filter: var(--lg-blur);
}
.card, .board, .mini, .stat-card, .recent-glass-panel, .sheet-card { position: relative; }
.card::before, .board::before, .sheet-card::before {      /* specular sheen sweeping from the top-left corner */
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(120% 70% at 8% -10%, rgb(255 255 255 / .34), transparent 55%);
}
:is([data-theme=dark], [data-theme=neon], [data-theme=cyberpunk], [data-theme=midnight], [data-theme=royal], [data-theme=ocean],[data-theme=slate],[data-theme=moss],[data-theme=plum],[data-theme=deepsea]) :is(.card, .board, .sheet-card)::before {
  background: radial-gradient(120% 70% at 8% -10%, rgb(255 255 255 / .12), transparent 55%);
}

/* ---- buttons ---- */
.btn { border-radius: 999px; }
.btn-primary {
  position: relative; overflow: hidden; border: 1px solid rgb(255 255 255 / .38);
  background-image: linear-gradient(180deg, color-mix(in oklab, var(--brand) 72%, #fff), var(--brand) 55%, color-mix(in oklab, var(--brand) 86%, #000));
  box-shadow: inset 0 1.5px 0 rgb(255 255 255 / .7), inset 0 -2px 6px rgb(0 0 0 / .14), 0 12px 26px -10px color-mix(in oklab, var(--brand) 70%, transparent);
  text-shadow: 0 1px 1px rgb(0 0 0 / .18);
}
.btn-primary::after { content: ''; position: absolute; inset: 0 0 52% 0; background: linear-gradient(180deg, rgb(255 255 255 / .3), transparent); pointer-events: none; }
.seg { border-radius: 999px; }
.seg > button { border-radius: 999px; }
.seg > button[aria-pressed="true"] { box-shadow: inset 0 1px 0 rgb(255 255 255 / .6), 0 6px 14px -6px color-mix(in oklab, var(--brand) 70%, transparent); }
.card { border-radius: 1.75rem; }
.pf-genders .btn[aria-pressed="true"], .tile[aria-pressed="true"] { outline: none; box-shadow: inset 0 1.5px 0 var(--lg-spec), 0 0 0 2px var(--brand), var(--lg-shadow); }

/* ---- board: any size ---- */
.board, .mini { grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); gap: max(.25rem, calc(1.5rem / var(--n, 3))); }
.board { padding: max(.3rem, calc(1.5rem / var(--n, 3))); border-radius: 2rem; }
.mini { padding: .5rem; gap: max(.12rem, calc(.375rem * 3 / var(--n, 3))); }
.mini > div { padding: max(.05rem, calc(.375rem * 3 / var(--n, 3))); }
.cell {
  background-image: linear-gradient(150deg, var(--lg-fill-hi), var(--lg-fill)); background-color: transparent;
  border: 1px solid var(--lg-rim); box-shadow: inset 0 1.5px 0 var(--lg-spec), 0 6px 14px -8px rgb(var(--shadow-rgb, 30 50 110) / .4);
  border-radius: clamp(.5rem, calc(5rem / var(--n, 3)), 1.25rem);
}
.cell[data-win] { box-shadow: inset 0 1.5px 0 var(--lg-spec), 0 0 0 2px var(--brand), 0 0 22px color-mix(in oklab, var(--brand) 55%, transparent); }
.play-keys[data-off] { display: none !important; }

/* ---- online header: back + title left, connection + toggle right ---- */
[data-screen=online] > :not(header) { width: 100%; max-width: 48rem; margin-inline: auto; }
.ol-conn { margin-left: 0; }
@media (max-width: 520px) {
  [data-screen=online] > header { flex-wrap: nowrap; }
  [data-screen=online] > header > div:first-child { min-width: 0; flex: 1 1 0; }
  .ol-lbl, [data-screen=online] .screen-subtitle { display: none; }
  .ol-conn { order: 0; padding: .25rem .5rem; }
}

/* ---- grid picker sheet ---- */
.sheet { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 1rem max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)); background: rgb(12 22 55 / .28); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); animation: lg-fade .25s ease both; }
.sheet[hidden] { display: none; }
@media (min-width: 640px) { .sheet { place-items: center; } }
.sheet-card { width: min(100%, 27rem); display: grid; gap: .8rem; padding: 1.4rem 1.2rem 1.2rem; border-radius: 2.25rem; text-align: center; animation: lg-rise .5s var(--lg-spring) both; }
.grid-opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.grid-opts button { display: grid; justify-items: center; gap: .15rem; min-height: 44px; padding: .85rem .3rem .75rem; border-radius: 1.5rem; color: var(--foreground); cursor: pointer; }
.grid-opts b { font-family: var(--font-display, inherit); font-size: 1.15rem; margin-top: .35rem; }
.grid-opts small { font-size: .7rem; font-weight: 700; color: var(--foreground-muted); }
.gp { display: grid; grid-template-columns: repeat(var(--n, 3), 1fr); gap: 2px; width: 3.1rem; aspect-ratio: 1; }
.gp i { border-radius: 28%; background: color-mix(in oklab, var(--brand) 58%, transparent); box-shadow: inset 0 1px 0 rgb(255 255 255 / .6); }
@keyframes lg-fade { from { opacity: 0; } }
@keyframes lg-rise { from { opacity: 0; transform: translateY(24px) scale(.94); } }
:where(.screen-enter) > .card, :where(.screen-enter) .mode-card-v2 { animation: lg-rise .55s var(--lg-spring) backwards; }

/* ---- stats: two series cards under the six existing ones ---- */
.stats-cards-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stats-cards-grid > .stat-card { grid-column: span 2; }
.stats-cards-grid > .stat-card--b3, .stats-cards-grid > .stat-card--b5 { grid-column: span 3; }
@media (max-width: 559px) {
  .stats-cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-cards-grid > .stat-card, .stats-cards-grid > .stat-card--b3, .stats-cards-grid > .stat-card--b5 { grid-column: span 1; }
}
.stat-card--b3 { --corner-bl: rgba(45, 212, 191, .3); --corner-br: rgba(20, 184, 166, .2); --corner-tr: rgba(153, 246, 228, .14); --edge-tint: rgba(45, 212, 191, .48); }
.stat-card--b5 { --corner-bl: rgba(251, 191, 36, .3); --corner-br: rgba(245, 158, 11, .2); --corner-tr: rgba(253, 230, 138, .14); --edge-tint: rgba(251, 191, 36, .48); }

/* ---- accessibility fallbacks ---- */
@media (prefers-reduced-transparency: reduce) {
  .card, .btn-secondary, .icon-btn, .seg, .tile, .board, .mini, .ol-input, .ol-conn, .stat-card, .recent-glass-panel, .sheet-card, .grid-opts button, .cell { background-image: none; background-color: var(--surface-strong); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet-card, :where(.screen-enter) > .card, :where(.screen-enter) .mode-card-v2 { animation: none; }
  }
.stats-cards-grid { align-content: start; }
@media (max-width: 520px) { [data-screen=online] .screen-title { white-space: normal; text-overflow: clip; font-size: 1rem; line-height: 1.1; } }
/* audit fixes: 44px touch targets; series cards no longer overflow desktop #/stats */
.stats-play-cta, .stats-reset-btn { min-height: 2.75rem !important; }
.stats-cards-grid > .stat-card--b3, .stats-cards-grid > .stat-card--b5 { aspect-ratio: auto; min-height: 7.5rem; }
/* 3D stat art: original transparent PNGs, no container/filter */
.recent-empty-art { display: block; width: auto; height: 5.65rem; max-width: 70%; object-fit: contain; overflow: visible; }
.mode-v2-icon.mode-art { object-fit: contain; display: block; pointer-events: none; }

/* ==========================================================================
   INTERACTION SYSTEM — single source of truth for hover / press / release.
   Root cause fixed: Tailwind v4 moves elements with the *individual* `translate`/`scale`
   properties, but older rules here and in extra.css/input.css transitioned only `transform`
   (so movement snapped), re-declared 120/160/180/220/300/350ms timings, and `.btn:active`
   applied `transform: scale(.95)` ON TOP of Tailwind's `scale: .97` (double press, ~.92).
   Rule: move with translate/scale only, never `transform`; one duration set; hover only where hover exists.
   ========================================================================== */
:root { --ix-ease: cubic-bezier(.22, 1, .36, 1); --ix-press: cubic-bezier(.2, .8, .2, 1); --ix-hover: 200ms; --ix-press-t: 110ms; --ix-release: 200ms; }

/* touch reliability: no 300ms/double-tap-zoom delay, no text-select/callout on long-press (scroll still works) */
:where(button, a[href], [role=button], [role=switch], .switch, .theme-switch, .cell, .tile, .lift-card, summary, label[for]) {
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none;
}
:where(button, a[href], [role=button], [role=switch], .cell, .tile, .lift-card) { -webkit-user-select: none; user-select: none; }
.mode-wave-wrap, .mode-wave-wrap * { pointer-events: none; }

/* release (default) -> hover -> press, all on translate/scale (compositor-friendly) + colour/shadow */
.btn, .icon-btn, .tile, .cell, .lift-card, .grid-opts button {
  transition-property: translate, scale, background-color, border-color, box-shadow, opacity, filter;
  transition-duration: var(--ix-release); transition-timing-function: var(--ix-ease);
}
.seg > button {
  transition-property: scale, background-color, color, box-shadow;
  transition-duration: var(--ix-release); transition-timing-function: var(--ix-ease);
}
.seg > button:active { scale: .96; }
.grid-opts button:active { translate: 0 0; scale: .97; }

@media (hover: hover) and (pointer: fine) {
  .btn:hover, .icon-btn:hover, .tile:hover, .lift-card:hover, .grid-opts button:hover, .cell:not([aria-disabled="true"]):hover { transition-duration: var(--ix-hover); }
  .btn-secondary:hover, .icon-btn:hover, .tile:hover { background-color: color-mix(in oklab, var(--surface-strong) 26%, transparent); }
  .btn-primary:hover { filter: brightness(1.06); }
  .grid-opts button:hover { translate: 0 -2px; scale: 1.02; }
  .grid-opts button:active { translate: 0 0; scale: .97; }      /* must follow :hover: press wins while hovered */
}

/* press timing last so it beats hover timing when both match */
.btn:active, .icon-btn:active, .tile:active, .lift-card:active, .grid-opts button:active, .seg > button:active,
.cell:not([aria-disabled="true"]):active { transition-duration: var(--ix-press-t); transition-timing-function: var(--ix-press); }

@media (prefers-reduced-motion: reduce) {
  .btn, .icon-btn, .tile, .cell, .lift-card, .grid-opts button, .seg > button,
  .grid-opts button:is(:hover, :active), .seg > button:active { translate: none; scale: none; transition-duration: .01ms; }
}
/* 3D stat art: transparent PNGs as-is (no filter/background), contained */
.stat-card-art { display: block; width: auto; height: 3.1rem; max-width: 70%; object-fit: contain; margin-bottom: .3rem; pointer-events: none; }
@media (min-width: 960px) { .stat-card-art { height: 3.6rem; } }
/* Shared by index.html and the legal pages: radius scale, HR divider, site footer.
   Reads the theme tokens (--foreground, --brand, --border ...) from styles.css / legal.css. */

:root {
  --r-sm: .5rem;
  --r-md: .75rem;
  --r-lg: 1rem;
  --hr-ink: color-mix(in srgb, var(--foreground) 16%, transparent);
}

/* ---------- HR divider ---------- */
.hr {
  position: relative;
  display: block;
  width: 100%;
  height: 1px;
  margin: 0;
  border: 0;
  background: linear-gradient(90deg, transparent, var(--hr-ink) 16%, var(--hr-ink) 84%, transparent);
}
/* Premium variant: a brand-coloured core with a soft bloom, fading out on both sides */
.hr--glow::before,
.hr--glow::after {
  content: "";
  position: absolute;
  inset-inline: 34%;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
}
.hr--glow::before { top: 0; height: 1px; opacity: .85; }
.hr--glow::after  { top: -2px; height: 5px; border-radius: 999px; opacity: .35; filter: blur(4px); }
/* Quiet variant for inner dividers */
.hr--soft { --hr-ink: color-mix(in srgb, var(--foreground) 10%, transparent); }

/* ---------- Site footer ---------- */
.site-footer {
  width: 100%;
  margin-top: auto;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
}
/* On the game page the footer only shows with the Home screen */
#app > .site-footer { display: none; padding-top: 1.5rem; }
/* Home footer: Game modes and Legal columns sit side by side, compact, at the right on wide screens */
#app > .site-footer .site-footer-inner { gap: 1.25rem; padding-block: 1.5rem 1.25rem; }
#app > .site-footer .sf-cols { grid-template-columns: repeat(2, max-content); justify-content: start; gap: 1.25rem 3.5rem; }
@media (min-width: 720px) {
  #app > .site-footer .site-footer-inner { grid-template-columns: minmax(0, 1fr) auto; }
  #app > .site-footer .sf-cols { justify-content: end; }
}
#app:has([data-screen="home"]:not([hidden])) > .site-footer { display: block; }
/* Home fills one full screen, so the footer sits below the fold and the page scrolls to it */
#app:has([data-screen="home"]:not([hidden])) { justify-content: flex-start; }
#app > [data-screen="home"]:not([hidden]) { flex: 0 0 auto; min-height: calc(100dvh - 1.25rem); }

.site-footer-inner {
  width: min(100%, 72rem);
  margin-inline: auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  padding-block: 2rem 1.75rem;
}
.sf-brand p {
  max-width: 30ch;
  margin: .85rem 0 0;
  color: var(--foreground-muted);
  font-size: .875rem;
  line-height: 1.6;
}
.sf-logo {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  color: var(--foreground);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -.025em;
  text-decoration: none;
  border-radius: var(--r-sm);
}
.sf-logo img { display: block; width: auto; height: 1.75rem; }

.sf-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.75rem 1.5rem; }
.sf-col h2 {
  margin: 0 0 .75rem;
  color: var(--foreground);
  font-size: .875rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
.sf-col ul { display: grid; gap: .15rem; margin: 0; padding: 0; list-style: none; }

.site-footer a:not(.sf-logo) {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  color: var(--foreground-muted);
  font-size: .875rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--r-sm);
  transition: color .15s ease-out;
}
.site-footer a:not(.sf-logo):hover { color: var(--foreground); text-decoration: underline; text-decoration-color: var(--brand); text-underline-offset: 4px; }
.site-footer a:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.site-footer a[aria-current="page"] { color: var(--foreground); }

.site-footer-bottom {
  width: min(100%, 72rem);
  margin-inline: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .35rem 1.5rem;
  padding-top: 1.25rem;
  color: var(--foreground-muted);
  font-size: .8125rem;
}
.site-footer-bottom p { margin: 0; }

@media (min-width: 720px) {
  .site-footer-inner { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.6fr); gap: 3rem; }
  .sf-cols { gap: 1.75rem 3rem; }
}
@media (prefers-reduced-motion: reduce) {
  .site-footer a:not(.sf-logo) { transition: none; }
}
/* Color-matched ambient panels. All movement stays behind existing controls. */
.mode-ai { --panel-color: #1d8cf8; --panel-light: #60efff; --flow-delay: 0s; }
.mode-2p { --panel-color: #ec4899; --panel-light: #fbcfe8; --flow-delay: -3s; }
.mode-series { --panel-color: #06b6d4; --panel-light: #2dd4bf; --flow-delay: -6s; }
.mode-online { --panel-color: #f59e0b; --panel-light: #fde68a; --flow-delay: -9s; }

.mode-card-v2 .mode-wave-wrap {
  inset: 0;
  height: 100%;
  border-radius: inherit;
  mask-image: none;
  -webkit-mask-image: none;
  will-change: auto;
}
.mode-card-v2 .mode-wave-svg {
  position: absolute;
  inset: auto 0 0;
  height: 40%;
  mask-image: linear-gradient(transparent, #000 25%);
  -webkit-mask-image: linear-gradient(transparent, #000 25%);
}
.mode-card-v2 .mode-wave-wrap::before,
.mode-card-v2 .mode-wave-wrap::after {
  content: '';
  position: absolute;
  pointer-events: none;
  inset: -45%;
  border-radius: 45%;
  background:
    radial-gradient(ellipse at 23% 73%, color-mix(in srgb, var(--panel-color) 45%, transparent), transparent 40%),
    radial-gradient(ellipse at 74% 29%, color-mix(in srgb, var(--panel-light) 65%, transparent), transparent 38%),
    radial-gradient(ellipse at 80% 85%, color-mix(in srgb, var(--panel-color) 24%, transparent), transparent 45%);
  animation: card-gradient-orbit 14s linear infinite;
  animation-delay: var(--flow-delay);
  opacity: .65;
}
.mode-card-v2 .mode-wave-wrap::after {
  inset: -30% -90%;
  border-radius: 0;
  background: linear-gradient(115deg, transparent 36%, color-mix(in srgb, var(--panel-light) 30%, transparent) 46%, rgb(255 255 255 / .25) 50%, transparent 59%);
  animation: card-gradient-ribbon 9s ease-in-out infinite;
  animation-delay: var(--flow-delay);
  opacity: .7;
}
[data-dark] .mode-card-v2 .mode-wave-wrap::before { opacity: .35; }
[data-dark] .mode-card-v2 .mode-wave-wrap::after { opacity: .25; }

@keyframes card-gradient-orbit {
  from { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.12); }
  to { transform: rotate(360deg) scale(1); }
}
@keyframes card-gradient-ribbon {
  0%, 100% { transform: translateX(-24%) rotate(-8deg); }
  50% { transform: translateX(24%) rotate(8deg); }
}
@media (prefers-reduced-motion: reduce) {
  .mode-card-v2 .mode-wave-wrap::before,
  .mode-card-v2 .mode-wave-wrap::after { animation: none; }
}
/* Decorative flowing waves behind the original home UI. */
[data-screen="home"] { position:relative; isolation:isolate; }
[data-screen="home"] > header,
[data-screen="home"] > div { position:relative; z-index:1; }
.home-depth { position:absolute; inset:-25px -5%; width:110%; height:calc(100% + 50px); pointer-events:none; z-index:0; opacity:.85; }
[data-screen="home"]::before { content:''; position:absolute; inset:5% 0; z-index:-1; pointer-events:none; background:radial-gradient(ellipse at 26% 48%,color-mix(in srgb,var(--mark-x) 12%,transparent),transparent 53%),radial-gradient(ellipse at 75% 68%,color-mix(in srgb,var(--mark-o) 10%,transparent),transparent 50%); }
[data-dark] .home-depth { }
@media(max-width:639px){.home-depth{inset:0 -5%;height:100%}}

/* Touch creates a luminous elliptical wake; the canvas supplies the surface displacement. */
.water-touch {
  position:absolute; z-index:0; pointer-events:none; width:100px; height:100px;
  border:1.5px solid color-mix(in srgb, var(--mark-x) 55%, white);
  border-radius:50%;
  box-shadow:0 0 16px color-mix(in srgb, var(--mark-x) 20%, transparent), inset 0 0 12px rgb(255 255 255 / .3);
  animation:water-touch-spread 1.8s cubic-bezier(.16,.65,.3,1) both;
}
.water-touch::after {
  content:''; position:absolute; inset:12px; border:1px solid color-mix(in srgb, var(--mark-o) 35%, white); border-radius:inherit;
}
@keyframes water-touch-spread {
  0% { transform:translate(-50%,-50%) scale(.18,.07); opacity:0; }
  12% { opacity:.75; }
  100% { transform:translate(-50%,-50%) scale(2.8,.85); opacity:0; }
}
@media(prefers-reduced-motion:reduce) { .water-touch { display:none; animation:none; } }
/* Desktop only. The original mobile/tablet rules are intentionally untouched. */
@media (min-width: 1024px) {
  #app,
  #app:has(> [data-screen]) {
    width: 100%;
    max-width: none !important;
    padding-inline: clamp(32px, 5vw, 112px) !important;
    padding-block: 28px;
  }
  #app > [data-screen="home"]:not([hidden]) {
    min-height: calc(100svh - 56px);
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    column-gap: clamp(32px, 6vw, 128px);
  }
  [data-screen="home"] > div:first-of-type {
    min-width: 0;
    padding-block: clamp(32px, 6vh, 80px);
  }
  [data-screen="home"] > div:first-of-type > img {
    width: clamp(260px, 24vw, 460px);
    max-width: 100%;
  }
  [data-screen="home"] .title-img {
    width: min(100%, 640px);
  }
  [data-screen="home"] > div:last-of-type {
    width: 100%;
    max-width: 600px;
    justify-self: center;
    padding: clamp(24px, 2.4vw, 44px);
  }
  /* Feather the lighting into the page instead of exposing a rectangular panel. */
  [data-screen="home"]::before {
    inset: 0 -4vw;
    mask-image: radial-gradient(ellipse at center, #000 30%, transparent 72%);
    -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 72%);
  }
  .home-depth {
    inset-inline: calc(0px - clamp(32px, 5vw, 112px));
    width: calc(100% + clamp(32px, 5vw, 112px) + clamp(32px, 5vw, 112px));
    mask-image: none;
    -webkit-mask-image: none;
  }
  .site-footer-inner, .site-footer-bottom { width:100%; max-width:none; }
  .mode-select-grid {
    width:100%;
    grid-template-columns:repeat(4,minmax(0,320px));
    justify-content:center;
    gap:clamp(20px,2vw,40px);
  }
  .mode-card-v2 { min-height:0; aspect-ratio:1; width:100%; }
  @media (max-width:1199px) {
    .mode-select-grid { grid-template-columns:repeat(2,minmax(0,300px)); }
  }
  .play-grid { grid-template-columns:minmax(0,1.2fr) minmax(320px,1fr); column-gap:clamp(40px,7vw,140px); }
  .play-grid > #board { width:min(100%,40rem,calc(100svh - 220px)); }
  #app > [data-screen="series"] { max-width:1200px; }
  #app > [data-screen="stats"] {
    height:auto;
    min-height:calc(100svh - 56px);
    grid-template-columns:36rem minmax(0,1fr) !important;
    align-content:start !important;
    column-gap:clamp(24px,3vw,64px) !important;
  }
}

@media (min-width:1024px) {
  /* header spans the page (back left, theme right); the form boxes stay centred below it */
  #app > [data-screen="profile"], #app > [data-screen="account"] { width:100%; max-width:none; margin-inline:0; align-items:center; }
  [data-screen="profile"] > header, [data-screen="account"] > header { align-self:stretch; }
  [data-screen="profile"] > :not(header), [data-screen="account"] > :not(header) { width:min(100%,34rem); }
  [data-screen="profile"] > .card { padding:1.75rem 2rem; gap:1rem; }
  .stats-dashboard > .recent-glass-panel { min-height:36rem; contain:none; }
  .stats-dashboard .recent-glass-body { flex:1; display:flex; flex-direction:column; }
  .stats-dashboard .recent-history-list { max-height:calc(100svh - 13rem); }
  .stats-dashboard > .stats-reset-btn { align-self:start !important; }
}
@media (min-width:1024px) and (max-width:1199px) {
  #app > [data-screen="stats"] { grid-template-columns:36rem !important; justify-content:center; }
  .stats-dashboard > .recent-glass-panel { grid-column:1 !important; grid-row:3 !important; min-height:30rem; }
  .stats-dashboard > .stats-reset-btn { grid-row:4 !important; }
}

/* Outer desktop navigation, with independent content grids. */
@media(min-width:1024px) {
  #app:has([data-screen="stats"]:not([hidden])),
  #app:has([data-screen="mode"]:not([hidden])),
  #app:has([data-screen="series"]:not([hidden])) { max-width:none !important; padding-inline:clamp(24px,3vw,56px) !important; }
  #app > [data-screen="series"] { max-width:none; }
  #app > [data-screen="stats"] {
    position:relative; grid-template-columns:33rem minmax(0,1fr) !important;
    column-gap:clamp(32px,4vw,72px) !important; padding-bottom:6rem;
    grid-template-rows:auto 1fr !important;
  }
  .stats-dashboard > .recent-glass-panel { grid-row:2 !important; min-height:32rem; }
  .stats-dashboard > .stats-reset-btn { position:absolute; bottom:1rem; left:0; }
  [data-screen="mode"] > header,[data-screen="series"] > header,.stats-header { width:100%; }
  [data-screen="series"] > .card.row, [data-screen="mode"] > .diff-row { width:min(100%,680px); align-self:center; }
  .series-select-grid { width:100%; justify-content:center; gap:clamp(20px,2vw,40px); margin-block:auto; }
  [data-screen="series"] > p { text-align:center; }
  #toast { left:auto; right:clamp(24px,3vw,56px); bottom:1.5rem; max-width:30rem; padding:0; }
}
@media(min-width:1024px) and (max-width:1199px) {
  #app > [data-screen="stats"] { grid-template-columns:33rem !important; }
  .stats-dashboard > .stats-header { width:calc(100vw - 6vw); justify-self:center; }
  .stats-dashboard > .recent-glass-panel { grid-column:1 !important; grid-row:3 !important; }
}
/* Solid mode-palette accents; no changes to statistic card dimensions. */
.stat-card { --stat-color:#1d8cf8; background:transparent !important; border-color:color-mix(in srgb,var(--stat-color) 55%,var(--border)); }
.stat-card--wins,.stat-card--losses { --stat-color:#ec4899; }
.stat-card--draws,.stat-card--b3 { --stat-color:#2dd4bf; }
.stat-card--streak,.stat-card--b5 { --stat-color:#f59e0b; }


/* Fixed capsules: reference blue/pink light travels inside each bar. */
.stats-logo i {
  transform:none;
  background:linear-gradient(180deg,#89baff 0%,#2497ff 22%,#ff50bc 46%,#ff8bd4 56%,#89baff 78%,#2497ff 100%);
  background-size:100% 300%;
  box-shadow:inset 1px 1px 1px rgb(255 255 255 / .65),0 0 5px rgb(63 153 255 / .45),0 0 9px rgb(255 80 188 / .2);
  animation:stats-capsule-color 5s ease-in-out infinite;
}
.stats-logo i:nth-child(2) { animation-delay:-1.1s; }
.stats-logo i:nth-child(3) { animation-delay:-2.2s; }
@keyframes stats-capsule-color {
  0%,100% {background-position:50% 0%}
  50% {background-position:50% 100%}
}
[data-theme="ocean"] { --brand:#168ee8; --brand-strong:#0876cc; --mark-o:#a78bfa; --focus:#67e8f9; }
:root { --sky-light:255 221 143; }
[data-dark] { --sky-light:184 215 255; }
[data-theme="sunset"] { --sky-light:255 166 98; }

[data-screen="home"] .btn { border-top-color:rgb(var(--sky-light) / .7); }
[data-screen="home"] .btn-primary { box-shadow:inset 0 2px 2px rgb(var(--sky-light) / .65),0 6px 22px -8px rgb(var(--sky-light) / .45); }
[data-dark] .home-depth { opacity:.9; }
@media(prefers-reduced-motion:reduce) { .stats-logo i { animation:none; } }

/* Solid overlapping waves, like the mode cards; artwork and numbers stay still. */
.stat-card { --stat-delay:0s; }
.stat-card:nth-child(2n) { --stat-delay:-1.4s; }
.stat-card:nth-child(3n) { --stat-delay:-2.8s; }
.stat-card:nth-child(4n) { --stat-delay:-4.2s; }
.stat-card::before,.stat-card::after {
  content:''; position:absolute; inset:auto auto -1px -25%; width:200%; height:24%;
  border-radius:0; clip-path:none; pointer-events:none; z-index:-1; opacity:1;
  mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 100' preserveAspectRatio='none'%3E%3Cpath d='M0 40 Q100 0 200 40 T400 40 V100 H0Z' fill='black'/%3E%3C/svg%3E") 0 0 / 50% 100% repeat-x;
  background:color-mix(in srgb,var(--stat-color) 45%,var(--surface-strong)) !important;
  animation:stat-water-flow 8s ease-in-out infinite;
  animation-delay:var(--stat-delay);
}
.stat-card::after {
  height:19%; background:var(--stat-color) !important;
  animation-direction:reverse; animation-duration:10s;
}
@keyframes stat-water-flow {
  0%,100% {transform:translateX(-12%) translateY(1px)}
  50% {transform:translateX(12%) translateY(-2px)}
}

[data-screen="stats"][hidden] .stats-logo i,
[data-screen="stats"][hidden] .stat-card::before,
[data-screen="stats"][hidden] .stat-card::after { animation-play-state:paused; }
@media(prefers-reduced-motion:reduce) { .stat-card::before,.stat-card::after {animation:none;} }

/* Disabled actions remain readable and clearly distinct from active glass buttons. */
.btn:disabled, [data-action="save-profile"]:disabled {
  opacity:1 !important; color:var(--foreground-muted) !important; background-color:transparent !important;
  background-image:linear-gradient(150deg,color-mix(in oklab,var(--foreground-muted) 18%,transparent),color-mix(in oklab,var(--foreground-muted) 8%,transparent)) !important;
  border:1.5px dashed color-mix(in oklab,var(--foreground-muted) 65%,transparent) !important;
  box-shadow:inset 0 1.5px 0 rgb(255 255 255 / .3) !important; -webkit-backdrop-filter:var(--lg-blur); backdrop-filter:var(--lg-blur);
  text-shadow:none !important; filter:none !important; cursor:not-allowed;
  transform:none !important; animation:none !important;
}
.btn:disabled::before,.btn:disabled::after { display:none !important; }
.ol-disabled-note {
  margin:0; padding:.8rem 1rem; border:1px solid var(--border); border-left:4px solid var(--foreground-muted);
  border-radius:1rem; background:color-mix(in oklab,var(--surface-strong) 85%,var(--foreground-muted)); color:var(--foreground); font-size:.85rem; font-weight:600; line-height:1.5;
}

/* One continuous home scene; light stays on the buttons, not a rectangular wrapper. */
[data-screen="home"]::before { display:none; }
[data-screen="home"] > div:last-of-type {
  background:none !important; border:0 !important; box-shadow:none !important;
  backdrop-filter:none !important; -webkit-backdrop-filter:none !important;
}
.home-depth { right:auto; max-width:none; }
@media(max-width:639px) { .home-depth { opacity:.7; } }
[data-theme="nature"] { --page-from:#bfe9e3; --page-to:#a9d3ee; }
[data-theme="forest"] { --page-from:#c2eab5; --page-to:#8bce9b; }
/* Saturated color lighting across mode cards in all themes, with no white wash. */
:root .mode-card-v2 {
  background:transparent !important;
  border-color:color-mix(in srgb,var(--panel-color) 65%,transparent) !important;
  box-shadow:inset 0 0 28px color-mix(in srgb,var(--panel-color) 18%,transparent),0 8px 24px -8px color-mix(in srgb,var(--panel-color) 35%,transparent) !important;
}
:root .mode-card-v2::before { background:none !important; }
:root .mode-card-v2 .mode-wave-wrap::before {
  opacity:.8;
  background:radial-gradient(ellipse at 23% 73%,color-mix(in srgb,var(--panel-color) 65%,transparent),transparent 58%),radial-gradient(ellipse at 74% 29%,color-mix(in srgb,var(--panel-color) 42%,transparent),transparent 62%);
}
:root .mode-card-v2 .mode-wave-wrap::after {
  opacity:.65;
  background:linear-gradient(115deg,transparent 36%,color-mix(in srgb,var(--panel-color) 45%,transparent) 48%,color-mix(in srgb,var(--panel-light) 25%,transparent) 52%,transparent 64%);
}
:root .mode-card-v2 .mode-wave-main { fill:var(--panel-color); opacity:.85; }
:root .mode-card-v2 .mode-wave-sub { fill:var(--panel-light); opacity:.55; }

/* Toast is above the app stacking context, with an explicit non-overlapping row. */
#toast { z-index:100; pointer-events:none; }
#toast > .card { display:flex; align-items:center; gap:1rem; max-width:100%; padding:.65rem .8rem .65rem 1rem; pointer-events:auto; }
#toast > .card > span { min-width:0; overflow-wrap:anywhere; }
#toast button { flex:0 0 auto; position:relative; z-index:1; }
.series-select-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:1rem; }
.series-select-grid .mode-card-v2 { aspect-ratio:1; min-height:0; }

/* Keep compact card sizing independent of the full-width desktop headers. */
@media(min-width:1024px) {
  .mode-select-grid { grid-template-columns:repeat(4,230px); }
  .series-select-grid { grid-template-columns:repeat(2,230px); }
  .mode-select-grid,.series-select-grid {
    width:100%; justify-content:center; align-items:start;
    gap:clamp(20px,2vw,40px);
  }
  .mode-select-grid > .mode-card-v2,.series-select-grid > .mode-card-v2 {
    width:230px; height:230px; min-height:0; aspect-ratio:1;
  }
}
@media(min-width:1024px) and (max-width:1199px) {
  .mode-select-grid { grid-template-columns:repeat(2,230px); }
}

/* ==========================================================================
   GLASS EVERYWHERE — one recipe (see glass.css) for every clickable surface in every theme.
   Primary = brand-tinted glass (same blur, specular edge and rim as the secondary buttons), so hierarchy
   survives without a solid fill. Text stays --foreground: it is >=4.5:1 on every theme's tint.
   ========================================================================== */
:root { --tint-a: 40%; --tint-line: color-mix(in oklab, var(--brand) 45%, rgb(255 255 255 / .75)); }
[data-dark] { --tint-a: 48%; --tint-line: color-mix(in oklab, var(--brand) 55%, rgb(255 255 255 / .3)); }
:where(:root, .btn-primary) { --tint-fill: linear-gradient(150deg, color-mix(in oklab, var(--brand) calc(var(--tint-a) + 14%), transparent), color-mix(in oklab, var(--brand) var(--tint-a), transparent) 55%, color-mix(in oklab, var(--brand) calc(var(--tint-a) - 8%), transparent)); }

.btn-primary { --tint-a:52%; }
[data-dark] .btn-primary { --tint-a:54%; }
.btn-primary {
  color:var(--foreground) !important; background-color:transparent !important;
  background-image:linear-gradient(180deg, rgb(255 255 255 / .28), rgb(255 255 255 / 0) 55%), var(--tint-fill) !important;
  border:1px solid var(--tint-line) !important;
  box-shadow:inset 0 1.5px 0 var(--lg-spec), inset 0 -1px 0 rgb(255 255 255 / .14), inset 0 0 22px rgb(255 255 255 / .08), 0 12px 28px -12px color-mix(in oklab, var(--brand) 60%, transparent) !important;
  -webkit-backdrop-filter:var(--lg-blur); backdrop-filter:var(--lg-blur); text-shadow:none;
}
.btn-primary::after { display:none; }

/* active segment / gender / symbol pill: tinted glass instead of a solid brand block */
.seg > button[aria-pressed="true"], .pf-genders .btn[aria-pressed="true"] {
  color:var(--foreground) !important; background-color:transparent !important; background-image:var(--tint-fill) !important;
  box-shadow:inset 0 0 0 1px var(--tint-line), inset 0 1.5px 0 var(--lg-spec), 0 6px 14px -6px color-mix(in oklab, var(--brand) 60%, transparent) !important;
  outline:none;
}
.seg > button { -webkit-backdrop-filter:var(--lg-blur); backdrop-filter:var(--lg-blur); }

/* sound switch: glass track, tinted when on */
.switch::before {
  background-color:color-mix(in oklab, var(--foreground-muted) 26%, transparent); border:1px solid var(--lg-rim);
  box-shadow:inset 0 1.5px 0 var(--lg-spec); -webkit-backdrop-filter:var(--lg-blur); backdrop-filter:var(--lg-blur);
}
.switch[aria-checked="true"]::before { background-color:color-mix(in oklab, var(--brand) var(--tint-a), transparent); border-color:var(--tint-line); }
.switch::after { box-shadow:inset 0 1px 0 #fff, 0 3px 8px -2px rgb(var(--shadow-rgb, 30 50 110) / .45); }

/* volume slider: glass track, tinted fill (--val set in app.js), glass thumb */
#volume { -webkit-appearance:none; appearance:none; background:transparent; height:2.75rem; cursor:pointer; --val:70%; }
#volume::-webkit-slider-runnable-track {
  height:10px; border-radius:999px; border:1px solid var(--lg-rim); box-shadow:inset 0 1px 0 var(--lg-spec);
  background:linear-gradient(90deg, color-mix(in oklab, var(--brand) var(--tint-a), transparent) var(--val), color-mix(in oklab, var(--foreground-muted) 26%, transparent) var(--val));
}
#volume::-moz-range-track { height:10px; border-radius:999px; border:1px solid var(--lg-rim); background:color-mix(in oklab, var(--foreground-muted) 26%, transparent); }
#volume::-moz-range-progress { height:10px; border-radius:999px; background:color-mix(in oklab, var(--brand) var(--tint-a), transparent); }
#volume::-webkit-slider-thumb {
  -webkit-appearance:none; width:26px; height:26px; margin-top:-9px; border-radius:50%; border:1px solid var(--tint-line);
  background:radial-gradient(circle at 35% 28%, #fff, color-mix(in oklab, var(--surface-strong) 70%, #fff)); box-shadow:inset 0 1.5px 0 #fff, 0 4px 10px -3px rgb(var(--shadow-rgb, 30 50 110) / .5);
}
#volume::-moz-range-thumb { width:24px; height:24px; border-radius:50%; border:1px solid var(--tint-line); background:#fff; box-shadow:0 4px 10px -3px rgb(var(--shadow-rgb, 30 50 110) / .5); }
#volume:focus-visible { outline:2px solid var(--focus); outline-offset:4px; border-radius:999px; }

/* hover only where hover exists (glass.css owns the timing); primary gets a lift of its own tint */
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { filter:brightness(1.05) saturate(1.1); }
}

/* mobile: series (and mode) cards size to their content; a forced square clipped the title, subtitle and arrow */
@media (max-width:1023px) { .series-select-grid .mode-card-v2 { aspect-ratio:auto; min-height:13.5rem; height:auto; } }
@media (max-width:359px) { .series-select-grid, .mode-select-grid { gap:.6rem; } .series-select-grid .mode-card-v2, .mode-select-grid .mode-card-v2 { padding:.8rem .75rem .75rem !important; } }

/* ==========================================================================
   RESULT SCREEN MOTION — crown pops in on a win, drops and settles on a loss.
   transform + opacity only (compositor), ease-out, replays whenever the view is shown (display none -> block).
   ========================================================================== */
.res-icon { transform-origin: 50% 90%; will-change: transform, opacity; }
.res-icon[data-state="win"] { animation: res-crown-in .55s var(--lg-spring) both; }
.res-icon[data-state="draw"] { animation: res-crown-in .4s var(--ix-ease, ease-out) both; }
@keyframes res-crown-in { from { opacity: 0; transform: translateY(-14px) scale(.7) rotate(-8deg); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .res-icon { animation: none !important; will-change: auto; } }

/* programmatic heading focus (screen readers) should not draw a ring on the result title */
h1[tabindex="-1"]:focus-visible, h2[tabindex="-1"]:focus-visible { outline: none; }
/* online result view mirrors the offline one: back/title chrome steps aside, the result is the page */
[data-screen="online"]:has([data-ol-view="result"]:not([hidden])) > header > div:first-child { visibility: hidden; }

/* Hint: reduced motion has no pulse, so show a static ring instead (JS removes data-hint after 1.2s) */
@media (prefers-reduced-motion: reduce) {
  .cell[data-hint] { box-shadow: inset 0 1.5px 0 var(--lg-spec), 0 0 0 4px var(--brand); }
}

/* Selected tiles/segments drop their outline for a ring; keep the keyboard focus ring visible on them */
.tile[aria-pressed="true"]:focus-visible, .seg > button[aria-pressed="true"]:focus-visible, .pf-genders .btn[aria-pressed="true"]:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---- Stats: Recent games shows every row (no inner scroll box) with room to breathe ---- */
.stats-dashboard { height: auto !important; }
.stats-dashboard > .recent-glass-panel { contain: none !important; min-height: 0 !important; align-self: start !important; }
.recent-history-list { max-height: none !important; overflow: visible !important; padding-right: 0 !important; gap: .6rem; }
.recent-history-list > .row { padding-block: .8rem; min-height: 4.2rem; }
.recent-glass-body { padding: .6rem 1.5rem 1.4rem; }

/* ---- How to play (desktop): back button in the left corner, theme toggle in the right corner; content stays centred ---- */
@media (min-width: 1024px) {
  #app:has([data-screen="howto"]:not([hidden])) { max-width: none !important; padding-inline: clamp(24px, 3vw, 56px) !important; }
  #app > [data-screen="howto"] { max-width: none; margin-inline: 0; align-items: center; }
  [data-screen="howto"] > header { align-self: stretch; }
  [data-screen="howto"] > :not(header) { width: min(100%, 60rem); }
}
/* Top/bottom breathing room on every screen (the Tailwind pt-/pb- classes on #app were never compiled); desktop keeps its own padding-block. */
#app { padding-top: max(1.25rem, env(safe-area-inset-top)); padding-bottom: max(1.5rem, env(safe-area-inset-bottom)); }
/* ==========================================================================
   LIQUID SELECTION + NEW SCREENS (loaded last). Pairs with js/liquid.js.
   ========================================================================== */

/* ---- liquid pill: the highlight that glides between pressed buttons ---- */
:is(.seg, .pf-genders) { position: relative; }
.lg-pill {
  position: absolute; left: 0; top: 0; width: 0; height: 0; z-index: 2; pointer-events: none; opacity: 0;
  background: linear-gradient(150deg, color-mix(in oklab, var(--brand) 32%, transparent), color-mix(in oklab, var(--brand) 12%, transparent) 60%, color-mix(in oklab, var(--brand) 24%, transparent));
  box-shadow: inset 0 1.5px 0 var(--lg-spec), inset 0 0 0 1.5px var(--tint-line), inset 0 0 18px rgb(255 255 255 / .12), 0 10px 22px -10px color-mix(in oklab, var(--brand) 70%, transparent);
  transition: opacity .25s ease;
}
.lg-pill::after { content: ''; position: absolute; inset: 0; border-radius: inherit; background: radial-gradient(120% 90% at 18% -25%, rgb(255 255 255 / .5), transparent 55%); }
/* the buttons themselves look unselected: the pill alone shows the selection */
.seg > button[aria-pressed="true"] { background-image: none !important; box-shadow: none !important; }
.pf-genders .btn[aria-pressed="true"] {
  background-image: linear-gradient(150deg, var(--lg-fill-hi), var(--lg-fill) 55%, color-mix(in oklab, var(--lg-fill) 60%, transparent)) !important;
  box-shadow: inset 0 1.5px 0 var(--lg-spec), inset 0 -1px 0 rgb(255 255 255 / .14), inset 0 0 22px rgb(255 255 255 / .08), var(--lg-shadow) !important;
}
.pf-genders .btn:hover { translate: none !important; }   /* the pill does not lift with hover, so the buttons must not either */
@media (prefers-reduced-motion: reduce) { .lg-pill { transition: none; } }

/* ---- lost round: friendly message, highlighted Rematch (no lose icon, no sad face) ---- */
.res-icon[hidden] { display: none !important; }
.rematch-note { max-width: 24rem; margin: .25rem 0 0; line-height: 1.5; text-wrap: balance; }
.rematch-word {
  padding: .05em .5em; border-radius: 999px; color: var(--foreground); font-weight: 800;
  background-image: linear-gradient(150deg, color-mix(in oklab, var(--brand) 36%, transparent), color-mix(in oklab, var(--brand) 16%, transparent));
  box-shadow: inset 0 1px 0 var(--lg-spec), inset 0 0 0 1px var(--tint-line);
}
[data-hl] { animation: rematch-glow 2.2s ease-in-out .6s infinite; }
@keyframes rematch-glow {
  0%, 100% { box-shadow: inset 0 1.5px 0 var(--lg-spec), 0 12px 28px -12px color-mix(in oklab, var(--brand) 60%, transparent), 0 0 0 0 color-mix(in oklab, var(--brand) 45%, transparent); }
  50% { box-shadow: inset 0 1.5px 0 var(--lg-spec), 0 12px 28px -12px color-mix(in oklab, var(--brand) 60%, transparent), 0 0 0 9px color-mix(in oklab, var(--brand) 0%, transparent); }
}
@media (prefers-reduced-motion: reduce) { [data-hl] { animation: none; outline: 3px solid var(--brand); outline-offset: 3px; } }

/* ---- settings: every item in its own box, grouped under small headings ---- */
.set-col { display: grid; gap: .75rem; align-content: start; }
.set-h { margin: .25rem .5rem 0; font-size: .8rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--foreground-muted); }
.set-legal { display: grid; gap: .75rem; }
@media (min-width: 640px) { .set-legal { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
[data-screen="settings"] a.card { text-decoration: none; color: inherit; }
[data-screen="settings"] a.card:hover .icon:last-child { translate: 3px 0; }
[data-screen="settings"] a.card .icon:last-child { transition: translate .2s var(--ix-ease); }
@media (min-width: 1024px) {   /* header spans the page (back left, theme right); the boxes stay centred below it */
  #app > [data-screen="settings"] { display: flex; flex-direction: column; align-items: center; }
  [data-screen="settings"] > header { align-self: stretch; }
  [data-screen="settings"] > .set-col { width: min(100%, 44rem); }
}

/* ---- mode screen: computer difficulty box ---- */
.diff-row { margin-inline: 0; }

/* ---- profile: boxes keep a little air ---- */
[data-screen="profile"] > .card { gap: .75rem; }

/* ---- online: series score line ---- */
.ol-series { margin: 0; text-align: center; font-size: .85rem; font-weight: 700; color: var(--foreground-muted); }
.ol-series b { color: var(--foreground); }

/* ---- stats: three online series cards share the row; same wave effect as every other card ---- */
.stat-card--b10 { --stat-color: #8b5cf6; --corner-bl: rgba(139, 92, 246, .3); --corner-br: rgba(124, 58, 237, .2); --corner-tr: rgba(196, 181, 253, .14); --edge-tint: rgba(139, 92, 246, .48); }
.stats-cards-grid > .stat-card--b10 { grid-column: span 2; aspect-ratio: auto; min-height: 7.5rem; }
#stats-grid-online > .stat-card--b3, #stats-grid-online > .stat-card--b5 { grid-column: span 2; }
@media (max-width: 559px) {
  .stats-cards-grid > .stat-card--b10 { grid-column: span 2; }
  #stats-grid-online > .stat-card--b3, #stats-grid-online > .stat-card--b5 { grid-column: span 1; }
}
/* ---- game-mode picker: 3×3 / 5×5 / 7×7 on top, the special modes below ---- */
.grid-opts { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .55rem; width: 100%; box-sizing: border-box; }
.grid-opts button { grid-column: span 2; min-width: 0; max-width: 100%; box-sizing: border-box; overflow: hidden; }
.grid-opts button:nth-child(n+4) { grid-column: span 3; }
.grid-opts button:nth-child(8):last-child:not([hidden]) { grid-column: 1 / -1; }
.grid-opts small { text-wrap: balance; max-width: 100%; overflow-wrap: break-word; }
.grid-opts.ser-opts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-opts.ser-opts button { grid-column: auto; }
.grid-opts button:disabled { opacity: .5; cursor: not-allowed; }
.ol-stack > .grid-opts { width: 100%; }
.ol-fmt button[aria-pressed="true"] {
  background-image: linear-gradient(150deg, color-mix(in oklab, var(--brand) 32%, transparent), color-mix(in oklab, var(--brand) 12%, transparent) 60%, color-mix(in oklab, var(--brand) 24%, transparent)) !important;
  border-color: var(--tint-line) !important;
  box-shadow: inset 0 1.5px 0 var(--lg-spec), inset 0 0 0 1.5px var(--tint-line), inset 0 0 18px rgb(255 255 255 / .12), 0 10px 22px -10px color-mix(in oklab, var(--brand) 70%, transparent) !important;
}
.ol-fmt button[aria-pressed="true"]:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* previews: Ultimate = nine small boards; the highlighted one is where the opponent must play, Free-Choice lights them all */
.gp { display: grid; grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr)); grid-template-rows: repeat(var(--n, 3), minmax(0, 1fr)); gap: 2px; width: 3rem; aspect-ratio: 1; overflow: hidden; box-sizing: border-box; flex-shrink: 0; }
.gp i { min-width: 0; min-height: 0; }
.gp[data-u] { gap: 2px; }
.gp u { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 1px; padding: 1px; min-width: 0; min-height: 0; border-radius: 3px; text-decoration: none; opacity: .42; outline: 1px solid color-mix(in oklab, var(--brand) 55%, transparent); overflow: hidden; box-sizing: border-box; }
.gp u i { border-radius: 18%; box-shadow: none; min-width: 0; min-height: 0; }
.gp[data-u="u"] u:nth-child(5), .gp[data-u="f"] u { opacity: 1; }

/* ---- custom series sheet ---- */
.ft-chips { justify-self: center; align-self: center; }
.ft-step { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .75rem; }
.ft-step .icon-btn { width: 3rem; height: 3rem; font-size: 1.5rem; font-weight: 800; line-height: 1; justify-content: center; }
.ft-step .icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.ft-val { margin: 0; display: grid; justify-items: center; line-height: 1; }
.ft-val output { font-family: var(--font-display, inherit); font-size: 3.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ft-val small { margin-top: .25rem; font-size: .75rem; font-weight: 700; color: var(--foreground-muted); }

/* ---- All boards (3×3, 5×5, 7×7, Gravity, Vanishing, Ultimate, Free-Choice): strict square grid, zero overlap ---- */
.board {
  width: min(100%, 34rem, max(14.5rem, calc(100dvh - 23rem)));
  aspect-ratio: 1;
  grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr));
  grid-template-rows: repeat(var(--n, 3), minmax(0, 1fr));
  gap: clamp(.22rem, calc(1.35rem / var(--n, 3)), .55rem);
  padding: clamp(.35rem, calc(1.5rem / var(--n, 3)), .65rem);
  box-sizing: border-box;
}
.board .cell {
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  aspect-ratio: 1;
  box-sizing: border-box;
  overflow: hidden;
  border-radius: clamp(.35rem, calc(4.2rem / var(--n, 3)), 1.25rem);
}
.board .cell > svg { width: 62%; height: 62%; display: block; flex-shrink: 0; }
.board:not([data-n="3"]) .cell:not([data-win]):not([data-hint]) { animation-name: fade-in; animation-delay: 0ms !important; }

/* ---- Rewind / forward highlight: the cell of the move being viewed pulses a few times per click, then stays lit. Never during live play or on resume. ---- */
.board[data-replay] .cell[data-new] {
  border-color: var(--brand) !important;
  background-color: color-mix(in oklab, var(--brand) 18%, var(--surface-strong)) !important;
  box-shadow: inset 0 0 0 2px var(--brand), 0 0 10px color-mix(in oklab, var(--brand) 35%, transparent) !important;
  z-index: 2;
}
.board[data-replay] .cell[data-new] {
  background-color: color-mix(in oklab, var(--brand) 28%, var(--surface-strong)) !important;
  box-shadow: inset 0 0 0 2.5px var(--brand), 0 0 14px color-mix(in oklab, var(--brand) 55%, transparent) !important;
  animation: replay-cell-pulse .45s var(--ease-out, ease) 6 alternate;
}
@keyframes replay-cell-pulse {
  from { filter: brightness(1); }
  to { filter: brightness(1.12); box-shadow: inset 0 0 0 3px var(--brand), 0 0 18px color-mix(in oklab, var(--brand) 75%, transparent); }
}

/* ---- Ultimate & Free-Choice board ---- */
.board-u {
  gap: clamp(.35rem, 1.8vmin, .55rem);
  padding: clamp(.42rem, 2.2vmin, .65rem);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  aspect-ratio: 1;
}
.board-u .ub {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  aspect-ratio: 1;
  gap: clamp(2px, .55vmin, 3.5px);
  min-width: 0;
  min-height: 0;
  padding: clamp(2.5px, .8vmin, 5px);
  border-radius: clamp(.6rem, 2.2vmin, 1rem);
  border: 1.5px solid transparent;
  box-sizing: border-box;
  overflow: hidden;
  transition: opacity .25s var(--ease-out, ease), border-color .25s var(--ease-out, ease), background-color .25s var(--ease-out, ease), box-shadow .25s var(--ease-out, ease);
}
.board-u .cell { border-radius: clamp(.2rem, 1.2vmin, .45rem); min-width: 0; min-height: 0; padding: 0; }
.board-u .cell:not([aria-disabled="true"]):hover { translate: 0 -1px; scale: 1.04; }
.board-u .cell > svg { width: 70%; height: 70%; }
.board-u:not([data-over]) .ub:not([data-active]) { opacity: .5; }
.board-u[data-replay] .ub:not([data-active]):not([data-last]) { opacity: .58; }
.board-u[data-replay] .ub[data-last] {
  border-color: color-mix(in oklab, var(--brand) 75%, transparent);
  background: color-mix(in oklab, var(--brand) 8%, transparent);
  opacity: 1 !important;
}
.board-u .ub[data-active] {
  border-color: var(--brand);
  background: color-mix(in oklab, var(--brand) 12%, transparent);
  box-shadow: 0 0 0 1.5px color-mix(in oklab, var(--brand) 36%, transparent), inset 0 0 10px color-mix(in oklab, var(--brand) 16%, transparent);
}
.board-u:not([data-replay]) .ub[data-won] > .cell { opacity: 0 !important; pointer-events: none; }
.board-u[data-replay] .ub[data-won] > .cell:not([data-new]), .board-u .ub[data-draw] > .cell:not([data-new]) { opacity: .18; }
.board-u[data-replay] .ub[data-won] .ub-mark { opacity: .38; }
.board-u .ub[data-draw] { opacity: .6; }
.board-u .ub-mark { position: absolute; inset: 10%; display: grid; place-items: center; pointer-events: none; animation: ub-pop .32s var(--lg-spring, ease-out) both; }
.board-u .ub-mark svg { filter: none; }
.board-u .ub[data-win] { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand), inset 0 0 14px color-mix(in oklab, var(--brand) 35%, transparent); opacity: 1 !important; }
.board-u[data-over] .ub:not([data-win]) { opacity: .55; }
.board-u .cell[data-win] { animation: none; }
@keyframes ub-pop { from { opacity: 0; scale: .6; } to { opacity: 1; scale: 1; } }
/* a mark pops only in the moment it is placed (JS sets data-fresh, clears it when the pop ends) */
.cell[data-fresh] > svg { animation: mark-pop var(--spring-pop-dur) var(--spring-pop) both; }
@media (prefers-reduced-motion: reduce) {
  .cell[data-fresh] > svg { animation: fade-in 120ms both; }
  .board-u .ub, .board-u .ub-mark, .cell[data-new] { transition: none; animation: none; }
  .board-u .cell:hover { translate: none; scale: none; }
}
@media (max-width: 420px) { .grid-opts button { padding-inline: .2rem; } .grid-opts b { font-size: .95rem; } }
/* the sheets float over busy cards: a firmer pane keeps the option labels legible */
@media (prefers-reduced-transparency: no-preference) { .sheet-card { background-color: color-mix(in oklab, var(--surface-strong) 58%, transparent); } }

/* Vanishing marks: the mark that goes next fades. Random Rotation: loading screen between games. */
.cell[data-old] { opacity: .4; }
#rot-load[hidden] { display: none; }
.grid-opts button[data-grid="v"] b, .grid-opts button[data-grid="r"] b { font-size: .85rem; }

/* ---- Popups: nothing scrolls inside a card. The card is compact so it fits; on a screen too short for it the popup layer itself scrolls (pill scrollbar), and the page behind stays still ---- */
body:has(.sheet:not([hidden])) { overflow: hidden; }
.sheet { place-items: start center; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }
.sheet-card { display: grid; margin: auto; max-height: none; overflow: visible; box-sizing: border-box; }
.sheet-card > .grid-opts { max-height: none; overflow: visible; padding: 0; margin: 0; }
/* the card already blurs what is behind it; a second blur on every button inside it painted the grey rectangle */
.sheet-card :is(.grid-opts button, .btn-secondary, .icon-btn, .seg) { -webkit-backdrop-filter: none; backdrop-filter: none; }
/* extra boards: icon beside the text, so all eight options fit without scrolling */
#grid-sheet .grid-extra { grid-template-columns: 2.6rem minmax(0, 1fr); grid-template-areas: "gp t" "gp s"; column-gap: .5rem; row-gap: 0; align-items: center; justify-items: start; text-align: left; padding: .55rem .5rem .55rem .6rem; overflow: visible; }
#grid-sheet .grid-extra .gp { grid-area: gp; width: 2.6rem; justify-self: center; overflow: visible; }
#grid-sheet .grid-extra b { grid-area: t; min-width: 0; margin: 0; font-size: .88rem; line-height: 1.15; align-self: end; }
#grid-sheet .grid-extra small { grid-area: s; align-self: start; text-align: left; font-size: .68rem; line-height: 1.2; }
@media (max-height: 640px) { .sheet-card { padding: 1rem .9rem .9rem; gap: .5rem; } }

/* ---- Pill scrollbar. Firefox gets the standard properties; Chromium must NOT see them, or it drops the ::-webkit-scrollbar rules and draws its square native bar ---- */
@supports not selector(::-webkit-scrollbar) {
  .sheet, #ol-quick, .recent-history-list { scrollbar-width: thin; scrollbar-color: var(--brand) transparent; }
}
:is(.sheet, #ol-quick)::-webkit-scrollbar { width: 10px; height: 10px; }
:is(.sheet, #ol-quick)::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
:is(.sheet, #ol-quick)::-webkit-scrollbar-track { background: color-mix(in oklab, var(--foreground) 10%, transparent); border-radius: 9999px; margin-block: .6rem; }
:is(.sheet, #ol-quick)::-webkit-scrollbar-thumb {
  border-radius: 9999px; border: 2px solid transparent; background-clip: padding-box;
  background-image: linear-gradient(180deg, var(--brand), var(--mark-o, var(--brand-strong)), var(--brand));
  background-size: 100% 220%;
  animation: grid-scrollbar-flow 2.2s ease-in-out infinite alternate;
}
@media (prefers-reduced-motion: reduce) { :is(.sheet, #ol-quick)::-webkit-scrollbar-thumb { animation: none; } }
@keyframes grid-scrollbar-flow {
  0% { background-position: 0% 0%; }
  100% { background-position: 0% 100%; }
}

/* Ultimate mode: combined shield logo (pink + blue) and the five board cards */
.mode-ultimate { --wave-color: #7c3aed; --wave-rim: #f472b6; --panel-color: #ec4899; --panel-light: #60a5fa; --flow-delay: -12s; }
.mode-u-red { --wave-color: #dc2626; --wave-rim: #f87171; --panel-color: #ef4444; --panel-light: #fecaca; --flow-delay: 0s; }
.mode-u-navy { --wave-color: #1e3a8a; --wave-rim: #3b82f6; --panel-color: #1e3a8a; --panel-light: #60a5fa; --flow-delay: -3s; }
.mode-u-green { --wave-color: #16a34a; --wave-rim: #4ade80; --panel-color: #22c55e; --panel-light: #bbf7d0; --flow-delay: -6s; }
.mode-u-gold { --wave-color: #ca8a04; --wave-rim: #facc15; --panel-color: #eab308; --panel-light: #fef08a; --flow-delay: -9s; }
.mode-u-orange { --wave-color: #ea580c; --wave-rim: #fb923c; --panel-color: #f97316; --panel-light: #fed7aa; --flow-delay: -12s; }
.mode-u-navy :is(.mode-v2-title, .mode-v2-sub) { color: #fff; }
button.mode-card-v2 { text-align: left; font: inherit; }
.ult-logo { height: 5.35rem; }
.ult-logo img { position: absolute; top: 0; width: 4.9rem; height: 4.9rem; object-fit: contain; pointer-events: none; }
.ult-a { left: calc(50% - 4.2rem); animation: ult-a 4s ease-in-out infinite alternate, ult-glow 3s ease-in-out infinite alternate; }
.ult-b { left: calc(50% - .7rem); animation: ult-b 4s ease-in-out infinite alternate, ult-glow 3s ease-in-out infinite alternate-reverse; }
@keyframes ult-a { from { transform: rotate(-7deg) translateY(2px); } to { transform: rotate(-3deg) translateY(-4px); } }
@keyframes ult-b { from { transform: rotate(7deg) translateY(-4px); } to { transform: rotate(3deg) translateY(2px); } }
@keyframes ult-glow { from { filter: drop-shadow(0 0 6px #ec4899); } to { filter: drop-shadow(0 0 8px #3b82f6); } }
@media (prefers-reduced-motion: reduce) { .ult-a, .ult-b { animation: none; } }

.grid-opts button[hidden] { display: none; }
.mode-select-grid .mode-card-v2 { min-height: 14.5rem; }
.mode-v2-arrow { flex: none; }
.mode-u-orange .mode-v2-title { font-size: .98rem; }
.stats-modes { display: grid; gap: .6rem; padding: 0; margin: 0; list-style: none; }
.stats-modes li { align-items: center; gap: .8rem; justify-content: flex-start; }
.stats-modes img { object-fit: contain; }
.stats-modes .grow { flex: 1; }
.local-note { max-width: 20rem; margin: .5rem auto 0; font-size: .8rem; line-height: 1.4; font-weight: 600; color: var(--foreground-muted, inherit); text-align: center; }
@keyframes rot-fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---- popups: two-up option row, centred labels, +/- icons ---- */
.grid-opts.two { grid-template-columns: 1fr 1fr; }
.grid-opts.two button { grid-column: auto; align-content: center; min-height: 3.5rem; padding-block: .6rem; }
.grid-opts button > b:only-child { margin: 0; line-height: 1.2; }
.grid-opts button, .sheet .btn { text-align: center; }
.sheet .btn { justify-content: center; line-height: 1.2; flex-shrink: 0; }
.ft-step .icon-btn svg { display: block; }

/* ---- loading screens: the backdrop IS the page background (inherited from body), so every theme matches; fonts match the game headings ---- */
#rot-load { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 1.5rem; overflow: hidden; text-align: center; background: inherit; }
.ld-card { position: relative; display: grid; justify-items: center; gap: .6rem; width: min(100%, 25rem); padding: 1.6rem 1.3rem 1.2rem; border-radius: 2rem; color: var(--foreground); border: 1px solid var(--border);
  background: color-mix(in oklab, var(--surface-strong, #fff) 80%, transparent); backdrop-filter: blur(16px) saturate(1.4); box-shadow: 0 24px 60px -18px rgb(var(--shadow-rgb, 0 0 0) / .45), inset 0 1px 0 rgb(255 255 255 / .5); }
#rot-load img { width: 6rem; height: 6rem; object-fit: contain; }
#rot-load small { font-family: var(--font-display); font-weight: 600; color: var(--foreground-muted); }
#rot-load span { font-weight: 600; color: var(--foreground-muted); }
#rot-load b { font-family: var(--font-display); font-weight: 700; font-size: 1.9rem; line-height: 1.15; color: var(--foreground); }
#rot-load i { position: relative; width: 12rem; height: .5rem; border-radius: 9px; overflow: hidden; background: color-mix(in oklab, var(--ld1, #ec4899) 25%, transparent); }
#rot-load i::after { content: ""; position: absolute; inset: 0; transform-origin: left; animation: rot-fill var(--ld-ms, 3s) cubic-bezier(.4, 0, .2, 1) forwards;
  background: linear-gradient(90deg, var(--ld0, #7c3aed), var(--ld1, #ec4899), var(--ld2, #f59e0b), var(--ld3, #38bdf8)); }
#rot-load i::before { content: ""; position: absolute; inset: 0; z-index: 1; width: 40%; background: linear-gradient(90deg, transparent, rgb(255 255 255 / .7), transparent); animation: ld-sweep 1s linear infinite; }
.ol-spinner { position: relative; width: 3rem; height: 3rem; border: 0; border-radius: 50%;   /* comet ring: a fading gradient tail behind a glowing head */
  background: conic-gradient(transparent, var(--ld0, #7c3aed) 25%, var(--ld1, #ec4899) 55%, var(--ld2, #f59e0b) 80%, var(--ld3, #38bdf8));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5px)); mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5px));
  filter: drop-shadow(0 0 5px var(--ld1, #ec4899)); animation: ol-spin .9s linear infinite, ld-pulse 1.4s ease-in-out infinite alternate; }
.ol-spinner::after { content: ""; position: absolute; top: 0; left: calc(50% - 3px); width: 6px; height: 6px; border-radius: 50%; background: var(--ld3, #38bdf8); }
@keyframes ld-sweep { from { transform: translateX(-100%); } to { transform: translateX(350%); } }
@keyframes ld-pulse { from { scale: .88; } to { scale: 1.08; } }
@media (prefers-reduced-motion: reduce) {
  #rot-load i::before { animation: none; }
  .ol-spinner { animation-duration: 3s, 3s; }
}

/* Per-mode stats icon: set here because the production CSP blocks style="" attributes. */
#stats-modes .gp { width: 2.2rem; }
/* Tailwind's @theme inline never emits these as variables, so var(--font-display) fell back to the body font. Same stacks as the .font-display / font-sans utilities. */
:root{--font-display:"Fredoka",ui-rounded,"Plus Jakarta Sans",system-ui,sans-serif;--font-sans:"Plus Jakarta Sans",ui-sans-serif,system-ui,sans-serif}
/* ---- extra themes: rich, saturated gradients ---- */
[data-theme="mist"]{color-scheme:light;--page-from:#cfe3ff;--page-to:#a9c8fb;--foreground:#0b2350;--foreground-muted:#33508a;--surface:rgb(255 255 255 / .62);--surface-strong:#f4f8ff;--border:color-mix(in oklab,#2f63d6 35%,transparent);--brand:#2f63d6;--brand-strong:#2552b8;--brand-foreground:#ffffff;--mark-x:#2f63d6;--mark-o:#d6307f;--success:#15803d;--danger:#b91c1c;--focus:#2f63d6;--shadow-rgb:40 40 70}
[data-theme="sage"]{color-scheme:light;--page-from:#c6f0d0;--page-to:#96dcae;--foreground:#0a3320;--foreground-muted:#26603f;--surface:rgb(255 255 255 / .6);--surface-strong:#f3fff6;--border:color-mix(in oklab,#18813f 35%,transparent);--brand:#18813f;--brand-strong:#136b34;--brand-foreground:#ffffff;--mark-x:#15803d;--mark-o:#d9560f;--success:#15803d;--danger:#b91c1c;--focus:#18813f;--shadow-rgb:40 40 70}
[data-theme="sand"]{color-scheme:light;--page-from:#ffe8bd;--page-to:#ffcf86;--foreground:#3d2105;--foreground-muted:#7a4a14;--surface:rgb(255 255 255 / .6);--surface-strong:#fff9ec;--border:color-mix(in oklab,#bd5f08 35%,transparent);--brand:#bd5f08;--brand-strong:#a14f05;--brand-foreground:#ffffff;--mark-x:#b45309;--mark-o:#0e7490;--success:#15803d;--danger:#b91c1c;--focus:#bd5f08;--shadow-rgb:40 40 70}
[data-theme="blush"]{color-scheme:light;--page-from:#ffd3e3;--page-to:#ffadcb;--foreground:#4a0d27;--foreground-muted:#8a2c55;--surface:rgb(255 255 255 / .6);--surface-strong:#fff5f9;--border:color-mix(in oklab,#d12f6a 35%,transparent);--brand:#d12f6a;--brand-strong:#b02359;--brand-foreground:#ffffff;--mark-x:#be185d;--mark-o:#6d28d9;--success:#15803d;--danger:#b91c1c;--focus:#d12f6a;--shadow-rgb:40 40 70}
[data-theme="lagoon"]{color-scheme:light;--page-from:#b8f2ee;--page-to:#76d9e8;--foreground:#053a45;--foreground-muted:#1d6672;--surface:rgb(255 255 255 / .6);--surface-strong:#f1ffff;--border:color-mix(in oklab,#0e7490 35%,transparent);--brand:#0e7490;--brand-strong:#0b5f77;--brand-foreground:#ffffff;--mark-x:#0e7490;--mark-o:#db2777;--success:#15803d;--danger:#b91c1c;--focus:#0e7490;--shadow-rgb:40 40 70}
[data-theme="peach"]{color-scheme:light;--page-from:#ffd7bf;--page-to:#ffb086;--foreground:#4a1a05;--foreground-muted:#8a3d17;--surface:rgb(255 255 255 / .6);--surface-strong:#fff7f2;--border:color-mix(in oklab,#d9480f 35%,transparent);--brand:#d9480f;--brand-strong:#b83b0a;--brand-foreground:#ffffff;--mark-x:#c2410c;--mark-o:#1d4ed8;--success:#15803d;--danger:#b91c1c;--focus:#d9480f;--shadow-rgb:40 40 70}
[data-theme="slate"]{color-scheme:dark;--page-from:#0f172a;--page-to:#2a3b6b;--foreground:#f1f5ff;--foreground-muted:#c3cff0;--surface:rgb(255 255 255 / .1);--surface-strong:#2c3f73;--border:color-mix(in oklab,#4f7cf0 45%,transparent);--brand:#4f7cf0;--brand-strong:#3f67d4;--brand-foreground:#ffffff;--mark-x:#7dd3fc;--mark-o:#fda4af;--success:#4ade80;--danger:#ff8a8a;--focus:#4f7cf0;--shadow-rgb:0 0 0}
[data-theme="moss"]{color-scheme:dark;--page-from:#062b1e;--page-to:#0f6144;--foreground:#effff6;--foreground-muted:#b4e6cb;--surface:rgb(255 255 255 / .1);--surface-strong:#12684b;--border:color-mix(in oklab,#0b8a58 45%,transparent);--brand:#0b8a58;--brand-strong:#08744a;--brand-foreground:#ffffff;--mark-x:#4ade80;--mark-o:#fbbf24;--success:#4ade80;--danger:#ff8a8a;--focus:#0b8a58;--shadow-rgb:0 0 0}
[data-theme="plum"]{color-scheme:dark;--page-from:#2b0b40;--page-to:#5f1f82;--foreground:#faf0ff;--foreground-muted:#dbbdf2;--surface:rgb(255 255 255 / .1);--surface-strong:#64298c;--border:color-mix(in oklab,#9333ea 45%,transparent);--brand:#9333ea;--brand-strong:#7c22cc;--brand-foreground:#ffffff;--mark-x:#d8b4fe;--mark-o:#ff9ec7;--success:#4ade80;--danger:#ff8a8a;--focus:#9333ea;--shadow-rgb:0 0 0}
[data-theme="deepsea"]{color-scheme:dark;--page-from:#03222f;--page-to:#07607a;--foreground:#eafcff;--foreground-muted:#a9e0ec;--surface:rgb(255 255 255 / .1);--surface-strong:#0b6580;--border:color-mix(in oklab,#0e7490 45%,transparent);--brand:#0e7490;--brand-strong:#0b6078;--brand-foreground:#ffffff;--mark-x:#22d3ee;--mark-o:#fdba74;--success:#4ade80;--danger:#ff8a8a;--focus:#0e7490;--shadow-rgb:0 0 0}

/* dark themes: brand colours are tuned for buttons, too dim as icon ink on dark glass */
[data-dark] .icon.text-brand{color:var(--mark-x)}
[data-theme="cyberpunk"]{--surface-strong:#2a3d78}   /* same value as src/input.css; keeps panels visible until styles.css is rebuilt */
/* Tailwind arbitrary classes that styles.css never compiled (rebuild with npm run build:css to drop these) */
#toast{bottom:max(1.5rem,env(safe-area-inset-bottom))}
#theme-grid [data-theme]{background:var(--page-from)}
.font-normal{font-weight:400}

/* Settings: system theme dropdown */
.sysmode{padding:0;overflow:hidden}
.sysmode-btn{display:flex;width:100%;min-height:56px;align-items:center;justify-content:space-between;gap:.75rem;padding:.5rem 1rem;text-align:left}
.sysmode-caret{transform:rotate(90deg);transition:transform .2s ease}
.sysmode-btn[aria-expanded="true"] .sysmode-caret{transform:rotate(-90deg)}
.sysmode-list{display:grid;border-top:1px solid var(--border)}
.sysmode-list button{display:flex;min-height:48px;align-items:center;gap:.75rem;padding:.5rem 1rem;font-weight:700;text-align:left;transition:background-color .15s}
.sysmode-list button[aria-selected="true"]{color:var(--brand)}
@media (hover:hover){.sysmode-list button:hover,.sysmode-btn:hover{background:var(--surface-strong)}}

/* System defaults: pure white / pure black (no tint, no gradient) */
[data-theme="white"] body,[data-theme="black"] body{background-image:none;background-color:var(--page-from)}
/* No glow on X / O while playing by default (including system default Light / Dark themes); only explicit symbol glow styles keep their filter */
:is(.cell > svg, .mini svg, .board-u .ub-mark svg):not([data-s="3"]):not([data-s="5"]):not([data-s="10"]){filter:none}
:is([data-theme="white"],[data-theme="black"]) :is(.cell > svg, .mini svg, .board-u .ub-mark svg):not([data-s="3"]):not([data-s="5"]){filter:none}

/* ===== System default themes: Light / Dark. Solid surfaces (no glass), blue accent, logo-coloured marks ===== */
[data-theme="white"]{color-scheme:light;--page-from:#fff;--page-to:#fff;--foreground:#2b2f36;--foreground-muted:#64748b;--surface:#fff;--surface-strong:#f5f7fa;--border:rgb(100 116 139/.32);--brand:#2563eb;--brand-strong:#1d4ed8;--brand-foreground:#fff;--mark-x:#329ff9;--mark-o:#ed46f2;--success:#15803d;--danger:#b91c1c;--focus:#1d4ed8;--accent-text:#2563eb;--shadow-rgb:15 23 42;--lg-shadow:0 1px 2px rgb(15 23 42/.12),0 8px 18px -8px rgb(15 23 42/.3);--dis-fg:#8a9bb5;--dis-bg:#eef2f7;--dis-line:#d5dde9}
[data-theme="black"]{color-scheme:dark;--page-from:#24272c;--page-to:#24272c;--foreground:#f3f5f8;--foreground-muted:#aab4c4;--surface:#2e3238;--surface-strong:#393e46;--border:rgb(255 255 255/.14);--brand:#1d6fe8;--brand-strong:#1559c4;--brand-foreground:#fff;--mark-x:#329ff9;--mark-o:#ed46f2;--success:#34d399;--danger:#ff8a8a;--focus:#5cb8ff;--accent-text:#5cb8ff;--shadow-rgb:0 0 0;--lg-shadow:0 1px 2px rgb(0 0 0/.45),0 8px 18px -8px rgb(0 0 0/.6);--dis-fg:#7d8aa0;--dis-bg:#2a2d33;--dis-line:#3d434c}
:is([data-theme="white"],[data-theme="black"]){--lg-blur:none;--lg-spec:transparent;--lg-rim:var(--border);--lg-fill:var(--surface);--lg-fill-hi:var(--surface);--tint-fill:none;--tint-line:var(--brand)}
[data-theme="white"] body,[data-theme="black"] body{background-image:none;background-color:var(--page-from)}
:is([data-theme="white"],[data-theme="black"]) :is(.card,.btn-secondary,.icon-btn,.seg,.tile,.board,.mini,.ol-input,.ol-conn,.stat-card,.recent-glass-panel,.sheet-card,.grid-opts button,.mode-card-v2,.mode-v2-arrow,.stats-back-btn,.stats-reset-btn,.stats-play-cta){background-image:none!important;background-color:var(--surface)!important;-webkit-backdrop-filter:none!important;backdrop-filter:none!important;border:1px solid var(--border)!important;box-shadow:var(--lg-shadow)!important}
:is([data-theme="white"],[data-theme="black"]) :is(.card,.board,.sheet-card)::before{display:none}
:is([data-theme="white"],[data-theme="black"]) .btn-primary{background-image:none!important;background-color:var(--brand)!important;color:var(--brand-foreground)!important;border:1px solid var(--brand-strong)!important;-webkit-backdrop-filter:none!important;backdrop-filter:none!important;box-shadow:0 8px 18px -8px rgb(37 99 235/.65),0 1px 2px rgb(0 0 0/.2)!important}
@media (hover:hover){:is([data-theme="white"],[data-theme="black"]) .btn-primary:hover{background-color:var(--brand-strong)!important}}
:is([data-theme="white"],[data-theme="black"]) :is(.seg > button,.pf-genders .btn,.ol-fmt button)[aria-pressed="true"]{background-image:none!important;background-color:var(--brand)!important;color:var(--brand-foreground)!important;border-color:var(--brand-strong)!important;box-shadow:0 6px 14px -6px rgb(37 99 235/.6)!important}
:is([data-theme="white"],[data-theme="black"]) :is(.tile,.grid-opts button)[aria-pressed="true"]{border-color:var(--brand)!important;box-shadow:0 0 0 2px var(--brand),var(--lg-shadow)!important}
[data-theme="white"] .seg > button:not([aria-pressed="true"]){box-shadow:var(--lg-shadow)}
:is([data-theme="white"],[data-theme="black"]) :is(.btn,.icon-btn,.grid-opts button,.seg > button):disabled{color:var(--dis-fg)!important;background-image:none!important;background-color:var(--dis-bg)!important;border:1px solid var(--dis-line)!important;box-shadow:none!important;opacity:1!important}
:is([data-theme="white"],[data-theme="black"]) :is(.text-brand,.set-h){color:var(--accent-text)}
:is([data-theme="white"],[data-theme="black"]) .stats-logo i:nth-child(odd){--b1:#329ff9;--b2:#1d6fe8;--b3:rgba(29,111,232,.55)}
:is([data-theme="white"],[data-theme="black"]) .stats-logo i:nth-child(2){--b1:#f58bf8;--b2:#ed46f2;--b3:rgba(237,70,242,.55)}
/* more blue for the two system themes: titles + icon buttons */
:is([data-theme="white"],[data-theme="black"]) .screen-title{color:var(--accent-text)}
:is([data-theme="white"],[data-theme="black"]) .icon-btn:not(:disabled) .icon{color:var(--accent-text)}
/* ==========================================================================
   Performance and feel. Compositor-only motion, cheaper blur, instant press.
   ========================================================================== */
/* One blur for every glass control: 22px/180% repainted on ~40 elements per frame was the main cost */
:root { --lg-blur: blur(14px) saturate(150%); }
/* No 300ms tap delay, no grey flash, on anything pressable */
button, a, [role="button"], [data-i], .cell, .mode-card-v2, .sheet { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
/* Press feedback lands within one frame; release keeps the softer base duration */
.btn:active, .icon-btn:active, .tile:active, .lift-card:active, .mode-card-v2:active, .seg > button:active, .grid-opts button:active { transition-duration: 70ms; }
.cell:not([aria-disabled="true"]):active { transition-duration: 70ms; }
/* Screen change: fade and 6px rise only. The old scale re-rasterised every blurred card on the screen */
.screen-enter { animation: screen-in 200ms var(--ease-out) both; }
@keyframes screen-in { from { opacity: 0; transform: translate3d(0, 6px, 0); } }
.screen-enter .cell:not([data-win]):not([data-hint]) { animation-duration: 220ms; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 180ms; }
/* Sheets: the backdrop blur is static, only the tint fades */
.sheet { -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
/* Waves: 14 SVG paths morphed their "d" every frame on the main thread, which delayed clicks.
   One composited transform on each wave svg gives the same flowing look at no layout or paint cost. */
.mode-wave-main, .mode-wave-sub { animation: none; }
.mode-wave-svg { width: 112%; margin-left: -6%; transform-origin: 50% 100%; will-change: transform; animation: wave-sway 4.6s ease-in-out infinite alternate; }
.mode-card-v2:nth-child(2n) .mode-wave-svg { animation-delay: -1.7s; }
.mode-card-v2:nth-child(3n) .mode-wave-svg { animation-delay: -3.1s; }
@keyframes wave-sway { from { transform: translate3d(-3.5%, 0, 0) scaleY(1); } to { transform: translate3d(3.5%, 0, 0) scaleY(1.08); } }
@media (prefers-reduced-motion: reduce) { .mode-wave-svg { animation: none; will-change: auto; } }
@media (pointer: coarse) { :root { --lg-blur: blur(10px) saturate(140%); } }
