/* Look: quiet and businesslike. Slate ink on cool grey paper, one steel-blue accent, one typeface.
   Colour is spent only where it tells something: the accent marks the choice in force, brick marks a loss or
   an irreversible action, and the whole screen goes dark when time is up. */

@font-face { font-family: 'Golos Text'; font-weight: 400; font-display: swap;
  src: url(fonts/GolosText-400-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Golos Text'; font-weight: 400; font-display: swap;
  src: url(fonts/GolosText-400-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2212; }
@font-face { font-family: 'Golos Text'; font-weight: 600; font-display: swap;
  src: url(fonts/GolosText-600-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Golos Text'; font-weight: 600; font-display: swap;
  src: url(fonts/GolosText-600-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2212; }

:root {
  --ink: #1c2733;      /* slate: text, primary buttons, the time-is-up screen */
  --paper: #f4f5f7;    /* page */
  --surface: #ffffff;  /* cards, fields */
  --line: #dde1e6;
  --mute: #66727f;
  --accent: #2b5378;   /* steel blue: links, focus, the first team */
  --tint: #e8edf2;     /* the card's back */
  --loss: #9c4238;     /* brick: skip, end game */
  --text: 'Golos Text', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 17px/1.45 var(--text);
  overscroll-behavior: none; touch-action: manipulation;
  transition: background-color .4s;
}
body.extra-time { background: var(--ink); }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, p, ol, ul, fieldset { margin: 0; padding: 0; border: 0; }
ol, ul { list-style: none; }

#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) 20px env(safe-area-inset-bottom); }
#app > section { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* ---- shared pieces ---- */

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 58px;
  padding: 12px 18px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line);
  font: 600 17px/1.2 var(--text); text-align: center; }
.btn:active { opacity: .82; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--mute); }
.btn.danger { background: var(--loss); color: var(--surface); border-color: var(--loss); }
.btn small { font: 400 15px var(--text); opacity: .7; }
.link { font-weight: 600; color: var(--accent); padding: 12px 0; min-height: 44px; }
.link.danger { color: var(--loss); }
.hint { color: var(--mute); font-size: 15px; }
.hint.pad { padding: 4px 0 12px; }

/* team markers: four quiet tones, told apart by lightness as much as hue */
.pennant { display: inline-block; flex: none; width: 10px; height: 22px; border-radius: 2px; background: var(--accent); }
.pennant.p0 { background: var(--accent); }
.pennant.p1 { background: #a98a4b; }
.pennant.p2 { background: #4f7f7a; }
.pennant.p3 { background: #8a93a0; }

.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0 4px; min-height: 60px; }
.bar h2 { font: 600 19px/1.2 var(--text); flex: 1; }
.bar .link:first-child + h2 { text-align: center; }
.dock { position: sticky; bottom: 0; display: grid; gap: 10px; padding: 14px 0 20px; margin-top: auto;
  background: linear-gradient(to top, var(--paper) 78%, transparent); }
.dock.two { grid-template-columns: 1fr 1.25fr; align-items: end; }
.extra-time .dock { background: none; }

/* ---- home ---- */

.home { justify-content: center; gap: 18px; padding: 28px 0; }
.home h1 { font: 600 clamp(38px, 11.5vw, 50px)/1.05 var(--text); letter-spacing: -.025em; }
.home h1::before { content: ''; display: block; width: 44px; height: 4px; background: var(--accent); margin-bottom: 22px; }
.lead { font-size: 18px; color: var(--mute); max-width: 28ch; }
.stack { display: grid; gap: 10px; margin-top: 18px; }
.resume-note { color: var(--mute); font-size: 15px; margin: -2px 0 8px; text-align: center; }

/* ---- rules ---- */

.prose { padding: 8px 0 32px; }
.prose h3 { font: 600 17px/1.3 var(--text); margin: 22px 0 4px; }
.prose p { color: #3b4753; }

/* ---- setup ---- */

.form { display: grid; gap: 24px; padding: 10px 0 12px; }
legend { font: 600 15px/1.3 var(--text); color: var(--mute); margin-bottom: 8px; }
fieldset .hint { margin-top: 8px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { flex: 1 1 auto; min-height: 46px; padding: 8px 14px; border-radius: 8px; background: var(--surface);
  border: 1px solid var(--line); font-weight: 400; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); font-weight: 600; }
.teams { display: grid; gap: 6px; margin-top: 10px; }
.team { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 0 14px; }
.team:focus-within { border-color: var(--accent); }
.team input { flex: 1; min-width: 0; border: 0; background: none; font: 600 17px var(--text); color: var(--ink);
  min-height: 48px; outline: none; }
.count { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 4px; color: var(--mute); }
.count button { width: 52px; height: 46px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
  font: 400 24px/1 var(--text); color: var(--ink); }
.count button:disabled { opacity: .3; }

/* ---- handoff, finish ---- */

.center { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 6px; padding: 16px 0; }
.whose { font-size: 18px; color: var(--mute); }
.big { font: 600 clamp(30px, 9vw, 40px)/1.1 var(--text); letter-spacing: -.02em; overflow-wrap: anywhere;
  display: flex; align-items: center; gap: 14px; }
.big .pennant { width: 12px; height: 34px; }
.meta { color: var(--mute); margin-top: 6px; }
.prev { margin-bottom: 26px; padding: 12px 14px; background: var(--surface); border-radius: 8px; border: 1px solid var(--line); }
.handoff .dock .hint { text-align: center; }

.scores { display: grid; margin-top: 26px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.scores li { display: flex; align-items: center; gap: 12px; padding: 13px 14px; }
.scores li + li { border-top: 1px solid var(--line); }
.scores li.now .name { font-weight: 600; }
.scores li.out { opacity: .45; }
.scores .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scores b { font: 600 19px var(--text); font-variant-numeric: tabular-nums; }
.scores.totals { margin: 18px 0 8px; }
.scores:empty { display: none; }

/* ---- play ---- */

.play-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; padding-top: 8px; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; font-weight: 600; }
.who > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pts { flex: none; font-weight: 600; font-variant-numeric: tabular-nums; padding: 1px 9px; border-radius: 999px; background: var(--tint); }
.net { flex: none; color: var(--mute); font-weight: 400; font-size: 15px; }
.pause { flex: none; width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  display: flex; align-items: center; justify-content: center; gap: 5px; }
.pause i { width: 4px; height: 15px; background: currentColor; border-radius: 1px; }

.clock { font: 600 clamp(60px, 21vw, 92px)/1 var(--text); letter-spacing: -.04em; text-align: center;
  font-variant-numeric: tabular-nums; padding: 4px 0 16px; }
.clock.soon { color: var(--loss); }
.clock.none { font: 400 16px var(--text); color: var(--mute); letter-spacing: 0; padding: 22px 0; }

.banner { background: rgba(255, 255, 255, .1); color: var(--surface); border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; font-size: 16px; }
.extra-time .play-top, .extra-time .clock, .extra-time .clock.soon { color: var(--surface); }
.extra-time .net { color: #a9b3be; }
.extra-time .pts { background: rgba(255, 255, 255, .14); }
.extra-time .pause { background: transparent; border-color: rgba(255, 255, 255, .35); }
.extra-time .btn.ghost { color: #c5ccd4; }
.extra-time .btn.primary { background: var(--surface); border-color: var(--surface); color: var(--ink); }
.extra-time .card { border-color: transparent; }

.card { position: relative; flex: 1; min-height: 190px; width: 100%; border-radius: 14px; border: 1px solid var(--line);
  overflow: hidden; background: var(--surface); user-select: none; -webkit-user-select: none; }
.card .back, .card .face { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.card .back { background: var(--tint); }
.card .back i { display: none; }
.card .back::before { content: ''; position: absolute; inset: 12px; border: 1px solid #cfd7df; border-radius: 8px; }
.card .back em { position: relative; max-width: 70%; font: 400 16px/1.35 var(--text); font-style: normal; color: var(--mute); text-align: center; }
.card .face { gap: 14px; padding: 18px; background: var(--surface); opacity: 0; visibility: hidden; }
.card.open .face { opacity: 1; visibility: visible; }
.card.open .back { visibility: hidden; }
.lvl { font: 400 14px var(--text); color: var(--mute); padding: 3px 12px; border-radius: 999px; border: 1px solid var(--line); }
.word { font: 600 40px/1.14 var(--text); letter-spacing: -.02em; text-align: center; overflow-wrap: break-word; text-wrap: balance; max-width: 100%; }
.sub { font-size: 19px; color: var(--mute); text-align: center; text-wrap: balance; }

.ask { text-align: center; color: var(--mute); padding-bottom: 12px; }
.picks { flex: 1; display: grid; gap: 10px; padding-bottom: 24px; }
.pickcard { border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: flex; align-items: center;
  justify-content: space-between; padding: 0 22px; min-height: 96px; font: 600 21px var(--text); }
.pickcard b { font-size: 30px; font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; }
.pickcard:active { background: var(--tint); }

/* ---- summary ---- */

.log { display: grid; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.log li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 7px 7px 14px; }
.log li + li { border-top: 1px solid var(--line); }
.log .w { min-width: 0; overflow-wrap: anywhere; }
.log .w small { display: block; color: var(--mute); }
.chip { flex: none; min-height: 42px; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); font-size: 15px; white-space: nowrap; }
.chip b { margin-left: 4px; font-variant-numeric: tabular-nums; }
.chip.guessed { background: var(--tint); border-color: var(--tint); }
.chip.skipped { border-color: var(--loss); color: var(--loss); }
.chip.missed { color: var(--mute); }
.empty { padding: 40px 0; text-align: center; color: var(--mute); }

/* ---- overlays ---- */

.sheet { position: fixed; inset: 0; z-index: 10; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(28, 39, 51, .6); }
.sheet-in { width: 100%; max-width: 480px; background: var(--paper); color: var(--ink); border-radius: 16px 16px 0 0;
  padding: 26px 20px calc(22px + env(safe-area-inset-bottom)); display: grid; gap: 10px; }
.sheet-in h3 { font: 600 22px/1.2 var(--text); }
.sheet-in p { color: var(--mute); margin-bottom: 8px; }
.sheet-in .btn.ghost { color: var(--mute); }
.team-btn { justify-content: flex-start; gap: 12px; }

@media (prefers-reduced-motion: reduce) { body { transition: none; } }

.extra-time .play-top .pennant.p0 { background: #7fa3c6; }
