:root {
  color-scheme: light;
  --paper: oklch(97.8% 0.012 85); --paper-2: oklch(94.5% 0.018 80); --paper-3: oklch(90% 0.026 78);
  --ink: oklch(27% 0.02 60); --ink-2: oklch(41% 0.022 60); --muted: oklch(53% 0.022 65);
  --rule: oklch(88% 0.022 75);
  --accent: oklch(72% 0.15 52); --accent-soft: oklch(93% 0.045 60); --accent-ink: oklch(42% 0.12 48);
  --sky: oklch(66% 0.09 230); --sky-soft: oklch(93% 0.03 230);
  --red: oklch(58% 0.18 28);
  --white: #fff;
  --font: "Fredoka", 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.2rem; --t-3xl: 3rem;
  --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; overscroll-behavior-y: none; }
h1, h2, p, ol, ul, fieldset { margin: 0; }
h1, h2 { font-weight: 700; line-height: 1.05; letter-spacing: -0.01em; 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); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.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)); }
.page--draw { gap: var(--s-3); }

.masthead h1 { font-size: var(--t-3xl); }
.masthead h1::after { content: ""; display: inline-block; width: 0.2em; height: 0.2em; margin-left: 0.08em; border-radius: 50%; background: var(--accent); }
.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); }
.block--start { display: grid; gap: var(--s-2); }
.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:empty { display: none; }
.center { text-align: center; }
.link.center-self { align-self: center; justify-self: center; }
.error { color: var(--red); font-weight: 600; }
.first { font-size: var(--t-sm); color: var(--ink-2); text-wrap: pretty; }
.first:empty { display: none; }

.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); }
.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(--accent); text-decoration-thickness: 2px; text-underline-offset: 0.25em; cursor: pointer; }
.link:hover { color: var(--ink); }

/* home */
.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, .field { 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, .field:hover { background: var(--paper-3); }
.player input:focus, .field:focus { background: var(--white); box-shadow: inset 0 0 0 2px var(--accent); outline: none; }
.player input::placeholder, .field::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; }

.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(--white); box-shadow: 0 1px 3px oklch(27% 0.02 60 / 0.14); }

.rules { padding-left: 1.3em; display: grid; gap: var(--s-2); color: var(--ink-2); font-size: var(--t-lg); line-height: 1.35; }
.rules--small { font-size: var(--t-md); gap: var(--s-1); }
.rules li::marker { color: var(--accent); font-weight: 700; }
.foot { margin-top: var(--s-6); font-size: var(--t-sm); color: var(--muted); }

/* hand-over */
.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; }
.clock { min-width: 4.2em; padding: var(--s-1) var(--s-3); border-radius: var(--pill); background: var(--paper-2); text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.clock.low { background: oklch(93% 0.05 28); color: var(--red); }
.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: var(--s-2); }
.task { display: flex; align-items: center; gap: var(--s-4); padding: var(--s-5); border-radius: var(--radius); background: var(--paper-2); font-size: var(--t-lg); line-height: 1.35; text-wrap: pretty; }
.task__icon { flex: none; width: 52px; height: 52px; border-radius: 50%; background: var(--accent-soft) no-repeat center / 26px; }
.task__icon[data-kind="write"] { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a04f12' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 7h16M4 12h11M4 17h7'/%3E%3C/svg%3E"); }
.task__icon[data-kind="draw"] { background-color: var(--sky-soft); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23235f86' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 17c3-6 5-6 6-3s3 3 5-1 4-5 7-2'/%3E%3C/svg%3E"); }

/* what the player sees: a phrase or a drawing */
.show { display: grid; }
.phrase { padding: var(--s-5); border-radius: var(--radius); background: var(--paper-2); font-size: var(--t-xl); font-weight: 600; line-height: 1.2; overflow-wrap: anywhere; text-wrap: balance; }
.phrase--big { padding: var(--s-6) var(--s-5); font-size: var(--t-2xl); text-align: center; }
.art { display: block; width: 100%; aspect-ratio: 1; border-radius: var(--radius); background: var(--white); box-shadow: inset 0 0 0 1.5px var(--rule), 0 1px 2px oklch(27% 0.02 60 / 0.06); }

/* write */
.field { flex: none; min-height: 56px; font-size: var(--t-lg); font-weight: 500; border-radius: var(--radius); }
#write-random { align-self: flex-start; }
.peek { min-height: 44px; padding: var(--s-2) var(--s-4); border: 0; border-radius: var(--pill); background: var(--sky-soft); color: oklch(36% 0.07 230); font-size: var(--t-sm); font-weight: 600; cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.peek:active { background: oklch(89% 0.045 230); }

/* draw */
.pad-wrap { display: flex; justify-content: center; }
.pad { display: block; width: min(100%, calc(100dvh - 360px - var(--safe-t) - var(--safe-b))); min-width: min(100%, 240px); aspect-ratio: 1; border-radius: var(--radius); background: var(--white); box-shadow: inset 0 0 0 1.5px var(--rule), 0 1px 2px oklch(27% 0.02 60 / 0.06); touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: crosshair; }
.tools { display: grid; gap: var(--s-2); }
.swatches { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--s-1); }
.swatch { height: 44px; display: grid; place-items: center; border: 0; border-radius: var(--pill); background: transparent; color: var(--ink-2); cursor: pointer; touch-action: manipulation; }
.swatch::before { content: ""; width: 30px; height: 30px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px oklch(0% 0 0 / 0.08); transition: transform var(--dur) var(--ease); }
.swatch--eraser::before { display: none; }
.swatch[aria-pressed="true"] { background: var(--paper-2); }
.swatch[aria-pressed="true"]::before { transform: scale(0.82); box-shadow: 0 0 0 3px var(--white), 0 0 0 5px var(--c); }
.swatch--eraser[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.tools__row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.sizes, .acts { display: flex; gap: var(--s-1); padding: var(--s-1); border-radius: var(--pill); background: var(--paper-2); }
.tool { min-width: 44px; height: 44px; display: grid; place-items: center; padding: 0 var(--s-2); border: 0; border-radius: var(--pill); background: transparent; color: var(--ink); font-weight: 600; font-size: var(--t-sm); cursor: pointer; touch-action: manipulation; transition: background-color var(--dur) linear; }
.tool:hover:not(:disabled) { background: var(--paper-3); }
.tool:disabled { opacity: 0.35; cursor: not-allowed; }
.tool--text { padding: 0 var(--s-4); }
.size::before { content: ""; width: var(--d); height: var(--d); border-radius: 50%; background: var(--c); }
.size[aria-pressed="true"] { background: var(--white); box-shadow: 0 1px 3px oklch(27% 0.02 60 / 0.14); }

/* peek overlay */
.overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: calc(var(--s-5) + var(--safe-t)) var(--s-4) calc(var(--s-5) + var(--safe-b)); background: oklch(27% 0.02 60 / 0.55); pointer-events: none; animation: fade 120ms linear both; }
.overlay__card { width: min(100%, var(--page)); display: grid; padding: var(--s-3); border-radius: calc(var(--radius) + 6px); background: var(--paper); }
.overlay__card .art { box-shadow: none; }
.overlay__card .phrase { background: transparent; }

/* reveal and chain */
#reveal .show { animation: rise 360ms var(--ease) both; }
.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); margin-top: auto; }
.row .btn { min-height: 60px; font-size: var(--t-lg); }
.chain { list-style: none; padding: 0; display: grid; gap: var(--s-5); margin-top: var(--s-6); }
.link-step { display: grid; gap: var(--s-2); }
.who { color: var(--muted); }
.who b { color: var(--ink); font-weight: 600; }
.stack { display: grid; gap: var(--s-2); margin-top: auto; padding-top: var(--s-5); }
#chain .stack { margin-top: var(--s-6); }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (max-width: 22.5rem) { :root { --t-3xl: 2.5rem; --t-2xl: 1.9rem; } .swatch::before { width: 26px; height: 26px; } }

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