:root {
  color-scheme: light;
  --paper: oklch(98% 0.012 95); --paper-2: oklch(94.6% 0.02 92); --paper-3: oklch(90.5% 0.028 90);
  --ink: oklch(27% 0.03 340); --ink-2: oklch(41% 0.03 340); --muted: oklch(53% 0.025 340);
  --rule: oklch(88.5% 0.022 90);
  --butter: oklch(87% 0.13 92); --butter-2: oklch(82% 0.14 88); --butter-soft: oklch(94% 0.06 95);
  --plum: oklch(49% 0.16 350); --plum-2: oklch(43% 0.15 350); --plum-soft: oklch(93% 0.035 350);
  --face: oklch(99.2% 0.008 95); --edge: oklch(88% 0.03 90);
  --font: "Rubik", 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: 2.2rem; --t-3xl: 3.2rem;
  --dur: 140ms; --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --page: 30rem;
  --die: 112px;
  --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 200ms linear; }
body.is-bust { background: var(--plum); }
h1, h2, h3, 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(--ink); outline-offset: 2px; }
[hidden] { display: none !important; }
.noscript { padding: var(--s-5); }
.sr-only { 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-3); padding-top: calc(var(--s-3) + var(--safe-t)); padding-bottom: calc(var(--s-4) + 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(--plum); }
.lead { margin-top: var(--s-2); color: var(--ink-2); font-size: var(--t-lg); line-height: 1.35; max-width: 32ch; 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: 500; 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); }

.resume { padding: var(--s-4); border-radius: var(--radius); background: var(--butter-soft); }
.resume__text { margin-bottom: var(--s-3); color: var(--ink-2); overflow-wrap: anywhere; }

.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: 500; 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), opacity var(--dur) linear; }
.btn:hover { background: var(--paper-3); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--ink); color: var(--paper); }
.btn--primary:hover { background: var(--ink-2); }
.btn--accent { background: var(--butter); color: var(--ink); }
.btn--accent:hover { background: var(--butter-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); }
.link { background: none; border: 0; min-height: 44px; padding: var(--s-2) 0; font-size: var(--t-sm); font-weight: 500; color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--butter-2); 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(--butter-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:not(:disabled) { background: var(--paper-2); color: var(--ink); }
.remove:disabled { opacity: 0.3; cursor: default; }

.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: 500; 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 oklch(27% 0.03 340 / 0.16); }

.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(--plum); }
.drink-note { margin: 0 0 0 34px; }

.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(--butter-soft); }
.scores .sub { display: block; font-size: var(--t-sm); color: var(--muted); }
#wins-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(--plum); font-weight: 700; }
.foot { margin-top: var(--s-6); font-size: var(--t-sm); color: var(--muted); text-wrap: pretty; }

/* play */
.topline { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); min-height: 44px; }
.step { font-size: var(--t-sm); font-weight: 500; color: var(--muted); }

.board { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s-1); }
.board li { position: relative; flex: 1 1 0; min-width: 4.6rem; display: grid; gap: 1px; padding: 6px var(--s-2) 8px; border-radius: 12px; background: var(--paper-2); overflow: hidden; line-height: 1.15; transition: background-color var(--dur) linear; }
.board .who { font-size: 0.8rem; font-weight: 500; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board .pts { font-size: var(--t-lg); font-weight: 700; font-variant-numeric: tabular-nums; }
.board .pts small { margin-left: 3px; font-size: 0.75rem; font-weight: 500; color: var(--plum); }
.board .bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--plum); border-radius: 0 3px 3px 0; transition: width 300ms var(--ease); }
.board li.is-turn { background: var(--butter); }
.board li.is-turn .who { color: var(--ink); }
.board li.pop .pts { animation: pop 420ms var(--ease); }
.board--dark li { background: oklch(100% 0 0 / 0.13); color: var(--paper); }
.board--dark .who { color: oklch(93% 0.03 350); }
.board--dark .bar { background: var(--butter); }
.board--dark li.is-turn { background: oklch(100% 0 0 / 0.26); }
.board--dark li.is-turn .who { color: var(--paper); }

.stage { flex: 1; min-height: 360px; max-height: 600px; display: flex; flex-direction: column; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-4) var(--s-3); border-radius: var(--radius); background: var(--paper-2); text-align: center; }
.stage__head { display: grid; gap: 2px; width: 100%; }
.kicker { font-size: var(--t-sm); font-weight: 500; color: var(--muted); }
.turn-name { font-size: var(--t-2xl); overflow-wrap: anywhere; }
.stage__foot { display: grid; justify-items: center; gap: var(--s-1); width: 100%; }
.tally { font-size: var(--t-md); color: var(--ink-2); }
.tally b { font-size: var(--t-3xl); font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1; letter-spacing: -0.02em; margin-right: 2px; }
.tally.lost b { color: var(--plum); text-decoration: line-through; text-decoration-thickness: 5px; }
.tally.bump b { display: inline-block; animation: pop 360ms var(--ease); }
.rolls { list-style: none; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; min-height: 26px; }
.rolls li { min-width: 26px; height: 26px; padding: 0 7px; display: grid; place-items: center; border-radius: 8px; background: var(--paper); font-size: var(--t-sm); font-weight: 500; font-variant-numeric: tabular-nums; }
.rolls li.bad { background: var(--plum); color: var(--paper); }
.need { font-size: var(--t-sm); color: var(--muted); min-height: 1.5em; }
.undo { min-height: 44px; margin-top: -6px; }

/* dice */
.dice { flex: 1; display: flex; align-items: center; justify-content: center; gap: calc(var(--die) * 0.32); width: 100%; min-height: calc(var(--die) * 1.7); perspective: 700px; }
.dice.two { --die: 92px; }
.die-wrap { position: relative; width: var(--die); height: var(--die); }
.die-hop { width: 100%; height: 100%; transform-style: preserve-3d; }
.die-view { width: 100%; height: 100%; transform-style: preserve-3d; transform: rotateX(-16deg) rotateY(20deg); }
.die { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; }
.face, .core { position: absolute; inset: 0; border-radius: 22%; }
.face { display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 15%; background: var(--face); box-shadow: inset 0 0 0 2px var(--edge), inset 0 -6px 12px oklch(85% 0.03 90 / 0.55); backface-visibility: hidden; }
.core { background: var(--edge); border-radius: 12%; }
.pip { width: 74%; aspect-ratio: 1; margin: auto; border-radius: 50%; background: var(--ink); box-shadow: inset 0 2px 2px oklch(0% 0 0 / 0.25); }
.face--1 .pip { width: 112%; background: var(--plum); }
.die-shadow { position: absolute; left: 12%; right: 12%; bottom: calc(var(--die) * -0.34); height: 14px; border-radius: 50%; background: oklch(40% 0.03 340 / 0.16); filter: blur(4px); }
.dice.trap .face--1 { box-shadow: inset 0 0 0 3px var(--plum), inset 0 -6px 12px oklch(85% 0.03 90 / 0.55); }
.dice.trap .die-wrap { animation: shake 420ms linear; }

.actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); gap: var(--s-2); }
.btn--bank { min-height: 76px; padding-inline: var(--s-3); background: var(--paper); box-shadow: inset 0 0 0 2px var(--ink); font-size: var(--t-lg); font-weight: 700; line-height: 1.1; }
.btn--bank:hover { background: var(--paper-2); }
.btn--bank small { display: block; font-size: 0.75rem; font-weight: 500; }
.btn--roll { min-height: 76px; background: var(--butter); font-size: var(--t-xl); font-weight: 800; -webkit-touch-callout: none; }
.btn--roll:hover { background: var(--butter-2); }
.btn--roll:disabled, .btn--bank:disabled { opacity: 0.45; }

/* bust */
#bust { color: var(--paper); }
.bust__head { margin-top: var(--s-4); text-align: center; display: grid; justify-items: center; gap: var(--s-2); }
.bust__dice { width: 220px; height: auto; animation: tumble-in 640ms var(--ease) both; }
.bust__dice .dz--a { transform-origin: 120px 90px; animation: dizzy 1.4s ease-in-out 600ms infinite; }
.bust__dice .dz--b { transform-origin: 182px 96px; animation: dizzy 1.4s ease-in-out 700ms infinite reverse; }
.bust__dice .stars { transform-origin: 120px 40px; animation: twinkle 1.1s ease-in-out infinite; }
.bust__word { font-size: clamp(4.2rem, 24vw, 7rem); line-height: 0.9; letter-spacing: -0.03em; animation: thump 520ms var(--ease) 80ms both; }
.bust__word::after { content: ""; display: inline-block; width: 0.16em; height: 0.16em; margin-left: 0.06em; border-radius: 50%; background: var(--butter); }
.bust__line { max-width: 24ch; font-size: var(--t-lg); line-height: 1.3; font-weight: 500; text-wrap: balance; }
.bust__meta { font-size: var(--t-md); color: oklch(92% 0.035 350); max-width: 30ch; text-wrap: pretty; overflow-wrap: anywhere; }
.sips { margin-top: var(--s-1); padding: var(--s-2) var(--s-4); border-radius: var(--pill); background: var(--butter); color: var(--ink); font-weight: 700; overflow-wrap: anywhere; }
.sips--light { background: var(--plum-soft); color: var(--plum-2); }
.bust__body { flex: 1; display: flex; flex-direction: column; gap: var(--s-4); margin-top: var(--s-4); }
.bust__body .btn { margin-top: auto; }
.btn--light { background: var(--paper); color: var(--ink); }
.btn--light:hover { background: var(--paper-2); }
#bust :focus-visible { outline-color: var(--paper); }

/* won */
#won { position: relative; }
.won__head { margin-top: var(--s-6); text-align: center; display: grid; justify-items: center; gap: var(--s-2); }
.won__name { font-size: clamp(3rem, 15vw, 4.6rem); line-height: 0.95; overflow-wrap: anywhere; animation: thump 560ms var(--ease) both; }
.won__name::after { content: ""; display: inline-block; width: 0.18em; height: 0.18em; margin-left: 0.06em; border-radius: 50%; background: var(--butter-2); }
.won__meta { color: var(--ink-2); font-size: var(--t-lg); max-width: 28ch; text-wrap: balance; }
.final li .tag { margin-left: var(--s-2); font-size: var(--t-sm); color: var(--muted); }
.stack { display: grid; gap: var(--s-2); margin-top: auto; padding-top: var(--s-5); }
.confetti { position: absolute; inset: 0 0 auto 0; height: 280px; overflow: hidden; pointer-events: none; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 3px; opacity: 0; animation: fall 1800ms cubic-bezier(0.3, 0.6, 0.6, 1) both; }

@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.22); } 100% { transform: scale(1); } }
@keyframes thump { 0% { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.08); opacity: 1; } 100% { transform: none; } }
@keyframes shake { 0%, 100% { transform: none; } 15% { transform: translateX(-9px) rotate(-6deg); } 35% { transform: translateX(8px) rotate(5deg); } 55% { transform: translateX(-6px) rotate(-3deg); } 75% { transform: translateX(4px) rotate(2deg); } }
@keyframes tumble-in { 0% { transform: translateY(-60px) rotate(-200deg) scale(0.5); opacity: 0; } 70% { transform: translateY(6px) rotate(8deg) scale(1.04); opacity: 1; } 100% { transform: none; } }
@keyframes dizzy { 0%, 100% { transform: rotate(-5deg); } 50% { transform: rotate(5deg); } }
@keyframes twinkle { 0%, 100% { transform: rotate(-6deg) scale(1); opacity: 1; } 50% { transform: rotate(6deg) scale(0.9); opacity: 0.6; } }
@keyframes fall { 0% { opacity: 1; transform: translateY(0) rotate(0); } 100% { opacity: 0; transform: translateY(280px) rotate(540deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } .confetti { display: none; } }
@media (max-width: 22.5rem) { :root { --t-3xl: 2.7rem; --t-2xl: 1.9rem; --die: 100px; } .dice.two { --die: 82px; } .board li { min-width: 4.2rem; } }
@media (max-height: 700px) { :root { --die: 92px; } .dice.two { --die: 78px; } .stage { min-height: 300px; } .bust__dice { width: 170px; } }

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