/* Offsuit-inspired: pure black, no table, big friendly cards, players in a row on top. */
:root {
  color-scheme: dark;
  --bg: #000;
  --surface: #0f0f10;
  --surface-2: #161618;
  --surface-3: #202023;
  --line: #2b2b2f;
  --line-2: #3a3a3f;
  --text: #f4f4f5;
  --muted: #8b8b92;
  --faint: #55555c;
  --red: #e5484d;
  --blue: #2f7cf6;
  --green: #1f9d55;
  --win: #3ddc97;
  --danger: #f2555a;
  --warn: #f5b942;
  --board-w: min(17.4vw, 92px);
  --mine-w: min(27vw, 130px);
  --emoji: min(11vw, 46px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.35 Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-variant-numeric: tabular-nums;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; }
.hidden { display: none !important; }
.emoji { font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Samsung Color Emoji", sans-serif; line-height: 1; }

/* ---------- top bar ---------- */
#topbar {
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 6px) 12px 2px;
  z-index: 5;
}
#title { flex: 1; min-width: 0; }
#blinds { font-weight: 600; font-size: 14px; }
#subtitle { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  position: relative; width: 38px; height: 38px; border-radius: 19px;
  background: transparent; border: 1px solid var(--line); font-size: 16px; color: var(--text);
}
.badge {
  position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--danger); color: #fff; border-radius: 9px; font-size: 11px; line-height: 18px; font-weight: 700;
}
.pill {
  height: 34px; padding: 0 16px; border-radius: 17px; border: 0; font-weight: 600; font-size: 13px;
  background: var(--accent, var(--text)); color: var(--accent-ink, #000);
}
.pill.pause { background: transparent; color: var(--text); border: 1px solid var(--line); }

/* ---------- game layout ---------- */
#game { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 14px calc(12px + var(--safe-b)); }

/* opponents */
#opps {
  display: grid; grid-template-columns: repeat(var(--cols, 5), 1fr);
  gap: 10px 4px; padding-top: 18px; align-items: start;
}
.opp { position: relative; display: flex; flex-direction: column; align-items: center; min-width: 0; transition: opacity .35s ease; }
.opp .turn {
  position: absolute; top: -16px; font-size: 11px; color: var(--text); opacity: 0; transform: translateY(-4px);
  transition: opacity .2s, transform .2s;
}
.opp.acting .turn { opacity: 1; transform: none; animation: nudge 1.2s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(3px); } }
.opp .name { margin-top: 6px; font-size: 13px; color: var(--muted); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opp .stack { font-size: 17px; font-weight: 600; }
.opp.folded, .opp.out { opacity: .28; }
.opp .tagbox { min-height: 20px; margin-top: 2px; }
.opp .cards { display: flex; gap: 2px; margin-top: 2px; flex-wrap: wrap; justify-content: center; }
.opp .cards .card { --w: min(8.5vw, 36px); }
.opp .cards .hn { width: 100%; text-align: center; font-size: 10px; color: var(--muted); margin-top: 2px; }
.opp.empty .name { font-size: 11px; color: var(--faint); }
.sit {
  width: var(--emoji); height: var(--emoji); border-radius: 50%; border: 1px dashed var(--line-2);
  background: transparent; color: var(--muted); font-size: 20px; font-weight: 300;
}
.sit:active { background: var(--surface-2); }

/* avatar */
.ava { position: relative; width: calc(var(--emoji) + 8px); height: calc(var(--emoji) + 8px); display: flex; align-items: center; justify-content: center; }
.ava .emoji { font-size: var(--emoji); transition: transform .3s; }
.acting .ava .emoji { transform: scale(1.08); }
.ava .ring { position: absolute; inset: -4px; width: calc(100% + 8px); height: calc(100% + 8px); transform: rotate(-90deg); }
.ava .ring circle { fill: none; stroke-width: 2; }
.ava .ring .track { stroke: #ffffff12; }
.ava .ring .prog { stroke: var(--accent, var(--text)); stroke-linecap: round; transition: stroke .3s; }
.ava .ring .prog.low { stroke: var(--danger); }
.ava .dbtn {
  position: absolute; right: -2px; bottom: -2px; width: 20px; height: 20px; border-radius: 50%;
  background: #2a2a2e; color: var(--text); border: 1px solid var(--line-2);
  font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.ava .offline { position: absolute; left: 0; bottom: 0; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px var(--bg); }
.winner .ava::before {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  background: radial-gradient(circle, #3ddc9740, transparent 70%); animation: glow 1.4s ease-in-out 2;
}
@keyframes glow { 50% { transform: scale(1.25); opacity: .4; } }

.tag {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px;
  background: var(--surface-3); color: var(--text); white-space: nowrap; animation: pop .25s cubic-bezier(.3,1.6,.5,1) both;
}
.tag.allin { background: var(--danger); color: #fff; }
.tag.win { background: var(--win); color: #04281a; }
.tag.quiet { background: transparent; color: var(--faint); animation: none; }
@keyframes pop { from { transform: scale(.5); opacity: 0; } }

/* center: board + info */
#center { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 12px; }
#board { display: flex; gap: 3px; perspective: 800px; }
#board .card { --w: var(--board-w); }
#infoRow { width: calc(var(--board-w) * 5 + 12px); max-width: 100%; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; min-height: 40px; }
#message { font-size: 14px; color: var(--muted); line-height: 1.35; }
#message b { color: var(--text); font-weight: 600; }
#message .win { color: var(--win); font-weight: 600; display: block; }
#message .hn { color: var(--text); font-size: 13px; }
#message.pop { animation: fadeUp .3s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } }
#potLine { text-align: right; transition: opacity .4s; flex-shrink: 0; }
#potLine.gone { opacity: 0; }
#potLine .amt { font-size: 30px; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; letter-spacing: -.01em; }
#potLine .amt .chip { width: 14px; height: 14px; }
#potLine small { display: block; color: var(--muted); font-size: 11px; }
.bump { animation: bump .35s ease; }
@keyframes bump { 40% { transform: scale(1.12); } }
#potLine b.bump, .stack.bump { display: inline-block; }

/* ---------- cards ---------- */
.card {
  --w: 56px;
  width: var(--w); height: calc(var(--w) * 1.38); flex-shrink: 0;
  border-radius: calc(var(--w) * .16);
  background: linear-gradient(160deg, #ffffff 0%, #f1f1f3 100%);
  color: #111; position: relative;
  box-shadow: 0 1px 0 #ffffff inset, 0 6px 16px #0007, 0 1px 3px #0005;
}
.card .r {
  position: absolute; left: 12%; top: 7%;
  font-size: calc(var(--w) * .42); font-weight: 500; letter-spacing: -.03em; line-height: 1;
}
.card .s { position: absolute; left: 12%; bottom: 9%; font-size: calc(var(--w) * .3); line-height: 1; }
.card.h, .card.d { color: var(--red); }
.four .card.d { color: var(--blue); }
.four .card.c { color: var(--green); }
/* undealt board slots and card backs: white with black hatching */
.card.slot { background: #f4f4f5; }
.card.slot::after {
  content: ""; position: absolute; inset: 9%; border-radius: calc(var(--w) * .08);
  background: repeating-linear-gradient(135deg, #111 0 1.6px, transparent 1.6px 9px);
}
.card.slot.idle { opacity: .12; }
.card.slot.mini { --w: 26px; }
.card.dim { opacity: .3; }
.card.win { box-shadow: 0 0 0 2px var(--win), 0 8px 20px #3ddc9733; transform: translateY(-4px); transition: transform .3s; }
.card.flip { animation: flipIn .45s cubic-bezier(.2,.8,.2,1) both; }
.card.reveal { animation: flipIn .4s cubic-bezier(.2,.8,.2,1) both; }
@keyframes flipIn {
  0% { transform: perspective(600px) rotateY(90deg) translateY(-8px); opacity: 0; }
  60% { opacity: 1; }
  100% { transform: none; }
}

/* ---------- dock (actions + my hand) ---------- */
#dock { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.btn {
  height: 52px; border-radius: 26px; border: 1px solid var(--line-2);
  background: transparent; font-weight: 500; font-size: 16px; color: var(--text);
  transition: background .15s, transform .1s, border-color .15s;
}
.btn:active { transform: scale(.97); background: var(--surface-2); }
.btn.up { flex: 0 0 64px; font-size: 20px; }
.btn.primary { background: var(--accent, var(--text)); color: var(--accent-ink, #000); border-color: var(--accent, var(--text)); font-weight: 600; }
.btn.on { border-color: var(--text); background: var(--surface-3); }
.btn.fold { color: var(--danger); }
.btn:disabled { opacity: .4; }
.actions { animation: rise .25s ease both; }
.actions.pre .btn { color: var(--muted); font-size: 14px; height: 46px; }
.actions.pre .btn.on { color: var(--text); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.note { text-align: center; color: var(--muted); padding: 14px 0; font-size: 14px; }
.note b { color: var(--text); font-weight: 600; }

#mine { display: flex; align-items: stretch; gap: 12px; min-height: calc(var(--mine-w) * 1.38); }
#myCards { flex: 1.15; display: flex; align-items: center; }
#myCards .fan { display: flex; transition: opacity .4s, transform .4s; }
#myCards .fan.mucked { opacity: .3; transform: translateY(8px); }
#myCards .card { --w: var(--mine-w); animation: dealMine .5s cubic-bezier(.2,.8,.2,1) both; }
#myCards .card + .card { margin-left: calc(var(--mine-w) * -.32); }
#myCards .card .r { font-size: calc(var(--w) * .38); top: 9%; }
#myCards .card .s { font-size: calc(var(--w) * .26); bottom: 10%; }
@keyframes dealMine {
  0% { transform: translateY(-38vh) scale(.35) rotate(-8deg); opacity: 0; }
  55% { transform: translateY(0) scale(1) scaleX(1); opacity: 1; }
  75% { transform: scaleX(.08); }
  100% { transform: none; }
}
#myPanel {
  flex: 1; border: 1px solid var(--line-2); border-radius: 26px; padding: 12px 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  transition: border-color .3s, box-shadow .3s;
}
#myPanel .hn { font-size: 13px; color: var(--muted); min-height: 18px; text-align: center; padding: 0 26px; line-height: 1.25; }
#myPanel .stack { font-size: 20px; font-weight: 600; }
#myPanel .tagbox { min-height: 20px; }
#myPanel.acting { border-color: var(--accent, var(--text)); box-shadow: 0 0 0 1px var(--accent, var(--text)), 0 0 24px #ffffff1a; }
#myPanel.winner { border-color: var(--win); }
#myPanel.watching .stack { font-size: 13px; color: var(--muted); font-weight: 400; }

/* raise sizing */
.raise-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 14px; animation: rise .2s ease both; }
.raise-amount { text-align: center; margin-bottom: 10px; }
.raise-amount .lbl { font-size: 11px; letter-spacing: .12em; color: var(--muted); font-weight: 600; }
.raise-amount input {
  display: block; width: 100%; background: transparent; border: 0; color: var(--text); text-align: center;
  font-size: 34px; font-weight: 700; padding: 0; outline: none; font-variant-numeric: tabular-nums;
}
.presets { display: flex; gap: 6px; margin-bottom: 12px; }
.presets button {
  flex: 1; height: 38px; border-radius: 19px; border: 1px solid var(--line-2); background: transparent;
  font-size: 13px; font-weight: 500; color: var(--text);
}
.presets button.on { background: var(--accent, var(--text)); color: var(--accent-ink, #000); border-color: var(--accent, var(--text)); }
.slider-row { display: flex; align-items: center; gap: 10px; }
.slider-row input[type=range] { flex: 1; accent-color: var(--text); height: 32px; }
.step { width: 44px; height: 40px; border-radius: 20px; border: 1px solid var(--line-2); background: transparent; font-size: 20px; color: var(--text); }

/* ---------- chips + flying effects ---------- */
.chip {
  display: inline-block; width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0;
  background:
    radial-gradient(circle, #f5b942 0 36%, transparent 37%),
    repeating-conic-gradient(#fff 0 20deg, #f5b942 20deg 60deg);
  box-shadow: 0 1px 2px #0008, inset 0 0 0 1.5px #c98d1c;
}
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 15; }
.flyer { position: absolute; transform: translate(-50%, -50%); will-change: transform, opacity; }
.flyer.chiponly .chip { width: 18px; height: 18px; }
.flyer .card { animation: none !important; }

/* ---------- sheet ---------- */
#sheet { position: fixed; inset: 0; z-index: 20; }
#sheetBackdrop { position: absolute; inset: 0; background: #000b; }
#sheetPanel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 86vh;
  background: var(--surface); border-radius: 24px 24px 0 0; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; animation: up .22s ease-out;
  padding-bottom: var(--safe-b);
}
@media (min-width: 700px) { #sheetPanel { left: auto; width: 440px; top: 0; max-height: none; border-radius: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: .5; } }
#tabs { display: flex; gap: 4px; padding: 10px 10px 0; overflow-x: auto; flex-shrink: 0; }
#tabs button {
  position: relative; flex: 1; height: 36px; border-radius: 18px; border: 0; background: transparent; color: var(--muted);
  font-weight: 500; white-space: nowrap; padding: 0 12px; font-size: 14px;
}
#tabs button.on { background: var(--surface-3); color: var(--text); }
#tabs .badge { top: -2px; right: -2px; }
#sheetBody { overflow-y: auto; padding: 14px 16px 20px; flex: 1; user-select: text; }
.sec { margin-bottom: 20px; }
.sec h3 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; }
.list .item { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list .item .grow { flex: 1; min-width: 0; }
.list .item .sub { color: var(--muted); font-size: 12px; }
.mini { height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--line-2); background: transparent; font-weight: 500; font-size: 13px; color: var(--text); }
.mini.ok { background: var(--accent, var(--text)); color: var(--accent-ink, #000); border-color: var(--accent, var(--text)); }
.mini.no { color: var(--danger); }
.pos { color: var(--win); font-weight: 700; }
.neg { color: var(--danger); font-weight: 700; }
table.ledger { width: 100%; border-collapse: collapse; font-size: 14px; }
table.ledger th { text-align: right; color: var(--muted); font-weight: 500; font-size: 12px; padding: 6px 4px; }
table.ledger td { text-align: right; padding: 9px 4px; border-top: 1px solid var(--line); }
table.ledger th:first-child, table.ledger td:first-child { text-align: left; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.form label.full { grid-column: 1 / -1; }
.form label.check { flex-direction: row; align-items: center; gap: 10px; font-size: 14px; color: var(--text); }
.form input, .form select, .field {
  height: 46px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--bg); color: var(--text); padding: 0 14px; font-size: 16px; width: 100%;
}
.form input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--text); }
.log { font-size: 13px; display: flex; flex-direction: column; gap: 3px; }
.log .e { padding: 2px 0; }
.log .hand { color: var(--muted); margin-top: 10px; font-weight: 600; }
.log .board { color: #c9ccd1; }
.log .win { color: var(--win); font-weight: 600; }
.log .chat { color: #cfe0ff; }
.log .system { color: var(--faint); }
.chatbar { display: flex; gap: 8px; margin-bottom: 10px; }
.chatbar input { flex: 1; }
.qr { background: #fff; padding: 12px; border-radius: 18px; width: min(240px, 66vw); margin: 4px auto 12px; }
.qr svg, .qr img { width: 100%; height: auto; display: block; }
.url { text-align: center; font-size: 22px; font-weight: 700; word-break: break-all; margin: 4px 0; }
.help { color: var(--muted); font-size: 13px; }
.help li { margin: 4px 0; }
.help b { color: var(--text); }

/* emoji picker */
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; margin: 4px 0 14px; }
.emoji-grid button {
  aspect-ratio: 1; border-radius: 12px; border: 1px solid transparent; background: transparent; font-size: 24px; padding: 0;
}
.emoji-grid button.on { border-color: var(--text); background: var(--surface-3); }

/* ---------- modal ---------- */
#modal { position: fixed; inset: 0; z-index: 30; background: #000d; display: flex; align-items: center; justify-content: center; padding: 12px; }
/* Fits any screen: the card scrolls inside the visible area and the ✕ stays put. */
#modalBox { position: relative; width: min(400px, 100%); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); display: flex; animation: up .2s ease-out; }
#modalCard {
  background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 22px; width: 100%;
  max-height: 100%; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
#modalX {
  position: absolute; top: 8px; right: 8px; z-index: 2; width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line-2); background: var(--surface-3); color: var(--text); font-size: 16px; line-height: 1;
}
#modal[data-kind="join"] #modalX, #modal[data-kind="gone"] #modalX { display: none; }
#modalCard h2 { padding-right: 34px; }
.stickfoot { position: sticky; bottom: -22px; margin: 0 -22px -22px; padding: 12px 22px 22px; background: var(--surface); box-shadow: 0 -10px 16px var(--surface); }
@media (max-height: 640px) { #modalCard { padding: 16px; } .stickfoot { bottom: -16px; margin: 0 -16px -16px; padding: 10px 16px 16px; } }
#modalCard h2 { margin: 0 0 4px; font-size: 22px; font-weight: 700; }
#modalCard p { color: var(--muted); margin: 0 0 16px; font-size: 14px; }
#modalCard .field { margin-bottom: 12px; }
#modalCard .btn.primary { width: 100%; }
.logo { font-size: 30px; letter-spacing: 6px; text-align: center; margin-bottom: 8px; color: var(--text); }
.logo .r { color: var(--red); }

/* ---------- toasts ---------- */
#toasts { position: fixed; left: 0; right: 0; top: calc(env(safe-area-inset-top, 0px) + 54px); display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 40; pointer-events: none; }
.toast { background: var(--surface-3); border: 1px solid var(--line); padding: 8px 14px; border-radius: 14px; font-size: 14px; box-shadow: 0 6px 20px #0008; animation: up .2s; max-width: 90vw; }
.toast.err { border-color: var(--danger); }

.logview {
  max-height: 60vh; overflow: auto; font: 11px/1.4 ui-monospace, Menlo, monospace; white-space: pre-wrap; word-break: break-word;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 8px; margin: 0 0 12px; user-select: text;
}

/* small / short screens */
@media (max-height: 700px) {
  :root { --board-w: min(15vw, 70px); --mine-w: min(22vw, 100px); --emoji: min(9vw, 38px); }
  #opps { padding-top: 14px; gap: 6px 4px; }
}
@media (max-width: 360px) {
  :root { --mine-w: min(25vw, 86px); }
  #myPanel { padding: 10px 6px; }
  #myPanel .hn { font-size: 12px; padding: 0 28px; }
  .info-btn { top: 5px; right: 5px; }
}
@media (orientation: landscape) and (max-height: 520px) {
  :root { --board-w: min(9vw, 64px); --mine-w: min(11vw, 80px); --emoji: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- 1.3: peek, cheat sheet, sizing track, setup, invite ---------- */
#myCards { position: relative; cursor: pointer; }
#myCards .card.again { animation: flipIn .35s cubic-bezier(.2,.8,.2,1) both; }
#myCards .card.slot.mine { --w: var(--mine-w); }
#myCards.hidden-cards::after {
  content: "Tap to peek"; position: absolute; left: calc(var(--mine-w) * .55); top: 50%; transform: translate(-50%, -50%);
  background: #000c; color: var(--text); font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 12px; pointer-events: none;
}
#myCards.mucked .fan { opacity: .3; transform: translateY(8px); }
#myPanel { position: relative; }
.info-btn {
  position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid var(--line-2); background: transparent; color: var(--muted);
  font: italic 600 14px Georgia, serif; line-height: 1; padding: 0;
}
.info-btn:active { background: var(--surface-3); }

.track {
  --f: 0; position: relative; flex: 1; height: 44px; border-radius: 22px; background: var(--surface-3);
  touch-action: none; overflow: hidden; cursor: pointer;
}
.track .fill { position: absolute; inset: 0 auto 0 0; width: calc(22px + (100% - 22px) * var(--f)); background: #ffffff26; border-radius: 22px; }
.track .thumb {
  position: absolute; top: 4px; width: 36px; height: 36px; border-radius: 50%; background: var(--text);
  left: calc((100% - 40px) * var(--f) + 2px); box-shadow: 0 2px 8px #0008; transition: transform .1s;
}
.track.drag .thumb { transform: scale(1.12); }
.track .lo, .track .hi { position: absolute; top: 50%; transform: translateY(-50%); font-size: 11px; color: var(--muted); pointer-events: none; }
.track .lo { left: 46px; }
.track .hi { right: 12px; }

.cheat h2 { margin-bottom: 2px; }
.ranks { display: flex; flex-direction: column; gap: 2px; margin: 0 -6px; padding: 0 6px; }
.rank-row { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 14px; }
.rank-row.on { background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--win); }
.rank-no { width: 18px; color: var(--faint); font-size: 12px; text-align: center; }
.rank-main { flex: 1; min-width: 0; }
.rank-name { font-weight: 600; font-size: 14px; }
.rank-name .you { color: var(--win); font-size: 12px; }
.rank-desc { color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.rank-cards { display: flex; gap: 2px; }
.rank-cards .card { --w: 26px; box-shadow: none; border-radius: 4px; }
.rank-cards .card .r { font-size: 12px; top: 3px; left: 3px; font-weight: 600; }
.rank-cards .card .s { font-size: 9px; bottom: 3px; left: 3px; }
.rank-odds { color: var(--muted); font-size: 11px; width: 44px; text-align: right; }
.rules { padding-left: 18px; margin: 0 0 14px; }

.setup .presetrow { display: flex; gap: 8px; }
.preset { flex: 1; border: 1px solid var(--line-2); background: transparent; border-radius: 14px; padding: 8px 4px; color: var(--text); }
.preset b { display: block; font-size: 14px; font-weight: 600; }
.preset small { color: var(--muted); font-size: 11px; }
.preset.on { border-color: var(--text); background: var(--surface-3); }
.flabel { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.seg { display: flex; gap: 4px; flex-wrap: wrap; }
.seg label { flex: 1; min-width: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: flex; align-items: center; justify-content: center; text-align: center; min-height: 38px; padding: 4px 6px;
  border: 1px solid var(--line-2); border-radius: 12px; font-size: 13px; color: var(--muted); line-height: 1.15;
}
.seg input:checked + span { border-color: var(--text); color: var(--text); background: var(--surface-3); }
.maxrow { margin-top: 8px; }

.steps { display: flex; flex-direction: column; gap: 12px; }
.stepcard { border: 1px solid var(--line); border-radius: 20px; padding: 12px; text-align: center; }
.stephead { display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; margin-bottom: 8px; }
.stepno { width: 22px; height: 22px; border-radius: 50%; background: var(--text); color: #000; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; }
.stepcard .qr { width: min(200px, 56vw); }
.help.center { text-align: center; }
.help a { color: var(--text); }
.wifi-form { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.wifi-form .field { margin: 0; }
.form .full { grid-column: 1 / -1; }
.setup .seg span { font-size: 12.5px; }

/* your-turn edge glow */
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 50; opacity: 0;
  box-shadow: inset 0 0 0 3px #fff, inset 0 0 60px #ffffff55; border-radius: 28px;
}
body.turn-flash::after { animation: edgeflash 1.6s ease-out; }
@keyframes edgeflash { 0%, 30% { opacity: 1; } 100% { opacity: 0; } }
.online-form { display: flex; flex-direction: column; gap: 8px; }
.online-form .field { margin: 0; font-size: 14px; }
.help.small { font-size: 12px; margin-top: 6px; }
.net-options { display: flex; flex-direction: column; gap: 6px; }
.net-options .help.small { margin: 0 0 8px; text-align: center; }
.url.small-url { font-size: 15px; }
.spinner { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--text); animation: spin .8s linear infinite; vertical-align: -1px; margin-right: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- PC server: welcome screen, PIN, share ---------- */
body[data-mode="lobby"] #topbar, body[data-mode="lobby"] #game { visibility: hidden; }
#modal[data-kind="lobby"] #modalX, #modal[data-kind="pin"] #modalX { display: none; }
.or { color: var(--faint); margin: 20px 0 10px; font-size: 13px; text-align: center; }
.err { color: var(--danger); min-height: 18px; font-size: 13px; margin: 2px 0 6px; }
.code-field, .pin-field { text-transform: uppercase; letter-spacing: 4px; text-align: center; font-weight: 600; }
.lobby-join .row { align-items: stretch; }
.lobby-join .row .field { margin-bottom: 0 !important; height: 52px; }
.lobby-join .pin-field { margin-top: 10px; }
.recent { margin-top: 18px; }
.recent a.item { color: var(--text); text-decoration: none; }
.bigcode { font-size: 40px; font-weight: 800; letter-spacing: 8px; text-align: center; margin: 4px 0 10px; color: var(--accent, var(--text)); }
b.code { letter-spacing: 3px; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.swatch { background: transparent; border: 1px solid var(--line-2); border-radius: 14px; padding: 8px 4px 6px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.swatch.on { border-color: var(--accent, var(--text)); background: var(--surface-3); }
.swatch .sw { width: 34px; height: 34px; border-radius: 50%; background: var(--sw-bg); border: 1px solid #ffffff30; display: flex; align-items: center; justify-content: center; }
.swatch .sw i { width: 14px; height: 14px; border-radius: 50%; background: var(--sw-ac); }
.swatch small { font-size: 11px; color: var(--muted); }
.custom-colors { margin-top: 10px; }
.form label.color { flex-direction: row; align-items: center; justify-content: space-between; gap: 8px; border: 1px solid var(--line-2); border-radius: 14px; padding: 6px 10px; }
.form label.color input { width: 44px; height: 30px; padding: 0; border: 0; background: transparent; }

/* ---------- desktop: keyboard hints ---------- */
.kbd { display: none; }
body.desktop .kbd {
  display: inline-block; margin-left: 8px; padding: 0 5px; min-width: 18px; height: 18px; line-height: 17px;
  border: 1px solid currentColor; border-radius: 5px; font-size: 10px; font-weight: 600; opacity: .55; vertical-align: 2px; text-align: center;
}
.presets button .kbd { margin-left: 5px; }

/* ---------- wide screens (PC browsers) ---------- */
@media (min-width: 900px) and (min-height: 600px) {
  :root { --board-w: min(7.2vw, 108px); --mine-w: min(9vw, 128px); --emoji: 52px; }
  #topbar { width: 100%; max-width: 1180px; margin: 0 auto; padding: 14px 24px 4px; }
  #blinds { font-size: 16px; }
  #subtitle { font-size: 13px; }
  #game { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 24px 22px; }
  #opps { gap: 16px 10px; padding-top: 26px; }
  .opp .cards .card { --w: 40px; }
  .opp .name { font-size: 14px; }
  #center { gap: 18px; }
  #message { font-size: 16px; }
  #dock { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); grid-template-areas: "mine controls"; align-items: end; gap: 28px; }
  #controls { grid-area: controls; }
  #mine { grid-area: mine; }
  .btn { height: 54px; }
  #modalBox { width: min(460px, 100%); }
}
