:root {
  color-scheme: light;
  --paper: oklch(97.8% 0.011 95); --paper-2: oklch(94.6% 0.018 95); --paper-3: oklch(90.6% 0.026 95);
  --ink: oklch(27% 0.03 255); --ink-2: oklch(41% 0.03 255); --muted: oklch(52% 0.025 255);
  --rule: oklch(88% 0.02 95);
  --accent: oklch(84% 0.15 92); --accent-2: oklch(78% 0.15 84); --accent-soft: oklch(94.5% 0.055 95); --accent-ink: oklch(42% 0.09 80);
  --gz-body: oklch(80% 0.075 232); --gz-bell: oklch(66% 0.09 236); --gz-face: oklch(98.5% 0.01 95); --gz-cheek: oklch(80% 0.1 15);
  --hot: oklch(66% 0.17 30); --lucky-bg: oklch(94% 0.05 160); --lucky-ink: oklch(38% 0.08 160);
  --font: "Baloo 2", 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.5rem; --t-2xl: 2rem; --t-3xl: 3rem;
  --dur: 140ms; --ease: cubic-bezier(0.16, 1, 0.3, 1); --spring: cubic-bezier(0.34, 1.56, 0.64, 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: 500 var(--t-md)/1.45 var(--font); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overflow-x: clip; transition: background-color 200ms linear; }
body[data-screen="end"][data-kind="caught"] { background: var(--accent-soft); }
body[data-screen="end"][data-kind="lucky"] { background: var(--lucky-bg); }
h1, h2, h3, p, ol, ul, fieldset { margin: 0; }
h1, h2 { font-weight: 800; line-height: 1; letter-spacing: -0.01em; text-wrap: balance; overflow-wrap: break-word; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2.5px solid var(--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-3); padding-top: calc(var(--s-3) + var(--safe-t)); padding-bottom: calc(var(--s-5) + var(--safe-b)); }

/* home */
.masthead { display: flex; align-items: flex-start; gap: var(--s-3); }
.masthead__text { flex: 1; min-width: 0; }
.masthead h1 { font-size: var(--t-3xl); }
.masthead h1::after { content: ""; display: inline-block; width: 0.2em; height: 0.2em; margin-left: 0.06em; border-radius: 50%; background: var(--accent); box-shadow: inset 0 0 0 0.035em var(--ink); }
.masthead__art { flex: none; width: 92px; height: 92px; margin-top: var(--s-1); }
.lead { margin-top: var(--s-2); color: var(--ink-2); font-size: var(--t-lg); line-height: 1.3; max-width: 30ch; 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: 700; color: var(--ink-2); }
.label .opt { font-weight: 500; color: var(--muted); }
.note { font-size: var(--t-sm); color: var(--muted); text-wrap: pretty; }
.note:not(:empty) { margin-top: var(--s-2); }

.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: 700; font-size: var(--t-md); line-height: 1.2; cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; transition: background-color var(--dur) linear, transform var(--dur) var(--ease); }
.btn:hover { background: var(--paper-3); }
.btn:active { transform: scale(0.98); }
.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); }
.link { background: none; border: 0; min-height: 44px; padding: var(--s-2) 0; font-size: var(--t-sm); font-weight: 700; color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--accent-2); text-decoration-thickness: 2.5px; text-underline-offset: 0.25em; cursor: pointer; }
.link:hover { color: var(--ink); }

.players { list-style: none; padding: 0; display: grid; gap: var(--s-2); counter-reset: p; }
.players:not(:empty) { margin-bottom: var(--s-2); }
.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: var(--paper); box-shadow: inset 0 0 0 2px var(--accent-2); 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); }

.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: 700; font-size: var(--t-lg); cursor: pointer; touch-action: manipulation; font-variant-numeric: tabular-nums; 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 oklch(27% 0.03 255 / 0.16), inset 0 -3px 0 var(--accent); }

.toggles { margin-top: var(--s-5); display: grid; gap: var(--s-1); }
.toggle { display: flex; align-items: flex-start; gap: var(--s-3); min-height: 48px; padding: var(--s-2) 0; cursor: pointer; }
.toggle input { width: 22px; height: 22px; margin: 2px 0 0; flex: none; accent-color: var(--ink); }
.toggle span { display: grid; line-height: 1.3; }
.toggle b { font-weight: 700; }
.toggle small { font-size: var(--t-sm); color: var(--muted); }
.drinks-note { margin-top: var(--s-2); padding: var(--s-2) var(--s-4); border-radius: var(--radius); background: var(--accent-soft); color: var(--accent-ink); font-size: var(--t-sm); font-weight: 600; }

.scores { list-style: none; padding: 0; display: grid; gap: 2px; }
.scores li { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); min-height: 40px; padding: var(--s-2) var(--s-3); border-radius: 10px; background: var(--paper-2); font-variant-numeric: tabular-nums; }
.scores li > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.scores li b { font-weight: 800; }
.scores li.top { background: var(--accent-soft); }
.scores li .plus { font-size: var(--t-sm); font-weight: 700; color: var(--hot); margin-right: var(--s-2); }
#tally-block .link { margin-top: var(--s-2); }
.rules { padding-left: 1.3em; display: grid; gap: var(--s-1); color: var(--ink-2); }
.rules li::marker { color: var(--accent-ink); font-weight: 800; }
.foot { margin-top: var(--s-6); font-size: var(--t-sm); color: var(--muted); }

/* play: one screen tall, nothing scrolls while fingers swipe across the wires */
.play { max-width: var(--page); margin-inline: auto; min-height: 100dvh; 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-4) + var(--safe-b)) calc(var(--s-4) + var(--safe-l)); }
.topline { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); min-height: 44px; flex: none; }
.status { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex: none; }
.status__text { min-width: 0; }
.kicker { font-size: var(--t-sm); font-weight: 700; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.turn { font-size: var(--t-2xl); line-height: 1.05; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-bottom: 2px; }
.turn.pop { animation: pop 260ms var(--spring) both; }
.clock { position: relative; flex: none; width: 76px; height: 44px; display: grid; place-items: center; border-radius: var(--pill); background: var(--paper-2); overflow: hidden; box-shadow: inset 0 0 0 2px var(--ink); }
.clock__fill { position: absolute; inset: 0; background: var(--accent); transform-origin: left center; }
.clock.hot .clock__fill { background: var(--hot); }
.clock__num { position: relative; font-size: var(--t-xl); font-weight: 800; font-variant-numeric: tabular-nums; }
.stage { position: relative; flex: 1 1 0; min-height: 72px; max-height: 210px; }
.stage .gz { position: absolute; inset: var(--s-3) 0 var(--s-1); width: 100%; height: calc(100% - var(--s-3) - var(--s-1)); }
.hint { flex: none; font-size: var(--t-sm); color: var(--muted); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.wires { --n: 8; flex: 3 1 auto; min-height: calc(var(--n) * 44px + 16px); max-height: calc(var(--n) * 52px + 16px); list-style: none; margin: 0; padding: var(--s-2) var(--s-1); display: grid; grid-template-rows: repeat(var(--n), minmax(44px, 1fr)); border-radius: var(--radius); background: var(--paper-2); touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; overscroll-behavior: contain; }
.wires li { display: flex; min-height: 0; }
.wire { flex: 1; display: flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 var(--s-2) 0 var(--s-1); border: 0; border-radius: 12px; background: transparent; cursor: pointer; touch-action: none; transition: background-color var(--dur) linear; }
@media (hover: hover) { .wire:hover { background: var(--paper-3); } }
.wires.locked .wire, .wire[aria-disabled="true"] { cursor: default; background: transparent; }
.wire:focus-visible { outline-offset: -2px; }
.wire__num { flex: none; width: 1.4em; font-size: var(--t-sm); font-weight: 700; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.wire[aria-disabled="true"] .wire__num { opacity: 0.4; }
.wire__line { position: relative; flex: 1; min-width: 0; align-self: stretch; }
.wire svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; display: block; }
.wire .post { fill: oklch(78% 0.015 255); stroke: var(--ink-2); stroke-width: 2; }
.wire path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.wire .w-under { stroke: var(--c2); stroke-width: 9; }
.wire .w-main { stroke: var(--c); stroke-width: 6; }
.wire .w-shine { stroke: oklch(100% 0 0 / 0.45); stroke-width: 1.6; transform: translateY(-1.4px); }
.wire .tip { fill: oklch(70% 0.13 55); stroke: oklch(48% 0.1 50); stroke-width: 1; }
.wire .half { transform-box: view-box; transform: rotate(var(--r)); }
.wire .snipping .half { animation: droop 640ms var(--ease) both; }
.wire .snip path { fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; }
.wire .snip { opacity: 0; transform-box: fill-box; transform-origin: center; }
.wire .snipping .snip { animation: snip 420ms ease-out both; }

/* the gizmo */
.gz { display: block; overflow: visible; }
.gz-shadow { fill: oklch(27% 0.03 255 / 0.1); }
.gz-legs { fill: none; stroke: var(--ink); stroke-width: 6; stroke-linecap: round; }
.gz-bells path { fill: var(--gz-bell); stroke: var(--ink); stroke-width: 4; stroke-linejoin: round; }
.gz-spring polyline { fill: none; stroke: var(--ink-2); stroke-width: 4; stroke-linejoin: round; stroke-linecap: round; }
.gz-spring { transform-box: view-box; transform-origin: 100px 56px; transform: scaleY(0.04); }
.gz-body { fill: var(--gz-body); stroke: var(--ink); stroke-width: 5; }
.gz-face { fill: var(--gz-face); }
.gz-ticks { fill: none; stroke: var(--ink-2); stroke-width: 3; stroke-linecap: round; }
.gz-eyes, .gz-mouth { display: none; }
.gz-eyes--open ellipse { fill: var(--ink); }
.gz-eyes--wide circle { fill: #fff; stroke: var(--ink); stroke-width: 3; }
.gz-eyes--wide .pupil { fill: var(--ink); stroke: none; }
.gz-eyes--x path, .gz-eyes--shut path { fill: none; stroke: var(--ink); stroke-width: 4; stroke-linecap: round; }
.gz-cheek { fill: var(--gz-cheek); opacity: 0.6; }
.gz-mouth { fill: none; stroke: var(--ink); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.gz-mouth--o, .gz-mouth--grin { fill: var(--ink); }
.gz-lid path, .gz-lid rect, .gz-lid circle { fill: var(--accent); stroke: var(--ink); stroke-width: 4; stroke-linejoin: round; }
.gz-lid { transform-box: view-box; transform-origin: 100px 55px; }
.gz-all { transform-box: view-box; transform-origin: 100px 186px; }
.gz-glitter { display: none; }
.gl { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); }

.gz[data-mood="idle"] .gz-eyes--open, .gz[data-mood="idle"] .gz-mouth--smile { display: inline; }
.gz[data-mood="tense"] .gz-eyes--wide, .gz[data-mood="tense"] .gz-mouth--flat { display: inline; }
.gz[data-mood="tense"] .gz-all { animation: jitter 90ms linear infinite alternate; }
.gz[data-mood="tense"] .gz-lid { animation: rattle 140ms linear infinite alternate; }
.gz[data-mood="phew"] .gz-eyes--shut, .gz[data-mood="phew"] .gz-mouth--smile { display: inline; }
.gz[data-mood="phew"] .gz-all { animation: squash 480ms var(--spring) both; }
.gz[data-mood="caught"] .gz-eyes--x, .gz[data-mood="caught"] .gz-mouth--o { display: inline; }
.gz[data-mood="caught"] .gz-lid { transform: translateY(-62px) rotate(-14deg); animation: lid-fly 1100ms linear both; }
.gz[data-mood="caught"] .gz-spring { transform: scaleY(0.94); animation: spring-fly 1100ms linear both; }
.gz[data-mood="caught"] .gz-all { animation: recoil 600ms var(--ease) both; }
.gz[data-mood="lucky"] .gz-eyes--shut, .gz[data-mood="lucky"] .gz-mouth--grin { display: inline; }
.gz[data-mood="lucky"] .gz-lid { transform: translateY(-24px) rotate(16deg); animation: lid-lift 700ms var(--spring) both; }
.gz[data-mood="lucky"] .gz-spring { transform: scaleY(0.36); animation: spring-lift 700ms var(--spring) both; }
.gz[data-mood="lucky"] .gz-all { animation: hop 700ms var(--ease) both; }
.gz[data-mood="caught"] .gz-glitter, .gz[data-mood="lucky"] .gz-glitter { display: inline; }
.gz[data-mood="caught"] .gl, .gz[data-mood="lucky"] .gl { animation: glitter 1300ms var(--d) cubic-bezier(0.2, 0.7, 0.3, 1) both; }

/* the end */
.end__art { flex: none; display: grid; place-items: center; height: 230px; padding-top: 50px; }
.end__art .gz { width: 180px; height: 180px; }
.end__head { text-align: center; }
.end__word { font-size: clamp(3.4rem, 19vw, 5.4rem); line-height: 0.95; letter-spacing: -0.02em; }
.end[data-kind="lucky"] .end__word { font-size: clamp(2.6rem, 13vw, 4rem); color: var(--lucky-ink); }
.end[data-kind="caught"] .end__head { animation: thump 520ms var(--spring) both; }
.end__who { margin: var(--s-2) auto 0; max-width: 26ch; font-size: var(--t-lg); line-height: 1.3; font-weight: 700; text-wrap: balance; overflow-wrap: anywhere; }
.end__meta { margin-top: var(--s-1); font-size: var(--t-sm); color: var(--ink-2); }
.end__drink { display: inline-block; margin-top: var(--s-3); padding: var(--s-2) var(--s-4); border-radius: var(--pill); background: var(--ink); color: var(--paper); font-weight: 700; overflow-wrap: anywhere; }
.end__body { flex: 1; display: flex; flex-direction: column; gap: var(--s-4); margin-top: var(--s-3); }
.end .scores li { background: oklch(100% 0 0 / 0.55); }
.end .scores li.top { background: oklch(100% 0 0 / 0.95); }
.end .btn--quiet { box-shadow: inset 0 0 0 1.5px oklch(27% 0.03 255 / 0.25); }
.end .btn--quiet:hover { background: oklch(100% 0 0 / 0.4); }
.stack { display: grid; gap: var(--s-2); margin-top: auto; padding-top: var(--s-3); }
.end.shake { animation: shake 480ms linear both; }

@keyframes pop { from { transform: scale(0.9); opacity: 0.4; } to { transform: none; opacity: 1; } }
@keyframes thump { 0% { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.08); opacity: 1; } 100% { transform: none; } }
@keyframes droop { 0% { transform: rotate(0deg); } 35% { transform: rotate(calc(var(--r) * 1.7)); } 65% { transform: rotate(calc(var(--r) * 0.75)); } 100% { transform: rotate(var(--r)); } }
@keyframes snip { 0% { opacity: 1; transform: scale(0.6); } 100% { opacity: 0; transform: scale(1.4); } }
@keyframes jitter { from { transform: rotate(-2.2deg); } to { transform: rotate(2.2deg) translateY(-1px); } }
@keyframes rattle { from { transform: translateY(0); } to { transform: translateY(-3px) rotate(2deg); } }
@keyframes squash { 0% { transform: scale(1.06, 0.92); } 100% { transform: none; } }
@keyframes recoil { 0% { transform: scale(1.12, 0.84); } 40% { transform: scale(0.95, 1.06); } 100% { transform: none; } }
@keyframes hop { 0% { transform: none; } 35% { transform: translateY(-14px); } 70% { transform: scale(1.04, 0.96); } 100% { transform: none; } }
@keyframes lid-fly {
  0% { transform: none; }
  18% { transform: translateY(-92px) rotate(-28deg); }
  36% { transform: translateY(-46px) rotate(12deg); }
  54% { transform: translateY(-74px) rotate(-20deg); }
  72% { transform: translateY(-56px) rotate(-8deg); }
  86% { transform: translateY(-66px) rotate(-16deg); }
  100% { transform: translateY(-62px) rotate(-14deg); }
}
@keyframes spring-fly {
  0% { transform: scaleY(0.04); }
  18% { transform: scaleY(1.39); }
  36% { transform: scaleY(0.7); }
  54% { transform: scaleY(1.12); }
  72% { transform: scaleY(0.85); }
  86% { transform: scaleY(1); }
  100% { transform: scaleY(0.94); }
}
@keyframes lid-lift { from { transform: none; } }
@keyframes spring-lift { from { transform: scaleY(0.04); } }
@keyframes glitter {
  0% { transform: translate(0, 0) scale(0.2); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(var(--dx), calc(var(--dy) + 36px)) rotate(var(--rot)); opacity: 0; }
}
@keyframes shake {
  0%, 100% { transform: none; }
  10% { transform: translate(-10px, 4px); } 20% { transform: translate(9px, -5px); } 30% { transform: translate(-8px, -3px); }
  40% { transform: translate(7px, 4px); } 55% { transform: translate(-5px, 2px); } 70% { transform: translate(4px, -2px); } 85% { transform: translate(-2px, 1px); }
}
@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: 1.75rem; } .masthead__art { width: 76px; height: 76px; } }
@media (max-height: 720px) { .play { gap: var(--s-1); } .hint, .kicker { display: none; } .stage { min-height: 64px; } .turn { font-size: 1.6rem; } .clock { height: 40px; } }
@media (max-height: 700px) { .end__art { height: 190px; padding-top: 40px; } .end__art .gz { width: 150px; height: 150px; } }

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