/* ===== Tokens: retheme here ===== */
:root {
  --bg: #0b1220;
  --surface: #121b2f;
  --surface-2: #1a2640;
  --surface-3: #243350;
  --line: #27344f;
  --text: #eaeff8;
  --text-2: #b0bad0;
  --muted: #8591aa;

  --green: #5ccf8a;
  --green-ink: #06230f;
  --gold: #f2b84b;
  --gold-ink: #2a1c02;
  --accent: #ff9a2e;
  --accent-ink: #1d1100;
  --danger: #ff7a7a;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --r-s: 8px; --r-m: 12px; --r-l: 18px; --r-pill: 999px;
  --fs-2xs: 10px; --fs-xs: 11px; --fs-s: 13px; --fs-m: 15px; --fs-l: 18px; --fs-xl: 24px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --col: 540px;
  --tap: 44px;
}

/* ===== Base ===== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 var(--fs-m)/1.4 var(--font);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
h1, h2, h3, p, ol, ul, dl, dd { margin: 0; padding: 0; }
ol, ul { list-style: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
img { display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.shell {
  max-width: var(--col); margin: 0 auto; min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + var(--s2)) calc(env(safe-area-inset-right) + var(--s4))
           calc(env(safe-area-inset-bottom) + var(--s5)) calc(env(safe-area-inset-left) + var(--s4));
  display: flex; flex-direction: column;
}
main { flex: 1; outline: none; }

/* ===== Top bar ===== */
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: var(--tap); margin-bottom: var(--s2); }
.brand { display: inline-flex; align-items: center; gap: var(--s2); min-height: var(--tap); }
.brand__mark {
  width: 22px; height: 22px; border-radius: 50%; background: var(--accent);
  box-shadow: inset 0 0 0 5px var(--accent), inset 0 0 0 8px var(--bg), inset 0 0 0 11px var(--accent);
}
.brand__name { font-size: var(--fs-l); font-weight: 700; letter-spacing: -0.01em; }
.linkbtn { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--s2); font-size: var(--fs-s); color: var(--text-2); }

/* ===== Tabs ===== */
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s1); padding: var(--s1); background: var(--surface); border-radius: var(--r-m); margin-bottom: var(--s4); }
.tab { position: relative; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap); border-radius: var(--r-s); font-size: var(--fs-s); font-weight: 600; color: var(--text-2); }
.tab--active { background: var(--accent); color: var(--accent-ink); }
.tab__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.tab__dot--won { background: var(--green); }
.tab__dot--lost { background: var(--danger); }
.tab__dot--live { background: var(--gold); }
.tab--active .tab__dot { box-shadow: 0 0 0 2px var(--accent-ink); }

/* ===== Home ===== */
.home__head { padding: var(--s3) 0 var(--s4); }
.home__title { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.home__date { margin-top: var(--s1); color: var(--muted); font-size: var(--fs-s); }
.cards { display: grid; gap: var(--s3); }
.card { display: block; padding: var(--s4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); }
.card:active { background: var(--surface-2); }
.card--won { border-color: color-mix(in srgb, var(--green) 55%, var(--line)); }
.card__row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); }
.card__row--foot { align-items: center; margin-top: var(--s4); min-height: var(--tap); }
.card__name { font-size: var(--fs-l); font-weight: 700; }
.card__lang { font-size: var(--fs-s); color: var(--muted); margin-top: 2px; }
.card__streak { text-align: right; }
.card__streak-n { display: block; font-size: var(--fs-xl); font-weight: 700; line-height: 1; color: var(--gold); }
.card__streak-l { font-size: var(--fs-xs); color: var(--muted); }
.status { font-size: var(--fs-s); font-weight: 600; color: var(--text-2); }
.status--won { color: var(--green); }
.status--lost { color: var(--danger); }
.status--live { color: var(--gold); }
.pips { display: flex; gap: 3px; margin-left: auto; margin-right: var(--s3); }
.pips i { width: 6px; height: 14px; border-radius: 2px; background: var(--surface-3); }
.pips i.on { background: var(--gold); }
.card--won .pips i.on { background: var(--green); }
.card--lost .pips i.on { background: var(--danger); }
.card__go { font-size: 26px; line-height: 1; color: var(--muted); }

/* ===== Search ===== */
.search { position: relative; z-index: 5; }
.search__input {
  width: 100%; min-height: 52px; padding: 0 var(--s4); font: inherit; font-size: 16px; color: var(--text);
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-m); outline: none;
  -webkit-appearance: none; appearance: none;
}
.search__input::placeholder { color: var(--muted); }
.search__input:focus { border-color: var(--accent); }
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); max-height: min(60vh, 420px); overflow-y: auto;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-m);
  box-shadow: 0 16px 40px rgb(0 0 0 / .5); overscroll-behavior: contain;
}
.opt { display: flex; align-items: center; gap: var(--s3); min-height: 56px; padding: var(--s2) var(--s3); cursor: pointer; }
.opt + .opt { border-top: 1px solid var(--line); }
.opt--active { background: var(--surface-3); }
.opt--empty { color: var(--muted); font-size: var(--fs-s); cursor: default; }
.opt__text { min-width: 0; }
.opt__title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opt__meta { font-size: var(--fs-s); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: var(--s2) 0 var(--s1); flex-wrap: wrap; }
.toolbar__count { font-size: var(--fs-s); color: var(--muted); }
.toolbar__count strong { color: var(--text); }
.toolbar__btns { display: flex; gap: var(--s2); }
.pill { min-height: var(--tap); padding: 0 var(--s3); border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--line); font-size: var(--fs-s); font-weight: 600; color: var(--text-2); cursor: pointer; }
.pill--on { border-color: var(--accent); color: var(--text); }
.pill--danger { color: var(--muted); }
.pill--armed { color: var(--danger); border-color: var(--danger); }

/* ===== Hints ===== */
.hints { display: grid; gap: var(--s2); margin: var(--s2) 0 var(--s1); }
.hint { padding: var(--s3); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r-m); }
.hint--locked { opacity: .65; }
.hint__label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--accent); font-weight: 700; margin-bottom: var(--s1); }
.hint__body { display: flex; gap: var(--s3); align-items: center; }
.hint__title { font-weight: 600; }
.hint__sub { font-size: var(--fs-s); color: var(--text-2); }
.hint__sub--strong { font-size: var(--fs-m); color: var(--text); }

/* ===== Posters ===== */
.poster { position: relative; flex: none; overflow: hidden; background: var(--surface-3); border-radius: var(--r-s); aspect-ratio: 2 / 3; }
.poster img { width: 100%; height: 100%; object-fit: cover; }
.poster--xs { width: 34px; border-radius: 5px; }
.poster--s { width: 64px; }
.poster--m { width: 104px; border-radius: var(--r-m); }
.poster-ph { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; font-size: var(--fs-2xs); color: var(--muted); background: linear-gradient(160deg, var(--surface-2), var(--surface-3)); padding: 4px; }
.poster--xs .poster-ph { font-size: 0; }

/* ===== Guess card ===== */
.guesses { display: grid; gap: var(--s3); margin-top: var(--s3); }
.guess { padding: var(--s3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); display: grid; gap: var(--s3); }
.guess--win { border-color: var(--green); }
.guess__top { display: flex; gap: var(--s3); align-items: flex-start; }
.guess__main { flex: 1; min-width: 0; display: grid; gap: var(--s2); }
.guess__title { font-size: var(--fs-m); font-weight: 700; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { display: inline-flex; align-items: center; gap: 3px; max-width: 100%; padding: 3px 8px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; line-height: 1.3; background: transparent; color: var(--text-2); border: 1px solid var(--line); }
.chip > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip--match { background: var(--green); border-color: var(--green); color: var(--green-ink); }
.chip--plain { color: var(--text-2); }
.chips--co .chip { font-weight: 500; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tile { position: relative; display: grid; gap: 1px; padding: 6px 8px; border-radius: var(--r-s); background: var(--surface-2); border: 1px solid var(--line); min-height: 48px; }
.tile__label { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.tile__value { font-size: var(--fs-s); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tile__arrow { margin-left: 3px; font-size: var(--fs-m); }
.tile__glyph { position: absolute; top: 4px; right: 6px; font-size: var(--fs-xs); font-weight: 800; }
.tile--match { background: var(--green); border-color: var(--green); color: var(--green-ink); }
.tile--match .tile__label { color: color-mix(in srgb, var(--green-ink) 70%, transparent); }
.tile--close { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.tile--close .tile__label { color: color-mix(in srgb, var(--gold-ink) 70%, transparent); }

/* ===== Avatars ===== */
.people { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s2); }
.av { display: grid; justify-items: center; align-content: start; gap: 3px; min-width: 0; text-align: center; }
.av__ring { position: relative; width: 52px; height: 52px; border-radius: 50%; padding: 2px; background: var(--line); }
.av__photo { width: 100%; height: 100%; border-radius: 50%; overflow: hidden; background: var(--surface-3); }
.av__photo img, .initials { width: 100%; height: 100%; object-fit: cover; }
.initials { display: grid; place-items: center; font-size: var(--fs-m); font-weight: 700; color: #fff; letter-spacing: .02em; }
.initials--empty { background: var(--surface-3); color: var(--muted); }
.av--none .av__photo { filter: grayscale(1); opacity: .5; }
.av--match .av__ring { background: var(--green); }
.av--close .av__ring { background: var(--gold); }
.av__badge { position: absolute; right: -3px; bottom: -3px; min-width: 18px; height: 18px; padding: 0 3px; border-radius: 9px; display: grid; place-items: center; font-size: 11px; font-weight: 800; border: 2px solid var(--surface); }
.av--match .av__badge { background: var(--green); color: var(--green-ink); }
.av--close .av__badge { background: var(--gold); color: var(--gold-ink); }
.av__name { width: 100%; font-size: var(--fs-xs); line-height: 1.2; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.av--none .av__name { color: var(--muted); }
.av__role { font-size: var(--fs-2xs); color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

/* ===== Result ===== */
.result { display: grid; gap: var(--s4); padding: var(--s4); margin-bottom: var(--s3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); }
.result--won { border-color: var(--green); }
.result--lost { border-color: var(--danger); }
.result__banner { display: flex; align-items: baseline; justify-content: space-between; }
.result__eyebrow { font-size: var(--fs-s); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--green); }
.result--lost .result__eyebrow { color: var(--danger); }
.result__score { font-size: var(--fs-xl); font-weight: 800; letter-spacing: -0.02em; }
.result__film { display: flex; gap: var(--s4); }
.result__info { min-width: 0; display: grid; gap: var(--s2); align-content: start; }
.result__label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.result__title { font-size: var(--fs-l); font-weight: 700; line-height: 1.2; }
.result__meta { font-size: var(--fs-s); color: var(--text-2); }
.result__facts { display: grid; gap: var(--s2); font-size: var(--fs-s); }
.result__facts > div { display: grid; grid-template-columns: 84px 1fr; gap: var(--s2); }
.result__facts dt { color: var(--muted); }
.result__facts dd { color: var(--text); }
.result__actions { display: grid; grid-template-columns: 1fr auto; gap: var(--s2); }
.result__actions--pad { margin-top: var(--s5); grid-template-columns: 1fr; }
.result__next { font-size: var(--fs-xs); color: var(--muted); text-align: center; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 var(--s5); border-radius: var(--r-m); border: 1px solid transparent; font-weight: 700; font-size: var(--fs-m); cursor: pointer; }
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--text); }

/* ===== Stats ===== */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s2); margin: var(--s4) 0 var(--s5); }
.stat { padding: var(--s3) var(--s1); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); text-align: center; }
.stat__n { font-size: var(--fs-xl); font-weight: 700; line-height: 1.1; }
.stat__l { font-size: var(--fs-2xs); color: var(--muted); margin-top: 2px; text-transform: uppercase; letter-spacing: .04em; }
.section-title { font-size: var(--fs-s); font-weight: 700; color: var(--text-2); margin-bottom: var(--s3); }
.dist { display: grid; gap: 6px; }
.dist__row { display: grid; grid-template-columns: 20px 1fr 28px; align-items: center; gap: var(--s2); font-size: var(--fs-s); }
.dist__k { color: var(--muted); text-align: right; }
.dist__bar { height: 22px; background: var(--surface); border-radius: 5px; overflow: hidden; }
.dist__fill { display: block; height: 100%; background: var(--surface-3); }
.dist__row--today .dist__fill { background: var(--green); }
.dist__n { color: var(--text-2); font-variant-numeric: tabular-nums; }

/* ===== Misc ===== */
.loading, .notice { padding: var(--s5) 0; text-align: center; color: var(--muted); display: grid; gap: var(--s3); justify-items: center; }
.footer { margin-top: var(--s6); padding-top: var(--s4); text-align: center; font-size: var(--fs-xs); color: var(--muted); }
.footer a { text-decoration: underline; }
.noscript { padding: var(--s5); text-align: center; }

@media (min-width: 640px) {
  .shell { padding-top: var(--s5); }
  .tab:hover, .card:hover, .opt:hover, .pill:hover { filter: brightness(1.12); }
}
@media (prefers-reduced-motion: no-preference) {
  .card, .tab, .pill, .btn { transition: background-color .15s, filter .15s; }
}
