:root {
  color-scheme: light;
  --paper: #f7f5ef; --paper-2: #edeae1; --paper-3: #e2ded2;
  --ink: #1f2a29; --ink-2: #3c4a48; --muted: #5f6b69;
  --rule: #dcd8cc;
  /* the two accents: the ring (teal) and the ball (apricot). The canvas reads these too. */
  --ring: #2a9a8a; --ring-soft: #d5ece6; --ring-ink: #11463f;
  --ball: #ee8a3d; --ball-soft: #fbe3cf; --ball-ink: #6b3207;
  --font: "Outfit", 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.25rem; --t-xl: 1.6rem; --t-2xl: 2.4rem; --t-3xl: 3.2rem;
  --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; }
html.playing, html.playing body { overflow: hidden; overscroll-behavior: none; }
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.02; letter-spacing: -0.02em; text-wrap: balance; overflow-wrap: break-word; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ring-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)); }

.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(--ball); box-shadow: 0 0 0 0.06em var(--paper), 0 0 0 0.11em var(--ring); }
.lead { margin-top: var(--s-2); color: var(--ink-2); font-size: var(--t-lg); line-height: 1.35; max-width: 34ch; text-wrap: pretty; }

.block { border: 0; padding: 0; min-width: 0; margin-top: var(--s-6); }
.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; }
.control-note { margin-top: var(--s-2); }
.error { margin-top: var(--s-5); padding: var(--s-3) var(--s-4); border-radius: var(--radius); background: var(--ball-soft); color: var(--ball-ink); font-weight: 600; text-wrap: pretty; }

.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); cursor: pointer; touch-action: manipulation; transition: background-color var(--dur) linear, transform var(--dur) var(--ease); }
.btn:hover { background: var(--paper-3); }
.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--primary:hover { background: var(--ink-2); }
.btn--quiet { background: transparent; box-shadow: inset 0 0 0 1.5px var(--rule); }
.btn--quiet:hover { background: var(--paper-2); }
.btn--wide { width: 100%; }
.btn--big { min-height: 60px; font-size: var(--t-lg); }
#start { margin-top: var(--s-5); }
.page--stage > .btn--big { margin-top: auto; }
.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(--ring); text-decoration-thickness: 2px; text-underline-offset: 0.25em; cursor: pointer; }
.link:hover { color: var(--ink); }

.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:hover { background: var(--paper-3); }
.segments button[aria-pressed="true"] { background: var(--paper); box-shadow: 0 1px 3px rgb(31 42 41 / 0.14); }

.best { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-radius: var(--radius); background: var(--ring-soft); color: var(--ring-ink); }
.best__label { font-weight: 600; }
.best__value { font-size: var(--t-xl); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
#reset-best { margin-top: var(--s-1); }

.players { list-style: none; padding: 0; display: grid; gap: var(--s-2); margin-bottom: var(--s-2); counter-reset: p; }
.player { display: flex; align-items: center; gap: var(--s-2); counter-increment: p; }
.player::before { content: counter(p); width: 1.6em; flex: none; text-align: right; font-size: var(--t-sm); color: var(--muted); font-variant-numeric: tabular-nums; }
.player 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); }
.player input:hover { background: var(--paper-3); }
.player input:focus { background: #fff; box-shadow: inset 0 0 0 2px var(--ring); outline: none; }
.player 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:hover { background: var(--paper-2); color: var(--ink); }
.remove:disabled { visibility: hidden; }
#players-note:empty { display: none; }
#players-note { margin-top: var(--s-2); }

.foot { margin-top: var(--s-6); font-size: var(--t-sm); color: var(--muted); max-width: 40ch; }

/* pass */
.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; overflow-wrap: anywhere; }
.last { align-self: flex-start; padding: var(--s-2) var(--s-4); border-radius: var(--pill); background: var(--paper-2); font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); }
.kicker { font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); margin-top: var(--s-3); }
.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-3) * -1); overflow-wrap: anywhere; }
.rules { padding-left: 1.3em; display: grid; gap: var(--s-2); margin-top: var(--s-3); color: var(--ink-2); font-size: var(--t-lg); line-height: 1.35; }
.rules li::marker { color: var(--ring); font-weight: 800; }
#pass-error { margin-top: 0; }

/* play */
.play { height: 100dvh; max-width: var(--page); margin-inline: auto; display: flex; flex-direction: column; gap: var(--s-2); padding: calc(var(--s-2) + var(--safe-t)) calc(var(--s-4) + var(--safe-r)) calc(var(--s-3) + var(--safe-b)) calc(var(--s-4) + var(--safe-l)); overflow: hidden; }
.clock { display: flex; align-items: baseline; gap: 0.12em; font-size: var(--t-3xl); font-weight: 800; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.clock__unit, .score__unit { font-size: 0.45em; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.field { position: relative; flex: 1; min-height: 0; border-radius: var(--radius); background: var(--paper-2); overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.field.drag { cursor: grab; }
.field.drag:active { cursor: grabbing; }
.field canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.overlay { position: absolute; inset: 0; display: grid; align-content: start; justify-content: center; justify-items: center; gap: var(--s-2); padding: var(--s-6) var(--s-4); text-align: center; pointer-events: none; }
.overlay__big { font-size: 5rem; font-weight: 800; line-height: 1; letter-spacing: -0.03em; color: var(--ink); font-variant-numeric: tabular-nums; }
.overlay__big:empty { display: none; }
.overlay__text { max-width: 22ch; padding: var(--s-1) var(--s-3); border-radius: var(--pill); background: rgb(247 245 239 / 0.82); font-weight: 600; color: var(--ink-2); text-wrap: balance; }
.overlay__text:empty { display: none; }
.overlay .btn { pointer-events: auto; margin-top: var(--s-2); min-width: 9rem; }
.overlay.tick .overlay__big { animation: tick 400ms var(--ease) both; }
.hint { font-size: var(--t-sm); color: var(--muted); text-align: center; min-height: 1.5em; text-wrap: balance; }

/* over and rank */
.score { display: flex; align-items: baseline; gap: 0.1em; font-size: 4.4rem; margin-top: calc(var(--s-3) * -1); font-variant-numeric: tabular-nums; }
.outcome { font-size: var(--t-lg); font-weight: 600; line-height: 1.35; padding: var(--s-4) var(--s-5); border-radius: var(--radius); background: var(--paper-2); color: var(--ink-2); text-wrap: pretty; }
.outcome.new { background: var(--ring-soft); color: var(--ring-ink); }
#over-error { margin-top: 0; }
.scores { list-style: none; padding: 0; display: grid; gap: 2px; counter-reset: r; }
.scores li { display: flex; align-items: baseline; gap: var(--s-3); min-height: 48px; padding: var(--s-3) var(--s-4); border-radius: 12px; background: var(--paper-2); font-size: var(--t-lg); font-variant-numeric: tabular-nums; counter-increment: r; }
.scores li::before { content: counter(r); width: 1.2em; flex: none; font-size: var(--t-sm); font-weight: 600; color: var(--muted); }
.scores li span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.scores li b { font-weight: 800; }
.scores li.top { background: var(--ring-soft); color: var(--ring-ink); }
.scores li.top::before { color: var(--ring-ink); }
.stack { display: grid; gap: var(--s-2); margin-top: auto; padding-top: var(--s-3); }

@keyframes tick { from { opacity: 0.2; transform: scale(1.25); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (max-width: 22rem) { :root { --t-3xl: 2.6rem; --t-2xl: 2rem; } .score { font-size: 3.6rem; } }
@media (max-height: 34rem) { .clock { font-size: var(--t-2xl); } .hint { display: none; } }

/* 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; }
