/* The Benny Games.
   Palette + type from [[linear]] (vaults/crunch/profiles/linear.md):
   ground #0F1011, deep #08090A, line rgb(35,37,42), text #F7F8F8 / #D0D6E0 / #8A8F98,
   accent #5E6AD2, white pill as the one primary action, Inter, h1 510 at -0.022em,
   hover rgba(255,255,255,.08), blur(20px) sticky chrome.
   Motion splash from the [[whop-hub]] mix: press scale .97 / 120ms, enter 4px / 180ms,
   same curve; plus one earned flourish, the dice tumble.
   Invented, not in the vault: --danger, the dice themselves. */

:root {
  --bg: #0F1011;
  --deep: #08090A;
  --line: #23252A;
  --line-2: #2E3138;
  --text: #F7F8F8;
  --text-2: #D0D6E0;
  --muted: #8A8F98;
  --accent: #5E6AD2;
  --danger: #EB5757;
  --hover: rgba(255, 255, 255, .08);
  --panel: rgba(255, 255, 255, .02);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --bar: 84px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: 'Inter var', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-feature-settings: 'cv11', 'ss01';
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); color: var(--text-2); }
body { font-size: 15px; line-height: 1.6; min-height: 100dvh; -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; color: inherit; }
h1, h2, h3 { color: var(--text); font-weight: 510; letter-spacing: -0.022em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

.enter { animation: enter 180ms var(--ease) both; }
@keyframes enter { from { opacity: 0; transform: translateY(4px); } }

/* Buttons: pills, white is the primary action, everything else is a quiet outline */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: 9999px;
  border: 1px solid var(--line-2); background: transparent; color: var(--text);
  font-size: 15px; font-weight: 510; cursor: pointer; white-space: nowrap;
  transition: transform 120ms var(--ease), background 120ms var(--ease), opacity 120ms;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.primary:hover { background: #fff; }
.btn.ghost { border-color: transparent; color: var(--muted); height: 36px; padding: 0 12px; }
.btn.ghost:hover { color: var(--text); }
.btn:disabled { opacity: .35; pointer-events: none; }
.btn.grow { flex: 1; }

.card { border: 1px solid var(--line); background: var(--panel); border-radius: 12px; }

input.field {
  height: 44px; padding: 0 14px; border-radius: 9999px; border: 1px solid var(--line-2);
  background: var(--deep); outline: none; min-width: 0; flex: 1; color: var(--text);
}
input.field:focus { border-color: var(--accent); }

/* Home */
.home { max-width: 560px; margin: 0 auto; padding: 56px 20px 48px; display: grid; gap: 28px; }
.home-head { display: grid; gap: 8px; }
.home-head h1 { font-size: 38px; line-height: 1.05; }
.mark { width: 40px; height: 40px; margin-bottom: 12px; }
.games { display: grid; gap: 12px; }
.game { display: grid; grid-template-columns: auto 1fr; gap: 14px 16px; padding: 18px; align-items: center; }
.game h2 { font-size: 20px; }
.game p { font-size: 14px; color: var(--muted); line-height: 1.45; }
.game .btn { grid-column: 1 / -1; }
.game.soon { opacity: .55; }
.tag { font-size: 12px; color: var(--muted); border: 1px solid var(--line-2); border-radius: 9999px; padding: 2px 8px; margin-left: 6px; vertical-align: 3px; font-weight: 400; letter-spacing: 0; }
.join { display: flex; gap: 8px; padding: 8px; }
.join .field { text-transform: uppercase; letter-spacing: .12em; }

/* Room chrome: sticky header, pinned bottom bar */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 4px;
  height: 56px; padding: 0 8px; background: rgba(15, 16, 17, .78);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-bottom: 1px solid var(--line);
}
.top h1 { font-size: 17px; margin-right: auto; display: flex; align-items: center; gap: 8px; }
.code-chip { font-size: 12px; font-weight: 510; letter-spacing: .14em; color: var(--muted); border: 1px solid var(--line-2); border-radius: 9999px; padding: 2px 8px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); display: inline-block; }

.room { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(var(--bar) + var(--safe-b) + 24px); display: grid; gap: 16px; }

.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 12px 16px calc(12px + var(--safe-b));
  background: rgba(8, 9, 10, .86); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
}
.bar-in { max-width: 560px; margin: 0 auto; display: flex; gap: 8px; align-items: center; min-height: 44px; }
.bar-note { flex: 1; font-size: 14px; color: var(--muted); line-height: 1.3; }
.bar-note b { color: var(--text); font-weight: 510; }

/* Scoreboard */
.board { list-style: none; display: grid; }
.p { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 10px 14px; position: relative; }
.p + .p { border-top: 1px solid var(--line); }
.p.cur::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px; border-radius: 2px; background: var(--accent); }
.p-name { color: var(--text); font-weight: 510; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-name em { font-style: normal; font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 4px; }
.p-score { color: var(--text); font-weight: 510; font-variant-numeric: tabular-nums; }
.p-sub { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.p-bar { flex: 1; height: 2px; background: var(--line-2); border-radius: 2px; overflow: hidden; }
.p-bar i { display: block; height: 100%; background: var(--text-2); border-radius: 2px; transition: width 400ms var(--ease); }
.p.cur .p-bar i { background: var(--accent); }
.off { color: var(--danger); }
.winner .p-score::after { content: ' 👑'; }

/* The table */
.table { padding: 18px 16px 20px; display: grid; gap: 16px; justify-items: center; text-align: center; }
.status { font-size: 15px; color: var(--text-2); min-height: 24px; }
.status.bust { color: var(--danger); font-weight: 510; }
.status.hot { color: var(--accent); font-weight: 510; }
.turn-pts { font-size: 38px; line-height: 1; font-weight: 510; letter-spacing: -0.022em; color: var(--text); font-variant-numeric: tabular-nums; }
.turn-pts small { display: block; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 510; margin-bottom: 8px; }
.held { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; min-height: 0; }
.held-g { display: flex; gap: 3px; align-items: center; padding: 4px 8px 4px 4px; border: 1px solid var(--line); border-radius: 9999px; }
.held-g span.pts { font-size: 12px; color: var(--muted); margin-left: 4px; font-variant-numeric: tabular-nums; }
.dice { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; width: 100%; max-width: 420px; min-height: 60px; }
.hint { font-size: 13px; color: var(--muted); min-height: 20px; }
.hint.bad { color: var(--danger); }
.final { padding: 10px 14px; text-align: center; font-size: 14px; color: var(--text); border-color: rgba(94, 106, 210, .5); background: rgba(94, 106, 210, .08); }
.log { list-style: none; font-size: 13px; color: var(--muted); display: grid; gap: 2px; padding: 0 4px; }
.log li:first-child { color: var(--text-2); }

/* Dice */
.die {
  position: relative; aspect-ratio: 1; width: 100%; max-width: 60px; justify-self: center;
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 18%;
  background: var(--text); border-radius: 22%; border: 0; cursor: default;
  transition: transform 160ms var(--ease), box-shadow 160ms var(--ease), opacity 160ms;
}
.die i { width: 70%; aspect-ratio: 1; border-radius: 50%; place-self: center; }
.die i.on { background: var(--bg); }
button.die { cursor: pointer; }
button.die:active { transform: scale(.94); }
.die.sel { transform: translateY(-6px); box-shadow: 0 0 0 3px var(--accent); }
.die.sel i.on { background: var(--accent); }
.dice.wait .die { opacity: .9; }
.die.mini { width: 22px; max-width: 22px; padding: 4px; border-radius: 6px; background: var(--text-2); }
.die.mini i { width: 80%; }
.ghost-die { aspect-ratio: 1; width: 100%; max-width: 60px; justify-self: center; border-radius: 22%; border: 1px dashed var(--line-2); }

.dice.rolling .die { animation: tumble 520ms var(--ease) both; }
.dice.rolling .die:nth-child(2n) { animation-delay: 40ms; }
.dice.rolling .die:nth-child(3n) { animation-delay: 80ms; }
@keyframes tumble {
  0% { transform: translateY(-14px) rotate(-24deg) scale(.9); opacity: .4; }
  45% { transform: translateY(3px) rotate(14deg); opacity: 1; }
  75% { transform: translateY(-2px) rotate(-5deg); }
  100% { transform: none; }
}
.dice.shake { animation: shake 420ms var(--ease); }
.dice.shake .die { opacity: .55; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* Lobby */
.lobby { padding: 20px 16px; display: grid; gap: 14px; text-align: center; }
.big-code { font-size: 38px; font-weight: 510; letter-spacing: .18em; color: var(--text); line-height: 1; padding-left: .18em; }
.seats { list-style: none; display: grid; gap: 0; text-align: left; }
.seats li { padding: 10px 14px; color: var(--text); font-weight: 510; display: flex; justify-content: space-between; }
.seats li + li { border-top: 1px solid var(--line); }
.seats li span { color: var(--muted); font-weight: 400; font-size: 13px; }

/* Rules sheet: fits the screen, never scrolls inside */
dialog#rules { margin: auto; border: 1px solid var(--line); background: var(--bg); color: var(--text-2); border-radius: 16px; width: min(520px, calc(100vw - 24px)); padding: 0; }
dialog#rules::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(4px); }
.sheet { padding: 16px 18px 18px; display: grid; gap: 12px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet h2 { font-size: 18px; }
#rules-table { border-collapse: collapse; width: 100%; font-size: 14px; }
#rules-table td { padding: 7px 0; border-top: 1px solid var(--line); vertical-align: top; }
#rules-table td:last-child { text-align: right; color: var(--text); padding-left: 12px; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--bar) + var(--safe-b) + 16px); z-index: 20;
  transform: translate(-50%, 8px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 510;
  padding: 8px 14px; border-radius: 9999px; transition: opacity 180ms var(--ease), transform 180ms var(--ease);
  max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
