:root {
  --felt: #0f4a41; --felt-2: #0a332d; --felt-3: #145c51;
  --ink: #f3f1e8; --muted: #a9c7bf; --gold: #f2c14e; --danger: #ff6b5e;
  --card: #fffdf6; --card-ink: #1d1d1f; --line: rgba(255,255,255,.12);
  --money: #e9f3de; --money-ink: #2f5d1e;
  --hand-w: 96px; --hand-h: 138px; --mini-w: 60px; --mini-h: 84px;
  font-family: 'Outfit', system-ui, -apple-system, Segoe UI, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 80% at 50% 40%, var(--felt-3), var(--felt) 55%, var(--felt-2));
  background-attachment: fixed; color: var(--ink); overflow-x: hidden;
  -webkit-user-select: none; user-select: none;
}
button { font: inherit; cursor: pointer; border: 0; }
input { font: inherit; }

/* ---------- lobby ---------- */
.lobby { max-width: 440px; margin: 0 auto; padding: calc(32px + env(safe-area-inset-top)) 16px 40px; display: flex; flex-direction: column; gap: 18px; }
.logo { display: flex; align-items: center; gap: 14px; }
.logo-cards { position: relative; width: 58px; height: 64px; flex: none; }
.logo-cards span { position: absolute; width: 40px; height: 56px; border-radius: 7px; box-shadow: 0 4px 10px rgba(0,0,0,.3); }
.logo-cards span:nth-child(1) { background: #f5cf12; left: 0; top: 6px; transform: rotate(-10deg); }
.logo-cards span:nth-child(2) { background: #4fc3ef; left: 9px; top: 2px; transform: rotate(-2deg); }
.logo-cards span:nth-child(3) { background: #dc2a32; left: 18px; top: 4px; transform: rotate(8deg); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 22px; }
h1 { font-size: 38px; margin: 0; letter-spacing: -.02em; line-height: 1; }
h1 small { display: block; font-size: 14px; font-weight: 400; color: var(--muted); letter-spacing: 0; margin-top: 6px; }
.panel { background: rgba(0,0,0,.22); border: 1px solid var(--line); border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.panel h2 { margin: 0; font-size: 17px; }
.field { width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.08); color: var(--ink); outline: none; font-size: 16px; }
.field:focus { border-color: var(--gold); }
.code-field { text-transform: uppercase; letter-spacing: .3em; font-weight: 700; text-align: center; }
.btn { padding: 13px 16px; border-radius: 12px; font-weight: 700; background: rgba(255,255,255,.12); color: var(--ink); transition: transform .08s, filter .15s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--gold); color: #2a1f00; }
.btn.danger { background: var(--danger); color: #2a0500; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.muted { color: var(--muted); font-size: 14px; }
.big-code { font-size: 44px; font-weight: 800; letter-spacing: .25em; text-align: center; color: var(--gold); }
.seat-list { display: flex; flex-direction: column; gap: 8px; }
.seat { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.06); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #58606a; flex: none; }
.dot.on { background: #3ee07a; box-shadow: 0 0 8px #3ee07a; }
.rules-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: #dfeee9; }

/* ---------- game layout ---------- */
.game { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; padding-bottom: calc(var(--hand-h) + 76px + env(safe-area-inset-bottom)); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: rgba(6,32,28,.82); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar .title { font-weight: 800; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.logo-mini { width: 24px; height: 32px; border-radius: 5px; background: #dc2a32; display: grid; place-items: center; font-size: 15px; box-shadow: -4px 2px 0 #f5cf12; transform: rotate(6deg); }
@media (max-width: 480px) { .title-text { display: none; } }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 99px; background: rgba(255,255,255,.1); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.chip.gold { background: rgba(242,193,78,.18); color: var(--gold); }
.spacer { flex: 1; }
.iconbtn { width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.1); color: var(--ink); display: grid; place-items: center; font-size: 16px; }
.ticker { padding: 7px 14px; font-size: 13px; color: var(--muted); background: rgba(0,0,0,.18); border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.zone { padding: 10px 12px 6px; }
.zone-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.zone-head .who { font-weight: 700; font-size: 16px; }
.turn-flag { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; background: var(--gold); color: #2a1f00; padding: 3px 7px; border-radius: 6px; }
.backs { display: flex; }
.backs span { width: 14px; height: 20px; border-radius: 3px; background: repeating-linear-gradient(45deg, #b8332c 0 3px, #d84a3f 3px 6px); border: 1.5px solid #fff; margin-left: -6px; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.backs span:first-child { margin-left: 0; }
.sets { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; min-height: calc(var(--mini-h) + 22px); scrollbar-width: none; }
.sets::-webkit-scrollbar { display: none; }
.set { flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.set-stack { position: relative; width: var(--mini-w); }
.set-stack .mini { position: absolute; left: 0; }
.set-label { font-size: 11px; font-weight: 700; color: var(--muted); display: flex; gap: 4px; align-items: center; }
.set.complete .set-label { color: var(--gold); }
.set.complete .set-stack { filter: drop-shadow(0 0 6px rgba(242,193,78,.55)); }
.empty-note { color: var(--muted); font-size: 13px; padding: 20px 4px; }
.bankrow { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.bank-pill small { font-weight: 600; opacity: .7; margin-left: 3px; }
.bank-pill { min-width: 30px; height: 24px; padding: 0 7px; border-radius: 6px; background: var(--money); color: var(--money-ink); font-weight: 800; font-size: 13px; display: grid; place-items: center; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.bank-pill.chip-m { background: #d9ecf7; color: #18465e; }
.divider { height: 1px; background: var(--line); margin: 4px 12px; }
.center { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 4px 12px; }
.pile { width: 52px; height: 72px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.pile.deck { background: repeating-linear-gradient(45deg, #b8332c 0 6px, #d84a3f 6px 12px); border: 3px solid #fff; color: #fff; text-shadow: 0 1px 2px #000; box-shadow: 2px 2px 0 #ddd, 4px 4px 0 #bbb, 0 6px 14px rgba(0,0,0,.4); }
.status { flex: 1; max-width: 360px; font-size: 15px; font-weight: 600; text-align: center; }
.status .sub { display: block; font-size: 12.5px; font-weight: 400; color: var(--muted); margin-top: 2px; }
.pips { display: inline-flex; gap: 4px; vertical-align: middle; margin-left: 6px; }
.pips i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--gold); }
.pips i.on { background: var(--gold); }

/* hand dock */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: rgba(4,24,21,.94); backdrop-filter: blur(8px); border-top: 1px solid var(--line); padding: 8px 0 calc(10px + env(safe-area-inset-bottom)); }
.dock-bar { display: flex; align-items: center; gap: 8px; padding: 0 12px 6px; min-height: 40px; }
.dock-bar .btn { padding: 9px 18px; }
.hand { display: flex; gap: 8px; overflow-x: auto; padding: 6px 12px 4px; scroll-snap-type: x proximity; scrollbar-width: none; }
.hand::-webkit-scrollbar { display: none; }
.hand .card { scroll-snap-align: start; }
.hand .card.fresh { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- cards ---------- */
.card { flex: none; width: var(--hand-w); height: var(--hand-h); border-radius: 10px; background: var(--card); color: var(--card-ink); position: relative; overflow: hidden; box-shadow: 0 3px 8px rgba(0,0,0,.35); display: flex; flex-direction: column; text-align: center; transition: transform .12s; }
.card:active { transform: translateY(-4px) scale(.98); }
.card .val { position: absolute; top: 5px; left: 5px; width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 2px solid #1d1d1f; font-size: 10.5px; font-weight: 800; display: grid; place-items: center; z-index: 2; color: #1d1d1f; }
.card .band { padding: 22px 6px 6px; min-height: 58px; display: flex; flex-direction: column; justify-content: center; }
.card .band .nm { font-weight: 800; font-size: 12.5px; line-height: 1.1; overflow-wrap: anywhere; hyphens: auto; }
.card .band .nm.long { font-size: 11px; }
.sheet .sheet-card .card .band .nm.long { font-size: 14px; }
.card .band .rg { font-size: 9.5px; opacity: .85; margin-top: 2px; text-transform: uppercase; letter-spacing: .05em; }
.card .ladder { flex: 1; padding: 5px 9px; display: flex; flex-direction: column; justify-content: center; gap: 2px; font-size: 10.5px; }
.card .ladder div { display: flex; justify-content: space-between; border-bottom: 1px dotted #ccc; }
.card .ladder div:last-child { border: 0; font-weight: 800; }
.card.action { background: linear-gradient(160deg, #fff7e6, #ffe7b8); }
.card.action .glyph, .card.rent .glyph { font-size: 36px; margin-top: 26px; line-height: 1; }
.card .anm { font-weight: 800; font-size: 13px; padding: 6px 6px 2px; line-height: 1.05; }
.card .atx { font-size: 9.5px; padding: 0 7px; line-height: 1.2; color: #4b4b4b; }
.card.action.attack { background: linear-gradient(160deg, #ffece8, #ffc9bd); }
.card.money { background: linear-gradient(160deg, #f1f8e8, #d4eabb); color: var(--money-ink); justify-content: center; }
.card.money .big { font-size: 42px; font-weight: 800; }
.card.money .big small { font-size: 22px; }
.card.money.chipcard { background: linear-gradient(160deg, #eef7fc, #cbe5f4); color: #18465e; }
.card.wild .band { color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.card.rent .wheel { width: 54px; height: 54px; border-radius: 50%; margin: 28px auto 4px; border: 3px solid #fff; box-shadow: 0 0 0 2px #1d1d1f; display: grid; place-items: center; font-weight: 800; color: #fff; text-shadow: 0 1px 2px #000; font-size: 12px; }
.card .tag { position: absolute; bottom: 5px; left: 0; right: 0; font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #777; }
.mini { width: var(--mini-w); height: var(--mini-h); border-radius: 7px; background: var(--card); color: var(--card-ink); box-shadow: 0 2px 5px rgba(0,0,0,.4); overflow: hidden; display: flex; flex-direction: column; text-align: center; font-size: 9.5px; position: relative; }
.mini .band { overflow-wrap: anywhere; hyphens: auto; padding: 4px 3px; min-height: 30px; display: flex; align-items: center; justify-content: center; font-weight: 800; line-height: 1.05; }
.mini .mv { font-weight: 800; margin-top: auto; padding-bottom: 4px; font-size: 10px; }
.mini.bld { background: linear-gradient(160deg, #fff7e6, #ffe7b8); display: grid; place-items: center; font-size: 22px; }
.mini.selectable { cursor: pointer; }
.mini.selected, .card.selected { outline: 3px solid var(--gold); outline-offset: 2px; }
.bld-badges { position: absolute; bottom: -8px; right: -8px; display: flex; gap: 2px; z-index: 5; }
.bld-badges span { background: #fff; border-radius: 6px; font-size: 14px; padding: 1px 3px; box-shadow: 0 1px 3px rgba(0,0,0,.4); }

/* ---------- sheets ---------- */
.scrim { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto; background: #10302b; border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; animation: up .2s cubic-bezier(.2,.9,.3,1.2); }
@media (min-width: 640px) { .scrim { align-items: center; } .sheet { border-radius: 22px; border-bottom: 1px solid var(--line); } }
.sheet h3 { margin: 0; font-size: 19px; }
.sheet .sheet-card { display: flex; justify-content: center; padding: 4px 0; }
.sheet .sheet-card .card { --hand-w: 132px; --hand-h: 190px; transform: none; }
.sheet .sheet-card .card .band .nm { font-size: 16px; }
.sheet .sheet-card .card .ladder { font-size: 13px; }
.sheet .sheet-card .card .atx { font-size: 12px; }
.sheet .sheet-card .card .anm { font-size: 16px; }
.opts { display: flex; flex-direction: column; gap: 8px; }
.opts .btn { text-align: left; display: flex; justify-content: space-between; align-items: center; }
.opts .btn span.hint { font-weight: 400; font-size: 13px; opacity: .8; }
.pick-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.pick-group { display: flex; flex-direction: column; gap: 6px; }
.pick-group .lbl { font-size: 12px; font-weight: 700; color: var(--muted); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { padding: 10px 14px; border-radius: 10px; font-weight: 700; font-size: 14px; border: 2px solid transparent; }
.swatch.on { border-color: #fff; box-shadow: 0 0 0 2px var(--gold); }
.notice { background: rgba(242,193,78,.12); border: 1px solid rgba(242,193,78,.35); color: #ffe3a1; border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.notice.red { background: rgba(255,107,94,.12); border-color: rgba(255,107,94,.4); color: #ffc2bb; }
.total { font-size: 15px; font-weight: 700; }
.log-list { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.log-list div { padding: 6px 0; border-bottom: 1px solid var(--line); }
.emotes { display: flex; gap: 4px; }
.emotes button { font-size: 20px; background: rgba(255,255,255,.08); border-radius: 10px; width: 36px; height: 36px; }
.float-emote { position: fixed; z-index: 70; font-size: 64px; left: 50%; top: 40%; transform: translate(-50%,-50%); animation: pop 1.6s forwards; pointer-events: none; }

#toasts { position: fixed; z-index: 80; top: calc(60px + env(safe-area-inset-top)); left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; padding: 0 16px; }
.toast { background: rgba(20,20,20,.92); color: #fff; padding: 8px 12px; border-radius: 10px; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.4); max-width: 440px; animation: up .2s; }
.toast.err { background: #7a1d17; }
.conn { position: fixed; z-index: 90; bottom: 0; left: 0; right: 0; background: #7a1d17; color: #fff; text-align: center; font-size: 13px; padding: 6px; }

.winner { text-align: center; font-size: 26px; font-weight: 800; }
.confetti { font-size: 54px; text-align: center; }

@keyframes up { from { transform: translateY(30px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { 0% { transform: translate(-50%,-50%) scale(.3); opacity: 0; } 20% { transform: translate(-50%,-50%) scale(1.15); opacity: 1; } 75% { opacity: 1; } 100% { transform: translate(-50%,-80%) scale(1); opacity: 0; } }

@media (min-width: 900px) {
  :root { --hand-w: 112px; --hand-h: 160px; --mini-w: 70px; --mini-h: 98px; }
  .game { max-width: 1100px; margin: 0 auto; }
  .hand { justify-content: center; }
}

.card.paycard { --hand-w: 58px; --hand-h: 74px; }
.card.paycard .big { font-size: 26px; }
.card.paycard .big small { font-size: 14px; }
.card.paycard .tag { font-size: 7px; letter-spacing: .03em; }
.bank-pill { height: auto; padding: 3px 7px; white-space: nowrap; }
.targets { flex-wrap: nowrap; }
.targets .swatch { flex: 1; padding: 10px 0; font-size: 17px; }
