:root {
  --bg: #14161f; --panel: #1e2130; --panel2: #262a3d; --line: #353a52;
  --text: #e8e9f0; --muted: #9a9fb8; --accent: #f3c04b; --good: #5fd08a; --bad: #ef6b6b;
  --blue: #4a90ff; --green: #3fc46b; --pink: #ff6fb1; --purple: #a46bff; --yellow: #ffd23f;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.4 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; background: var(--bg); color: var(--text); }
button { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--panel2); color: var(--text); border-radius: 8px; padding: 7px 14px; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: #1a1a1a; border-color: var(--accent); font-weight: 600; }
button.small { padding: 3px 9px; font-size: 13px; }
input, select { font: inherit; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
h2, h3 { margin: 0 0 10px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

.topbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 18px; }
.logo { color: var(--accent); }
main { padding: 16px; max-width: 1300px; margin: 0 auto; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.center { max-width: 460px; margin: 40px auto; display: grid; gap: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack { display: grid; gap: 10px; }

/* gems */
.gem { display: inline-block; width: 22px; height: 22px; transform: rotate(45deg); border-radius: 4px; margin: 3px; box-shadow: inset -3px -3px 0 rgba(0,0,0,.25), inset 3px 3px 0 rgba(255,255,255,.35); vertical-align: middle; }
.gem.lg { width: 38px; height: 38px; margin: 8px; }
.gem.sm { width: 13px; height: 13px; margin: 2px; border-radius: 2px; }
.gem.blue { background: var(--blue); } .gem.green { background: var(--green); } .gem.pink { background: var(--pink); }
.gem.purple { background: var(--purple); } .gem.yellow { background: var(--yellow); }
.gem.empty { background: transparent; border: 2px dashed var(--line); box-shadow: none; }
.c-blue { color: var(--blue); } .c-green { color: var(--green); } .c-pink { color: var(--pink); } .c-purple { color: var(--purple); } .c-yellow { color: var(--yellow); }

/* layout */
.board { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 14px; }
.main-col, .side-col { display: grid; gap: 14px; align-content: start; }
@media (max-width: 900px) { .board { grid-template-columns: 1fr; } }
.top-row { display: grid; grid-template-columns: 1.3fr 1fr; gap: 14px; }
@media (max-width: 700px) { .top-row { grid-template-columns: 1fr; } }

.lot { display: flex; gap: 14px; align-items: center; }
.lotcard { width: 110px; height: 150px; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 700; text-align: center; padding: 8px; border: 2px solid rgba(255,255,255,.2); flex-shrink: 0; }
.lotcard.treasure { background: linear-gradient(160deg, #3b2f6b, #1f2a52); }
.lotcard.loan { background: linear-gradient(160deg, #6b2f2f, #3d1d1d); }
.lotcard.invest { background: linear-gradient(160deg, #2f6b46, #1b3d28); }
.lotcard .big { font-size: 34px; }
.lotcard .kind { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; opacity: .8; }

.offer { display: flex; gap: 18px; align-items: center; }
.slot { text-align: center; font-size: 12px; color: var(--muted); }

.action { border-color: var(--accent); }
.action.idle { border-color: var(--line); }
.bidrow input { width: 110px; font-size: 18px; }

.chart { width: 100%; border-collapse: collapse; font-size: 13px; }
.chart td, .chart th { padding: 4px 6px; text-align: center; border-bottom: 1px solid var(--line); }
.chart th { color: var(--muted); font-weight: 500; }
.chart td.cur { background: rgba(243,192,75,.18); font-weight: 700; color: var(--accent); border-radius: 4px; }
.chart td.lbl { text-align: left; white-space: nowrap; }

.missions { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.mission { background: var(--panel2); border-radius: 8px; padding: 8px; text-align: center; border: 1px solid var(--line); }
.mission .reward { font-weight: 700; color: var(--accent); }
.mission.done { opacity: .85; border-color: var(--good); }

.players { display: grid; gap: 10px; }
.player { background: var(--panel2); border-radius: 10px; padding: 10px; border: 1px solid var(--line); }
.player.me { border-color: #6a74b5; }
.player.turn { box-shadow: 0 0 0 2px var(--accent); }
.player .name { font-weight: 600; display: flex; justify-content: space-between; gap: 6px; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--line); color: var(--muted); font-weight: 500; white-space: nowrap; }
.badge.ok { background: rgba(95,208,138,.2); color: var(--good); }
.badge.wait { background: rgba(243,192,75,.2); color: var(--accent); }
.stats { display: flex; gap: 12px; font-size: 13px; color: var(--muted); flex-wrap: wrap; margin: 4px 0; }
.stats b { color: var(--text); }
.chips { font-size: 12px; display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.chip { background: var(--bg); border-radius: 6px; padding: 1px 6px; }

.hand { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.hand button.gembtn { padding: 6px 10px; }

.log { max-height: 280px; overflow-y: auto; font-size: 13px; display: flex; flex-direction: column-reverse; }
.log div { padding: 3px 0; border-bottom: 1px solid rgba(255,255,255,.04); }
.log .r { color: var(--muted); font-size: 11px; margin-right: 6px; }

.seats { display: grid; gap: 6px; }
.seat { display: flex; justify-content: space-between; align-items: center; background: var(--panel2); padding: 8px 10px; border-radius: 8px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); margin-right: 6px; }
.dot.on { background: var(--good); }
.code { font-family: ui-monospace, monospace; font-size: 26px; letter-spacing: .2em; color: var(--accent); }

.scores { width: 100%; border-collapse: collapse; }
.scores th, .scores td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; }
.scores th:first-child, .scores td:first-child { text-align: left; }
.scores tr.win td { color: var(--accent); font-weight: 700; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--bad); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 10; }
.rules { font-size: 13px; color: var(--muted); }
.rules li { margin: 3px 0; }

/* =================== table view =================== */
.topbar #roomInfo { display: flex; gap: 8px; align-items: center; }
main:has(.table) { max-width: none; padding: 10px; }
.small { font-size: 12px; }
button.link { background: none; border: none; padding: 0 4px; color: var(--accent); text-decoration: underline dotted; font-size: inherit; }

.table {
  --cw: clamp(46px, 4.4vw, 66px);
  height: calc(100vh - 72px); min-height: 640px;
  display: grid; gap: 10px; padding: 12px;
  grid-template-columns: minmax(160px, 1fr) minmax(0, 3.2fr) minmax(160px, 1fr);
  grid-template-rows: auto 1fr auto;
  grid-template-areas: ". top ." "left mid right" "me me me";
  background: radial-gradient(ellipse at center, #24503f 0%, #183829 70%, #11281e 100%);
  border-radius: 22px; box-shadow: inset 0 0 0 6px #0d1f17, inset 0 0 60px rgba(0,0,0,.5);
}
.seats-top { grid-area: top; display: flex; justify-content: center; gap: 14px; }
.seats-left { grid-area: left; display: flex; flex-direction: column; justify-content: center; gap: 10px; }
.seats-right { grid-area: right; display: flex; flex-direction: column; justify-content: center; gap: 10px; }
.mid-area { grid-area: mid; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; min-width: 0; }
.me-zone { grid-area: me; display: grid; gap: 8px; justify-items: center; }

.zone { position: relative; border: 1.5px dashed rgba(255,255,255,.16); border-radius: 12px; padding: 18px 10px 10px; }
.zone-label { position: absolute; top: 3px; left: 10px; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: rgba(255,255,255,.55); display: flex; gap: 4px; align-items: center; }
.empty-zone { font-size: 12px; color: rgba(255,255,255,.35); font-style: italic; }

/* cards */
.pcard { --w: var(--cw); width: var(--w); height: calc(var(--w) * 1.4); border-radius: calc(var(--w) * .11);
  background: #f5f0e4; border: 1px solid rgba(0,0,0,.25); box-shadow: 0 2px 4px rgba(0,0,0,.35);
  display: flex; flex-direction: column; align-items: center; justify-content: center; flex-shrink: 0; color: #222; position: relative; }
.pcard.sm { --w: calc(var(--cw) * .66); }
.pcard.xs { --w: calc(var(--cw) * .42); }
.pcard .gem { width: calc(var(--w) * .4); height: calc(var(--w) * .4); margin: 0; }
.pcard.slot-empty { background: transparent; border: 1.5px dashed rgba(255,255,255,.25); box-shadow: none; }
.pcard.back { background: #2d5bb8 repeating-linear-gradient(45deg, rgba(255,255,255,.12) 0 4px, transparent 4px 9px); border: 2px solid #f5f0e4; }
.pcard.back.aucback { background-color: #b8352d; }
.pcard.lot { color: #fff; font-weight: 700; text-align: center; gap: 2px; border: 2px solid #f5f0e4; }
.pcard.lot .kind { font-size: calc(var(--w) * .15); text-transform: uppercase; letter-spacing: .05em; opacity: .85; }
.pcard.lot .pips { font-size: calc(var(--w) * .3); line-height: 1; }
.pcard.lot .amt { font-size: calc(var(--w) * .34); line-height: 1; }
.pcard.lot .sub { font-size: calc(var(--w) * .12); }
.pcard.lot .locked { position: absolute; bottom: -6px; right: -8px; }
.pcard.treasure { background: linear-gradient(160deg, #5b48a8, #2a2f6b); }
.pcard.loan { background: linear-gradient(160deg, #b8352d, #6b1f1a); }
.pcard.invest { background: linear-gradient(160deg, #2f8a52, #1a4d2e); }
.pcard.mission { background: #e4f2e2; justify-content: space-between; padding: calc(var(--w) * .1) 2px; }
.pcard.mission .req { display: flex; flex-wrap: wrap; justify-content: center; }
.pcard.mission .req .gem { width: calc(var(--w) * .2); height: calc(var(--w) * .2); margin: 2px; }
.pcard.mission .reward { font-weight: 800; font-size: calc(var(--w) * .26); color: #8a6200; }

.deck { position: relative; width: calc(var(--cw) + 6px); height: calc(var(--cw) * 1.4 + 6px); }
.deck .pcard { position: absolute; }
.deck .pcard:nth-child(1) { top: 6px; left: 0; } .deck .pcard:nth-child(2) { top: 3px; left: 3px; } .deck .pcard:nth-child(3) { top: 0; left: 6px; }
.deck .count { position: absolute; bottom: -8px; right: -8px; background: #0d1f17; border-radius: 99px; font-size: 11px; padding: 1px 7px; z-index: 2; }

/* overlapping stacks */
.cstack { display: flex; position: relative; }
.cstack > .pcard + .pcard { margin-left: calc(var(--w) * -.72); }
.cstack .badge-n { position: absolute; top: -6px; right: -6px; background: #0d1f17; color: #fff; border-radius: 99px; font-size: 10px; padding: 0 5px; z-index: 2; }
.vstack { flex-direction: column; }
.vstack > .pcard + .pcard { margin-left: 0; margin-top: calc(var(--w) * -1.15); }

/* market + value display */
.middle { display: flex; gap: 18px; align-items: stretch; flex-wrap: wrap; justify-content: center; }
.market { display: grid; gap: 14px; }
.market-row { display: flex; gap: 12px; align-items: center; }
.offer-slot { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10px; color: rgba(255,255,255,.5); text-transform: uppercase; letter-spacing: .06em; }
.offer-slot.live .pcard { box-shadow: 0 0 0 3px var(--accent), 0 0 18px rgba(243,192,75,.5); }
.last { font-size: 12px; color: rgba(255,255,255,.7); max-width: 150px; }
.last .gem { margin: 1px; }
.vd { display: flex; gap: 10px; align-items: flex-start; height: 100%; }
.vd-col { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.vd-val { font-weight: 800; font-size: 15px; text-shadow: 0 1px 2px #000; }
.missions-zone .cards { display: flex; gap: 8px; }

/* coins & bid tokens */
.coins { display: inline-flex; align-items: center; gap: 4px; }
.coin { width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ffe58a, #d49b17); box-shadow: 0 0 0 1px #8a6200, 0 2px 0 #8a6200; }
.coins.big .coin { width: 30px; height: 30px; box-shadow: 0 0 0 1px #8a6200, 0 3px 0 #8a6200, 0 6px 0 #d49b17, 0 7px 0 #8a6200; }
.coins.big b { font-size: 24px; }
.coins.tiny .coin { width: 11px; height: 11px; } .coins.tiny b { font-size: 11px; color: #fff; text-shadow: 0 1px 2px #000; }
.token { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; }
.token.down { background: #0d1f17; border: 2px solid #d49b17; color: #d49b17; }
.token.wait { border: 2px dashed rgba(255,255,255,.35); color: rgba(255,255,255,.5); }
.token.up { background: radial-gradient(circle at 35% 35%, #ffe58a, #d49b17); color: #3a2a00; }
.token.won { box-shadow: 0 0 0 3px #fff, 0 0 14px #ffe58a; }
.token.tied { box-shadow: 0 0 0 3px var(--bad); }
.crown { color: var(--accent); }

/* opponent seats */
.seat-zone { background: rgba(0,0,0,.18); border: 1.5px dashed rgba(255,255,255,.18); border-radius: 12px; padding: 8px 10px; display: grid; gap: 6px; min-width: 0; }
.seat-zone.acting { border: 1.5px solid var(--accent); box-shadow: 0 0 14px rgba(243,192,75,.3); }
.seat-head { display: flex; align-items: center; gap: 8px; }
.seat-name { font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-hand { display: flex; min-height: calc(var(--cw) * .42 * 1.4); }
.seat-hand .pcard + .pcard { margin-left: calc(var(--w) * -.45); }
.seat-coll { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* your side */
.prompt { background: rgba(0,0,0,.35); border-radius: 18px; padding: 6px 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; min-height: 40px; }
.prompt.active { background: rgba(243,192,75,.14); box-shadow: 0 0 0 1.5px var(--accent); }
.bidbox { display: flex; gap: 4px; align-items: center; }
.bidbox input { width: 70px; text-align: center; font-size: 18px; font-weight: 700; padding: 4px; }
.bidbox .step { width: 34px; padding: 4px 0; font-size: 18px; }
.me-row { display: flex; gap: 14px; align-items: stretch; justify-content: center; width: 100%; }
.me-zone.acting .hand-zone, .me-zone.acting .purse { border-color: rgba(243,192,75,.6); }
.hand-zone { min-width: 260px; display: flex; align-items: flex-end; justify-content: center; }
.fan { display: flex; padding: 6px 10px 14px; }
.fan .pcard { transform: rotate(calc(var(--i) * 7deg)) translateY(calc(var(--i) * var(--i) * 2px)); transform-origin: 50% 150%; transition: transform .15s; }
.fan .pcard + .pcard { margin-left: calc(var(--w) * -.28); }
.fan.pick .pcard { cursor: pointer; box-shadow: 0 0 0 2px var(--accent), 0 2px 6px rgba(0,0,0,.4); }
.fan.pick .pcard:hover { transform: rotate(calc(var(--i) * 7deg)) translateY(-14px); z-index: 2; }
.purse { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-width: 120px; padding-top: 22px; }
.coll-zone { min-width: 240px; display: flex; align-items: center; }
.coll-zone .seat-coll { gap: 10px; }

/* overlays */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 340px; background: var(--panel); border-left: 1px solid var(--line); padding: 14px; transform: translateX(100%); transition: transform .2s; z-index: 20; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer .log { max-height: none; flex: 1; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 30; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: grid; gap: 12px; max-width: 520px; }
.modal-card.wide { max-width: 680px; width: 92vw; }

@media (max-width: 860px) {
  .table { height: auto; min-height: 0; grid-template-columns: 1fr; grid-template-rows: auto;
    grid-template-areas: "top" "left" "right" "mid" "me"; }
  .seats-top, .seats-left, .seats-right { flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .me-row { flex-wrap: wrap; }
}

.pcard.xs .locked { display: none; }
.vd-val { min-height: 20px; }

/* pass-and-play */
.hand-zone { flex-direction: column; align-items: center; }
.peek { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }
.curtain { position: fixed; inset: 0; z-index: 40; background: rgba(10,14,12,.92); backdrop-filter: blur(14px); display: flex; align-items: center; justify-content: center; padding: 20px; }
.curtain-card { text-align: center; display: grid; gap: 14px; max-width: 460px; }
.curtain-name { font-size: 40px; font-weight: 800; color: var(--accent); }
.recap { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; display: grid; gap: 4px; }
button.big { font-size: 18px; padding: 12px 20px; }
#localCard select { max-width: 100%; }

.netbar { position: fixed; top: 58px; left: 50%; transform: translateX(-50%); background: #3a2f10; color: var(--accent); border: 1px solid var(--accent); padding: 6px 14px; border-radius: 99px; font-size: 13px; z-index: 50; }
