/* ============================================================
   Quizzly — design system
   Everything visual is driven by the tokens in :root.
   Recolour the whole site by editing the first 40 lines.
   ============================================================ */

:root {
  /* --- brand gradients (used by covers, buttons, accents) --- */
  --g-candy: linear-gradient(135deg, #ff2d95 0%, #7b2ff7 100%);
  --g-sunset: linear-gradient(135deg, #ff6b6b 0%, #ffd93d 100%);
  --g-ocean: linear-gradient(135deg, #00c9ff 0%, #92fe9d 100%);
  --g-grape: linear-gradient(135deg, #8e2de2 0%, #4a00e0 100%);
  --g-fire: linear-gradient(135deg, #f83600 0%, #fe8c00 100%);
  --g-berry: linear-gradient(135deg, #fc466b 0%, #3f5efb 100%);
  --g-mint: linear-gradient(135deg, #00f260 0%, #0575e6 100%);
  --g-gold: linear-gradient(135deg, #fdbb2d 0%, #22c1c3 100%);

  --accent: #ff2d95;
  --accent-2: #7b2ff7;
  --accent-ink: #ffffff;

  /* --- surfaces & text (light theme is the base) --- */
  --paper: #fff5fb;
  --paper-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #fdf2f9;
  --ink: #16121f;
  --ink-2: #574f68;
  --ink-3: #8b8398;
  --line: #efe4f0;
  --shadow: 0 6px 0 rgba(22, 18, 31, .08), 0 12px 30px rgba(123, 47, 247, .10);
  --shadow-sm: 0 3px 0 rgba(22, 18, 31, .06), 0 6px 16px rgba(123, 47, 247, .08);

  /* --- geometry --- */
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 10px;
  --pad: 16px;
  --maxw: 1120px;
  --maxw-read: 680px;

  --font-display: "Fredoka", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

:root:not([data-theme="light"]) {
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #100d18;
    --paper-2: #171227;
    --surface: #1c1630;
    --surface-2: #241c3c;
    --ink: #f6f2ff;
    --ink-2: #c3b9da;
    --ink-3: #8e84ab;
    --line: #2e2547;
    --shadow: 0 6px 0 rgba(0, 0, 0, .35), 0 14px 34px rgba(0, 0, 0, .45);
    --shadow-sm: 0 3px 0 rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #100d18;
  --paper-2: #171227;
  --surface: #1c1630;
  --surface-2: #241c3c;
  --ink: #f6f2ff;
  --ink-2: #c3b9da;
  --ink-3: #8e84ab;
  --line: #2e2547;
  --shadow: 0 6px 0 rgba(0, 0, 0, .35), 0 14px 34px rgba(0, 0, 0, .45);
  --shadow-sm: 0 3px 0 rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

/* ============================ reset ============================ */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
ul, ol { list-style: none; padding: 0; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.12; letter-spacing: -.02em; font-weight: 700; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* ============================ layout ============================ */
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--pad); }
.wrap--read { max-width: var(--maxw-read); }
.stack > * + * { margin-top: var(--gap, 16px); }

/* ============================ header ============================ */
.hdr {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.hdr__in { display: flex; align-items: center; gap: 12px; height: 58px; }
.logo { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: -.03em; }
.logo__mark {
  width: 32px; height: 32px; display: grid; place-items: center;
  border-radius: 10px; background: var(--g-candy); font-size: 17px;
  box-shadow: 0 3px 0 rgba(123, 47, 247, .35);
}
.logo__text { background: var(--g-candy); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hdr__nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.hdr__link {
  padding: 7px 12px; border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--ink-2);
}
.hdr__link:hover, .hdr__link[aria-current="page"] { background: var(--surface-2); color: var(--ink); }
.iconbtn {
  width: 36px; height: 36px; border-radius: 999px; display: grid; place-items: center;
  font-size: 16px; background: var(--surface-2); border: 1px solid var(--line);
}
.iconbtn:hover { transform: translateY(-1px); }
@media (max-width: 560px) { .hdr__link { display: none; } }

/* ============================ hero ============================ */
/* one line of headline, one of subtitle: on a phone the Daily card and the
   start of Trending have to fit on the first screen under it */
.hero { padding: 14px 0 0; text-align: center; }
.hero h1 { font-size: clamp(20px, 6.2vw, 46px); }
.hero h1 em { font-style: normal; background: var(--g-candy); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--ink-2); max-width: 46ch; margin: 4px auto 0; font-size: clamp(14px, 3.6vw, 18px); }

/* ============================ chips ============================ */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 14px 0 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 8px 14px; border-radius: 999px; font-weight: 700; font-size: 14px;
  background: var(--surface); border: 2px solid var(--line); color: var(--ink-2); white-space: nowrap;
  transition: transform .12s ease;
}
.chip:hover { transform: translateY(-2px); }
.chip--on { background: var(--g-candy); border-color: transparent; color: #fff; box-shadow: 0 3px 0 rgba(123, 47, 247, .3); }

/* ============================ section head ============================ */
.shead { display: flex; align-items: baseline; gap: 10px; margin: 26px 0 12px; }
.shead h2 { font-size: clamp(21px, 4.6vw, 28px); }
.shead a { margin-left: auto; font-size: 14px; font-weight: 700; color: var(--accent); }

/* ============================ card grid ============================ */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
@media (max-width: 600px) { .grid { grid-template-columns: 1fr 1fr; gap: 12px; } }
@media (max-width: 380px) { .grid { grid-template-columns: 1fr; } }

.card {
  display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden;
  box-shadow: var(--shadow-sm); transition: transform .16s ease, box-shadow .16s ease;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.card:active { transform: translateY(-1px) scale(.995); }
.card__cover { position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); }
.card__cover img { width: 100%; height: 100%; object-fit: cover; }
.card__body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card__title { font-family: var(--font-display); font-weight: 600; font-size: 16px; line-height: 1.25; }
.card__meta { margin-top: auto; font-size: 12px; color: var(--ink-3); display: flex; gap: 8px; align-items: center; }
.card--big { grid-column: span 2; }
@media (max-width: 600px) { .card--big { grid-column: span 2; } .card--big .card__title { font-size: 19px; } }
.card__meta { flex-wrap: wrap; row-gap: 2px; }
.card__time { font-weight: 700; color: var(--ink-2); white-space: nowrap; }

/* ============================ home v2 ============================
   Daily card, numbered Trending grid, the swipeable Games row.        */
.daily { margin-top: 12px; }
.dailycard {
  position: relative; overflow: hidden; display: block; padding: 11px 14px 14px;
  border-radius: var(--r-lg); background: var(--g-candy); color: #fff;
  box-shadow: 0 6px 0 rgba(123, 47, 247, .28), 0 14px 30px rgba(123, 47, 247, .2);
  transition: transform .14s ease;
}
.dailycard::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(circle at 88% 18%, rgba(255, 255, 255, .2) 0 11%, transparent 12%),
    radial-gradient(circle at 8% 110%, rgba(255, 255, 255, .16) 0 18%, transparent 19%);
}
.dailycard:hover { transform: translateY(-3px); }
.dailycard__top { position: relative; display: flex; align-items: baseline; gap: 10px; }
.dailycard__top h2 { font-size: 17px; letter-spacing: -.01em; }
.dailycard__top small { margin-left: auto; font-size: 12px; font-weight: 700; opacity: .88; white-space: nowrap; }
.dailycard__row { position: relative; display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.dailycard__ico {
  flex: 0 0 auto; width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center;
  font-size: 30px; background: rgba(255, 255, 255, .2); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .3);
}
.dailycard__body { flex: 1; min-width: 0; }
.dailycard__body b { display: block; font-family: var(--font-display); font-weight: 600; font-size: 21px; line-height: 1.15; }
.dailycard__body small { display: block; margin-top: 2px; font-size: 13px; font-weight: 600; line-height: 1.3; opacity: .92; }
.dailycard__go {
  flex: 0 0 auto; padding: 9px 16px; border-radius: 999px; background: #fff; color: #7b2ff7;
  font-family: var(--font-display); font-weight: 700; font-size: 16px; box-shadow: 0 3px 0 rgba(0, 0, 0, .16);
}

@media (min-width: 601px) { .grid--top { grid-template-columns: repeat(3, 1fr); } }
.card__rank {
  position: absolute; left: 8px; top: 8px; z-index: 2; min-width: 38px; height: 38px; padding: 0 6px;
  display: grid; place-items: center; border-radius: 12px; background: var(--g-candy); color: #fff;
  border: 2px solid rgba(255, 255, 255, .9); box-shadow: 0 3px 0 rgba(0, 0, 0, .22);
  font-family: var(--font-display); font-weight: 700; font-size: 23px; line-height: 1;
}

/* full-bleed on phones: the row runs to the screen edge and scrolls */
.gamerow {
  display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
  margin-inline: calc(-1 * var(--pad)); padding: 2px var(--pad) 10px; scroll-padding-inline: var(--pad);
}
.gamerow::-webkit-scrollbar { display: none; }
.gtile {
  flex: 0 0 104px; scroll-snap-align: start; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 12px 8px 10px; border-radius: var(--r-md); text-align: center;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  transition: transform .12s ease;
}
.gtile:hover { transform: translateY(-3px); }
.gtile__ico {
  width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center;
  font-size: 28px; box-shadow: 0 3px 0 rgba(0, 0, 0, .14);
}
.gtile__t {
  margin-top: 5px; min-height: 2.4em; font-family: var(--font-display); font-weight: 600; font-size: 14px; line-height: 1.2; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.gtile__time { font-size: 12px; font-weight: 700; color: var(--ink-3); white-space: nowrap; }

/* ============================ buttons ============================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 26px; border-radius: 999px; font-family: var(--font-display); font-weight: 600;
  font-size: 17px; background: var(--g-candy); color: #fff; border: 0;
  box-shadow: 0 5px 0 rgba(123, 47, 247, .35); transition: transform .12s ease, box-shadow .12s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 7px 0 rgba(123, 47, 247, .35); }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(123, 47, 247, .35); }
.btn--ghost { background: var(--surface); color: var(--ink); border: 2px solid var(--line); box-shadow: var(--shadow-sm); }
.btn--wide { width: 100%; }
.btn--sm { padding: 10px 18px; font-size: 15px; }

/* ============================ article / quiz page ============================ */
/* block padding only: the shorthand used to zero .wrap's side padding, and
   every quiz, game and category page ran edge to edge on phones */
.page { padding-block: 18px 60px; }
.ptitle { font-size: clamp(26px, 6vw, 40px); margin-bottom: 10px; }
.pdek { color: var(--ink-2); font-size: 17px; }
.pmeta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0; font-size: 13px; color: var(--ink-3); }
.pcover { border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); margin: 16px 0 22px; }

/* Compact hero on quiz/game pages: keeps the brand colour without pushing
   the first question below the fold (the cover art still ships as the OG image). */
.phero {
  height: 104px; border-radius: var(--r-lg); display: grid; place-items: center;
  margin: 14px 0 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.phero::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 12% 30%, rgba(255, 255, 255, .22) 0 12%, transparent 13%),
    radial-gradient(circle at 82% 70%, rgba(255, 255, 255, .18) 0 16%, transparent 17%),
    radial-gradient(circle at 62% 15%, rgba(255, 255, 255, .14) 0 9%, transparent 10%);
}
.phero__emoji { font-size: 54px; line-height: 1; position: relative; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .28)); }

/* progress */
.prog { display: flex; align-items: center; gap: 12px; margin: 8px 0 16px; }
.prog__bar { flex: 1; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.prog__fill { height: 100%; width: 0%; background: var(--g-candy); border-radius: 999px; transition: width .45s cubic-bezier(.34, 1.4, .64, 1); }
.prog__txt { font-family: var(--font-display); font-weight: 600; font-size: 15px; color: var(--ink-2); white-space: nowrap; }
.prog__txt b { color: var(--accent); font-size: 20px; }

/* question card */
.qcard {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  overflow: hidden; box-shadow: var(--shadow); animation: pop .38s cubic-bezier(.2, 1.2, .5, 1) both;
}
.qcard__head { padding: 18px 20px; background: var(--g-candy); color: #fff; font-family: var(--font-display); font-weight: 600; font-size: clamp(18px, 4.4vw, 24px); line-height: 1.25; }
.qcard__art { aspect-ratio: 16 / 9; background: var(--surface-2); }
.qcard__art img { width: 100%; height: 100%; object-fit: cover; }
.opts { padding: 14px; display: grid; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 14px 16px; border-radius: var(--r-md); background: var(--surface-2);
  border: 2px solid transparent; font-size: 16px; font-weight: 600; color: var(--ink);
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}
.opt:hover { border-color: var(--accent); transform: translateX(3px); }
.opt__dot { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 999px; border: 2.5px solid var(--accent); display: grid; place-items: center; }
.opt__dot::after { content: ""; width: 10px; height: 10px; border-radius: 999px; background: var(--accent); transform: scale(0); transition: transform .18s ease; }
.opt--picked { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface-2)); }
.opt--picked .opt__dot::after { transform: scale(1); }
.opt--right { border-color: #16c47f; background: color-mix(in srgb, #16c47f 14%, var(--surface-2)); }
.opt--right .opt__dot { border-color: #16c47f; }
.opt--right .opt__dot::after { background: #16c47f; transform: scale(1); }
.opt--wrong { border-color: #ff4d6d; background: color-mix(in srgb, #ff4d6d 12%, var(--surface-2)); }
.opt--wrong .opt__dot { border-color: #ff4d6d; }
.opt--wrong .opt__dot::after { background: #ff4d6d; transform: scale(1); }
.opt__emoji { font-size: 22px; line-height: 1; }
.explain {
  margin: 0 14px 14px; padding: 12px 14px; border-radius: var(--r-md);
  background: var(--surface-2); border-left: 4px solid var(--accent);
  font-size: 14.5px; color: var(--ink-2); animation: fade .3s ease both;
}

/* result */
.result { text-align: center; animation: pop .5s cubic-bezier(.2, 1.2, .5, 1) both; }
.result__badge {
  width: 128px; height: 128px; margin: 0 auto 14px; border-radius: 40px;
  display: grid; place-items: center; font-size: 62px; background: var(--g-candy);
  box-shadow: 0 10px 0 rgba(123, 47, 247, .3), 0 20px 40px rgba(123, 47, 247, .3);
  animation: bounce .7s cubic-bezier(.2, 1.3, .5, 1) both;
}
.result__kicker { text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 800; color: var(--ink-3); }
.result__title { font-size: clamp(26px, 6.5vw, 42px); margin: 6px 0 10px; }
.result__title span { background: var(--g-candy); -webkit-background-clip: text; background-clip: text; color: transparent; }
.result__text { color: var(--ink-2); font-size: 17px; max-width: 46ch; margin-inline: auto; }
.result__score { font-family: var(--font-display); font-size: 46px; font-weight: 700; }
.result__actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 22px; }

/* share */
.share { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.share__btn {
  width: 46px; height: 46px; border-radius: 999px; display: grid; place-items: center; font-size: 19px;
  background: var(--surface); border: 2px solid var(--line); box-shadow: var(--shadow-sm);
  transition: transform .12s ease;
}
.share__btn:hover { transform: translateY(-3px); }
.share__btn svg { width: 22px; height: 22px; display: block; }
.btn > svg { width: 18px; height: 18px; vertical-align: -4px; margin-right: 6px; }
.share__btn { color: var(--ink); }
.share__btn--wa { color: #25d366; }
.share__btn--tg { color: #2aabee; }
.share__btn--fb { color: #1877f2; }

/* ============================ games ============================ */
.game {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow); overflow: hidden; user-select: none; -webkit-user-select: none;
}
.game__hud {
  display: flex; gap: 8px; padding: 12px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line);
  font-family: var(--font-display); font-weight: 600;
}
.hudcell { flex: 1; text-align: center; }
.hudcell span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-family: var(--font-body); font-weight: 700; }
.hudcell b { font-size: 22px; }
.game__stage { position: relative; min-height: 360px; display: grid; place-items: center; padding: 18px; }
/* Phones: the HUD is one strip ~46px tall (small label over the value)
   instead of ~76px, and the stage takes the 30px it gave up. Desktop keeps
   the roomier HUD above. The Daily cell and the hearts/💀 of Lives are plain
   text in <b>, so they need nothing special here. */
@media (max-width: 719px) {
  .game__hud { gap: 0; padding: 6px 4px; }
  .hudcell { min-width: 0; padding: 0 4px; line-height: 1.15; }
  .hudcell + .hudcell { border-left: 1px solid var(--line); }
  .hudcell span { font-size: 10px; letter-spacing: .07em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .hudcell b { font-size: 18px; white-space: nowrap; }
  .game__stage { min-height: 390px; }
}
/* keeps the HUD clear of the sticky header when a game scrolls itself into view */
.game { scroll-margin-top: 66px; }
.game__msg { text-align: center; max-width: 34ch; }
.game__msg h3 { font-size: 24px; margin-bottom: 8px; }
.game__msg p { color: var(--ink-2); margin-bottom: 16px; }

.board { display: grid; gap: 8px; width: 100%; max-width: 420px; }
.cell {
  aspect-ratio: 1; border-radius: 14px; background: var(--surface-2); border: 2px solid var(--line);
  display: grid; place-items: center; font-size: 26px; transition: transform .1s ease, background .18s ease;
}
.cell:hover { transform: scale(1.04); }
.cell--on { background: var(--g-candy); border-color: transparent; box-shadow: 0 4px 0 rgba(123, 47, 247, .3); }
.cell--good { background: color-mix(in srgb, #16c47f 30%, var(--surface-2)); border-color: #16c47f; }
.cell--bad { background: color-mix(in srgb, #ff4d6d 30%, var(--surface-2)); border-color: #ff4d6d; }
.cell--pop { animation: pop .3s ease both; }

.reactzone {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  font-family: var(--font-display); font-size: 26px; font-weight: 600; color: #fff; cursor: pointer;
}
.reactzone--wait { background: linear-gradient(135deg, #ff4d6d, #ff8c42); }
.reactzone--go { background: linear-gradient(135deg, #00f260, #0575e6); }
.reactzone--idle { background: var(--g-grape); }

.target {
  position: absolute; border-radius: 999px; background: var(--g-candy);
  box-shadow: 0 4px 0 rgba(123, 47, 247, .4); display: grid; place-items: center;
  font-size: 20px; animation: pop .18s ease both;
}

.stroopword { font-family: var(--font-display); font-weight: 700; font-size: clamp(44px, 13vw, 86px); text-align: center; }
.stroopbtns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; max-width: 420px; margin-top: 22px; }

.schulte { display: grid; gap: 6px; width: 100%; max-width: 400px; }
.schulte .cell { font-family: var(--font-display); font-weight: 600; font-size: clamp(16px, 5vw, 24px); border-radius: 10px; }

.emojigrid { display: grid; gap: 4px; width: 100%; max-width: 420px; }
.emojigrid .cell { border: 0; background: transparent; font-size: clamp(18px, 6vw, 30px); border-radius: 8px; }
.emojigrid .cell:hover { background: var(--surface-2); }

/* ---------------------- game: colour vision ---------------------- */
.colorgrid { display: grid; gap: 6px; width: 100%; max-width: 400px; }
.colorgrid button { aspect-ratio: 1; border: 0; border-radius: 10px; transition: transform .1s ease; }
.colorgrid button:active { transform: scale(.93); }

/* ---------------------- game: typing ---------------------- */
/* Input on top, text below in a box exactly three lines tall that scrolls
   itself (games.js keeps the current word on the middle line). HUD + input +
   text come to ~225px, so all of it fits above a phone keyboard. The scroller
   is the inner .typing__words with no vertical padding and a px line-height:
   padding inside a scroller would show slivers of the lines above and below. */
.game__stage:has(> .typing) { min-height: 0; align-items: start; padding-top: 12px; }
.typing { width: 100%; max-width: 560px; display: flex; flex-direction: column; gap: 10px; }
.typing__text {
  padding: 9px 14px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--line); letter-spacing: .01em;
}
.typing__words { position: relative; overflow: hidden; scroll-behavior: smooth; font-size: 18px; line-height: 29px; height: 87px; }
@media (min-width: 600px) { .typing__words { font-size: 21px; line-height: 34px; height: 102px; } }
.typing__text i { font-style: normal; }
.typing__text .w-done { color: var(--ink-3); }
.typing__text .w-bad { color: #ff4d6d; text-decoration: line-through; }
.typing__text .w-now { background: var(--accent); color: #fff; border-radius: 6px; padding: 1px 5px; }
.typing input {
  width: 100%; padding: 12px 18px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--surface); font-size: 17px; font-weight: 600;
}
.typing input:focus { border-color: var(--accent); outline: none; }

/* ---------------------- game: memory pairs ---------------------- */
.pairs { display: grid; gap: 8px; width: 100%; max-width: 400px; grid-template-columns: repeat(4, 1fr); }
.pairs button {
  aspect-ratio: 1; border-radius: 14px; border: 2px solid var(--line); background: var(--g-grape);
  font-size: clamp(22px, 7vw, 32px); display: grid; place-items: center; color: transparent;
  transition: transform .18s ease, background .18s ease;
}
.pairs button.flip { background: var(--surface-2); color: inherit; transform: rotateY(0); }
.pairs button.done { background: color-mix(in srgb, #16c47f 26%, var(--surface-2)); border-color: #16c47f; color: inherit; }

/* ---------------------- game: snake ---------------------- */
.snakewrap { width: 100%; max-width: 400px; text-align: center; }
.snakewrap canvas {
  width: 100%; aspect-ratio: 1; border-radius: var(--r-md);
  background: var(--surface-2); border: 2px solid var(--line); touch-action: none;
}
.dpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-width: 210px; margin: 12px auto 0; }
.dpad button { padding: 12px 0; border-radius: 12px; background: var(--surface-2); border: 2px solid var(--line); font-size: 18px; }
.dpad button:active { background: var(--accent); color: #fff; }

/* ---------------------- game: precision bar ---------------------- */
.track {
  position: relative; width: 100%; max-width: 460px; height: 62px; border-radius: 999px;
  background: var(--surface-2); border: 2px solid var(--line); overflow: hidden;
}
.track__zone { position: absolute; top: 0; bottom: 0; background: linear-gradient(180deg, #16c47f, #0a9b62); opacity: .85; }
.track__needle { position: absolute; top: -4px; bottom: -4px; width: 6px; border-radius: 4px; background: var(--ink); box-shadow: 0 0 12px rgba(0, 0, 0, .35); }

/* ---------------------- game: spot the difference ---------------------- */
.diffpair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; max-width: 460px; }
.diffpanel { display: grid; gap: 3px; padding: 8px; border-radius: var(--r-md); background: var(--surface-2); border: 2px solid var(--line); }
.diffpanel button, .diffpanel span { aspect-ratio: 1; display: grid; place-items: center; font-size: clamp(13px, 4vw, 22px); border: 0; background: none; border-radius: 6px; }
.diffpanel button:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.diffpanel--static { opacity: .97; }

/* ---------------------- game: estimate ---------------------- */
.estpair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; max-width: 460px; }
.estbox {
  position: relative; aspect-ratio: 1; border-radius: var(--r-md); background: var(--surface-2);
  border: 2px solid var(--line); overflow: hidden; transition: border-color .12s ease;
}
.estbox:hover { border-color: var(--accent); }
.estbox i { position: absolute; width: 9px; height: 9px; border-radius: 999px; background: var(--accent); }

/* result v2 ===================================================
   Game result: percentile line, tier plaque, distribution strip
   and the "Next game" row. Tier colours live in --tc on .t0–.t4
   (D, C, B, A, S) and are shared by the plaque and the bars.     */
.game .result { width: 100%; }
.t0 { --tc: var(--ink-3); }
.t1 { --tc: #2f7bff; }
.t2 { --tc: #0fa86b; }
.t3 { --tc: #f08a00; }
.t4 { --tc: var(--accent); }

.result__pct { margin-top: 4px; font-size: 16px; font-weight: 700; color: var(--ink-2); }
.result__pct b {
  font-family: var(--font-display); font-size: 24px; font-weight: 700;
  background: var(--g-candy); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.result__cap { margin-top: 14px; font-size: 15px; }

.tier {
  display: flex; align-items: center; gap: 12px; text-align: left;
  max-width: 420px; margin: 14px auto 0; padding: 12px 14px;
  border-radius: var(--r-md); border: 2px solid var(--tc);
  background: color-mix(in srgb, var(--tc) 12%, var(--surface));
  animation: pop .5s .12s cubic-bezier(.2, 1.2, .5, 1) both;
}
.tier__grade {
  flex: 0 0 auto; width: 48px; height: 48px; border-radius: 14px;
  display: grid; place-content: center; text-align: center; line-height: 1;
  background: var(--tc); color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 25px;
  box-shadow: 0 3px 0 color-mix(in srgb, var(--tc) 55%, #000);
}
.tier__grade small { display: block; font-family: var(--font-body); font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; opacity: .9; margin-bottom: 2px; }
.t4 .tier__grade { background: var(--g-candy); box-shadow: 0 3px 0 rgba(123, 47, 247, .45); }
.tier__emoji { flex: 0 0 auto; font-size: 34px; line-height: 1; }
.tier__body { min-width: 0; }
.tier__body b { display: block; font-family: var(--font-display); font-weight: 600; font-size: 19px; line-height: 1.2; color: var(--ink); }
.tier__body small { display: block; margin-top: 2px; font-size: 14px; line-height: 1.35; color: var(--ink-2); }

.dist { max-width: 420px; margin: 14px auto 0; }
.dist__plot {
  position: relative; height: 70px; padding-top: 22px;
  display: flex; align-items: flex-end; gap: 2px;
  border-bottom: 2px solid var(--line);
}
.dist__plot i { flex: 1; min-width: 0; border-radius: 3px 3px 0 0; background: var(--tc); opacity: .32; }
.dist__plot i.on { opacity: 1; }
/* on the dark surfaces a third of the tier colour turns to mud */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .dist__plot i:not(.on) { opacity: .55; } }
:root[data-theme="dark"] .dist__plot i:not(.on) { opacity: .55; }
.dist__you {
  position: absolute; top: 18px; bottom: -4px; width: 3px; margin-left: -1.5px;
  border-radius: 2px; background: var(--ink);
}
.dist__tag {
  position: absolute; top: 0; transform: translateX(-50%);
  padding: 0 8px; border-radius: 999px; background: var(--ink); color: var(--paper);
  font-size: 11px; font-weight: 800; line-height: 18px; letter-spacing: .04em; text-transform: uppercase;
}
.dist__axis { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: 11.5px; font-weight: 700; color: var(--ink-3); }

.nextup { max-width: 460px; margin: 24px auto 0; padding-top: 18px; border-top: 2px dashed var(--line); }
.nextup__btn { width: 100%; flex-direction: column; gap: 0; padding-block: 11px; line-height: 1.25; }
.nextup__btn b { font-weight: 600; font-size: 18px; }
.nextup__btn small { font-family: var(--font-body); font-size: 13px; font-weight: 600; opacity: .9; }
.nextup__row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.nextup__chip {
  display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0;
  padding: 10px 6px; border-radius: var(--r-md); text-align: center;
  background: var(--surface-2); border: 2px solid var(--line);
  transition: transform .12s ease, border-color .12s ease;
}
.nextup__chip:hover { transform: translateY(-2px); border-color: var(--accent); }
.nextup__chip span { font-size: 26px; line-height: 1.15; }
.nextup__chip b { font-family: var(--font-display); font-weight: 600; font-size: 14px; line-height: 1.2; color: var(--ink); }
.nextup__chip small { font-size: 11.5px; font-weight: 700; color: var(--ink-3); }
@media (max-width: 480px) { .nextup__row { grid-template-columns: 1fr 1fr; } }

/* daily challenge on the game page ===============================
   Daily / Free play toggle above the game, the HUD cell, the note on
   the start screen and the streak + "Share daily" block on the result. */
.modebar {
  display: flex; gap: 6px; padding: 5px; margin: 0 0 12px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.modebar__btn {
  flex: 1; padding: 9px 12px; border-radius: 999px; font-family: var(--font-display);
  font-weight: 600; font-size: 15px; color: var(--ink-2); transition: background .14s ease;
}
.modebar__btn.on { background: var(--g-candy); color: #fff; box-shadow: 0 3px 0 rgba(123, 47, 247, .3); }
.modebar__link { flex: 1; padding: 8px 12px; text-align: center; font-weight: 700; font-size: 14px; color: var(--accent); }
.hudcell--daily b { background: var(--g-candy); -webkit-background-clip: text; background-clip: text; color: transparent; }
.game__msg .game__daily {
  display: inline-block; margin-bottom: 14px; padding: 6px 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--ink-2);
  font-size: 13.5px; font-weight: 700; line-height: 1.45;
}
.dailyres {
  max-width: 420px; margin: 16px auto 0; padding: 14px; border-radius: var(--r-md);
  background: var(--surface-2); border: 2px solid var(--line);
}
.dailyres__streak { font-family: var(--font-display); font-size: 20px; font-weight: 600; color: var(--ink); }
.dailyres__streak small { font-family: var(--font-body); font-size: 13px; font-weight: 700; color: var(--ink-3); }
.dailyres__grid { margin-top: 4px; font-size: 24px; line-height: 1.25; letter-spacing: 3px; }
.dailyres__note { margin-top: 6px; font-size: 13.5px; color: var(--ink-2); }
.dailyres__share { width: 100%; margin-top: 12px; }

/* ============================ ads & offers ============================ */
.ad { margin: 22px auto; text-align: center; min-height: 100px; }
.ad__label { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-3); margin-bottom: 4px; }
.ad__ph {
  display: grid; place-items: center; min-height: 100px; border-radius: var(--r-md);
  border: 2px dashed var(--line); color: var(--ink-3); font-size: 13px; background: var(--surface-2);
}

.offer {
  display: flex; align-items: center; gap: 14px; text-align: left; margin: 22px auto 0; padding: 16px;
  border-radius: var(--r-lg); background: var(--surface); border: 2px solid var(--accent);
  box-shadow: var(--shadow); max-width: 520px; transition: transform .14s ease;
}
.offer:hover { transform: translateY(-3px); }
.offer__ico { flex: 0 0 auto; width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; font-size: 28px; background: var(--g-sunset); }
.offer__t { font-family: var(--font-display); font-weight: 600; font-size: 17px; }
.offer__d { font-size: 14px; color: var(--ink-2); }
.offer__cta { margin-left: auto; flex: 0 0 auto; padding: 10px 16px; border-radius: 999px; background: var(--g-candy); color: #fff; font-weight: 700; font-size: 14px; }
@media (max-width: 520px) { .offer { flex-wrap: wrap; } .offer__cta { margin-left: 0; width: 100%; text-align: center; } }

/* ============================ footer ============================ */
.ftr { border-top: 1px solid var(--line); background: var(--paper-2); padding: 30px 0; margin-top: 40px; }
.ftr__in { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.ftr__links { display: flex; flex-wrap: wrap; gap: 14px; margin-left: auto; font-size: 14px; color: var(--ink-2); }
.ftr__links a:hover { color: var(--accent); }
.ftr small { display: block; width: 100%; color: var(--ink-3); font-size: 12.5px; margin-top: 8px; }

/* ============================ prose ============================ */
.prose { color: var(--ink-2); font-size: 16.5px; }
.prose > * + * { margin-top: 14px; }
.prose h2 { color: var(--ink); font-size: 24px; margin-top: 28px; }
.prose h3 { color: var(--ink); font-size: 19px; margin-top: 20px; }
.prose ul { list-style: disc; padding-left: 22px; }
.prose li + li { margin-top: 6px; }
.prose a { color: var(--accent); text-decoration: underline; }
.prose code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; font-size: .92em; }

/* ============================ animations ============================ */
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes bounce {
  0% { transform: scale(.3) rotate(-12deg); opacity: 0; }
  60% { transform: scale(1.12) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}
@keyframes shake { 10%, 90% { transform: translateX(-2px); } 30%, 70% { transform: translateX(4px); } 50% { transform: translateX(-4px); } }
.shake { animation: shake .4s ease; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* confetti canvas sits above everything, ignores clicks */
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; }
.hidden { display: none !important; }
