/* Chip Shift — "game night felt" theme.
   Tokens first; every color in the UI comes from these so themes stay coherent. */

:root {
  --font: "Bricolage Grotesque", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px -12px rgba(30, 20, 10, .35);
  --shadow-lg: 0 30px 60px -20px rgba(20, 12, 5, .5);
  --ease-out: cubic-bezier(.2, .9, .25, 1.15);
  --ease: cubic-bezier(.4, 0, .2, 1);

  /* light: cream tablecloth, bright felt */
  --bg: #f4ecdb;
  --bg-pattern: rgba(160, 110, 50, .07);
  --surface: #fffaf0;
  --surface-2: #f7efdf;
  --ink: #1f2420;
  --muted: #6c6a5f;
  --line: rgba(60, 40, 20, .13);
  --felt: #2f7d58;
  --felt-2: #3b9468;
  --felt-edge: #1f5a3e;
  --rim: #8a5a33;
  --rim-2: #6b4223;
  --accent: #e8a90c;
  --accent-ink: #2b1d00;
  --danger: #d9443b;
  --ok: #1f9d63;
  --focus: #2563eb;
  --die: #fffdf6;
  --die-ink: #1f2420;
  --die-shade: #e6dcc6;
  --die8: #e7f7f1;
  --die8-shade: #bfe3d5;
  --die10: #f1ecff;
  --die10-shade: #d4c9f5;

  --tone-red: #d6333a;
  --tone-blue: #2368d8;
  --tone-green: #138a55;
  --tone-gold: #c58700;
  --tone-violet: #7442d6;
  --tone-teal: #0c8c80;
  --tone-ink: #22262a;
  --tone-coral: #e2583b;

  --av-0: #f97362; --av-1: #f6b33b; --av-2: #57c785; --av-3: #3fa7e8; --av-4: #9b7bf2;
  --av-5: #f27ab8; --av-6: #2fc4b2; --av-7: #e8854a; --av-8: #8aa1b8; --av-9: #c2d14b;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b1511;
  --bg-pattern: rgba(255, 255, 255, .025);
  --surface: #13221b;
  --surface-2: #192c23;
  --ink: #f3eee2;
  --muted: #9fb1a5;
  --line: rgba(255, 255, 255, .09);
  --felt: #155037;
  --felt-2: #1c6145;
  --felt-edge: #0b3021;
  --rim: #4a2c17;
  --rim-2: #321c0d;
  --accent: #ffc83d;
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, .7);
  --shadow-lg: 0 30px 60px -20px rgba(0, 0, 0, .8);
  --focus: #7cb2ff;
  --tone-ink: #22262a;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1511;
    --bg-pattern: rgba(255, 255, 255, .025);
    --surface: #13221b;
    --surface-2: #192c23;
    --ink: #f3eee2;
    --muted: #9fb1a5;
    --line: rgba(255, 255, 255, .09);
    --felt: #155037;
    --felt-2: #1c6145;
    --felt-edge: #0b3021;
    --rim: #4a2c17;
    --rim-2: #321c0d;
    --accent: #ffc83d;
    --shadow: 0 10px 30px -12px rgba(0, 0, 0, .7);
    --shadow-lg: 0 30px 60px -20px rgba(0, 0, 0, .8);
    --focus: #7cb2ff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    linear-gradient(45deg, var(--bg-pattern) 25%, transparent 25%, transparent 75%, var(--bg-pattern) 75%),
    linear-gradient(45deg, var(--bg-pattern) 25%, transparent 25%, transparent 75%, var(--bg-pattern) 75%);
  background-size: 44px 44px;
  background-position: 0 0, 22px 22px;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------- shell */
.app { max-width: 560px; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; gap: 8px; min-height: 48px; }
.topbar .brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; letter-spacing: -.02em; text-decoration: none; color: inherit; margin-right: auto; }
.brand-chip { width: 30px; height: 30px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  display: inline-grid; place-items: center; cursor: pointer; box-shadow: 0 2px 0 var(--line);
  transition: transform .15s var(--ease);
}
.icon-btn:active { transform: translateY(2px); box-shadow: none; }
.icon-btn svg { width: 20px; height: 20px; }
.room-pill { font-weight: 800; letter-spacing: .12em; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 15px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.card h2 { margin: 0 0 12px; font-size: 18px; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.stack > * + * { margin-top: 10px; }

.btn {
  --b: var(--surface-2); --c: var(--ink);
  appearance: none; border: 0; cursor: pointer; font-weight: 750; font-size: 16px;
  padding: 13px 18px; border-radius: 14px; background: var(--b); color: var(--c);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--b) 60%, #000), inset 0 1px 0 rgba(255,255,255,.25);
  transition: transform .12s var(--ease), box-shadow .12s var(--ease), filter .2s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px;
  text-decoration: none;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 color-mix(in srgb, var(--b) 60%, #000); }
.btn:disabled { filter: grayscale(.7) opacity(.55); cursor: not-allowed; }
.btn.primary { --b: var(--accent); --c: var(--accent-ink); }
.btn.felt { --b: var(--felt-2); --c: #fff; }
.btn.danger { --b: var(--danger); --c: #fff; }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.block { width: 100%; }
.btn.lg { font-size: 19px; min-height: 58px; border-radius: 18px; }

.input {
  width: 100%; padding: 13px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface-2);
  font-size: 17px; min-height: 50px;
}
.input:focus { outline: none; border-color: var(--focus); }
.code-input { text-transform: uppercase; letter-spacing: .35em; font-weight: 800; text-align: center; font-size: 22px; }
label.field { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 55%, calc(100% - 14px) 55%; background-size: 6px 6px; background-repeat: no-repeat; }

.toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 650; }
.toggle input { appearance: none; width: 46px; height: 28px; border-radius: 999px; background: var(--line); position: relative; flex: none; cursor: pointer; transition: background .2s; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s var(--ease-out); }
.toggle input:checked { background: var(--ok); }
.toggle input:checked::after { transform: translateX(18px); }

/* ------------------------------------------------------------- home */
.hero { text-align: center; padding: 18px 0 8px; }
.hero h1 { font-size: clamp(44px, 13vw, 64px); line-height: .9; margin: 6px 0 8px; letter-spacing: -.045em; font-weight: 800; }
.hero h1 span { color: var(--accent); display: inline-block; transform: rotate(-4deg); }
.hero p { margin: 0 auto; max-width: 30ch; color: var(--muted); font-size: 17px; }
.hero-dice { display: flex; justify-content: center; gap: 10px; margin: 6px 0 10px; height: 64px; align-items: center; }
.hero-dice .die { animation: bob 3.2s ease-in-out infinite; }
.hero-dice .die:nth-child(2) { animation-delay: -1s; }
.hero-dice .die:nth-child(3) { animation-delay: -2s; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(6deg); } }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; font-weight: 700; margin: 14px 0; text-transform: uppercase; letter-spacing: .1em; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.nearby-list { display: grid; gap: 8px; }
.nearby-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); cursor: pointer; text-align: left; width: 100%; }
.nearby-item b { letter-spacing: .12em; }
.leader { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.leader:last-child { border: 0; }

details.howto summary { cursor: pointer; font-weight: 800; font-size: 18px; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.howto summary::-webkit-details-marker { display: none; }
details.howto summary::after { content: "+"; font-size: 24px; transition: transform .2s; }
details.howto[open] summary::after { transform: rotate(45deg); }
.rules-list { padding-left: 20px; line-height: 1.5; }

/* ------------------------------------------------------------- avatars */
.avatar {
  --c: var(--av-0);
  width: 44px; height: 44px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--c) 70%, #fff), var(--c));
  font-size: 24px; line-height: 1; box-shadow: inset 0 -3px 0 rgba(0,0,0,.18), 0 2px 6px rgba(0,0,0,.2);
  position: relative;
}
.avatar.sm { width: 34px; height: 34px; font-size: 18px; }
.avatar.lg { width: 72px; height: 72px; font-size: 40px; }
.emoji-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.emoji-grid button { aspect-ratio: 1; border-radius: 14px; border: 2px solid transparent; background: var(--surface-2); font-size: 26px; cursor: pointer; }
.emoji-grid button[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--surface)); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 2px var(--line); cursor: pointer; }
.swatches button[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--ink); }

/* ------------------------------------------------------------- lobby */
.share-code { font-size: 54px; font-weight: 800; letter-spacing: .14em; text-align: center; line-height: 1; margin: 4px 0 12px; }
.qr-box { background: #fff; padding: 10px; border-radius: 16px; width: min(220px, 70vw); margin: 10px auto 0; }
.qr-box img { width: 100%; display: block; image-rendering: pixelated; }
.player-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.player-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 14px; background: var(--surface-2); animation: pop-in .35s var(--ease-out) both; }
.player-row .name { font-weight: 750; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; padding: 3px 7px; border-radius: 999px; background: var(--line); color: var(--muted); }
.tag.host { background: color-mix(in srgb, var(--accent) 25%, transparent); color: color-mix(in srgb, var(--accent) 60%, var(--ink)); }
.tag.off { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger); }
@keyframes pop-in { from { opacity: 0; transform: scale(.85) translateY(6px); } }

.ruleset-grid { display: grid; gap: 10px; }
.ruleset-card { text-align: left; padding: 12px 14px; border-radius: 16px; border: 2px solid var(--line); background: var(--surface-2); cursor: pointer; width: 100%; transition: border-color .2s, transform .15s; }
.ruleset-card[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.ruleset-card:disabled { cursor: default; }
.ruleset-card .rs-head { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; }
.ruleset-card .rs-dice { display: flex; gap: 6px; margin-left: auto; }
.ruleset-card p { margin: 6px 0 0; font-size: 14px; color: var(--muted); line-height: 1.35; }

.legend { display: grid; gap: 6px; }
.legend-die-title { font-weight: 800; margin: 10px 0 4px; display: flex; align-items: center; gap: 8px; }
.legend-row { display: flex; align-items: center; gap: 10px; font-size: 14px; line-height: 1.3; }
.legend-row .die { flex: none; }
.legend-row b { min-width: 70px; }

/* ------------------------------------------------------------- dice */
.die {
  --s: 46px; --body: var(--die); --shade: var(--die-shade); --tone: var(--tone-ink);
  width: var(--s); height: var(--s); position: relative; display: inline-grid; place-items: center; flex: none;
  color: var(--tone); font-weight: 900; font-size: calc(var(--s) * .52); line-height: 1;
  filter: drop-shadow(0 3px 0 var(--shade)) drop-shadow(0 6px 8px rgba(0,0,0,.25));
}
.die::before { content: ""; position: absolute; inset: 0; background: var(--body); border-radius: 24%; }
.die.d8 { --body: var(--die8); --shade: var(--die8-shade); }
.die.d8::before { border-radius: 0; clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%); }
.die.d10 { --body: var(--die10); --shade: var(--die10-shade); }
.die.d10::before { border-radius: 0; clip-path: polygon(50% 0, 100% 38%, 82% 100%, 18% 100%, 0 38%); }
.die.d10 .die-face { transform: translateY(8%); }
.die .die-face { position: relative; display: grid; place-items: center; width: 100%; height: 100%; }
.die .die-face svg { width: 56%; height: 56%; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.die .die-face svg.fill { fill: currentColor; stroke: none; }
.die .die-tag { position: absolute; bottom: -2px; right: -4px; font-size: max(9px, calc(var(--s) * .16)); font-weight: 800; padding: 1px 4px; border-radius: 6px; background: var(--ink); color: var(--bg); opacity: .85; letter-spacing: .02em; }
.die.sm { --s: 30px; }
.die.sm .die-tag { display: none; }
.die.lg { --s: 64px; }
.die.xl { --s: clamp(64px, 7vw, 110px); }
.tone-red { --tone: var(--tone-red); } .tone-blue { --tone: var(--tone-blue); } .tone-green { --tone: var(--tone-green); }
.tone-gold { --tone: var(--tone-gold); } .tone-violet { --tone: var(--tone-violet); } .tone-teal { --tone: var(--tone-teal); }
.tone-ink { --tone: var(--tone-ink); } .tone-coral { --tone: var(--tone-coral); }
.die.blank .die-face { opacity: .2; }

.die.tumbling { animation: tumble .16s linear infinite; }
@keyframes tumble {
  0% { transform: translate(0, 0) rotate(0); }
  25% { transform: translate(3px, -6px) rotate(80deg); }
  50% { transform: translate(-2px, -2px) rotate(170deg); }
  75% { transform: translate(-4px, -7px) rotate(260deg); }
  100% { transform: translate(0, 0) rotate(360deg); }
}
.die.landed { animation: land .45s var(--ease-out); }
@keyframes land { 0% { transform: scale(1.35) rotate(-14deg); } 60% { transform: scale(.92) rotate(4deg); } 100% { transform: none; } }
.die.active { animation: pulse .55s var(--ease-out); z-index: 2; }
.die.active::after { content: ""; position: absolute; inset: -6px; border-radius: 30%; border: 3px solid var(--accent); animation: ring .6s var(--ease) forwards; }
@keyframes pulse { 40% { transform: scale(1.22); } }
@keyframes ring { from { opacity: 1; transform: scale(.9); } to { opacity: 0; transform: scale(1.25); } }
.die.used { opacity: .68; filter: grayscale(.4) drop-shadow(0 3px 0 var(--shade)); }
.die.fizzle { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
.die.pick { animation: pick-wiggle 1s ease-in-out infinite; cursor: grab; touch-action: none; }
.die.pick::after { content: ""; position: absolute; inset: -7px; border-radius: 30%; border: 3px dashed var(--accent); }
@keyframes pick-wiggle { 50% { transform: rotate(-8deg) scale(1.08); } }
.die.dragging { cursor: grabbing; animation: none; z-index: 50; }

/* ------------------------------------------------------------- chips */
.chip {
  --c: var(--accent);
  width: 22px; height: 22px; border-radius: 50%; display: inline-block; position: relative;
  background: var(--c);
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--c) 70%, #000), inset 0 0 0 5px rgba(255,255,255,.85), inset 0 0 0 7px var(--c), 0 2px 0 color-mix(in srgb, var(--c) 55%, #000);
}
.chip::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: repeating-conic-gradient(rgba(255,255,255,.9) 0 12deg, transparent 12deg 45deg); -webkit-mask: radial-gradient(circle, transparent 54%, #000 55%, #000 74%, transparent 75%); mask: radial-gradient(circle, transparent 54%, #000 55%, #000 74%, transparent 75%); }
.flying-chip { position: fixed; z-index: 1000; pointer-events: none; left: 0; top: 0; will-change: transform; }

/* ------------------------------------------------------------- table */
.table-wrap { position: relative; width: 100%; aspect-ratio: 1 / 1; max-width: 460px; margin: 8px auto 0; }
.table-felt {
  position: absolute; inset: 15%; border-radius: 50%;
  background: radial-gradient(ellipse at 50% 38%, var(--felt-2), var(--felt) 60%, var(--felt-edge));
  box-shadow: 0 0 0 10px var(--rim), 0 0 0 13px var(--rim-2), inset 0 6px 30px rgba(0,0,0,.35), var(--shadow-lg);
}
.table-felt::before { content: ""; position: absolute; inset: 9%; border-radius: 50%; border: 2px dashed rgba(255,255,255,.14); }
.direction { position: absolute; inset: 3%; border-radius: 50%; pointer-events: none; opacity: .55; color: var(--muted); transition: transform .8s var(--ease-out); }
.direction svg { width: 100%; height: 100%; }
.display .direction { inset: 5% 6%; }
.direction.ccw { transform: scaleX(-1); }
.center-stack { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: #fff; text-align: center; pointer-events: none; }
.pot { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.pot-pile { position: relative; width: 70px; height: 40px; }
.pot-pile .chip { position: absolute; transition: transform .3s var(--ease-out); }
.pot-count { font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .1em; opacity: .9; }
.pot-count b { font-size: 20px; letter-spacing: 0; }
.dice-row { display: flex; gap: 8px; min-height: 50px; align-items: center; justify-content: center; pointer-events: auto; }
.dice-row .die { --s: clamp(34px, 10vw, 46px); }

.seat {
  position: absolute; width: 74px; margin-left: -37px; margin-top: -40px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: left .5s var(--ease), top .5s var(--ease), opacity .3s; text-align: center; background: none; border: 0; padding: 0; cursor: default;
}
.seat .avatar { transition: transform .3s var(--ease-out), box-shadow .3s; }
.seat .seat-name { font-size: 12px; font-weight: 750; max-width: 74px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 1px 6px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.seat .seat-chips { position: absolute; top: -6px; right: 8px; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 999px; display: grid; place-items: center; font-weight: 800; font-size: 14px; background: var(--ink); color: var(--bg); border: 2px solid var(--surface); transition: transform .25s var(--ease-out); }
.seat .seat-chips.bump { animation: bump .35s var(--ease-out); }
@keyframes bump { 50% { transform: scale(1.45); } }
.seat.out .avatar { filter: grayscale(1) opacity(.55); }
.seat.out .seat-chips { background: var(--line); color: var(--muted); }
.seat.me .seat-name { background: var(--ink); color: var(--bg); }
.seat.turn .avatar { transform: translateY(-5px) scale(1.15); box-shadow: 0 0 0 4px var(--accent), 0 0 24px 4px color-mix(in srgb, var(--accent) 60%, transparent); }
.seat .timer-ring { position: absolute; top: -5px; left: 50%; width: 54px; height: 54px; margin-left: -27px; border-radius: 50%; pointer-events: none; background: conic-gradient(var(--accent) calc(var(--p, 1) * 360deg), transparent 0); -webkit-mask: radial-gradient(circle, transparent 62%, #000 64%); mask: radial-gradient(circle, transparent 62%, #000 64%); opacity: 0; transition: opacity .3s; }
.seat.turn .timer-ring.on { opacity: 1; }
.seat.offline .avatar::after { content: "zz"; position: absolute; top: -4px; left: -4px; font-size: 11px; font-weight: 800; background: var(--surface); color: var(--muted); border-radius: 999px; padding: 1px 4px; border: 1px solid var(--line); }
.seat.choosable { cursor: pointer; }
.seat .seat-name { position: relative; z-index: 1; }
.seat.choosable .avatar { box-shadow: 0 0 0 4px var(--tone-violet), 0 0 18px 4px color-mix(in srgb, var(--tone-violet) 50%, transparent); animation: beckon 1.1s ease-in-out infinite; }
.seat.drop-hover .avatar { transform: scale(1.3); }
@keyframes beckon { 50% { transform: scale(1.1); } }
.seat .reaction { position: absolute; top: -10px; left: 50%; font-size: 28px; pointer-events: none; animation: float-up 1.6s var(--ease) forwards; }
@keyframes float-up { from { opacity: 0; transform: translate(-50%, 10px) scale(.6); } 15% { opacity: 1; transform: translate(-50%, -6px) scale(1.15); } to { opacity: 0; transform: translate(-50%, -60px) scale(1); } }

/* ------------------------------------------------------------- game controls */
.status-bar { min-height: 56px; display: flex; align-items: center; justify-content: center; text-align: center; font-weight: 800; font-size: 19px; letter-spacing: -.01em; padding: 0 8px; }
.status-bar.mine { color: var(--accent); text-shadow: 0 1px 0 rgba(0,0,0,.15); }
.controls { min-height: 168px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; margin-top: 4px; }
.cup {
  position: relative; width: 100%; max-width: 360px; min-height: 104px; border-radius: 26px; border: 0; cursor: pointer;
  background: linear-gradient(180deg, var(--rim), var(--rim-2)); color: #fff; touch-action: none; user-select: none;
  box-shadow: 0 6px 0 #2a170a, var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  transition: transform .15s var(--ease), filter .2s;
}
.cup:disabled { filter: grayscale(.8) brightness(.8); cursor: not-allowed; }
.cup .cup-dice { display: flex; gap: 8px; }
.cup .cup-label { font-weight: 800; font-size: 18px; }
.cup .cup-hint { font-size: 12px; opacity: .75; font-weight: 600; }
.cup.ready { animation: ready 1.4s ease-in-out infinite; }
@keyframes ready { 50% { transform: translateY(-3px); box-shadow: 0 9px 0 #2a170a, 0 0 0 4px color-mix(in srgb, var(--accent) 70%, transparent), var(--shadow); } }
.cup.dragging { transition: none; animation: none; }
.my-stack { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.my-stack .chip-row { display: flex; }
.my-stack .chip-row .chip + .chip { margin-left: -10px; }
.choice-panel { width: 100%; max-width: 380px; text-align: center; }
.choice-panel .targets { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 10px; }
.choice-panel .targets .btn { min-height: 44px; padding: 8px 12px; font-size: 15px; }
.reactions { display: flex; justify-content: center; gap: 5px; flex-wrap: wrap; margin-top: 10px; }
.reactions button { width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 21px; cursor: pointer; transition: transform .12s; }
.reactions button:active { transform: scale(.85); }
.log { margin: 14px 0 0; padding: 0; list-style: none; font-size: 14px; color: var(--muted); display: grid; gap: 4px; min-height: 96px; }
.log li { animation: pop-in .3s var(--ease-out) both; }
.log li:first-child { color: var(--ink); font-weight: 650; }

.toast-zone { position: fixed; left: 0; right: 0; top: max(12px, env(safe-area-inset-top)); display: grid; justify-items: center; gap: 8px; z-index: 2000; pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 750; box-shadow: var(--shadow); animation: toast-in .3s var(--ease-out); max-width: 90vw; }
.toast.out { animation: toast-out .3s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px) scale(.95); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-12px); } }
.banner { position: fixed; inset: 0; display: grid; place-items: center; z-index: 1500; pointer-events: none; }
.banner span { font-size: clamp(44px, 12vw, 120px); font-weight: 800; letter-spacing: -.04em; color: var(--accent); text-shadow: 0 6px 0 rgba(0,0,0,.25); animation: banner 1.2s var(--ease-out) forwards; }
@keyframes banner { 0% { opacity: 0; transform: scale(.4) rotate(-8deg); } 25% { opacity: 1; transform: scale(1.08) rotate(-3deg); } 75% { opacity: 1; transform: scale(1) rotate(-3deg); } 100% { opacity: 0; transform: scale(1.1) rotate(-3deg); } }

.overlay { position: fixed; inset: 0; z-index: 1200; display: grid; place-items: center; padding: 20px; background: color-mix(in srgb, var(--bg) 55%, transparent); backdrop-filter: blur(6px); animation: fade-in .3s; }
@keyframes fade-in { from { opacity: 0; } }
.winner-card { text-align: center; max-width: 420px; width: 100%; animation: pop-in .5s var(--ease-out); }
.winner-card .avatar { margin: 0 auto; }
.winner-card h2 { font-size: 34px; margin: 12px 0 4px; letter-spacing: -.03em; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 1300; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translate(var(--dx), 110vh) rotate(var(--r)); } }

.conn-badge { position: fixed; bottom: calc(14px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--danger); color: #fff; padding: 8px 14px; border-radius: 999px; font-weight: 750; font-size: 14px; z-index: 2100; box-shadow: var(--shadow); }

/* ------------------------------------------------------------- big screen */
body.display { overflow: hidden; height: 100dvh; }
.display-shell { height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) clamp(300px, 26vw, 460px); gap: clamp(12px, 2vw, 32px); padding: clamp(12px, 2vw, 32px); }
.display-main { position: relative; display: flex; flex-direction: column; min-height: 0; }
.display-main .status-bar { font-size: clamp(24px, 3.4vw, 56px); min-height: clamp(60px, 8vh, 110px); }
.display-main .table-wrap { flex: 1; max-width: none; aspect-ratio: auto; width: 100%; min-height: 0; margin: 0; }
.display .table-wrap .table-felt { inset: 13% 12%; }
.display .seat { width: clamp(90px, 10vmax, 170px); margin-left: calc(clamp(90px, 10vmax, 170px) / -2); margin-top: calc(clamp(56px, 6vmax, 104px) / -2 - 10px); }
.display .seat .avatar { width: clamp(56px, 6vmax, 104px); height: clamp(56px, 6vmax, 104px); font-size: clamp(30px, 3.4vmax, 58px); }
.display .seat .seat-name { font-size: clamp(14px, 1.3vmax, 24px); max-width: 100%; padding: 2px 10px; }
.display .seat .seat-chips { min-width: clamp(32px, 3vmax, 52px); height: clamp(32px, 3vmax, 52px); font-size: clamp(17px, 1.6vmax, 28px); right: 6%; }
.display .seat .timer-ring { width: calc(clamp(56px, 6vmax, 104px) + 14px); height: calc(clamp(56px, 6vmax, 104px) + 14px); margin-left: calc((clamp(56px, 6vmax, 104px) + 14px) / -2); top: -7px; }
.display .pot-pile { width: clamp(90px, 9vw, 170px); height: clamp(50px, 5vw, 90px); }
.display .pot-pile .chip { width: clamp(24px, 2.2vw, 40px); height: clamp(24px, 2.2vw, 40px); }
.display .pot-count { font-size: clamp(14px, 1.2vw, 22px); }
.display .pot-count b { font-size: clamp(22px, 2.4vw, 44px); }
.display .dice-row { gap: clamp(10px, 1.4vw, 24px); min-height: clamp(70px, 8vw, 130px); }
.display .dice-row .die { --s: clamp(56px, 6.5vw, 116px); }
.display .seat .reaction { font-size: clamp(32px, 3vw, 60px); }
.display-side { display: flex; flex-direction: column; gap: clamp(10px, 1.4vw, 20px); min-height: 0; overflow: hidden; }
.display-side .card { padding: clamp(14px, 1.4vw, 24px); }
.join-card { text-align: center; }
.join-card .qr-box { width: 100%; max-width: 280px; margin: 8px auto; }
.join-card .join-url { font-size: clamp(14px, 1.1vw, 20px); font-weight: 700; word-break: break-all; }
.join-card .share-code { font-size: clamp(40px, 4vw, 76px); margin: 6px 0 2px; }
.display-side .legend-row { font-size: clamp(13px, .95vw, 17px); }
.display-side .log { font-size: clamp(14px, 1vw, 19px); min-height: 0; }
.display-tools { position: absolute; top: 0; left: 0; display: flex; gap: 8px; z-index: 5; }
.display-lobby { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2vh; text-align: center; padding: 20px; }
.display-lobby h1 { font-size: clamp(48px, 7vw, 130px); margin: 0; letter-spacing: -.045em; line-height: .9; }
.display-lobby h1 span { color: var(--accent); display: inline-block; transform: rotate(-4deg); }
.display-lobby .lobby-avatars { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(12px, 2vw, 32px); max-width: 90%; }
.display-lobby .lobby-avatars .who { display: flex; flex-direction: column; align-items: center; gap: 8px; font-weight: 800; font-size: clamp(16px, 1.5vw, 26px); animation: pop-in .5s var(--ease-out) both; }
.display-lobby .lobby-avatars .avatar { width: clamp(70px, 7vw, 130px); height: clamp(70px, 7vw, 130px); font-size: clamp(38px, 4vw, 72px); }
.display-lobby .big-msg { font-size: clamp(20px, 2vw, 36px); color: var(--muted); font-weight: 700; }
.display .winner-card .avatar.lg { width: clamp(90px, 8vw, 160px); height: clamp(90px, 8vw, 160px); font-size: clamp(50px, 4.5vw, 90px); }
.display-entry { max-width: 460px; margin: 12vh auto 0; padding: 20px; }

@media (max-width: 900px), (max-aspect-ratio: 1/1) {
  body.display { overflow: auto; height: auto; }
  .display-shell { grid-template-columns: 1fr; height: auto; min-height: 100dvh; }
  .display-main { min-height: 78vh; }
  .display-main .table-wrap { aspect-ratio: 1 / 1; flex: none; }
  .display .table-wrap .table-felt { inset: 15%; }
  .display-side { overflow: visible; }
}

/* ------------------------------------------------------------- larger player screens */
@media (min-width: 760px) {
  .app.game-mode { max-width: 1040px; }
  .game:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: center; }
  .game .table-wrap { max-width: 620px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
