:root {
  --sky1: #b6e4f8;
  --sky2: #dcf2fb;
  --sky3: #f2fafe;
  --ink: #0f2a44;
  --ink2: #3c5873;
  --muted: #6b8299;
  --panel: #ffffff;
  --soft: #f2f7fa;
  --line: rgba(15, 42, 68, 0.09);
  --line2: rgba(15, 42, 68, 0.16);
  --shadow: 0 1px 2px rgba(15, 42, 68, .05), 0 6px 16px rgba(15, 42, 68, .06);
  --shadow-lg: 0 2px 6px rgba(15, 42, 68, .06), 0 18px 40px rgba(15, 42, 68, .14);
  --brand: #1677c9;
  --hot: #f2622e;
  --hot-d: #db5021;
  --gold: #f5b301;
  --goldInk: #b97f00;
  --ice: #3f6fe0;
  --good: #1aa863;
  --good-d: #15914f;
  --bad: #e5384b;
  --cream: #fffdf8;
  --r-lg: 16px;
  --r-md: 12px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: linear-gradient(180deg, var(--sky1) 0%, var(--sky2) 50%, var(--sky3) 100%) fixed, var(--sky2);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
.hidden { display: none !important; }

#app { position: fixed; inset: 0; }
.screen { position: absolute; inset: 0; display: none; flex-direction: column; }
.screen.active { display: flex; }

@keyframes fade { from { opacity: 0; } }
@keyframes dropin { from { transform: translateY(-10px) scale(1.04); opacity: 0; } }

/* ---------- buttons ---------- */
.btn { border-radius: var(--r-md); padding: 14px 18px; font-weight: 600; font-size: 16px; transition: transform .1s, background .15s, opacity .15s; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--hot); color: #fff; box-shadow: 0 1px 2px rgba(219, 80, 33, .3), 0 6px 16px rgba(242, 98, 46, .22); }
.btn.primary:active { background: var(--hot-d); }
.btn.big { font-size: 17px; padding: 16px; }
.btn.ghost { background: var(--panel); border: 1px solid var(--line2); }
.btn.link { color: var(--brand); font-weight: 600; }
.btn.pink { background: var(--bad); color: #fff; }

/* ---------- setup ---------- */
#setup { padding: calc(var(--safe-t) + 20px) 20px calc(var(--safe-b) + 20px); gap: 16px; overflow-y: auto; max-width: 520px; margin: 0 auto; }
.logo { text-align: center; margin-top: auto; }
#setup > :last-child { margin-bottom: auto; }
.logo h1 { margin: 16px 0 0; font-size: 44px; font-weight: 800; letter-spacing: -.03em; line-height: 1; color: var(--ink); }
.logo h1 span { color: var(--hot); }
.tag { margin: 8px 0 0; color: var(--ink2); font-weight: 500; font-size: 15px; }

.panel { background: var(--panel); border-radius: var(--r-lg); padding: 16px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.panel label { font-weight: 600; font-size: 16px; }
.stepper { display: flex; align-items: center; gap: 2px; background: var(--soft); border-radius: 10px; padding: 3px; }
.stepper button { width: 38px; height: 34px; border-radius: 8px; font-size: 20px; font-weight: 500; color: var(--brand); }
.stepper button:active { background: #fff; }
.stepper span { min-width: 30px; text-align: center; font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
#names { display: flex; flex-direction: column; gap: 8px; }
.nameIn { display: flex; align-items: center; gap: 10px; }
.nameIn .sw { width: 10px; height: 10px; border-radius: 50%; flex: none; background: currentColor; }
.nameIn input { flex: 1; min-width: 0; font: inherit; font-size: 16px; font-weight: 500; color: var(--ink); background: var(--soft); border: 1px solid transparent; border-radius: 10px; padding: 11px 12px; outline: none; -webkit-user-select: text; user-select: text; transition: border-color .15s, background .15s; }
.nameIn input:focus { border-color: var(--brand); background: #fff; }
.nameIn input::placeholder { color: #9bb0c2; }
.seg { display: flex; background: var(--soft); border-radius: 10px; padding: 3px; }
.seg button { padding: 7px 11px; border-radius: 8px; font-weight: 600; font-size: 14px; color: var(--muted); transition: background .15s, color .15s; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(15, 42, 68, .12); }

/* ---------- table ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: calc(var(--safe-t) + 8px) 14px 8px 16px; font-weight: 600; color: var(--ink2); font-size: 13px; letter-spacing: .01em; }
.topbar .dot { margin: 0 6px; opacity: .4; }
.tb-left { background: rgba(255, 255, 255, .75); border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px; }
.iconbtn { width: 36px; height: 32px; border-radius: 10px; background: rgba(255, 255, 255, .8); font-size: 18px; line-height: 1; font-weight: 700; color: var(--ink2); border: 1px solid var(--line); }
.tablebody { flex: 1; display: flex; min-height: 0; gap: 10px; padding: 0 12px; }

#rail { width: 108px; flex: none; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; padding: 2px 2px 8px 0; scrollbar-width: none; }
#rail::-webkit-scrollbar { display: none; }
.chip { position: relative; text-align: left; border-radius: var(--r-md); padding: 8px 9px 8px 12px; background: var(--panel); border: 1.5px solid transparent; box-shadow: var(--shadow); transition: border-color .2s, background .2s; overflow: hidden; }
.chip::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--pc); }
.chip .nm { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 16px; color: var(--pc); }
.chip .tot { font-weight: 700; font-size: 24px; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.chip .rd { font-size: 12px; font-weight: 600; color: var(--muted); display: flex; gap: 5px; align-items: center; min-height: 16px; }
.chip .rd .plus { color: var(--goldInk); }
.chip .bar { height: 3px; border-radius: 2px; background: var(--soft); margin-top: 6px; overflow: hidden; }
.chip .bar i { display: block; height: 100%; background: var(--pc); border-radius: 2px; transition: width .6s; }
.chip .dealer { position: absolute; right: 7px; top: 7px; width: 16px; height: 16px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 9px; font-weight: 700; display: grid; place-items: center; }
.chip.turn { border-color: var(--gold); }
.chip.focus:not(.turn) { border-color: var(--line2); }
.chip.out { opacity: .7; }
.chip.busted .tot { color: var(--bad); }
.chip.locked { border-color: var(--ice); }
.tag-s { font-size: 9.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px; letter-spacing: .06em; color: #fff; text-transform: uppercase; line-height: 1.4; }
.tag-s.bust { background: var(--bad); }
.tag-s.closed { background: var(--good); }
.tag-s.locked { background: var(--ice); }
.tag-s.sc { background: #9550e0; }
.tag-s.turn { background: var(--gold); color: #3a2a00; }
.tag-s.skip { background: #9fb3c4; }

#stage { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: stretch; }


/* ---------- cards ---------- */
.card { position: relative; aspect-ratio: 5 / 7; border-radius: 10%/7.2%; container-type: inline-size; background: var(--cream); box-shadow: 0 0 0 1px rgba(15, 42, 68, .07), 0 2px 6px rgba(15, 42, 68, .1); overflow: hidden; flex: none; }
.card.num::before { content: ""; position: absolute; inset: 6cqw; border-radius: 7cqw; border: 1.4cqw solid color-mix(in srgb, var(--c) 55%, transparent); }
.card.num .big { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 750; font-size: 52cqw; color: var(--c); letter-spacing: -.05em; }
.card .corner { position: absolute; font-weight: 700; font-size: 13cqw; color: var(--c); line-height: 1; opacity: .8; }
.card .tl { left: 12cqw; top: 11cqw; }
.card .br { right: 12cqw; bottom: 11cqw; transform: rotate(180deg); }
.card .ic { position: absolute; left: 50%; top: 50%; width: 70cqw; height: 70cqw; transform: translate(-50%, -50%); }
.card .ic svg { width: 100%; height: 100%; display: block; }

/* Bonus cards teal; actions: Chill blue, Hat Trick green, Lifeline violet. */
.card.mod, .card.x2 { background: linear-gradient(165deg, #3fd1c2, #12a091); }
.card.mod .big, .card.x2 .big { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 750; font-size: 40cqw; letter-spacing: -.04em; color: #fff; text-shadow: 0 .6cqw 1.6cqw rgba(0, 70, 64, .3); }
.card.x2 .big { font-size: 44cqw; }
.card.lock { background: linear-gradient(165deg, #7fb2ff, #3f6fe0); }
.card.rush { background: linear-gradient(165deg, #7fe3a6, #26b468); }
.card.shield { background: linear-gradient(165deg, #cf9cff, #9550e0); }

/* Card back: matches the logo, a blue-to-purple gradient with the lightning bolt. */
.card.back { background: linear-gradient(160deg, #4f8cff, #6a5cf0 55%, #b44fe0); box-shadow: inset 0 0 0 3cqw rgba(255, 255, 255, .28), 0 2px 6px rgba(15, 42, 68, .14); }
.card.back::before { content: ""; position: absolute; left: 50%; top: 50%; width: 46cqw; height: 46cqw; transform: translate(-50%, -50%); border-radius: 50%; background: rgba(255, 255, 255, .16) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='44 30 40 60'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%23ffcf3f'/%3E%3Cstop offset='1' stop-color='%23ff7a2f'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M70 33 50 62h13l-6 24 21-31H64l6-22Z' fill='url(%23g)' stroke='%23fff' stroke-width='2.5' stroke-linejoin='round'/%3E%3C/svg%3E") center / 62% no-repeat; box-shadow: inset 0 0 0 1.6cqw rgba(255, 255, 255, .55); }

.card .xmark { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(229, 56, 75, .12); color: var(--bad); font-size: 56cqw; font-weight: 500; }

/* ---------- reveal ---------- */
#reveal { position: absolute; left: 50%; top: 46%; width: 56%; max-width: 180px; transform: translate(-50%, -50%); pointer-events: none; perspective: 900px; z-index: 5; }
#reveal .flipper { position: relative; width: 100%; aspect-ratio: 5 / 7; transform-style: preserve-3d; animation: flyflip .5s cubic-bezier(.3, .8, .3, 1) both; }
#reveal .flipper > .card { position: absolute; inset: 0; width: 100%; backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: var(--shadow-lg); }
#reveal .flipper > .card.back { transform: rotateY(180deg); }
#reveal.out .flipper { animation: flyout .3s cubic-bezier(.4, 0, .2, 1) forwards; }
@keyframes flyflip {
  0% { transform: translate(-60%, 110%) scale(.5) rotateY(180deg); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: none; }
}
@keyframes flyout { to { transform: translateY(-10%) scale(.8); opacity: 0; } }

/* Event label: a clean pill in the middle of the table. */
#stamp { position: fixed; left: 50%; top: 44%; transform: translate(-50%, -50%); z-index: 6; pointer-events: none; opacity: 0; white-space: nowrap; text-align: center;
  padding: 10px 22px; border-radius: 999px; font-size: 20px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #fff; box-shadow: var(--shadow-lg); }
#stamp small { display: block; font-size: 12px; font-weight: 500; letter-spacing: .02em; text-transform: none; opacity: .9; margin-top: 1px; }
#stamp.show { animation: stamp 1.3s cubic-bezier(.2, .8, .3, 1) forwards; }
#stamp.bust { background: var(--bad); }
#stamp.sweep { background: linear-gradient(135deg, #3fd1c2, #5563e6); }
#stamp.saved { background: #9550e0; }
#stamp.lock { background: #3f6fe0; }
#stamp.rush { background: #26b468; }
@keyframes stamp {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.9); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(.98); }
}

.flashred::after, .flashlock::after, .flashgold::after { content: ""; position: fixed; inset: 0; pointer-events: none; animation: flash .7s ease-out forwards; z-index: 40; }
.flashred::after { background: radial-gradient(circle, transparent 45%, rgba(229, 56, 75, .25)); }
.flashlock::after { background: radial-gradient(circle, transparent 40%, rgba(63, 111, 224, .28)); }
.flashgold::after { background: radial-gradient(circle, transparent 40%, rgba(245, 179, 1, .28)); }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

/* ---------- controls: three equal buttons ---------- */
#controls { display: grid; grid-template-columns: 1fr 1fr; grid-template-areas: "skip close" "flip flip"; gap: 8px; padding: 10px 12px calc(var(--safe-b) + 12px); }
#controls > button { position: relative; min-width: 0; height: 46px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden;
  font-size: 17px; font-weight: 600; letter-spacing: .01em; transition: transform .1s, background .15s, opacity .2s, box-shadow .2s; }
#controls > button:active { transform: scale(.97); }
#controls > button b { font-weight: 600; }
.deckbtn { grid-area: flip; height: 68px !important; font-size: 22px !important; font-weight: 700 !important; letter-spacing: .02em !important; background: var(--hot); color: #fff; box-shadow: 0 1px 2px rgba(219, 80, 33, .3), 0 6px 16px rgba(242, 98, 46, .22); touch-action: none; -webkit-touch-callout: none; }
.closebtn { grid-area: close; background: var(--good); color: #fff; box-shadow: 0 1px 2px rgba(21, 145, 79, .3), 0 6px 16px rgba(26, 168, 99, .2); }
.skipbtn { grid-area: skip; flex-direction: row !important; gap: 6px; background: var(--panel); color: var(--ink); border: 1px solid var(--line2); box-shadow: var(--shadow); }
.skipbtn small { font-size: 11px; font-weight: 500; color: var(--muted); }
.skipbtn.off { opacity: .4; pointer-events: none; box-shadow: none; }
#controls.locked button { opacity: .4; pointer-events: none; box-shadow: none; }

/* Hold to flip: the button fills from left to right while held. */
.deckbtn.charging { background: var(--hot-d); }
.deckbtn.charged { box-shadow: 0 0 0 3px rgba(245, 179, 1, .55), 0 6px 16px rgba(242, 98, 46, .3); }
.deckbtn > span { position: relative; }
.flycard { position: fixed; z-index: 45; pointer-events: none; margin: 0; }

/* ---------- banner / toast ---------- */
#banner { position: fixed; left: 0; right: 0; top: 38%; z-index: 30; text-align: center; pointer-events: none; opacity: 0; }
#banner.show { animation: banner 1.1s cubic-bezier(.2, .8, .3, 1) forwards; }
#banner .inner { display: inline-block; padding: 12px 26px; border-radius: var(--r-lg); background: rgba(255, 255, 255, .96); border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
#banner small { display: block; font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; }
#banner b { display: block; font-size: 26px; font-weight: 700; letter-spacing: -.01em; color: var(--pc, var(--ink)); }
@keyframes banner { 0% { opacity: 0; transform: translateY(8px); } 18% { opacity: 1; transform: none; } 78% { opacity: 1; } 100% { opacity: 0; transform: translateY(-6px); } }
#toast { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 150px); transform: translateX(-50%); z-index: 25; max-width: 88%; padding: 10px 16px; border-radius: var(--r-md); background: #fff; color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow-lg); font-weight: 500; font-size: 14px; text-align: center; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
#toast b { font-weight: 700; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

/* ---------- modal ---------- */
#modalWrap { position: fixed; inset: 0; z-index: 50; background: rgba(15, 42, 68, .3); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
#modal { width: 100%; max-width: 520px; max-height: 92%; overflow-y: auto; background: #fff; border-radius: 20px 20px 0 0; padding: 22px 18px calc(var(--safe-b) + 18px); box-shadow: 0 -8px 30px rgba(15, 42, 68, .14); animation: slideup .3s cubic-bezier(.2, .8, .3, 1); }
@keyframes slideup { from { transform: translateY(100%); } }
#modal h2 { margin: 0 0 4px; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
#modal h3 { font-size: 15px; font-weight: 600; }
#modal p { margin: 0 0 12px; color: var(--muted); font-weight: 400; font-size: 15px; line-height: 1.4; }
#modal p b { color: var(--ink); font-weight: 600; }
.mhead { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.mhead .card { width: 64px; animation: dropin .3s ease-out; }
.pick { display: flex; flex-direction: column; gap: 8px; }
.pick button { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 16px 13px 20px; border-radius: var(--r-md); background: var(--soft); border: 1px solid transparent; text-align: left; transition: transform .1s, background .15s, border-color .15s; }
.pick button::before { content: ""; position: absolute; left: 9px; top: 50%; width: 4px; height: 26px; transform: translateY(-50%); border-radius: 2px; background: var(--pc); }
.pick button:active { transform: scale(.98); border-color: var(--pc); background: #fff; }
.pick .pn { font-size: 17px; font-weight: 600; color: var(--ink); }
.pick .pm { font-size: 12.5px; font-weight: 500; color: var(--muted); margin-top: 1px; }
.pick .pr { font-size: 20px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.pick .you { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 999px; background: var(--ink); color: #fff; margin-left: 6px; vertical-align: middle; letter-spacing: .06em; }

.sumrows { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 16px; }
.sumrow { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 12px 14px 12px 20px; border-radius: var(--r-md); background: var(--soft); }
.sumrow::before { content: ""; position: absolute; left: 9px; top: 12px; bottom: 12px; width: 4px; border-radius: 2px; background: var(--pc); }
.sumrow .sn { font-weight: 600; font-size: 16px; }
.sumrow .st { font-weight: 700; font-size: 24px; letter-spacing: -.02em; text-align: right; font-variant-numeric: tabular-nums; grid-row: span 2; align-self: center; }
.sumrow .sb { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.sumrow .gain { color: var(--goldInk); font-weight: 700; }
.sumrow .gain.zero { color: var(--bad); }
.sumrow.lead { background: #fff7e0; }
.sumrow .bar { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: rgba(15, 42, 68, .08); overflow: hidden; margin-top: 8px; }
.sumrow .bar i { display: block; height: 100%; width: 0; background: var(--pc); transition: width 1s .2s; }
.winner { text-align: center; padding: 8px 0 4px; }
.winner small { display: block; font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.winner h2 { font-size: 30px !important; color: var(--pc, var(--ink)); margin-top: 4px !important; }
.mbtns { display: flex; flex-direction: column; gap: 10px; }
.menu-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.menu-list .btn { text-align: left; }
.rules { font-size: 15px; line-height: 1.5; color: var(--ink2); font-weight: 400; }
.rules p { color: var(--ink2) !important; }
.rules b { color: var(--ink); font-weight: 600; }
.rules h3 { margin: 18px 0 6px; font-size: 13px !important; font-weight: 600; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.rules ul { margin: 0; padding-left: 18px; }
.rules li { margin: 4px 0; }
.rules .minis { display: flex; gap: 6px; margin: 8px 0 10px; }
.rules .minis .card { width: 44px; }

#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }

@media (min-width: 600px) {
  #rail { width: 150px; }
  .tablebody, #controls { max-width: 760px; margin-left: auto; margin-right: auto; width: 100%; }
}
@media (max-height: 700px) {
  #controls > button { height: 42px; }
  .deckbtn { height: 60px !important; }
}

/* ---------- heat (table warms as your hand fills) ---------- */
#heat { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity .7s ease;
  background: linear-gradient(180deg, #ffc9a0 0%, #ffe0c4 50%, #fff4e8 100%); }
#heat.beat { animation: heatbeat var(--beat, 1s) ease-in-out infinite; }
@keyframes heatbeat { 0%, 100% { filter: none; } 15% { filter: saturate(1.35); } 30% { filter: none; } }

/* ---------- achievements, moments ---------- */
#badge { position: fixed; left: 50%; top: calc(var(--safe-t) + 54px); z-index: 70; transform: translate(-50%, -16px); opacity: 0; visibility: hidden; transition: transform .35s cubic-bezier(.2, .8, .3, 1), opacity .25s, visibility .25s; pointer-events: none;
  display: flex; align-items: center; gap: 12px; padding: 10px 16px 10px 12px; border-radius: var(--r-lg); background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow-lg); width: max-content; max-width: 92vw; }
#badge.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
#badge .be { font-size: 24px; width: 38px; height: 38px; border-radius: 10px; background: #fff7e0; display: grid; place-items: center; }
#badge small { display: block; font-size: 10.5px; font-weight: 600; color: var(--goldInk); letter-spacing: .08em; text-transform: uppercase; }
#badge b { display: block; font-size: 15px; font-weight: 700; }
#badge span.d { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.achlist { display: flex; flex-direction: column; gap: 6px; margin: 0 0 16px; }
.achrow { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
.achchips { display: flex; flex-wrap: wrap; gap: 6px; }
.achrow .an { color: var(--pc); min-width: 64px; }
.achchip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 9px; border-radius: 999px; background: var(--soft); border: 1px solid var(--line); font-size: 12.5px; font-weight: 500; }
.moment { margin: 8px 0 4px; padding: 11px 14px; border-radius: var(--r-md); background: var(--soft); font-weight: 500; font-size: 14.5px; }
.moment b { font-weight: 700; }
.moment small { display: block; font-size: 10.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.newlead { display: inline-block; margin-top: 6px; padding: 3px 10px; border-radius: 999px; background: #fff1c4; color: #6b4b00; font-weight: 600; font-size: 12.5px; }

/* ---------- undo ---------- */
#undo { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 200px); transform: translateX(-50%); z-index: 26; overflow: hidden; padding: 10px 18px; border-radius: var(--r-md); background: var(--ink); color: #fff; font-weight: 600; font-size: 15px; box-shadow: var(--shadow-lg); animation: dropin .25s ease-out; }
#undo i { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--gold); transform-origin: left; animation: undoBar 5s linear forwards; }
@keyframes undoBar { to { transform: scaleX(0); } }

/* ---------- hands: 2-3 players all on screen; 4+ players the focused hand beside the score rail ----------
   Card sizes (--cols, --cw, --xw) come from layoutSeats() in app.js so each hand fills its space. */
#table:not(.railmode) #rail { display: none; }
#seats { display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 0; padding: 2px 1px 2px; }
.seat { position: relative; flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; gap: 8px; background: var(--panel); border-radius: var(--r-lg); padding: 11px 12px 12px 16px; border: 1.5px solid transparent; box-shadow: var(--shadow); overflow: hidden; transition: border-color .2s, background .2s, box-shadow .2s; }
.seat::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 4px; border-radius: 0 4px 4px 0; background: var(--pc); }
.seat.turn { border-color: var(--gold); background: linear-gradient(180deg, #fff8e6, #fff 55%); box-shadow: 0 0 0 4px rgba(245, 179, 1, .15), var(--shadow); }
.seat.focus { border-color: var(--line2); }
.seat.out { background: rgba(255, 255, 255, .75); }
.seat.locked { border-color: var(--ice); background: linear-gradient(180deg, #ebf2ff, #fff 55%); }
.seat.busted .seat-cards .card { filter: grayscale(.9) opacity(.6); }
.seat-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.seat-name { flex: 1 1 0; display: flex; align-items: center; gap: 6px; min-width: 0; min-height: 26px; font-weight: 700; font-size: 16px; color: var(--pc); }
.seat-name .nm { flex: 0 1 auto; min-width: 2.5em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-name .tag-s { flex: none; }
.seat-score { display: flex; align-items: center; gap: 8px; flex: none; }
.seat-rd { font-size: 13px; font-weight: 600; color: var(--goldInk); font-variant-numeric: tabular-nums; }
.seat-rd small { font-size: 11px; font-weight: 500; color: var(--muted); }
.seat.busted .seat-rd { color: var(--bad); }
.seat-tot { min-width: 40px; text-align: center; padding: 3px 10px; border-radius: 999px; background: color-mix(in srgb, var(--pc) 13%, #fff); font-size: 20px; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.seat-body { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; justify-content: space-evenly; gap: 8px; }
.seat-cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; align-self: center;
  width: calc(var(--cols, 7) * var(--cw, 40px) + (var(--cols, 7) - 1) * 6px); }
.seat-cards > * { width: var(--cw, 40px); flex: none; }
.seat-cards .card.new, .seat-extras .card.new { animation: dropin .28s ease-out; }
.slot { aspect-ratio: 5 / 7; border-radius: 10%/7.2%; background: color-mix(in srgb, var(--pc) 7%, #f3f7fa); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pc) 12%, transparent); }
.seat-extras { display: flex; gap: 6px; justify-content: center; min-height: calc(var(--xw, 32px) * 1.4); }
.seat-extras .card { width: var(--xw, 32px); }
/* 4+ players: the hand panel is narrow, so the name gets its own line above the score. */
#table.railmode .seat-head { flex-wrap: wrap; row-gap: 6px; }
#table.railmode .seat-name { flex: 1 0 100%; }
/* Score chips share the rail's height (up to a point) so the column doesn't end in empty space. */
#rail .chip { flex: 1 1 0; min-height: 66px; max-height: 128px; display: flex; flex-direction: column; justify-content: center; }
#rail .chip .tot { font-size: 28px; }

/* 6 and 9 are underlined so they read correctly upside down. */
.card.num.u69 .big, .card.num.u69 .corner { text-decoration: underline; text-decoration-thickness: .08em; text-underline-offset: .08em; }
.seat-extras { align-items: center; }
.xhint { font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: color-mix(in srgb, var(--pc) 45%, #9fb0bf); }

/* ---------- whose turn ---------- */
.topbar { position: relative; }
.topbar { gap: 8px; }
.topbar .tb-left { margin-left: auto; flex: none; white-space: nowrap; }
#btnMenu { flex: none; }
#turnPill { order: -1; flex: 0 1 auto; min-width: 0; padding: 6px 14px; border-radius: 999px;
  background: var(--pc); color: #fff; font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--pc) 40%, transparent); }
.seat.turn { border: 2px solid var(--pc); background: linear-gradient(180deg, color-mix(in srgb, var(--pc) 10%, #fff), #fff 60%);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--pc) 16%, transparent), var(--shadow); }
#seats.hasturn .seat:not(.turn) { opacity: .6; filter: saturate(.7); }
.seat { transition: opacity .25s, filter .25s, border-color .2s, background .2s, box-shadow .2s; }
.tag-s.turn { background: var(--pc); color: #fff; }
.chip.turn { border-color: var(--pc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pc) 18%, transparent), var(--shadow); }

/* Dealer marker spelled out. */
.tag-s.dealer { background: var(--soft); color: var(--ink2); box-shadow: inset 0 0 0 1px var(--line2); }
.chip .dealer { width: auto; height: auto; padding: 1px 6px; border-radius: 999px; background: var(--soft); color: var(--ink2); font-size: 8.5px; letter-spacing: .04em; text-transform: uppercase; box-shadow: inset 0 0 0 1px var(--line2); }

/* Small phones (iPhone SE / mini width and below): trim secondary text so nothing collides. */
@media (max-width: 380px) {
  .seat-rd small { display: none; }
  .tb-left { padding: 6px 10px; font-size: 12px; }
  #turnPill { font-size: 13px; padding: 6px 12px; }
  .seat { padding: 10px 10px 11px 14px; }
}
@media (max-width: 340px) {
  #targetLbl, .topbar .dot { display: none; }
  .seat-name { font-size: 15px; }
  .seat-tot { font-size: 18px; padding: 2px 8px; }
}

/* ---------- full-screen action picker (Chill / Hat Trick / spare Lifeline) ---------- */
#modal.picker { max-width: none; height: 100%; max-height: 100%; border-radius: 0; display: flex; flex-direction: column; gap: 14px;
  padding: calc(var(--safe-t) + 22px) 18px calc(var(--safe-b) + 18px); box-shadow: none; animation: fade .2s ease-out; }
#modal.picker.lock { background: radial-gradient(120% 60% at 50% 0%, #b8d3ff, #ebf2ff 55%, #fff); }
#modal.picker.rush { background: radial-gradient(120% 60% at 50% 0%, #a6efc3, #e8fbf0 55%, #fff); }
#modal.picker.shield { background: radial-gradient(120% 60% at 50% 0%, #e2c4ff, #f6edff 55%, #fff); }
.pk-hero { flex: none; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; }
.pk-card { width: min(30vw, 22vh, 150px); perspective: 800px; margin-bottom: 6px; filter: drop-shadow(0 16px 26px rgba(15, 42, 68, .28)); }
.pk-card .card { width: 100%; animation: pkcard .7s cubic-bezier(.2, 1.25, .35, 1) both, pkfloat 3.2s ease-in-out .8s infinite; }
@keyframes pkcard { from { transform: rotateY(180deg) rotate(-18deg) scale(.4); opacity: 0; } }
@keyframes pkfloat { 50% { transform: translateY(-7px) rotate(-2deg); } }
#modal.picker h2 { margin: 0; font-size: 32px; font-weight: 800; letter-spacing: -.02em; }
#modal.picker.lock h2 { color: #2c58c4; }
#modal.picker.rush h2 { color: #17844a; }
#modal.picker.shield h2 { color: #7a35c4; }
#modal.picker p { margin: 0; max-width: 34ch; font-size: 15px; }
#modal.picker .pick { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
#modal.picker .pick button { flex: 1 1 0; min-height: 66px; max-height: 128px; padding: 12px 18px 12px 26px; border-radius: 18px; background: #fff;
  border: 1.5px solid var(--line); box-shadow: var(--shadow); animation: pkbtn .4s cubic-bezier(.2, .9, .3, 1) both; }
#modal.picker .pick button::before { left: 11px; width: 5px; height: 60%; }
#modal.picker .pick button:active { transform: scale(.97); border-color: var(--pc); background: color-mix(in srgb, var(--pc) 8%, #fff); }
@keyframes pkbtn { from { transform: translateY(18px); opacity: 0; } }
.pk-who { min-width: 0; flex: 1 1 auto; }
#modal.picker .pn { display: flex; align-items: center; gap: 6px; font-size: 21px; font-weight: 700; color: var(--pc); min-width: 0; }
.pn-t { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#modal.picker .pm { font-size: 13px; }
#modal.picker .pr { flex: none; text-align: right; font-size: 30px; font-weight: 800; line-height: 1; }
#modal.picker .pr small { display: block; font-size: 10.5px; font-weight: 600; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; margin-top: 3px; }

/* ---------- bust: the card swells and glows red, splits, and the halves drift apart ---------- */
#reveal.busting .flipper > .card:not(.back) { animation: bustswell .42s cubic-bezier(.3, .7, .4, 1) forwards; }
@keyframes bustswell {
  to { transform: scale(1.07); box-shadow: 0 0 0 3px rgba(229, 56, 75, .9), 0 0 36px 6px rgba(229, 56, 75, .5), 0 18px 36px rgba(15, 42, 68, .3); }
}
.shard { position: fixed !important; right: auto; bottom: auto; z-index: 46; margin: 0; pointer-events: none;
  box-shadow: 0 0 0 3px rgba(229, 56, 75, .9), 0 0 30px 4px rgba(229, 56, 75, .45) !important; }
#stamp.bust { font-size: 30px; padding: 14px 34px; letter-spacing: .1em; box-shadow: 0 0 0 6px rgba(229, 56, 75, .2), 0 18px 40px rgba(229, 56, 75, .4); }
#stamp.bust.show { animation: bustin 1.35s cubic-bezier(.2, .8, .3, 1) forwards; }
@keyframes bustin {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.5); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(.97); }
  28%, 82% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(.98); }
}
.seat.busting { animation: seatred 1s ease-out; }
@keyframes seatred {
  0% { box-shadow: 0 0 0 0 rgba(229, 56, 75, .55); background: #fff; }
  35% { box-shadow: 0 0 0 7px rgba(229, 56, 75, .22); background: #ffe8eb; }
  100% { box-shadow: var(--shadow); }
}
.seat.busting .seat-cards .card { transition: filter .6s ease; }

/* ---------- round results: tall sheet, big rows, big Next round button ---------- */
#modal.results { min-height: 84%; display: flex; flex-direction: column; padding: 26px 20px calc(var(--safe-b) + 20px); }
#modal.results h2 { font-size: 28px; }
#modal.results .moment { padding: 14px 16px; font-size: 16px; }
#modal.results .sumrows { flex: 1 1 auto; gap: 12px; margin: 14px 0 18px; }
#modal.results .sumrow { padding: 16px 18px 16px 26px; border-radius: 16px; }
#modal.results .sumrow::before { left: 11px; width: 5px; top: 16px; bottom: 16px; }
#modal.results .sumrow .sn { font-size: 20px; }
#modal.results .sumrow .sb { font-size: 14px; }
#modal.results .sumrow .st { font-size: 38px; }
#modal.results .sumrow .bar { height: 6px; margin-top: 10px; }
#modal.results .mbtns { margin-top: auto; gap: 12px; }
#modal.results #mNext, #modal.results #mRematch { min-height: 66px; font-size: 20px; font-weight: 700; border-radius: 18px; }
#modal.results #mNew, #modal.results #mUndo { min-height: 52px; font-size: 17px; }

/* ---------- controls: bigger Skip / Close (Flip stays the biggest) ---------- */
#controls > button { height: 54px; font-size: 18px; }
.deckbtn { height: 70px !important; font-size: 24px !important; }
.skipbtn small { font-size: 12px; }
@media (max-height: 700px) {
  #controls > button { height: 48px; }
  .deckbtn { height: 62px !important; }
}

/* ---------- tighter chrome around the hands so the cards get the space ---------- */
#table.railmode #seats, #seats { gap: 8px; }
.seat { padding: 10px 11px 11px 15px; gap: 6px; }
.seat-body { gap: 6px; }
#controls { padding-top: 8px; }

/* ---------- continue saved game: a big card at the top of setup ---------- */
.resume { display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px 16px 16px 20px; border-radius: 18px; text-align: left; color: #fff;
  background: linear-gradient(135deg, #2b8fe0, #1667b8); box-shadow: 0 2px 4px rgba(22, 103, 184, .3), 0 12px 28px rgba(22, 119, 201, .32);
  animation: dropin .35s ease-out; transition: transform .1s; }
.resume:active { transform: scale(.98); }
.rs-txt { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.rs-title { font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.rs-sub { font-size: 13px; font-weight: 600; opacity: .9; }
.rs-who { display: block; margin-top: 4px; padding: 4px 10px; align-self: flex-start; max-width: 100%; border-radius: 999px; background: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rs-go { flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: #fff; color: #1667b8; font-size: 18px; padding-left: 3px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .15); animation: rsPulse 2s ease-in-out infinite; }
@keyframes rsPulse { 50% { transform: scale(1.08); box-shadow: 0 0 0 8px rgba(255, 255, 255, .25); } }
#modal.results #mNext { display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15; }
#modal.results #mNext small { display: block; max-width: 100%; font-size: 13px; font-weight: 500; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Short phones (iPhone SE height): compact the results rows and the setup logo so nothing scrolls. */
@media (max-height: 740px) {
  #modal.results { padding-top: 20px; }
  #modal.results h2 { font-size: 24px; }
  #modal.results .moment { padding: 10px 14px; font-size: 15px; }
  #modal.results .sumrows { gap: 8px; margin: 10px 0 12px; }
  #modal.results .sumrow { padding: 11px 16px 11px 24px; }
  #modal.results .sumrow .sn { font-size: 18px; }
  #modal.results .sumrow .st { font-size: 32px; }
  #modal.results .sumrow .bar { margin-top: 7px; }
  #modal.results #mNext, #modal.results #mRematch { min-height: 60px; }
  .logo h1 { margin-top: 10px; font-size: 36px; }
  #setup { gap: 12px; }
}
/* Short phones: trim the Continue card and How-to-play link so setup fits without scrolling. */
@media (max-height: 740px) {
  .resume { padding: 12px 14px 12px 18px; }
  .rs-who { margin-top: 2px; }
  .rs-go { width: 40px; height: 40px; }
  #btnRules { padding: 6px; }
}

/* ---------- setup: app-icon style logo mark (flame rising behind a 7 card) ---------- */
.mark { width: 112px; height: 112px; margin: 0 auto; position: relative; animation: mkIn .8s cubic-bezier(.2, 1.2, .35, 1) both, mkFloat 4.5s ease-in-out .8s infinite; }
.mark::before { content: ""; position: absolute; inset: 10px 6px -10px; border-radius: 34px; background: rgba(240, 67, 106, .45); filter: blur(18px); z-index: -1; animation: mkGlow 4.5s ease-in-out infinite; }
.mark svg { width: 100%; height: 100%; display: block; overflow: visible; }
.mk-flame { transform-origin: 60px 70px; animation: mkFlicker 1.6s ease-in-out infinite; }
.mk-shine { animation: mkShine 4s ease-in-out 1.2s infinite; transform: translateX(-60px); }
@keyframes mkIn { from { transform: scale(.6) rotate(-12deg); opacity: 0; } }
@keyframes mkFloat { 50% { transform: translateY(-5px) rotate(1.5deg); } }
@keyframes mkGlow { 50% { opacity: .7; transform: scale(1.04); } }
@keyframes mkFlicker { 0%, 100% { transform: scale(1, 1); } 30% { transform: scale(.97, 1.05); } 60% { transform: scale(1.03, .96); } }
@keyframes mkShine { 0% { transform: translateX(-60px); } 40%, 100% { transform: translateX(60px); } }
@media (max-height: 740px) { .mark { width: 84px; height: 84px; } }

/* ---------- smoother turn changes ---------- */
.seat { transition: opacity .45s ease, filter .45s ease, border-color .4s ease, background .4s ease, box-shadow .4s ease; }
#turnPill { transition: background-color .4s ease, box-shadow .4s ease; }
#banner.show { animation: bannerSoft 1.25s cubic-bezier(.25, .8, .35, 1) forwards; }
@keyframes bannerSoft {
  0% { opacity: 0; transform: scale(.96); }
  20% { opacity: 1; transform: scale(1); }
  75% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(.99); }
}
#stamp { max-width: 92vw; overflow: hidden; text-overflow: ellipsis; }

/* ---------- action picker: who drew the card ---------- */
.pk-from { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; margin-bottom: 10px; padding: 8px 16px; border-radius: 999px;
  background: var(--pc); color: #fff; font-size: 16px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--pc) 40%, transparent); animation: spUp .45s cubic-bezier(.2, .8, .3, 1) both; }
.pk-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, .35); }

/* ---------- one game at a time: with a saved game, setup only offers continue / end ---------- */
#setup.has-save #localPane .panel, #setup.has-save #btnStart { display: none; }
.end-saved { color: var(--bad); font-weight: 600; }

/* ---------- last game recap on the home screen ---------- */
.recap { background: var(--panel); border-radius: var(--r-lg); padding: 12px 14px 13px; box-shadow: var(--shadow); animation: spUp .5s cubic-bezier(.2, .8, .3, 1) .15s both; }
.rc-head { display: flex; align-items: center; gap: 10px; }
.rc-trophy { flex: none; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 21px;
  background: linear-gradient(135deg, #fff3c4, #ffd56b); box-shadow: 0 4px 10px rgba(245, 179, 1, .3); animation: rcBob 3s ease-in-out infinite; }
@keyframes rcBob { 50% { transform: translateY(-2px) rotate(-6deg); } }
.rc-txt { flex: 1 1 auto; min-width: 0; }
.rc-title { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-sub { font-size: 12px; font-weight: 500; color: var(--muted); margin-top: 1px; }
.rc-again { flex: none; padding: 8px 14px; border-radius: 999px; background: var(--hot); color: #fff; font-size: 14px; font-weight: 700;
  box-shadow: 0 4px 12px rgba(242, 98, 46, .3); transition: transform .1s; }
.rc-again:active { transform: scale(.95); }
.rc-rows { display: flex; flex-direction: column; gap: 5px; margin-top: 10px; }
.rc-row { display: grid; grid-template-columns: minmax(0, 30%) 1fr auto; align-items: center; gap: 8px; font-size: 13px; }
.rc-name { font-weight: 700; color: var(--pc); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-bar { height: 8px; border-radius: 4px; background: var(--soft); overflow: hidden; }
.rc-bar i { display: block; height: 100%; width: 0; border-radius: 4px; background: linear-gradient(90deg, var(--pc), color-mix(in srgb, var(--pc) 55%, #ffd23f)); transition: width 1s cubic-bezier(.2, .8, .3, 1) .35s; }
.rc-pts { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 2.2em; text-align: right; }
@media (max-height: 740px) {
  .recap { padding: 9px 12px 10px; }
  .rc-trophy { width: 32px; height: 32px; font-size: 18px; }
  .rc-rows { margin-top: 7px; gap: 3px; }
  .rc-bar { height: 6px; }
}

/* Cards left in the deck, small under Flip. */
.deckbtn > span { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
#deckCount { font-size: 12px; font-weight: 500; letter-spacing: .02em; opacity: .85; margin-top: 2px; }

/* ---------- 4 players: hands in a 2x2 grid so every card is on screen ---------- */
#table #seats.four { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-auto-rows: minmax(0, 1fr); gap: 8px; }
#seats.four .seat { padding: 9px 9px 10px 13px; }
#seats.four .seat-head { flex-wrap: wrap; row-gap: 4px; }
#seats.four .seat-name { flex: 1 1 100%; font-size: 15px; gap: 5px; min-height: 20px; }
#seats.four .seat-name .nm { min-width: 1.5em; }
#seats.four .seat-name .tag-s { font-size: 8.5px; padding: 2px 5px; }
#seats.four .seat-name .tag-s.turn { display: none; } /* the colored outline and top pill already show whose turn it is */
#seats.four .seat-score { flex: 1 1 100%; justify-content: space-between; }
#seats.four .seat-rd small { display: none; }
#seats.four .seat-tot { font-size: 17px; padding: 2px 9px; }
#seats.four .seat { min-height: 0; }

/* 3-4 players: name boxes in two columns so setup fits without scrolling. */
#names.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
#names.two-col .nameIn input { padding: 10px; }

/* Short phones with 4 players: the picker and results fit without scrolling. */
@media (max-height: 740px) {
  #modal.picker { gap: 10px; padding-top: calc(var(--safe-t) + 14px); }
  .pk-card { width: min(24vw, 15vh, 120px); }
  #modal.picker h2 { font-size: 26px; }
  #modal.picker p { font-size: 14px; }
  .pk-from { margin-bottom: 6px; padding: 6px 14px; font-size: 15px; }
  #modal.picker .pick { gap: 8px; }
  #modal.picker .pick button { min-height: 56px; padding-top: 8px; padding-bottom: 8px; }
  #modal.picker .pn { font-size: 19px; }
  #modal.picker .pr { font-size: 26px; }
  #modal.results { min-height: 0; padding-top: 16px; }
  #modal.results .moment { margin-top: 6px; }
  #modal.results .sumrows { gap: 6px; margin: 8px 0 10px; }
  #modal.results .sumrow { padding: 8px 14px 8px 22px; }
  #modal.results .sumrow .st { font-size: 28px; }
  #modal.results .sumrow .bar { margin-top: 5px; height: 5px; }
}
@media (max-height: 740px) {
  #modal.results h2 { font-size: 22px; }
  #modal.results > p { margin-bottom: 4px; }
  #modal.results .moment { padding: 8px 12px; font-size: 14px; }
  #modal.results .sumrow .sn { font-size: 17px; }
  #modal.results .sumrow .sb { font-size: 12.5px; }
  #modal.results #mNext, #modal.results #mRematch { min-height: 56px; }
}

/* 4 players: compact results on every phone size so all rows and the button fit. */
#modal.results.many { min-height: 0; padding-top: 18px; }
#modal.results.many h2 { font-size: 22px; }
#modal.results.many > p { margin-bottom: 4px; }
#modal.results.many .moment { padding: 8px 12px; font-size: 14px; margin-top: 6px; }
#modal.results.many .sumrows { gap: 6px; margin: 8px 0 10px; }
#modal.results.many .sumrow { padding: 8px 14px 8px 22px; }
#modal.results.many .sumrow .sn { font-size: 17px; }
#modal.results.many .sumrow .sb { font-size: 12.5px; }
#modal.results.many .sumrow .st { font-size: 28px; }
#modal.results.many .sumrow .bar { margin-top: 5px; height: 5px; }
#modal.results.many #mNext, #modal.results.many #mRematch { min-height: 56px; }

/* ---------- logo mark ---------- */
.logo h1 span { color: #6a5cf0; }
.mark::before { background: rgba(106, 92, 240, .45); }
.mk-card { transform-box: view-box; }
.mk-bolt { transform-box: fill-box; transform-origin: center; animation: mkBolt 2.4s ease-in-out infinite; }
@keyframes mkBolt { 0%, 100% { transform: scale(1); } 45% { transform: scale(1.08) rotate(-3deg); } 55% { transform: scale(.98); } }

/* ---------- home: online / one-phone tabs ---------- */
.seg.modes { padding: 4px; border-radius: 14px; background: rgba(255, 255, 255, .6); box-shadow: inset 0 0 0 1px var(--line); }
.seg.modes button { flex: 1; padding: 11px 8px; font-size: 15px; border-radius: 11px; }
#onlinePane, #localPane { display: flex; flex-direction: column; gap: 16px; }
#onlinePane.hidden, #localPane.hidden { display: none; }
.nameIn.me { color: var(--brand); }
.nameIn.me input { font-size: 17px; padding: 13px 14px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; font-weight: 600; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line2); }
.joinrow { display: flex; gap: 8px; }
.joinrow input { flex: 1; min-width: 0; font: inherit; font-size: 22px; font-weight: 800; letter-spacing: .3em; text-align: center; text-transform: uppercase;
  color: var(--ink); background: var(--soft); border: 1px solid transparent; border-radius: 12px; padding: 10px; outline: none; -webkit-user-select: text; user-select: text; }
.joinrow input:focus { border-color: var(--brand); background: #fff; }
.joinrow input::placeholder { color: #b5c4d1; letter-spacing: .2em; }
.joinrow .btn { flex: none; padding: 0 26px; font-size: 17px; }
.btn:disabled { opacity: .55; }
#btnRejoin { background: linear-gradient(135deg, #6a5cf0, #4b3fc7); box-shadow: 0 2px 4px rgba(75, 63, 199, .3), 0 12px 28px rgba(106, 92, 240, .3); }
#btnRejoin .rs-go { color: #4b3fc7; }

/* ---------- lobby ---------- */
#lobby { padding: calc(var(--safe-t) + 12px) 20px calc(var(--safe-b) + 20px); gap: 16px; overflow-y: auto; max-width: 520px; margin: 0 auto; }
.lb-top { display: flex; }
.lb-top .btn { padding: 8px 4px; }
.lb-code { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 2px; margin-top: 8px; }
.lb-code small { font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.lb-code b { font-size: 64px; font-weight: 850; letter-spacing: .14em; line-height: 1.05; padding-left: .14em; color: var(--ink); -webkit-user-select: text; user-select: text; }
#lbConn { font-size: 13px; font-weight: 600; color: var(--bad); min-height: 1em; }
.lb-count { font-size: 14px; font-weight: 600; color: var(--muted); }
#lbPlayers { display: flex; flex-direction: column; gap: 8px; }
.lb-p { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--soft); animation: dropin .3s ease-out; }
.lb-p .sw { width: 12px; height: 12px; border-radius: 50%; background: var(--pc); flex: none; }
.lb-n { flex: 1 1 auto; min-width: 0; font-size: 17px; font-weight: 700; color: var(--pc); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-p.empty { background: transparent; border: 1.5px dashed var(--line2); animation: none; }
.lb-p.empty .sw { background: var(--line2); animation: lbPulse 1.4s ease-in-out infinite; }
.lb-p.empty .lb-n { color: var(--muted); font-weight: 600; font-size: 15px; }
@keyframes lbPulse { 50% { opacity: .3; } }
.lb-note { margin: 0; text-align: center; color: var(--ink2); font-size: 14px; font-weight: 500; }
#lobby:not(.is-host) .host-only { display: none; }

/* ---------- online table ---------- */
.tag-s.you { background: var(--ink); }
.tag-s.away { background: #9fb3c4; }
#controls.watching { opacity: .45; }
#waitNote { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 150px); transform: translate(-50%, 12px); z-index: 30; max-width: 90vw; padding: 10px 18px;
  border-radius: 999px; background: #fff; box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 600; color: var(--ink2); text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
#waitNote.show { opacity: 1; transform: translate(-50%, 0); animation: waitPulse 1.8s ease-in-out .3s infinite; }
@keyframes waitPulse { 50% { box-shadow: 0 0 0 6px rgba(106, 92, 240, .12), var(--shadow-lg); } }
.rules .lead { font-size: 15px; font-weight: 500; color: var(--ink); }

/* ---------- picker: one clear "who drew it" line, round + total columns ---------- */
#modal.picker h2 { font-size: 30px; line-height: 1.1; }
#modal.picker .pk-hero p { color: var(--ink2); }
.pk-cols { flex: none; display: grid; grid-template-columns: 1fr 76px 64px; padding: 0 18px 0 26px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.pk-cols span:not(:first-child) { text-align: right; }
#modal.picker .pick button { display: grid; grid-template-columns: 1fr 76px 64px; align-items: center; }
.pk-stat { text-align: right; font-size: 26px; font-weight: 800; line-height: 1; }
.pk-stat.rd { color: var(--pc); }
.pk-stat.tot { color: var(--ink); }
@media (max-height: 740px) { #modal.picker h2 { font-size: 25px; } .pk-stat { font-size: 22px; } }
@media (max-width: 360px) { .pk-cols, #modal.picker .pick button { grid-template-columns: 1fr 64px 52px; } }

/* ---------- away players: countdown / waiting-for-host note ---------- */
#awayNote { position: fixed; left: 50%; top: calc(var(--safe-t) + 54px); transform: translate(-50%, -8px); z-index: 31; max-width: 92vw; padding: 9px 16px;
  border-radius: 999px; background: var(--ink); color: #fff; box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 600; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
#awayNote.show { opacity: 1; transform: translate(-50%, 0); }
#awayNote b { font-variant-numeric: tabular-nums; }
.tag-s.sitout { background: #9fb3c4; }

/* ---------- install app ---------- */
.install { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; padding: 8px 16px 8px 13px; border-radius: 999px;
  background: #fff; color: var(--brand); font-weight: 700; font-size: 14px; box-shadow: var(--shadow); transition: transform .1s; }
.install:active { transform: scale(.96); }
.install svg { width: 17px; height: 17px; }
.install.hidden { display: none; }
.steps { display: flex; flex-direction: column; gap: 12px; margin: 6px 0 18px; }
.step { display: flex; align-items: center; gap: 12px; font-size: 16px; line-height: 1.35; }
.step .n { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: #fff; font-weight: 800; font-size: 14px; }
.step-note { margin: 0; font-size: 14px; color: var(--ink2); }
.ios-share { width: 18px; height: 18px; vertical-align: -3px; color: var(--brand); }

.tag-s.bot { background: #6a5cf0; }
.tag-s.rejoin { background: var(--gold); color: #3a2a00; }

/* ---------- target picker ---------- */
.seg button.custom { min-width: 76px; }
.target-in { display: block; width: 100%; margin: 14px 0 18px; padding: 14px; font: inherit; font-size: 32px; font-weight: 800; text-align: center; color: var(--ink);
  background: var(--soft); border: 1px solid transparent; border-radius: 14px; outline: none; -webkit-user-select: text; user-select: text; }
.target-in:focus { border-color: var(--brand); background: #fff; }

/* ---------- reshuffle (on the table) ---------- */
.shufflefx { position: fixed; z-index: 45; aspect-ratio: 5 / 7; pointer-events: none; }
.sf-label { position: absolute; bottom: calc(100% + 18px); left: 50%; transform: translateX(-50%); white-space: nowrap; padding: 8px 16px; border-radius: 999px;
  background: var(--ink); color: #fff; font-size: 15px; font-weight: 700; box-shadow: var(--shadow-lg); }
.sf-card { position: absolute; inset: 0; }
.sf-card > .card { position: absolute; inset: 0; width: 100%; box-shadow: 0 3px 10px rgba(15, 42, 68, .2); }
#controls.locked .deckbtn.refilling { opacity: 1; }
.deckbtn { position: relative; overflow: hidden; }
.deckbtn .refill { position: absolute; inset: 0; background: rgba(255, 255, 255, .3); transform-origin: left; transform: scaleX(0); pointer-events: none; }

.seg.modes button.on { background: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(22, 119, 201, .3); }
.stepper button:disabled { opacity: .3; }
.lbl-hint { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 4px; }

/* Number cards: one big number, no corner numbers. */
/* Every number is the same size: one size that a 12 fits comfortably. */
.card.num .big { font-size: 60cqw; letter-spacing: 0; }
/* Two digits: digits sit a touch closer, nudged so the pair stays dead center. */
.card.num.two .big { letter-spacing: -.05em; text-indent: -.05em; }

/* ---------- rules: the basics box ---------- */
.basics { background: var(--soft); border-radius: 14px; padding: 14px 14px 12px; margin: 4px 0 6px; }
.basics .goal { margin: 0 0 10px; font-size: 18px; font-weight: 600; color: var(--ink) !important; }
.steps3 { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.steps3 li { display: flex; align-items: flex-start; gap: 10px; margin: 0; color: var(--ink); font-size: 15.5px; }
.steps3 .n { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: #fff; font-size: 13px; font-weight: 800; margin-top: 1px; }
.bust-ex { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: #fff; border: 1.5px solid rgba(229, 56, 75, .3); }
.bust-ex .minis { align-items: center; margin: 0 0 6px; }
.bust-ex .plus { font-weight: 800; color: var(--muted); padding: 0 2px; }
.bust-ex p { margin: 0; font-size: 14px; }
.rules .card.bustcard { box-shadow: 0 0 0 2.5px var(--bad), 0 0 12px rgba(229, 56, 75, .45); }
.basics .trick { margin: 12px 0 0; font-size: 14px; font-style: italic; }
.basics .goal small { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-top: 2px; }

/* ---------- closable sheets: grab bar, close button ---------- */
#modal.dismissable { overscroll-behavior: contain; }
#modal .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line2); margin: -10px auto 8px; }
#modal .mclose { position: sticky; top: 0; z-index: 3; display: grid; place-items: center; width: 36px; height: 36px; margin: -6px -4px -30px auto;
  border-radius: 50%; background: var(--soft); color: var(--ink2); font-size: 16px; font-weight: 700; box-shadow: 0 1px 4px rgba(15, 42, 68, .12); }
#modal .mclose:active { transform: scale(.92); }
#modal.dismissable h2 { padding-right: 40px; }
