:root {
  color-scheme: light;
  --paper: oklch(97.6% 0.009 190); --paper-2: oklch(94% 0.018 190); --paper-3: oklch(89.5% 0.026 190);
  --card: oklch(99.6% 0.003 190);
  --ink: oklch(25% 0.035 222); --ink-2: oklch(39% 0.035 222); --muted: oklch(50% 0.03 222);
  --rule: oklch(87% 0.022 200);
  --accent: oklch(66% 0.1 195); --accent-soft: oklch(92% 0.042 195); --accent-ink: oklch(32% 0.07 205); --accent-deep: oklch(52% 0.1 196);
  --fish: oklch(70% 0.16 48); --fish-soft: oklch(93.5% 0.045 55); --fish-ink: oklch(42% 0.13 42);
  --font: "Figtree", system-ui, sans-serif;
  --radius: 18px; --pill: 999px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px;
  --t-sm: 0.875rem; --t-md: 1rem; --t-lg: 1.2rem; --t-xl: 1.6rem; --t-2xl: 2.3rem; --t-3xl: 3.1rem;
  --dur: 140ms; --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --page: 30rem;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body { margin: 0; min-height: 100dvh; background: var(--paper); color: var(--ink); font: 400 var(--t-md)/1.5 var(--font); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overflow-x: clip; }
h1, h2, p, ol, ul, fieldset { margin: 0; }
h1, h2 { font-weight: 800; line-height: 1.04; letter-spacing: -0.02em; text-wrap: balance; overflow-wrap: break-word; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
[hidden] { display: none !important; }
.noscript { padding: var(--s-5); }

.page { max-width: var(--page); margin-inline: auto; padding: calc(var(--s-6) + var(--safe-t)) calc(var(--s-4) + var(--safe-r)) calc(var(--s-7) + var(--safe-b)) calc(var(--s-4) + var(--safe-l)); }
.page--stage { min-height: 100dvh; display: flex; flex-direction: column; gap: var(--s-4); padding-top: calc(var(--s-3) + var(--safe-t)); padding-bottom: calc(var(--s-5) + var(--safe-b)); }

.masthead h1 { font-size: var(--t-3xl); }
.masthead h1::after { content: ""; display: inline-block; width: 0.2em; height: 0.2em; margin-left: 0.07em; border-radius: 50%; background: var(--fish); box-shadow: 0.24em -0.2em 0 -0.04em var(--accent); }
.lead { margin-top: var(--s-2); color: var(--ink-2); font-size: var(--t-lg); line-height: 1.38; max-width: 34ch; text-wrap: pretty; }

.block { border: 0; padding: 0; min-width: 0; margin-top: var(--s-6); }
.block--tight { margin-top: var(--s-5); }
.label { display: block; padding: 0; margin-bottom: var(--s-2); font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); }
.note { font-size: var(--t-sm); color: var(--muted); text-wrap: pretty; }
.note--gap { margin-top: var(--s-3); }
.center { text-align: center; }
.error { margin-top: var(--s-5); margin-bottom: var(--s-3); color: var(--fish-ink); font-weight: 600; }
#resume-block .note { margin-top: var(--s-3); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: 48px; padding: var(--s-2) var(--s-5); border: 0; border-radius: var(--pill); background: var(--paper-2); color: var(--ink); font-weight: 600; font-size: var(--t-md); line-height: 1.2; text-align: center; cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; transition: background-color var(--dur) linear, transform var(--dur) var(--ease); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--ink); color: var(--paper); }
.btn--go { background: var(--accent-deep); color: var(--card); }
.btn--quiet { background: transparent; box-shadow: inset 0 0 0 1.5px var(--rule); }
.btn--wide { width: 100%; }
.btn--big { min-height: 60px; font-size: var(--t-lg); }
.page--stage > .btn--big { margin-top: auto; }
#start { margin-top: var(--s-5); }
.link { align-self: flex-start; background: none; border: 0; min-height: 44px; padding: var(--s-2) 0; font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 0.25em; cursor: pointer; }

.teams { list-style: none; padding: 0; display: grid; gap: var(--s-2); margin-bottom: var(--s-2); }
.team { display: flex; align-items: center; gap: var(--s-2); }
.team input, .word-inputs input { flex: 1; min-width: 0; min-height: 48px; padding: var(--s-2) var(--s-4); border: 0; border-radius: var(--pill); background: var(--paper-2); font-size: var(--t-md); }
.team input:focus, .word-inputs input:focus { background: var(--card); box-shadow: inset 0 0 0 2px var(--accent); outline: none; }
.team input::placeholder, .word-inputs input::placeholder { color: var(--muted); }
.remove { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; }
.remove:disabled { visibility: hidden; }

.segments { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: var(--s-1); padding: var(--s-1); border-radius: var(--pill); background: var(--paper-2); }
.segments button { min-height: 44px; padding: var(--s-1) var(--s-2); border: 0; border-radius: var(--pill); background: transparent; font-weight: 600; cursor: pointer; touch-action: manipulation; transition: background-color var(--dur) linear; }
.segments button[aria-pressed="true"] { background: var(--card); box-shadow: 0 1px 3px oklch(25% 0.035 222 / 0.14); }

.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip { min-height: 44px; padding: var(--s-1) var(--s-4); border: 0; border-radius: var(--pill); background: var(--paper-2); font-size: var(--t-sm); font-weight: 600; cursor: pointer; touch-action: manipulation; transition: background-color var(--dur) linear; }
.chip[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); box-shadow: inset 0 0 0 1.5px var(--accent); }

.toggles { margin-top: var(--s-5); }
.toggle { display: flex; align-items: center; gap: var(--s-3); min-height: 48px; cursor: pointer; }
.toggle input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--accent-deep); }

.rounds { list-style: none; padding: 0; display: grid; gap: var(--s-2); counter-reset: r; }
.rounds li { display: flex; gap: var(--s-3); align-items: baseline; padding: var(--s-3) var(--s-4); border-radius: var(--radius); background: var(--paper-2); counter-increment: r; text-wrap: pretty; color: var(--ink-2); }
.rounds li::before { content: counter(r); flex: none; width: 1.6rem; height: 1.6rem; display: inline-grid; place-items: center; border-radius: 50%; background: var(--card); color: var(--accent-ink); font-weight: 800; font-size: var(--t-sm); transform: translateY(0.1em); }
.rounds b { color: var(--ink); }
.foot { margin-top: var(--s-6); font-size: var(--t-sm); color: var(--muted); }

/* game screens */
.topline { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-height: 44px; }
.step { font-size: var(--t-sm); color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.kicker { font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); margin-top: var(--s-2); }
.name { font-size: var(--t-3xl); margin-top: calc(var(--s-3) * -1); overflow-wrap: anywhere; }
.title { font-size: var(--t-2xl); margin-top: calc(var(--s-2) * -1); }
.facts { color: var(--ink-2); font-weight: 600; text-wrap: pretty; }
.facts--big { font-size: var(--t-xl); font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.stack { display: grid; gap: var(--s-2); margin-top: auto; padding-top: var(--s-3); }
.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
.row--play { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); }
.row--play .btn { min-height: 72px; }
.row--play #skip[hidden] + #got { grid-column: 1 / -1; }

.rule-card { display: grid; gap: var(--s-1); padding: var(--s-4) var(--s-5) var(--s-5); border-radius: var(--radius); background: var(--accent-soft); color: var(--accent-ink); }
.rule-card__tag { font-size: var(--t-sm); font-weight: 600; }
.rule-card__name { font-size: var(--t-xl); font-weight: 800; letter-spacing: -0.015em; line-height: 1.1; color: var(--ink); }
.rule-card__text { color: var(--accent-ink); text-wrap: pretty; }

.mini-scores { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s-2); }
.mini-scores li { display: inline-flex; align-items: baseline; gap: var(--s-2); min-height: 36px; padding: var(--s-1) var(--s-4); border-radius: var(--pill); background: var(--paper-2); font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; max-width: 100%; }
.mini-scores li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-scores li b { color: var(--ink); font-weight: 800; }
.mini-scores li.on { background: var(--card); box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--ink); }

/* the turn */
.clock { display: grid; gap: var(--s-2); }
.clock__time { font-size: var(--t-3xl); font-weight: 800; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; text-align: center; }
.clock__bar { display: block; height: 8px; border-radius: var(--pill); background: var(--paper-2); overflow: hidden; }
.clock__fill { display: block; height: 100%; background: var(--accent); transform-origin: left center; transition: transform 100ms linear; }
.clock.low .clock__time { color: var(--fish-ink); }
.clock.low .clock__fill { background: var(--fish); }
.word-card { flex: 1; min-height: 220px; display: grid; grid-template-rows: 1fr auto; justify-items: center; align-items: center; gap: var(--s-3); padding: var(--s-6) var(--s-5) var(--s-4); border-radius: calc(var(--radius) + 6px); background: var(--card); box-shadow: inset 0 0 0 2px var(--accent-soft), 0 1px 2px oklch(25% 0.035 222 / 0.06); text-align: center; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.word-card__word { font-size: var(--t-2xl); font-weight: 800; line-height: 1.08; letter-spacing: -0.02em; text-wrap: balance; overflow-wrap: anywhere; }
.word-card__rule { font-size: var(--t-sm); font-weight: 600; color: var(--muted); }
.word-card.swap .word-card__word { animation: rise 260ms var(--ease) both; }
#turn .facts { text-align: center; font-size: var(--t-sm); color: var(--muted); font-variant-numeric: tabular-nums; }

/* own words */
.words-form { display: flex; flex-direction: column; gap: var(--s-4); flex: 1; }
.word-inputs { display: grid; gap: var(--s-2); }
.words-form .btn--big { margin-top: auto; }
.bowl-count { display: grid; justify-items: center; gap: var(--s-1); margin-top: auto; padding: var(--s-6) 0 var(--s-3); }
.bowl-count__n { display: grid; place-items: center; width: 7.5rem; height: 7.5rem; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); font-size: var(--t-3xl); font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.bowl-count__label { font-weight: 600; color: var(--ink-2); }

/* summary */
.got-list { list-style: none; padding: 0; display: grid; gap: var(--s-2); }
.got { width: 100%; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "mark word" "mark state"; column-gap: var(--s-3); align-items: center; min-height: 56px; padding: var(--s-2) var(--s-4); border: 0; border-radius: var(--radius); background: var(--paper-2); text-align: left; cursor: pointer; touch-action: manipulation; transition: background-color var(--dur) linear; }
.got__mark { grid-area: mark; width: 26px; height: 26px; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--rule); background: var(--card); }
.got[aria-pressed="true"] .got__mark { background: var(--accent-deep) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 16px no-repeat; box-shadow: none; }
.got__word { grid-area: word; font-weight: 700; font-size: var(--t-lg); line-height: 1.2; overflow-wrap: anywhere; }
.got__state { grid-area: state; font-size: var(--t-sm); color: var(--muted); }
.got[aria-pressed="false"] .got__word { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 2px; }
.got--last .got__word { font-size: var(--t-md); font-weight: 600; }
.got--last[aria-pressed="false"] .got__word { text-decoration: none; }
.got--last[aria-pressed="false"] { background: var(--fish-soft); }
.got--last[aria-pressed="false"] .got__state { color: var(--fish-ink); }

/* scores */
.table { width: 100%; border-collapse: separate; border-spacing: 0 3px; font-variant-numeric: tabular-nums; table-layout: fixed; }
.table th, .table td { padding: var(--s-2) var(--s-2); text-align: left; }
.table thead th { font-size: var(--t-sm); font-weight: 600; color: var(--muted); padding-block: 0; }
.table th:first-child { width: auto; }
.table .num { width: 2.8rem; text-align: right; }
.table thead .num:last-child, .table .total { width: 3.6rem; }
.table tbody tr > * { background: var(--paper-2); }
.table tbody th { font-weight: 600; overflow-wrap: anywhere; border-radius: 12px 0 0 12px; padding-left: var(--s-4); }
.table tbody td:last-child { border-radius: 0 12px 12px 0; padding-right: var(--s-4); }
.table thead th:first-child { padding-left: var(--s-4); }
.table thead th:last-child { padding-right: var(--s-4); }
.table td { color: var(--ink-2); }
.table .total { font-weight: 800; color: var(--ink); font-size: var(--t-lg); }
.table tbody tr.top > * { background: var(--accent-soft); }

@media (hover: hover) {
  .btn:hover { background: var(--paper-3); }
  .btn--primary:hover { background: var(--ink-2); }
  .btn--go:hover { background: oklch(47% 0.1 196); }
  .btn--quiet:hover { background: var(--paper-2); }
  .link:hover { color: var(--ink); }
  .team input:hover:not(:focus), .word-inputs input:hover:not(:focus) { background: var(--paper-3); }
  .remove:hover { background: var(--paper-2); color: var(--ink); }
  .segments button:hover:not([aria-pressed="true"]) { background: var(--paper-3); }
  .chip:hover:not([aria-pressed="true"]) { background: var(--paper-3); }
  .got:not(.got--last[aria-pressed="false"]):hover { background: var(--paper-3); }
}

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (max-width: 22.5rem) { :root { --t-3xl: 2.6rem; --t-2xl: 2rem; } }
@media (max-height: 640px) { .word-card { min-height: 160px; } .row--play .btn { min-height: 60px; } }

/* back to games.el.zone, on the home screen only */
.back-home { display: inline-flex; align-items: center; gap: 2px; align-self: flex-start; min-height: 44px; margin: -12px 0 4px -6px; padding: 0 10px 0 4px; border-radius: 999px; color: inherit; opacity: 0.6; font-size: 0.875rem; font-weight: 600; line-height: 1; text-decoration: none; transition: opacity 140ms linear; }
.back-home:hover, .back-home:focus-visible { opacity: 1; }
.back-home svg { flex: none; }
