:root {
  --felt: #1D4F45;
  --felt-hi: #256356;
  --felt-edge: #123630;
  --rail: #22272B;
  --rail-hi: #343A40;
  --paper: #FBF8F2;
  --red: #C62F3A;
  --black: #1C1D1F;
  --brass: #E9B44C;
  --brass-ink: #2A1F08;
  --ink: #ECEAE4;
  --ink-mute: #9DB3AB;
  --bg: #0F1513;
  --panel: #171E1C;
  --panel-2: #1F2826;
  --line: rgba(236, 234, 228, 0.1);
  --win: #7BD88F;
  --lose: #F08A8A;
  --radius-s: 6px;
  --radius-m: 12px;
  --font: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-card: "PT Serif", Georgia, serif;
  --k: 1;
  --safe-t: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-b: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --safe-l: max(env(safe-area-inset-left, 0px), var(--tg-safe-area-inset-left, 0px));
  --safe-r: max(env(safe-area-inset-right, 0px), var(--tg-safe-area-inset-right, 0px));
  --ease-out: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); }
body { overflow: hidden; overscroll-behavior: none; font-size: 15px; line-height: 1.4; -webkit-user-select: none; user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--ink-mute); }

#app {
  height: 100vh; height: 100dvh; display: flex; flex-direction: column;
  padding-left: var(--safe-l); padding-right: var(--safe-r);
}

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 8px; padding: calc(10px + var(--safe-t)) 14px 6px; }
.topbar-title { flex: 1; min-width: 0; }
.chat-title { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table-meta { font-size: 12.5px; color: var(--ink-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-tools { display: flex; gap: 2px; }
.icon-btn {
  width: 34px; height: 34px; border: 0; border-radius: 50%; background: transparent; color: var(--ink-mute);
  display: grid; place-items: center; padding: 0;
}
.icon-btn:hover { background: var(--panel); color: var(--ink); }
.icon-btn svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs { display: flex; background: var(--panel); border-radius: 999px; padding: 3px; }
.tab { border: 0; background: transparent; padding: 6px 12px; border-radius: 999px; font-size: 13px; color: var(--ink-mute); }
.tab.is-active { background: var(--panel-2); color: var(--ink); }

.stage { flex: 1; min-height: 0; display: flex; }
.view { display: none; flex: 1; min-height: 0; min-width: 0; }
.view.is-active { display: flex; flex-direction: column; }
.side { display: none; }

/* ---------- felt ---------- */
.felt { position: relative; flex: 1; min-height: 280px; margin: 26px 8px 0; }
.rail {
  position: absolute; inset: 14px 22px 30px;
  border-radius: 999px;
  background:
    radial-gradient(ellipse at 50% 38%, var(--felt-hi) 0%, var(--felt) 48%, var(--felt-edge) 100%);
  box-shadow: 0 0 0 calc(9px * var(--k)) var(--rail), 0 0 0 calc(10px * var(--k)) var(--rail-hi),
              0 18px 40px rgba(0,0,0,.55), inset 0 0 70px rgba(0,0,0,.38);
}
.betline { position: absolute; inset: 15%; border-radius: 999px; border: 1px solid rgba(255,255,255,.055); }
.center {
  position: absolute; left: 50%; top: 47%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: calc(8px * var(--k));
  width: 76%; pointer-events: none;
}
.pot {
  font-weight: 600; font-size: calc(14px * var(--k)); background: rgba(0,0,0,.28);
  padding: 3px 12px 3px 6px; border-radius: 999px; font-variant-numeric: tabular-nums;
  display: inline-flex; align-items: center; gap: 6px;
}
.board { display: flex; gap: calc(4px * var(--k)); justify-content: center; min-height: calc(36px * 1.4 * var(--k)); }
.board .card { --w: calc(36px * var(--k)); }
.center-msg { text-align: center; font-size: calc(13.5px * var(--k)); max-width: 100%; text-wrap: balance; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.center-msg strong { color: var(--brass); font-weight: 600; }
.center-msg .start-btn, .center-msg .btn { pointer-events: auto; margin-top: 8px; }
.countdown { font-size: 12.5px; color: var(--ink-mute); display: inline-flex; align-items: center; gap: 6px; }
.countdown svg { width: 16px; height: 16px; transform: rotate(-90deg); }
.countdown circle { fill: none; stroke-width: 3; }
.countdown .bg { stroke: rgba(255,255,255,.12); }
.countdown .fg { stroke: var(--brass); stroke-linecap: round; }

/* ---------- cards ---------- */
.card {
  --w: 36px; --rot: 0deg;
  width: var(--w); height: calc(var(--w) * 1.4);
  border-radius: calc(var(--w) * 0.12);
  position: relative; flex: none; perspective: 700px;
  box-shadow: 0 1px 0 rgba(0,0,0,.25), 0 4px 10px rgba(0,0,0,.28);
  transform: rotate(var(--rot));
  font-family: var(--font-card);
}
.card .ci { position: absolute; inset: 0; transform-style: preserve-3d; }
.card .face { position: absolute; inset: 0; border-radius: inherit; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; }
.card .ci, .card .face { border-radius: calc(var(--w) * 0.12); }
.card .front { background: var(--paper); color: var(--black); }
.card.red .front { color: var(--red); }
.card .back {
  transform: rotateY(180deg);
  background:
    repeating-linear-gradient(45deg, rgba(233,180,76,.22) 0 3px, transparent 3px 7px),
    repeating-linear-gradient(-45deg, rgba(233,180,76,.22) 0 3px, transparent 3px 7px),
    #2D4A63;
  box-shadow: inset 0 0 0 calc(var(--w) * .05) var(--paper);
}
.card.back-only .back { transform: none; }
.card .r { position: absolute; left: 12%; top: 5%; font-size: calc(var(--w) * 0.42); line-height: 1; letter-spacing: -0.04em; }
.card .s { position: absolute; right: 9%; bottom: 4%; font-size: calc(var(--w) * 0.56); line-height: 1; font-family: var(--font); }
.card.dim { filter: brightness(.5) saturate(.6); }
.card.best { box-shadow: 0 0 0 2px var(--brass), 0 0 18px rgba(233,180,76,.45), 0 4px 12px rgba(0,0,0,.35); }
.board.showdown .card:not(.best) { filter: brightness(.55) saturate(.7); transition: filter .4s; }

/* animation hooks — delays/durations are set inline from app.js */
.a-flip .ci { animation: flip 520ms var(--ease-out) both; }
@keyframes flip { from { transform: rotateY(180deg); } to { transform: rotateY(0deg); } }
.a-deal { animation: deal 420ms var(--ease-out) both; }
@keyframes deal {
  from { transform: translate(var(--dx, 0px), var(--dy, -120px)) rotate(-30deg) scale(.6); opacity: 0; }
  20% { opacity: 1; }
  to { transform: rotate(var(--rot)); opacity: 1; }
}
.a-fade { animation: fadein 300ms ease-out both; }
@keyframes fadein { from { opacity: 0; transform: translate(-50%, -50%) scale(.6); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

/* ---------- seats ---------- */
.seats { position: absolute; inset: 0; }
.seat {
  position: absolute; transform: translate(-50%, -50%) scale(var(--k));
  display: flex; flex-direction: column; align-items: center; width: 84px;
}
.seat-empty {
  width: 46px; height: 46px; border-radius: 50%;
  border: 1.5px dashed rgba(236,234,228,.28); background: rgba(0,0,0,.18);
  color: var(--ink-mute); font-size: 12px; display: grid; place-items: center;
  transform: translate(-50%, -50%) scale(var(--k));
}
button.seat-empty:hover { border-color: var(--brass); color: var(--brass); }
.avatar-wrap { position: relative; width: 48px; height: 48px; }
.avatar {
  width: 48px; height: 48px; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center; font-weight: 600; font-size: 17px;
  color: #fff; border: 2px solid var(--rail); background-size: cover; background-position: center;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.timer { position: absolute; inset: -5px; width: 58px; height: 58px; transform: rotate(-90deg); pointer-events: none; }
.timer circle { fill: none; stroke: var(--brass); stroke-width: 3; stroke-linecap: round; transition: stroke .3s; }
.timer.low circle { stroke: var(--red); }
.secs {
  position: absolute; right: -12px; top: -4px; min-width: 22px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--brass); color: var(--brass-ink); font-size: 11px; font-weight: 700;
  display: grid; place-items: center; font-variant-numeric: tabular-nums; z-index: 3;
}
.secs.low { background: var(--red); color: #fff; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }
.seat.is-turn .avatar { border-color: var(--brass); }
.seat.is-folded .avatar, .seat.is-out .avatar { opacity: .4; }
.seat.is-winner .avatar { border-color: var(--brass); animation: glow 1.4s ease-in-out 3; }
@keyframes glow { 50% { box-shadow: 0 0 0 4px rgba(233,180,76,.35), 0 0 26px rgba(233,180,76,.6); } }
.plate {
  margin-top: -6px; background: var(--rail); border-radius: var(--radius-s);
  padding: 2px 8px 3px; text-align: center; min-width: 72px; position: relative; z-index: 1;
  box-shadow: 0 2px 6px rgba(0,0,0,.35);
}
.plate .name { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 80px; }
.plate .stack { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.seat.is-me .plate { box-shadow: 0 0 0 1px rgba(233,180,76,.45), 0 2px 6px rgba(0,0,0,.35); }
.tag { position: absolute; bottom: -12px; left: 50%; transform: translateX(-50%); font-size: 10.5px; padding: 1px 7px; border-radius: 999px; background: var(--panel-2); color: var(--ink); white-space: nowrap; z-index: 2; }
.tag.fold { color: var(--ink-mute); }
.tag.allin { background: var(--red); color: #fff; }
.tag.win { background: var(--win); color: #0E2A16; font-weight: 600; }
.seat-cards { position: absolute; top: -12px; display: flex; gap: 2px; z-index: 0; }
.seat-cards .card { --w: 26px; }
.seat-cards .card:first-child { --rot: -5deg; }
.seat-cards .card:last-child { --rot: 5deg; }
.seat-cards.reveal { top: -24px; z-index: 3; }
.seat-cards.reveal .card { --w: 30px; --rot: 0deg; }
.seat.is-top .seat-cards { top: auto; bottom: -30px; z-index: 3; }
.seat.is-top .seat-cards.reveal { bottom: -42px; }
.seat.is-top .tag { bottom: auto; top: -12px; }
.bet {
  position: absolute; transform: translate(-50%, -50%) scale(var(--k));
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
  background: rgba(0,0,0,.32); padding: 2px 8px 2px 3px; border-radius: 999px; white-space: nowrap;
}
.bet.a-fade { animation-name: fadeinScaled; }
@keyframes fadeinScaled { from { opacity: 0; } to { opacity: 1; } }
.chip { width: 14px; height: 14px; border-radius: 50%; background: var(--paper); box-shadow: inset 0 0 0 3px var(--red), inset 0 0 0 4.5px var(--paper); flex: none; }
.chip.c2 { box-shadow: inset 0 0 0 3px #2D4A63, inset 0 0 0 4.5px var(--paper); }
.chip.c3 { box-shadow: inset 0 0 0 3px var(--brass), inset 0 0 0 4.5px var(--paper); }
.dealer-btn {
  position: absolute; width: calc(20px * var(--k)); height: calc(20px * var(--k)); border-radius: 50%;
  background: var(--brass); color: var(--brass-ink); font-size: calc(10px * var(--k)); font-weight: 700;
  display: grid; place-items: center; transform: translate(-50%, -50%);
  box-shadow: 0 2px 0 #a47a2a, 0 4px 8px rgba(0,0,0,.4);
  transition: left .6s var(--ease-out), top .6s var(--ease-out);
  z-index: 4;
}

/* ---------- fx layer ---------- */
.fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 8; }
.fx-chips { position: absolute; left: 0; top: 0; width: 18px; height: 18px; }
.fx-chips .chip { position: absolute; width: 16px; height: 16px; }
.fx-chips .chip:nth-child(2) { left: 3px; top: -3px; }
.fx-chips .chip:nth-child(3) { left: -2px; top: -6px; }
.fx-card { position: absolute; left: 0; top: 0; }
.fx-card.card { --w: 24px; }
.bubble {
  position: absolute; transform: translate(-50%, -100%); white-space: nowrap;
  background: var(--paper); color: var(--black); font-weight: 600; font-size: 12.5px;
  padding: 3px 9px; border-radius: 999px; box-shadow: 0 4px 12px rgba(0,0,0,.35);
  animation: bubble 1.7s var(--ease-out) forwards;
}
.bubble.raise, .bubble.bet { background: var(--brass); color: var(--brass-ink); }
.bubble.all_in { background: var(--red); color: #fff; }
.bubble.fold { background: var(--panel-2); color: var(--ink-mute); }
@keyframes bubble {
  0% { opacity: 0; transform: translate(-50%, -60%) scale(.7); }
  12% { opacity: 1; transform: translate(-50%, -110%) scale(1.05); }
  20% { transform: translate(-50%, -100%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -140%); }
}
.emote-pop { position: absolute; font-size: 30px; transform: translate(-50%, -50%); animation: pop 2.2s ease-out forwards; }
@keyframes pop {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); }
  15% { opacity: 1; transform: translate(-50%, -80%) scale(1.15); }
  80% { opacity: 1; transform: translate(-50%, -110%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -130%) scale(1); }
}

/* ---------- dock ---------- */
.dock { position: relative; padding: 4px 14px calc(10px + var(--safe-b)); display: flex; flex-direction: column; gap: 6px; }
.dock-cards { position: relative; display: flex; flex-direction: column; align-items: center; min-height: 0; }
.my-cards { display: flex; justify-content: center; gap: 6px; pointer-events: none; }
.my-cards .card { --w: 58px; }
.my-cards .card:first-child { --rot: -4deg; }
.my-cards .card:last-child { --rot: 4deg; }
.my-hand { font-size: 12.5px; color: var(--brass); min-height: 17px; margin-top: 4px; text-align: center; }
.dock-main { display: flex; flex-direction: column; gap: 8px; }
.turn-bar { height: 4px; border-radius: 4px; background: rgba(255,255,255,.08); overflow: hidden; }
.turn-bar i { display: block; height: 100%; width: 100%; background: var(--brass); transform-origin: left; border-radius: inherit; transition: background-color .3s; }
.turn-bar.low i { background: var(--red); }
.status-line { text-align: center; font-size: 13px; color: var(--ink-mute); min-height: 18px; }
.status-line.my-turn { color: var(--brass); font-weight: 600; }
.actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; min-height: 48px; }
.actions:empty { display: none; }
.btn {
  border: 0; border-radius: var(--radius-m); padding: 12px 10px; font-weight: 600; font-size: 15px;
  background: var(--panel-2); color: var(--ink); min-height: 48px; line-height: 1.15;
  transition: transform .08s, filter .15s;
}
.btn small { display: block; font-weight: 500; font-size: 12px; opacity: .8; font-variant-numeric: tabular-nums; }
.btn:active { transform: translateY(1px) scale(.98); }
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: .4; }
.btn-fold { background: #2B2224; color: #F1C6C6; }
.btn-brass { background: var(--brass); color: var(--brass-ink); }
.btn-ghost { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.actions .btn { animation: rise .22s var(--ease-out) both; }
.actions .btn:nth-child(2) { animation-delay: .03s; }
.actions .btn:nth-child(3) { animation-delay: .06s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.pre-actions { display: flex; gap: 8px; justify-content: center; }
.pre-actions:empty { display: none; }
.pre {
  border: 0; border-radius: 999px; padding: 8px 14px; font-size: 13px;
  background: transparent; color: var(--ink-mute); box-shadow: inset 0 0 0 1px var(--line);
  display: inline-flex; align-items: center; gap: 8px;
}
.pre::before { content: ""; width: 14px; height: 14px; border-radius: 4px; box-shadow: inset 0 0 0 1.5px currentColor; }
.pre.is-on { color: var(--brass); box-shadow: inset 0 0 0 1px rgba(233,180,76,.6); }
.pre.is-on::before { background: var(--brass); box-shadow: none; }
.raise-panel {
  position: absolute; left: 10px; right: 10px; bottom: calc(8px + var(--safe-b)); z-index: 20;
  background: var(--panel); border-radius: var(--radius-m); padding: 12px;
  display: flex; flex-direction: column; gap: 10px; box-shadow: 0 -8px 30px rgba(0,0,0,.5);
  animation: rise .2s var(--ease-out) both;
}
.raise-head { display: flex; justify-content: space-between; align-items: baseline; }
.raise-head span { color: var(--ink-mute); font-size: 13px; }
.raise-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.raise-presets { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.raise-presets button { border: 0; background: var(--panel-2); border-radius: var(--radius-s); padding: 8px 2px; font-size: 12.5px; }
.raise-presets button.is-on { background: var(--brass); color: var(--brass-ink); }
.raise-row { display: flex; gap: 8px; align-items: center; }
.raise-row .btn { flex: 1; }
.step { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--panel-2); font-size: 20px; flex: none; }
input[type=range] { flex: 1; accent-color: var(--brass); height: 32px; }
.toolbar { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; min-height: 32px; }
.toolbar button { border: 0; background: transparent; color: var(--ink-mute); font-size: 13px; padding: 6px 10px; border-radius: 999px; }
.toolbar button:hover { color: var(--ink); background: var(--panel); }
.toolbar button.primary { background: var(--brass); color: var(--brass-ink); font-weight: 600; }
.toolbar .icon { font-size: 17px; padding: 4px 10px; }
.toolbar .log-btn { display: inline-block; }

/* ---------- side panel / log ---------- */
.side-block h3 { font-size: 13px; font-weight: 600; color: var(--ink-mute); margin: 0 0 8px; }
.hand-log, .past-hands { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.hand-log li { padding: 3px 0; display: flex; gap: 6px; align-items: baseline; }
.hand-log li.street { color: var(--ink-mute); font-size: 12px; padding-top: 9px; gap: 4px; align-items: center; }
.hand-log li.street:first-child { padding-top: 0; }
.hand-log .who { font-weight: 600; }
.hand-log .what { color: var(--ink-mute); }
.hand-log .what.agg { color: var(--brass); }
.hand-log .what.allin { color: var(--lose); }
.hand-log li.new { animation: rise .25s var(--ease-out) both; }
.past-hands li { padding: 6px 0; border-top: 1px solid var(--line); color: var(--ink); line-height: 1.45; }
.past-hands li:first-child { border-top: 0; }
.mini-card { font-family: var(--font-card); font-weight: 700; padding: 0 2px; border-radius: 3px; background: var(--paper); color: var(--black); font-size: 11.5px; }
.mini-card.red { color: var(--red); }
.empty-note { color: var(--ink-mute); font-size: 13px; }

/* ---------- emotes, sheet, toast ---------- */
.emote-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.emote-grid button { border: 0; background: var(--panel-2); border-radius: var(--radius-m); font-size: 26px; padding: 10px 0; }
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; z-index: 50; animation: fadeSheet .18s ease-out both; }
@keyframes fadeSheet { from { background: rgba(0,0,0,0); } }
.sheet-card {
  width: 100%; max-width: 560px; background: var(--panel); border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(18px + var(--safe-b)); max-height: 85vh; overflow: auto;
  animation: sheetUp .24s var(--ease-out) both;
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } }
.sheet h2 { margin: 0 0 12px; font-size: 18px; font-weight: 600; }
.field { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.field input[type=number] { width: 110px; background: var(--panel-2); border: 0; color: var(--ink); padding: 8px 10px; border-radius: var(--radius-s); font: inherit; text-align: right; }
.sheet-actions { display: flex; gap: 8px; margin-top: 16px; }
.sheet-actions .btn { flex: 1; }
.menu-list { display: flex; flex-direction: column; gap: 6px; }
.menu-list .btn { text-align: left; }
.toast { position: fixed; left: 50%; top: calc(64px + var(--safe-t)); transform: translate(-50%, -20px); background: #3A2326; color: #FFE1E1; padding: 9px 14px; border-radius: var(--radius-m); font-size: 14px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 60; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.info { background: var(--panel-2); color: var(--ink); }

/* ---------- stats ---------- */
.stats-view { overflow-y: auto; -webkit-user-select: text; user-select: text; }
.stats-body { padding: 8px 16px calc(24px + var(--safe-b)); max-width: 640px; width: 100%; margin: 0 auto; }
.stats-body h2 { font-size: 17px; font-weight: 600; margin: 18px 0 10px; }
.stat-hero { display: flex; align-items: baseline; gap: 10px; margin: 6px 0 14px; }
.stat-hero .big { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.pos { color: var(--win); }
.neg { color: var(--lose); }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border-radius: var(--radius-m); overflow: hidden; }
.stat-grid div { background: var(--panel); padding: 10px 10px 9px; }
.stat-grid b { display: block; font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-grid span { font-size: 12px; color: var(--ink-mute); }
.leader { list-style: none; padding: 0; margin: 0; }
.leader li { display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.leader .place { color: var(--ink-mute); font-variant-numeric: tabular-nums; }
.leader .sub { font-size: 12px; color: var(--ink-mute); }
.leader .net { font-weight: 600; font-variant-numeric: tabular-nums; }
.leader li.me .who { color: var(--brass); }
.glossary { font-size: 12.5px; color: var(--ink-mute); margin-top: 18px; }
.glossary dt { color: var(--ink); display: inline; }
.glossary dd { display: inline; margin: 0; }
.glossary div { margin-bottom: 4px; }
.fatal { margin: auto; padding: 24px; text-align: center; max-width: 320px; }
.fatal h2 { font-size: 18px; margin: 0 0 8px; }

/* ---------- tablets (portrait) ---------- */
/* ---------- equity, run it twice, rabbit ---------- */
.eq-badge {
  position: absolute; left: calc(100% + 2px); top: 50%; transform: translateY(-50%);
  background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; z-index: 4;
  font-variant-numeric: tabular-nums; animation: eqIn .25s ease-out both; white-space: nowrap;
}
@keyframes eqIn { from { opacity: 0; } }
.eq-badge.fav { background: var(--brass); color: var(--brass-ink); border-color: transparent; }
.board.multi { flex-direction: column; gap: calc(5px * var(--k)); align-items: center; }
.board.multi .card { --w: calc(30px * var(--k)); }
.board-row { display: flex; gap: calc(4px * var(--k)); align-items: center; }
.board-row.showdown .card:not(.best) { filter: brightness(.55) saturate(.7); }
.run-label, .run-tag {
  display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0,0,0,.35); color: var(--ink-mute); font-size: 11px; font-weight: 700; margin-right: 4px;
}
.card.rabbit { opacity: .55; outline: 1.5px dashed rgba(255,255,255,.45); outline-offset: 2px; }
.t-final { display: flex; flex-direction: column; gap: 2px; font-size: calc(14px * var(--k)); }
.t-final strong { font-size: calc(16px * var(--k)); margin-bottom: 2px; }
.avatar-wrap.bank .timer circle { stroke: #6FB4F0; }
.avatar-wrap.bank .secs { background: #6FB4F0; color: #08243A; }
.turn-bar.bank i { background: #6FB4F0; }

/* ---------- hints, review ---------- */
.hint-line:empty { display: none; }
.hint-line { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.hint, .review, .bank-note { font-size: 12.5px; color: var(--ink-mute); text-align: center; }
.hint.ok { color: var(--win); }
.hint.bad { color: var(--lose); }
.review b { color: var(--ink); font-weight: 600; }
.review .rv.good { color: var(--win); }
.review .rv.bad { color: var(--lose); }

/* ---------- achievement toast ---------- */
.ach-toast {
  position: fixed; left: 50%; top: calc(14px + var(--safe-t)); transform: translateX(-50%);
  display: flex; gap: 10px; align-items: center; z-index: 70;
  background: var(--panel-2); border: 1px solid rgba(233,180,76,.45); color: var(--ink);
  padding: 10px 14px; border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.5);
  max-width: min(92vw, 420px); animation: achIn .45s var(--ease-out) both;
}
.ach-toast.me { border-color: var(--brass); box-shadow: 0 0 0 3px rgba(233,180,76,.2), 0 10px 30px rgba(0,0,0,.5); }
.ach-toast.out { animation: achOut .4s ease-in both; }
.ach-toast .ach-emoji { font-size: 28px; line-height: 1; }
.ach-toast .ach-body { display: flex; flex-direction: column; font-size: 13px; }
.ach-toast .ach-body span { color: var(--ink-mute); font-size: 12.5px; }
@keyframes achIn { from { opacity: 0; transform: translate(-50%, -24px) scale(.95); } }
@keyframes achOut { to { opacity: 0; transform: translate(-50%, -16px); } }

/* ---------- settings ---------- */
.sheet-tabs { margin: 0 0 6px; align-self: flex-start; display: inline-flex; }
.sheet-body { min-height: 220px; }
.field .f-title { display: block; }
.field small { display: block; color: var(--ink-mute); font-size: 12px; margin-top: 2px; max-width: 36ch; }
.field.col { flex-direction: column; align-items: stretch; gap: 8px; }
.field.toggle input[type=checkbox] {
  appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 999px; flex: none;
  background: var(--panel-2); position: relative; cursor: pointer; transition: background .2s; margin: 0;
}
.field.toggle input[type=checkbox]::after {
  content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--ink-mute); transition: transform .2s var(--ease-out), background .2s;
}
.field.toggle input[type=checkbox]:checked { background: var(--brass); }
.field.toggle input[type=checkbox]:checked::after { transform: translateX(18px); background: var(--brass-ink); }
.field input:disabled { opacity: .45; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--panel-2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: transparent; padding: 8px 10px; border-radius: 8px; color: var(--ink-mute); font-size: 13.5px; }
.seg button.is-on { background: var(--bg); color: var(--ink); }
.seg.disabled { opacity: .5; }
.seg.small button { padding: 5px 9px; font-size: 12.5px; }
.muted.small { font-size: 12.5px; margin: 10px 0 0; }

/* ---------- stats extras ---------- */
.chart-wrap { background: var(--panel); border-radius: var(--radius-m); padding: 10px 8px 8px; }
.chart { width: 100%; height: auto; display: block; }
.chart .zero { stroke: rgba(255,255,255,.18); stroke-dasharray: 3 4; }
.chart .ax { fill: var(--ink-mute); font-size: 11px; font-family: var(--font); }
.chart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; opacity: .75; }
.chart .ln.me { stroke-width: 3; opacity: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--ink-mute); padding: 6px 6px 0; }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.sessions { list-style: none; padding: 0; margin: 8px 0 0; font-size: 13.5px; }
.sessions li { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.h2-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.h2-row h2 { margin: 18px 0 10px; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.ach { display: flex; gap: 10px; align-items: center; background: var(--panel); border-radius: var(--radius-m); padding: 10px; opacity: .55; }
.ach.on { opacity: 1; box-shadow: inset 0 0 0 1px rgba(233,180,76,.35); }
.ach .ach-emoji { font-size: 24px; }
.ach b { display: block; font-size: 13px; font-weight: 600; }
.ach small { display: block; font-size: 11.5px; color: var(--ink-mute); line-height: 1.3; }

@media (min-width: 600px) {
  .felt { margin: 30px 16px 0; }
  .dock { max-width: 620px; width: 100%; margin: 0 auto; }
  .my-cards .card { --w: 66px; }
}

/* ---------- wide: iPad landscape, laptops, desktop Telegram ---------- */
@media (min-width: 900px) and (min-height: 520px) {
  .stage { display: grid; grid-template-columns: minmax(0, 1fr) 300px; }
  .stage.stats-open { grid-template-columns: minmax(0, 1fr); }
  .stage.stats-open .side { display: none; }
  .side {
    display: flex; flex-direction: column; gap: 22px; padding: 10px 18px calc(16px + var(--safe-b)) 6px;
    overflow-y: auto; border-left: 1px solid var(--line); margin: 6px 0 0;
  }
  .side-block:first-child { flex: 0 1 auto; }
  .felt { margin: 26px 28px 0; }
  .rail { inset: 20px 36px 34px; }
  .dock {
    max-width: 860px; width: 100%; margin: 0 auto;
    display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: end; column-gap: 22px;
    padding-bottom: calc(14px + var(--safe-b));
  }
  .dock { grid-template-areas: "cards main"; }
  .dock-cards { grid-area: cards; margin-top: -54px; z-index: 6; }
  .dock-main { grid-area: main; }
  .raise-panel { grid-area: main; position: relative; left: auto; right: auto; bottom: auto; width: auto; align-self: end; box-shadow: 0 0 0 1px var(--line); }
  .my-cards .card { --w: 76px; }
  .dock-main { min-width: 0; }
  .status-line { text-align: left; }
  .hint-line { align-items: flex-start; }
  .hint, .review, .bank-note { text-align: left; }
  .toolbar { justify-content: flex-start; }
  .pre-actions { justify-content: flex-start; }
  .toolbar .log-btn { display: none; }
  .sheet { align-items: center; }
  .sheet-card { border-radius: 18px; }
}
@media (min-width: 1400px) and (min-height: 760px) {
  .stage { grid-template-columns: minmax(0, 1fr) 340px; }
  .my-cards .card { --w: 88px; }
}
@media (max-height: 640px) {
  .my-cards .card { --w: 48px; }
  .btn { min-height: 44px; padding: 9px 8px; }
}
@media (max-width: 420px) {
  .topbar { gap: 4px; padding-left: 12px; padding-right: 10px; }
  .tab { padding: 6px 9px; font-size: 12.5px; }
  .icon-btn { width: 30px; height: 30px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0ms !important; transition-duration: .001ms !important; }
}
