:root {
  color-scheme: light;
  --paper: #f8f6f1; --paper-2: #efebe3; --paper-3: #e6dfd2;
  --ink: #2c2433; --ink-2: #4a4152; --muted: #766c7c;
  --rule: #e2dcd2;
  --cup: #7a3b8f; --cup-dark: #5e2a70; --cup-light: #9d5fb1;
  --accent: #7a3b8f; --accent-soft: #efe2f2; --accent-ink: #4f2160;
  --ball: #eab72f; --ball-light: #fbe7a6; --ball-dark: #c8961a;
  --hit: #6a2d7e; --hit-2: #57226a;
  --font: "Lexend", 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);
  --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; transition: background-color 220ms linear; }
body.is-caught { background: var(--hit); }
h1, h2, h3, p, ol, ul { margin: 0; }
h1, h2 { font-weight: 700; 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(--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.08em; border-radius: 50%; background: var(--ball); }
.lead { margin-top: var(--s-2); color: var(--ink-2); font-size: var(--t-lg); line-height: 1.4; max-width: 34ch; text-wrap: pretty; }
.hero { margin-top: var(--s-5); }
.hero svg { display: block; width: 100%; max-width: 280px; height: auto; }

.block { margin-top: var(--s-6); }
.label { display: block; margin-bottom: var(--s-2); font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); }
.label .opt { font-weight: 400; 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: 600; font-size: var(--t-md); 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:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--cup); color: var(--paper); }
.btn--primary:hover { background: var(--cup-dark); }
.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); }
.link { 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(--ball); text-decoration-thickness: 2px; 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(--cup-light); 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); }

.toggles { margin: var(--s-5) 0; }
.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(--cup); }
.drink-note { margin-top: 0 !important; padding-left: calc(22px + var(--s-3)); }

.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: 700; }
.scores li.top { background: var(--accent-soft); }
.scores li .plus { font-size: var(--t-sm); font-weight: 600; margin-right: var(--s-2); }
#scores-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(--cup); font-weight: 700; }
.foot { margin-top: var(--s-6); font-size: var(--t-sm); color: var(--muted); }

/* play */
.topline { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-height: 44px; }
.level { padding: var(--s-1) var(--s-3); border-radius: var(--pill); background: var(--accent-soft); color: var(--accent-ink); font-size: var(--t-sm); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.status { display: grid; align-content: center; gap: var(--s-1); min-height: 8.5rem; padding: var(--s-4) var(--s-5); border-radius: var(--radius); background: var(--paper-2); text-align: center; }
.who { min-height: 1.5em; font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); overflow-wrap: anywhere; }
.caption { font-size: var(--t-2xl); font-weight: 700; line-height: 1.1; letter-spacing: -0.01em; text-wrap: balance; overflow-wrap: anywhere; }
.caption.pop { animation: pop 260ms var(--ease) both; }
.caption.good { color: var(--accent-ink); }
.sub { min-height: 1.5em; color: var(--ink-2); text-wrap: pretty; }

/* the table: cups move on transforms only, the buttons on top stay put and only know their position */
.table { position: relative; flex: 1; min-height: 240px; max-height: 440px; border-radius: var(--radius); background: var(--paper-2); overflow: hidden; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.table::after { content: ""; position: absolute; left: 0; right: 0; bottom: 52px; height: 2px; background: var(--paper-3); }
.table.is-hit { animation: shake 420ms var(--ease) both; }
.cups { position: absolute; inset: 0 var(--s-2); pointer-events: none; --cup-w: 90px; }
.cup { position: absolute; left: 0; bottom: 50px; width: var(--cup-w); height: calc(var(--cup-w) * 1.35); z-index: 3; will-change: transform; }
.cup::before { content: ""; position: absolute; left: 6%; right: 6%; bottom: -5px; height: 10px; border-radius: 50%; background: var(--paper-3); }
.cup__lift { position: absolute; inset: 0; transition: transform 300ms var(--ease); }
.cup.is-up .cup__lift { transform: translateY(-62%); }
.cup svg { display: block; width: 100%; height: 100%; transform-origin: 50% 95%; }
.cup.is-wobble svg { animation: wobble 180ms ease-in-out infinite alternate; }
.ball { position: absolute; bottom: 50px; width: calc(var(--cup-w) * 0.42); height: calc(var(--cup-w) * 0.42); border-radius: 50%; background: var(--ball); box-shadow: inset -3px -4px 0 var(--ball-dark); z-index: 1; }
.ball::after { content: ""; position: absolute; left: 22%; top: 18%; width: 28%; height: 28%; border-radius: 50%; background: var(--ball-light); }
.ball.is-found { animation: bounce 520ms var(--ease) 120ms both; }
.slots { position: absolute; inset: 0 var(--s-2); display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); z-index: 5; }
.slot { position: relative; display: flex; align-items: flex-end; justify-content: center; padding: 0 0 var(--s-2); border: 0; border-radius: 14px; background: transparent; cursor: pointer; touch-action: manipulation; }
.slot:disabled { cursor: default; }
.slot:not(:disabled):hover { background: oklch(100% 0 0 / 0.35); }
.slot:focus-visible { outline-offset: -4px; }
.slot__num { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); font-size: var(--t-sm); font-weight: 600; font-variant-numeric: tabular-nums; transition: background-color var(--dur) linear, color var(--dur) linear; }
.slot:not(:disabled) .slot__num { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px oklch(30% 0.03 320 / 0.18); }
.slot.is-swap .slot__num { background: var(--ball); color: var(--ink); }
.slot.is-picked .slot__num { background: var(--cup); color: var(--paper); }
#go { margin-top: auto; }
#go.is-off { visibility: hidden; }

/* caught */
#caught { color: var(--paper); }
.caught__head { margin-top: var(--s-6); text-align: center; animation: thump 520ms var(--ease) both; }
.caught__word { font-size: clamp(4rem, 22vw, 6.5rem); line-height: 0.9; }
.caught__word::after { content: ""; display: inline-block; width: 0.16em; height: 0.16em; margin-left: 0.06em; border-radius: 50%; background: var(--ball); }
.caught__line { margin: var(--s-4) auto 0; max-width: 24ch; font-size: var(--t-lg); line-height: 1.3; font-weight: 500; text-wrap: balance; overflow-wrap: anywhere; }
.caught__drink { display: inline-block; margin-top: var(--s-4); padding: var(--s-2) var(--s-4); border-radius: var(--pill); background: var(--ball); color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
.caught__meta { margin-top: var(--s-3); font-size: var(--t-sm); color: oklch(90% 0.03 320); text-wrap: balance; }
.caught__body { flex: 1; display: flex; flex-direction: column; gap: var(--s-5); margin-top: var(--s-3); }
#caught .label { color: oklch(92% 0.03 320); }
#caught .scores li { background: oklch(100% 0 0 / 0.12); }
#caught .scores li.top { background: oklch(100% 0 0 / 0.24); }
#caught .scores li .plus { color: var(--ball); }
.stack { display: grid; gap: var(--s-2); margin-top: auto; padding-top: var(--s-3); }
.btn--light { background: var(--paper); color: var(--ink); }
.btn--light:hover { background: var(--paper-2); }
.btn--ghost { background: transparent; color: var(--paper); box-shadow: inset 0 0 0 1.5px oklch(100% 0 0 / 0.45); }
.btn--ghost:hover { background: oklch(100% 0 0 / 0.12); }
#caught :focus-visible { outline-color: var(--paper); }

@keyframes pop { from { opacity: 0.3; transform: scale(0.94); } to { opacity: 1; transform: none; } }
@keyframes thump { 0% { transform: scale(0.7); opacity: 0; } 60% { transform: scale(1.06); opacity: 1; } 100% { transform: none; } }
@keyframes wobble { from { transform: rotate(-3.5deg); } to { transform: rotate(3.5deg); } }
@keyframes bounce { 0% { transform: none; } 40% { transform: translateY(-34px); } 70% { transform: none; } 85% { transform: translateY(-8px); } 100% { transform: none; } }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-10px); } 40% { transform: translateX(9px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(3px); } }
@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; } .status { padding-inline: var(--s-4); } }
@media (max-height: 680px) { .status { min-height: 7rem; padding-block: var(--s-3); } .table { min-height: 210px; } }

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