/* =============================================================================
   "Playmaker" theme — entertainer-mood reskin for the World Cup predictor.
   Shape language borrowed from the reference (dark rounded sidebar rail, soft
   cream/white shells, pill chips, capsule progress) applied to the project's
   existing indigo->pink brand palette. Layered on top of style.css.
   ========================================================================== */

/* ---- Self-hosted fonts (CSP-safe; no CDN) ---- */
@font-face { font-family:'Inter'; font-style:normal; font-weight:400; font-display:swap; src:url('/fonts/inter-400.ttf') format('truetype'); }
@font-face { font-family:'Inter'; font-style:normal; font-weight:500; font-display:swap; src:url('/fonts/inter-500.ttf') format('truetype'); }
@font-face { font-family:'Inter'; font-style:normal; font-weight:600; font-display:swap; src:url('/fonts/inter-600.ttf') format('truetype'); }
@font-face { font-family:'Inter'; font-style:normal; font-weight:700; font-display:swap; src:url('/fonts/inter-700.ttf') format('truetype'); }
@font-face { font-family:'Space Grotesk'; font-style:normal; font-weight:500; font-display:swap; src:url('/fonts/spacegrotesk-500.ttf') format('truetype'); }
@font-face { font-family:'Space Grotesk'; font-style:normal; font-weight:700; font-display:swap; src:url('/fonts/spacegrotesk-700.ttf') format('truetype'); }

/* Body in Inter; display/headings in Space Grotesk. Applied to body broadly so
   the auth pages (no .app class) get it too. */
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
.play-title, .tile-big, .final, h1, h2, h3, .auth-hero-title, .auth-card-title {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
}

:root {
  --ink: #14151a;            /* near-black rail */
  --ink-2: #20222b;          /* rail hover */
  --page: #eef0f6;           /* cool off-white page ground */
  --shell: #fafbff;          /* big rounded app shell */
  --card: #ffffff;
  --card-2: #f4f6fc;
  --rail-w: 76px;
  --r-lg: 26px;              /* big shell radius */
  --r-md: 20px;              /* cards */
  --r-sm: 14px;
}

/* The whole app sits inside a rounded "shell" on a soft ground, with a fixed
   dark sidebar rail on the left — the reference's signature frame. */
body.app {
  background: var(--page);
  display: block;            /* override the flex-column from style.css */
  min-height: 100vh;
  padding: 14px 14px 14px calc(var(--rail-w) + 22px);
}

/* ---- Sidebar rail ---- */
.rail {
  position: fixed; top: 14px; bottom: 14px; left: 14px; width: var(--rail-w);
  background: var(--ink); border-radius: var(--r-lg);
  display: flex; flex-direction: column; align-items: center;
  padding: 16px 0; gap: 6px; z-index: 50;
  box-shadow: 0 14px 40px rgba(15,23,42,.18);
}
.rail-logo {
  width: 44px; height: 44px; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; font-size: 22px; margin-bottom: 14px;
  box-shadow: 0 6px 16px rgba(79,70,229,.5);
}
.rail-links { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.rail-link {
  width: 46px; height: 46px; border-radius: 14px;
  display: grid; place-items: center; font-size: 19px;
  color: #aeb2c2; text-decoration: none; transition: background .15s, color .15s, transform .12s;
}
.rail-link:hover { background: var(--ink-2); color: #fff; text-decoration: none; transform: translateY(-1px); }
.rail-link.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.rail-link .tip {
  position: absolute; left: 58px; background: var(--ink); color: #fff;
  font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 8px;
  white-space: nowrap; opacity: 0; pointer-events: none; transform: translateX(-4px);
  transition: opacity .15s, transform .15s;
}
.rail-link:hover .tip { opacity: 1; transform: translateX(0); }
.rail-avatar {
  width: 46px; height: 46px; border-radius: 14px; margin-top: 6px;
  background: linear-gradient(135deg, #334155, #0f172a); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 16px;
  border: 2px solid #2b2e3a;
}

/* ---- App shell (everything to the right of the rail) ---- */
.shell {
  background: var(--shell); border-radius: var(--r-lg);
  padding: 30px 34px; min-height: calc(100vh - 28px);
  box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 18px 50px rgba(15,23,42,.07);
}

/* ---- Display hero header with inline emoji chips (reference signature) ---- */
.play-hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 26px; }
.play-title {
  font-size: clamp(30px, 4vw, 50px); font-weight: 900; line-height: 1.04;
  letter-spacing: -1.5px; margin: 0; max-width: 18ch;
}
.play-title .chip-i {
  display: inline-grid; place-items: center; width: .88em; height: .88em;
  /* Centre the chip on the text's cap-height: middle align + small upward nudge
     (cap-height sits above the x-middle that vertical-align:middle targets). */
  vertical-align: middle; position: relative; top: -0.08em;
  margin: 0 .1em; border-radius: 10px; color: #fff;
}
.play-title .chip-i svg { width: .52em; height: .52em; display: block; }
.play-title .chip-ink { background: var(--ink); }
.play-title .chip-lime { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.play-sub { color: var(--text-dim); font-weight: 600; margin: 8px 0 0; font-size: 15px; }

/* Big pill CTA in the header. */
.pill-cta {
  display: inline-flex; align-items: center; gap: 9px;
  background: var(--ink); color: #fff; font-weight: 800; font-size: 15px;
  padding: 14px 22px; border-radius: 999px; text-decoration: none;
  box-shadow: 0 8px 22px rgba(20,21,26,.3); transition: transform .12s, box-shadow .15s;
}
.pill-cta:hover { transform: translateY(-2px); text-decoration: none; box-shadow: 0 12px 30px rgba(20,21,26,.38); }
.pill-cta .plus { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 999px; background: rgba(255,255,255,.16); }

/* ---- Pill tab strip ---- */
.pill-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; }
.pill-tab {
  padding: 9px 18px; border-radius: 999px; font-weight: 700; font-size: 14px;
  background: var(--card); border: 1px solid var(--border); color: var(--text-dim);
  cursor: pointer; text-decoration: none; transition: all .15s;
}
.pill-tab:hover { border-color: var(--ink); color: var(--text); text-decoration: none; }
.pill-tab.active { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---- Stat tiles with chunky capsule progress (reference's Operations card) ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; margin-bottom: 24px; }
.tile { background: var(--card); border-radius: var(--r-md); padding: 20px 22px; border: 1px solid var(--border); }
.tile.feature { background: linear-gradient(140deg, var(--accent-soft), #fff 70%); border-color: #dcdcf6; }
.tile-head { display: flex; align-items: center; gap: 10px; color: var(--text-dim); font-weight: 700; font-size: 14px; }
.tile-head .ic { width: 30px; height: 30px; border-radius: 10px; background: var(--card-2); display: grid; place-items: center; font-size: 15px; }
.tile-big { font-size: 42px; font-weight: 900; letter-spacing: -1px; margin: 12px 0 2px; line-height: 1; }
.tile-big small { font-size: 15px; font-weight: 700; color: var(--text-dim); letter-spacing: 0; }
/* Chunky capsule segments. */
.caps { display: flex; gap: 6px; margin-top: 16px; }
.caps i { flex: 1; height: 26px; border-radius: 9px; background: var(--card-2); border: 1px dashed #d6d9e6; }
.caps i.on { background: var(--ink); border: none; }
.tile.feature .caps i.on { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }

@media (prefers-reduced-motion: reduce) {
  .rail-link, .pill-cta, .pill-tab { transition: none; }
}

/* =============================================================================
   MINIMAL REFINEMENT — smaller, quieter type; flatter surfaces; calmer accents.
   Tuned down from the bold first pass per design direction.
   ========================================================================== */

/* Tighter, smaller display type. */
.play-title { font-size: clamp(24px, 2.6vw, 34px); letter-spacing: -1px; font-weight: 800; }
.play-sub { font-size: 14px; font-weight: 500; }
.play-hero { margin-bottom: 22px; }

/* Quieter pill CTA — smaller, lighter shadow. */
.pill-cta { font-size: 14px; font-weight: 700; padding: 11px 18px; box-shadow: 0 4px 14px rgba(20,21,26,.18); }
.pill-cta:hover { transform: translateY(-1px); box-shadow: 0 7px 20px rgba(20,21,26,.24); }

/* Flatter tiles: smaller numbers, thinner edges, no heavy fill. */
.tiles { gap: 14px; margin-bottom: 22px; }
.tile { padding: 16px 18px; border-radius: 16px; }
.tile.feature { background: var(--card); border-color: var(--border); }   /* drop the gradient — minimal */
.tile.feature .tile-head .ic { background: var(--accent-soft); color: var(--accent); }
.tile-head { font-size: 12.5px; font-weight: 600; letter-spacing: .2px; }
.tile-head .ic { width: 26px; height: 26px; border-radius: 8px; font-size: 13px; }
.tile-big { font-size: 30px; font-weight: 800; letter-spacing: -.5px; margin: 10px 0 2px; }
.tile-big small { font-size: 13px; font-weight: 600; }
.caps { gap: 5px; margin-top: 12px; }
.caps i { height: 16px; border-radius: 6px; border-width: 1px; }
.tile.feature .caps i.on { background: var(--ink); }   /* single ink tone, no gradient */

/* Rail: slightly slimmer, quieter active state. */
.rail-link { font-size: 17px; }
.rail-link svg { display: block; }
.rail-link.active { background: var(--ink-2); color: #fff; box-shadow: inset 2px 0 0 var(--accent); }
.rail-logo { box-shadow: none; font-size: 20px; }

/* Quieter shell + cards. */
.shell { box-shadow: 0 1px 2px rgba(15,23,42,.03), 0 10px 30px rgba(15,23,42,.05); padding: 26px 28px; }

/* ---- Minimal element overrides (themed pages) ----
   Flatten the bolder first-pass elements: lighter cards, no gradient match-card
   headers, calmer badges/buttons, smaller score numbers. */
.card { border-radius: 16px; box-shadow: 0 1px 2px rgba(15,23,42,.03), 0 6px 18px rgba(15,23,42,.045); padding: 18px; }
.card h3 { font-size: 14px; font-weight: 700; }

/* Match cards: flat header, no gradient/stripe/glow. */
.match-card { border-radius: 16px; box-shadow: 0 1px 2px rgba(15,23,42,.03), 0 6px 16px rgba(15,23,42,.05); }
.match-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(15,23,42,.09); border-color: var(--border); }
.match-card .head { background: var(--card-2); border-bottom: 1px solid var(--border); padding: 14px 16px; }
.match-card .head::before { display: none; }   /* remove the gradient accent stripe */
.match-card .teams { font-size: 14px; }
.match-card .body { padding: 14px 16px 16px; }
.match-card .final {
  font-size: 24px; font-weight: 800; letter-spacing: 0;
  -webkit-text-fill-color: initial; background: none; color: var(--text);   /* solid, not gradient */
}
.match-card .score-line { min-height: 40px; }

/* Calmer "Your pick" panel + points badge (no gradient/glow). */
.my-pick { background: var(--card-2); border-color: var(--border); border-radius: 10px; }
.pts-badge { background: var(--accent); box-shadow: none; }

/* Flatter status badges. */
.badge { box-shadow: none; font-weight: 700; }

/* Buttons: flatter, tighter. */
.btn { border-radius: 10px; font-weight: 700; }
.btn:hover { filter: none; background: var(--ink); color: #fff; }
.btn.secondary:hover { background: var(--card-2); color: var(--text); border-color: var(--ink); }

/* Fan support + leaderboard: smaller, quieter. */
.fan-fill { background: var(--accent); }   /* single tone, drop the gradient */
.lb-list li { font-size: 13.5px; }

/* Section titles smaller. */
h2.section-title { font-size: 12px; }

/* Center narrow content (predict, create-match) within the shell. */
.shell > .narrow { margin: 0 auto; }

/* ---- Side-screen toast notifications ---- */
.toast-wrap {
  position: fixed; top: 18px; right: 18px; z-index: 9999;
  display: flex; flex-direction: column; gap: 10px; max-width: 340px;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: 12px; padding: 13px 15px; box-shadow: 0 10px 30px rgba(15,23,42,.16);
  font-size: 14px; font-weight: 600; color: var(--text);
  animation: toastIn .25s cubic-bezier(.2,.9,.3,1) both;
}
.toast.out { animation: toastOut .25s ease forwards; }
.toast.ok    { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--danger); }
.toast.info  { border-left-color: var(--accent); }
.toast-ic { font-size: 16px; line-height: 1.3; }
.toast-msg { flex: 1; }
@keyframes toastIn  { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(24px); } }
@media (prefers-reduced-motion: reduce) { .toast, .toast.out { animation: none; } }

/* ---- Entrance animation: stagger-fade cards/tiles in on load ---- */
@keyframes riseIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.tile, .match-card, .dash-row3 > .card, .layout > aside > .card {
  animation: riseIn .5s cubic-bezier(.2,.7,.3,1) both;
}
.tiles .tile:nth-child(2) { animation-delay: .06s; }
.tiles .tile:nth-child(3) { animation-delay: .12s; }
.match-grid .match-card:nth-child(2) { animation-delay: .05s; }
.match-grid .match-card:nth-child(3) { animation-delay: .1s; }
.match-grid .match-card:nth-child(4) { animation-delay: .15s; }
@media (prefers-reduced-motion: reduce) {
  .tile, .match-card, .dash-row3 > .card, .layout > aside > .card { animation: none; }
}

/* ---- Empty states ---- */
.empty {
  text-align: center; padding: 44px 24px; border: 1px dashed var(--border);
  border-radius: var(--r-md); background: var(--card-2); color: var(--text-dim);
}
.empty-emoji { font-size: 46px; line-height: 1; margin-bottom: 12px; }
.empty h3 { margin: 0 0 4px; font-size: 17px; color: var(--text); }
.empty p { margin: 0 0 16px; font-size: 14px; }

/* ---- "New since last visit" highlights ---- */
.new-banner {
  background: linear-gradient(120deg, var(--accent-soft), #fff);
  border: 1px solid #dcdcf6; border-radius: 14px; padding: 12px 16px;
  font-size: 14px; color: var(--text); margin-bottom: 16px;
}
.match-card.is-new { box-shadow: 0 0 0 2px var(--accent), 0 6px 16px rgba(79,70,229,.15); }
.match-card { position: relative; }
/* Inside the card (top-right) so the card's overflow:hidden doesn't clip it. */
.new-badge {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  font-size: 10px; font-weight: 800; letter-spacing: .5px; padding: 3px 8px; border-radius: 999px;
  box-shadow: 0 3px 10px rgba(79,70,229,.4);
}

/* ---- Spotlight onboarding tour ---- */
.tour-overlay { position: fixed; inset: 0; z-index: 9998; background: rgba(15,23,42,.55); }
.tour-spot {
  position: fixed; border-radius: 14px; transition: all .3s cubic-bezier(.3,.7,.3,1);
  box-shadow: 0 0 0 9999px rgba(15,23,42,.55), 0 0 0 3px var(--accent);
  pointer-events: none;
}
.tour-pop {
  position: fixed; width: 300px; max-width: calc(100vw - 32px);
  background: var(--card); border-radius: 16px; padding: 18px 20px;
  box-shadow: 0 18px 50px rgba(15,23,42,.3); transition: all .3s ease;
}
.tour-step { font-size: 11px; font-weight: 800; letter-spacing: .4px; color: var(--accent); text-transform: uppercase; }
.tour-title { margin: 6px 0 6px; font-size: 18px; }
.tour-body { margin: 0 0 16px; font-size: 14px; color: var(--text-dim); line-height: 1.5; }
.tour-actions { display: flex; justify-content: space-between; align-items: center; }
.tour-skip { background: none; border: none; color: var(--text-dim); font-weight: 600; cursor: pointer; font-size: 13px; }
.tour-skip:hover { color: var(--text); }
@media (prefers-reduced-motion: reduce) { .tour-spot, .tour-pop { transition: none; } }

/* ---- Reusable hover tooltip: add data-tip="..." to any element ---- */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%) translateY(4px);
  background: var(--ink); color: #fff; font-size: 11.5px; font-weight: 600; line-height: 1.3;
  padding: 5px 9px; border-radius: 7px; white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .14s ease, transform .14s ease; z-index: 200;
  box-shadow: 0 6px 16px rgba(15,23,42,.22);
}
[data-tip]::before {
  content: ''; position: absolute; left: 50%; bottom: calc(100% + 3px); transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: var(--ink);
  opacity: 0; transition: opacity .14s ease; pointer-events: none; z-index: 200;
}
[data-tip]:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }
[data-tip]:hover::before { opacity: 1; }
[data-tip].tip-below::after { top: calc(100% + 8px); bottom: auto; }
[data-tip].tip-below::before { top: calc(100% + 3px); bottom: auto; border-top-color: transparent; border-bottom-color: var(--ink); }

/* tip-right: tooltip to the RIGHT of the element (used on the rail, where
   above/below would clip at the top/bottom edges of the sidebar). */
[data-tip].tip-right::after {
  top: 50%; bottom: auto; left: calc(100% + 10px);
  transform: translateY(-50%) translateX(-4px);
}
[data-tip].tip-right::before {
  top: 50%; bottom: auto; left: calc(100% + 5px);
  transform: translateY(-50%);
  border-top-color: transparent; border-right-color: var(--ink);
}
[data-tip].tip-right:hover::after { transform: translateY(-50%) translateX(0); }
@media (prefers-reduced-motion: reduce) { [data-tip]::after, [data-tip]::before { transition: none; } }

/* =============================================================================
   DARK MODE (user pages, default). Toggled via <html data-theme="dark|light">.
   Overrides the CSS custom properties so every var-driven surface flips at once,
   then patches the few places that hardcode light colors. Deep indigo-black
   ground, elevated slate cards, brand indigo→pink accents kept vivid.
   ========================================================================== */
html[data-theme="dark"] {
  color-scheme: dark;
}
html[data-theme="dark"] body.app {
  /* Vars consumed across style.css + theme.css. */
  --bg: #0b0d17;
  --surface: #161a2b;
  --surface-2: #1e2338;
  --text: #e8eaf4;
  --text-dim: #9aa2c4;
  --accent: #7c73ff;          /* lifted indigo — pops on dark */
  --accent-soft: #21243d;
  --accent-2: #f45aa6;        /* lifted pink */
  --ok: #34d399;
  --ok-soft: #10241d;
  --warn: #fbbf24;
  --warn-soft: #2a2113;
  --danger: #f87171;
  --danger-soft: #2a1518;
  --border: #2a3050;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.45);

  /* theme.css frame vars. */
  --ink: #10131f;             /* rail / dark chips — deeper than cards */
  --ink-2: #262c45;
  --page: #05060d;            /* page ground behind the shell */
  --shell: #0f1220;           /* the big rounded shell */
  --card: #161a2b;
  --card-2: #1e2338;
}

/* Page background: replace the light radial-gradient wash with a dark one. */
html[data-theme="dark"] body.app {
  background:
    radial-gradient(1100px 460px at 85% -10%, #241033, transparent),
    radial-gradient(1100px 460px at 0% -10%, #101a3a, transparent),
    var(--page);
}

/* Shell + card shadows read as glow on dark; soften and darken. */
html[data-theme="dark"] .shell {
  box-shadow: 0 1px 2px rgba(0,0,0,.5), 0 16px 44px rgba(0,0,0,.55);
  border: 1px solid var(--border);
}
html[data-theme="dark"] .card,
html[data-theme="dark"] .match-card {
  box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 22px rgba(0,0,0,.4);
}
html[data-theme="dark"] .match-card:hover {
  box-shadow: 0 10px 26px rgba(0,0,0,.5);
}

/* Footer strip uses a hardcoded translucent white; flip to translucent dark. */
html[data-theme="dark"] footer.site-footer {
  background: rgba(255,255,255,.02);
}

/* Feature-tile gradient + "new" banner use white stops — dark equivalents. */
html[data-theme="dark"] .new-banner {
  background: linear-gradient(120deg, var(--accent-soft), var(--card));
  border-color: var(--border);
}
html[data-theme="dark"] .tile.feature {
  background: linear-gradient(140deg, var(--accent-soft), var(--card) 70%);
  border-color: var(--border);
}

/* Win popup + white-on-white text bits are set inline in JS with fixed colors;
   keep those readable by letting the modal keep its own light card (it's a
   celebration overlay). No override needed. */

/* Football cursor SVG is a white ball with black lines — still fine on dark. */

/* VS pill between teams: the base style uses a near-white background that reads
   faint on dark. Give it a dark chip with light text. */
html[data-theme="dark"] .match-card .teams .vs {
  background: var(--surface-2); color: var(--text); border-color: var(--border);
}

/* Win-celebration popup: it's a light card by default; make it dark + readable
   in dark mode (overrides the inline styles in index.js via higher specificity). */
html[data-theme="dark"] #win-popup .wp-card { background: var(--card) !important; box-shadow: 0 24px 70px rgba(0,0,0,.6) !important; border: 1px solid var(--border); }
html[data-theme="dark"] #win-popup .wp-title { color: var(--text) !important; }
html[data-theme="dark"] #win-popup .wp-sub { color: var(--text-dim) !important; }
html[data-theme="dark"] #win-popup .wp-total { color: #34d399 !important; }
html[data-theme="dark"] #win-popup li { border-top-color: var(--border) !important; color: var(--text); }
html[data-theme="dark"] #win-popup li span[style*="color:#888"] { color: var(--text-dim) !important; }

/* Ink-colored elements (CTA, active tab, button hover) go near-black in dark and
   vanish on the dark shell — give them the vivid brand gradient instead. */
html[data-theme="dark"] .pill-cta {
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent));
  background-size: 200% 100%;
  color: #fff;
  box-shadow: 0 6px 20px rgba(124,115,255,.35);
  animation: ctaGradient 4s linear infinite;
}
html[data-theme="dark"] .pill-cta:hover {
  box-shadow: 0 10px 28px rgba(124,115,255,.45);
  animation-duration: 2s;   /* speed up the shimmer on hover */
}
@keyframes ctaGradient {
  from { background-position: 0% 50%; }
  to   { background-position: -200% 50%; }
}
@media (prefers-reduced-motion: reduce) {
  html[data-theme="dark"] .pill-cta { animation: none; }
}
html[data-theme="dark"] .pill-tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent; color: #fff;
}
html[data-theme="dark"] .rail-link.active {
  background: var(--ink-2); box-shadow: inset 2px 0 0 var(--accent);
}
html[data-theme="dark"] .btn:hover {
  background: var(--accent); color: #fff;
}
html[data-theme="dark"] .btn.secondary:hover {
  background: var(--surface-2); color: var(--text); border-color: var(--accent);
}
/* The rail logo chip and dark title chip stay dark by design — bump their edge
   so they read against the shell. */
html[data-theme="dark"] .play-title .chip-ink { background: var(--ink-2); }

/* Rank medals on the leaderboard keep their warm tints; nudge for contrast. */
html[data-theme="dark"] .lb-list .rank { background: var(--surface-2); color: var(--text); }
html[data-theme="dark"] .lb-list li:nth-child(1) .rank { background: #3a2f0c; color: #fcd34d; }
html[data-theme="dark"] .lb-list li:nth-child(2) .rank { background: #2b2f3a; color: #cbd5e1; }
html[data-theme="dark"] .lb-list li:nth-child(3) .rank { background: #3a230f; color: #fdba74; }

/* Stage chip on match cards (e.g. "Group Stage" on My wins). */
.match-card .head { position: relative; }
.stage-chip {
  display: inline-block; margin-bottom: 8px;
  font-size: 10.5px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase;
  padding: 3px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--border);
}

/* Discovery hint dot on a rail link (e.g. "My wins" → posters live there). */
.rail-link { position: relative; }
.rail-dot {
  position: absolute; top: 8px; right: 8px;
  width: 9px; height: 9px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 2px var(--ink), 0 0 8px var(--accent-2);
  animation: railDotPulse 1.6s ease-in-out infinite;
}
@keyframes railDotPulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.35); opacity: .7; } }
@media (prefers-reduced-motion: reduce) { .rail-dot { animation: none; } }

/* ---- Theme toggle button in the rail ---- */
.rail-theme {
  position: relative;   /* anchor the notification dot */
  width: 46px; height: 46px; border-radius: 14px; margin-top: 6px;
  display: grid; place-items: center; cursor: pointer;
  background: var(--ink-2); color: #cfd3e6; border: none;
  transition: background .15s, color .15s, transform .12s;
}
.rail-theme:hover { background: var(--accent); color: #fff; transform: translateY(-1px); }
.rail-theme svg { width: 21px; height: 21px; display: block; }
/* Show the sun in dark mode (tap to go light) and the moon in light mode. */
.rail-theme .ic-sun { display: none; }
.rail-theme .ic-moon { display: block; }
html[data-theme="dark"] .rail-theme .ic-sun { display: block; }
html[data-theme="dark"] .rail-theme .ic-moon { display: none; }
@media (max-width: 720px) { .rail-theme { margin-top: 0; } }

/* ---- What's-new modal ---- */
.whatsnew-overlay {
  position: fixed; inset: 0; z-index: 9997;
  background: rgba(8,10,20,.62); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 20px;
  animation: wnFade .2s ease both;
}
.whatsnew-card {
  width: 460px; max-width: 100%; max-height: calc(100vh - 40px); overflow-y: auto;
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  border-radius: 22px; padding: 26px 26px 22px;
  box-shadow: 0 24px 70px rgba(0,0,0,.5);
  animation: wnPop .28s cubic-bezier(.2,.8,.3,1) both;
}
.whatsnew-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  font-size: 11px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase;
  padding: 5px 12px; border-radius: 999px;
}
.whatsnew-card h2 { font-size: 24px; font-weight: 800; margin: 14px 0 4px; letter-spacing: -.5px; }
.whatsnew-card .wn-sub { color: var(--text-dim); font-size: 14px; margin: 0 0 18px; }
.wn-list { list-style: none; margin: 0 0 20px; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.wn-item { display: flex; gap: 13px; align-items: flex-start; }
.wn-ic {
  flex: none; width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; font-size: 20px;
  background: var(--accent-soft); border: 1px solid var(--border);
}
.wn-item h4 { margin: 0 0 2px; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.wn-item p { margin: 0; font-size: 13px; color: var(--text-dim); line-height: 1.45; }

/* Featured (highlighted) update — accent-tinted card with a glowing icon + NEW tag. */
.wn-item.featured {
  padding: 12px 14px; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-soft), transparent 85%);
  border: 1px solid var(--accent);
  box-shadow: 0 6px 22px -6px var(--accent);
}
.wn-item.featured .wn-ic {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent; color: #fff;
}
.wn-item.featured h4 { font-size: 16px; }
.wn-tag {
  font-size: 10px; font-weight: 800; letter-spacing: .6px;
  padding: 2px 8px; border-radius: 999px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.whatsnew-card .wn-cta { width: 100%; }
@keyframes wnFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes wnPop { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .whatsnew-overlay, .whatsnew-card { animation: none; }
  .rail-theme { transition: none; }
}

/* =============================================================================
   MOBILE SIDE DRAWER — on small screens the right panel (Leaderboard, Fan
   support, Past matches) slides in from the edge instead of stacking. A
   floating tab opens it; a dimmed backdrop sits behind. On desktop the panel is
   a normal sidebar and all the drawer chrome is hidden.
   ========================================================================== */

/* Desktop defaults: hide drawer-only chrome. `!important` beats the `hidden`
   attribute on the backdrop so its own visibility is class-driven, not attr. */
.side-panel-head { display: none; }
.side-tab { display: none; }
.side-backdrop { display: none !important; }

@media (max-width: 860px) {
  /* The panel becomes a fixed off-canvas drawer on the right. The earlier
     860px rule in style.css sets it static/full-width — override that (the id
     selector out-specifies `.layout aside`). */
  .layout aside#side-panel {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: min(88vw, 380px);
    max-height: none;
    margin: 0;
    padding: 16px 16px 24px;
    background: var(--shell);
    border-left: 1px solid var(--border);
    box-shadow: -18px 0 50px rgba(0,0,0,.28);
    border-radius: 0;
    overflow-y: auto;
    z-index: 9990;
    transform: translateX(100%);
    transition: transform .26s cubic-bezier(.3,.8,.3,1);
    display: flex; flex-direction: column; gap: 16px;
  }
  .layout aside#side-panel.open { transform: translateX(0); }

  /* Drawer header with the close button. */
  .side-panel-head {
    display: flex; align-items: center; justify-content: space-between;
    font-weight: 800; font-size: 15px; color: var(--text);
    padding-bottom: 4px;
  }
  .side-panel-close {
    width: 34px; height: 34px; border-radius: 10px; border: none;
    background: var(--card-2); color: var(--text-dim); font-size: 16px;
    display: grid; place-items: center; cursor: pointer;
  }
  .side-panel-close:hover { background: var(--accent); color: #fff; }

  /* Floating tab that opens the drawer — pinned to the right edge, vertical. */
  .side-tab {
    display: flex; align-items: center; gap: 6px;
    position: fixed; right: 0; top: 42%;
    transform: translateY(-50%);
    z-index: 9985;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff; border: none; cursor: pointer;
    padding: 12px 10px; border-radius: 14px 0 0 14px;
    box-shadow: -6px 4px 18px rgba(0,0,0,.28);
    writing-mode: vertical-rl; text-orientation: mixed;
    font-weight: 800; font-size: 13px; letter-spacing: .3px;
  }
  .side-tab-i { writing-mode: horizontal-tb; font-size: 16px; }
  .side-tab:hover { padding-right: 14px; }

  /* Dim backdrop behind the open drawer. Hidden (not interactive) until .show;
     display is forced on so the `hidden` HTML attribute doesn't suppress it. */
  .side-backdrop {
    display: block !important; position: fixed; inset: 0; z-index: 9988;
    background: rgba(8,10,20,.5);
    opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity .22s ease, visibility .22s ease;
  }
  .side-backdrop.show { opacity: 1; visibility: visible; pointer-events: auto; }
  /* Lock body scroll while the drawer is open. */
  body.app.drawer-open { overflow: hidden; }
}

/* ---- Responsive: rail collapses to a top bar on narrow screens ---- */
@media (max-width: 720px) {
  body.app { padding: 10px; }
  .rail {
    position: static; width: auto; flex-direction: row; border-radius: var(--r-md);
    margin-bottom: 12px; padding: 10px 12px; gap: 6px;
  }
  .rail-logo { margin-bottom: 0; }
  .rail-links { flex-direction: row; flex: 1; justify-content: center; }
  .rail-link .tip { display: none; }
  .shell { padding: 20px 16px; min-height: 0; }
}

/* ---- Fit-to-width fixes for phones (content was overflowing to the right) ----
   Nothing may exceed the viewport width; cards shrink to fill, grids go single
   column, the shell never forces a min-width wider than the screen. */
@media (max-width: 640px) {
  html, body { max-width: 100%; overflow-x: hidden; }
  body.app { padding: 8px; }
  .shell { padding: 16px 12px; border-radius: 18px; }

  /* Stat tiles: single column so the 230px min doesn't overflow. */
  .tiles { grid-template-columns: 1fr; }

  /* Match cards fill the row and are allowed to shrink below their basis. */
  .match-grid { gap: 12px; }
  .match-grid > .match-card { flex: 1 1 100%; max-width: none; min-width: 0; }

  /* Hero: title + CTA stack, CTA goes full width. */
  .play-hero { gap: 12px; }
  .pill-cta { width: 100%; justify-content: center; }

  /* The drawer takes (almost) the whole width on a small phone. */
  .layout aside#side-panel { width: min(94vw, 400px); }
}

/* Guard against any single wide element (long team name, score row) pushing the
   page wider than the screen at every size. */
.match-card, .card, .tile, .shell, #matches, .layout, main { min-width: 0; }
