:root {
  --bg: #0f1218;
  --panel: #171c25;
  --panel-2: #1e2531;
  --line: #2a3242;
  --text: #e7e9ee;
  --muted: #8d97a8;
  --gold: #d4b062;
  --gold-2: #b38f3f;
  --danger: #e06363;
  --ok: #57c28a;
  --felt: #13201b;
  --seat0: #e3a54a;
  --seat1: #57a6e8;
  --seat2: #d8648c;
  --seat3: #59c08a;
  --radius: 10px;
  --card-r: 4.5%;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.4 Inter, system-ui, sans-serif; }
body { overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--gold); }
h1, h2, h3, .brand { font-family: Cinzel, Georgia, serif; letter-spacing: .02em; }
[hidden] { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 12px; cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--text);
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #263043; border-color: #3a4560; }
.btn.primary { background: linear-gradient(#dcb96b, #b8933f); color: #1b1408; border-color: #e3c47c; font-weight: 600; }
.btn.primary:hover { background: linear-gradient(#e6c57a, #c29c46); }
.btn.danger { color: #ffb4b4; border-color: #5a2d33; }
.btn.small { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.btn.icon { padding: 4px 7px; min-width: 28px; }
.btn:disabled { opacity: .45; cursor: default; }
input[type=text], input[type=search], input[type=number], textarea, select {
  background: #0c0f14; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; outline: none; width: 100%;
}
input:focus, textarea:focus, select:focus { border-color: var(--gold-2); }

/* ---------- page chrome ---------- */
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { font-size: 18px; color: var(--gold); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand img { width: 26px; height: 26px; }
.topbar .spacer { flex: 1; }
.avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: var(--panel-2); display: inline-grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; }
.page { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }
.page h1 { margin: 0 0 16px; font-size: 26px; }
.page h2 { font-size: 18px; margin: 28px 0 12px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at 50% 30%, #2a2138 0%, var(--bg) 60%); }
.login-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 32px 28px; text-align: center; box-shadow: 0 20px 60px #0008; }
.login-card h1 { color: var(--gold); margin: 10px 0 4px; font-size: 30px; }
.login-card .fan { height: 110px; position: relative; margin: 0 auto 8px; width: 200px; }
.login-card .fan img { position: absolute; width: 74px; border-radius: 5px; left: 63px; top: 8px; box-shadow: 0 6px 18px #000a; transform-origin: 50% 120%; }
.login-card .divider { margin: 18px 0; color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 10px; }
.login-card .divider::before, .login-card .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
#gbtn { display: flex; justify-content: center; min-height: 44px; }

/* ---------- lobby ---------- */
.rooms { display: grid; gap: 10px; }
.room-row { display: flex; align-items: center; gap: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.room-row .name { font-weight: 600; font-size: 15px; }
.seats-dots { display: flex; gap: 4px; }
.seats-dots span { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.seats-dots span.on { background: var(--gold); }
.empty { padding: 28px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.create-room { display: flex; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.create-room input { flex: 1; }

/* ---------- decks ---------- */
.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.deck-tile { position: relative; border-radius: var(--radius); overflow: hidden; background: var(--panel); border: 1px solid var(--line); cursor: pointer; text-decoration: none; color: var(--text); display: block; }
.deck-tile .art { height: 120px; background: #222 center 22% / cover no-repeat; }
.deck-tile .info { padding: 10px 12px; }
.deck-tile .info b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck-tile.new { display: grid; place-items: center; min-height: 172px; border-style: dashed; color: var(--muted); font-size: 15px; }

.editor { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.editor aside { position: sticky; top: 12px; display: grid; gap: 12px; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.box h3 { margin: 0 0 10px; font-size: 14px; color: var(--gold); }
.box textarea { min-height: 180px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.type-group h3 { font-size: 14px; color: var(--muted); margin: 18px 0 8px; font-family: Inter, sans-serif; text-transform: uppercase; letter-spacing: .08em; }
.card-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.deck-card { position: relative; }
.deck-card img { width: 100%; aspect-ratio: 488/680; border-radius: 6px; display: block; background: #222; }
.deck-card .qty { position: absolute; top: 6px; left: 6px; background: #000c; border-radius: 6px; padding: 1px 7px; font-weight: 700; }
.deck-card .tools { position: absolute; bottom: 6px; left: 6px; right: 6px; display: none; gap: 4px; justify-content: center; }
.deck-card:hover .tools, .deck-card:focus-within .tools { display: flex; }
.deck-card .tools button { background: #000d; border: 1px solid #fff3; border-radius: 6px; padding: 2px 7px; cursor: pointer; }
.commander-slot { display: flex; gap: 12px; flex-wrap: wrap; }
.commander-slot .deck-card { width: 170px; }
.commander-slot .deck-card img { box-shadow: 0 0 0 2px var(--gold), 0 8px 24px #0009; }
.add-cmd { width: 170px; aspect-ratio: 488/680; border: 2px dashed var(--line); border-radius: 8px; background: #ffffff05; display: grid; align-content: center; justify-items: center; gap: 6px; padding: 12px; text-align: center; cursor: pointer; color: var(--text); }
.add-cmd:hover { border-color: var(--gold-2); background: #d4b06210; }
.add-cmd .muted { font-size: 11px; }
@media (hover: none) { .deck-card .tools { display: flex; } }
.stat-row { display: flex; justify-content: space-between; padding: 2px 0; }
.curve { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; height: 110px; margin: 12px 0 6px; align-items: end; }
.curve .bar { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; }
.curve .bar > div { width: 100%; background: linear-gradient(var(--gold), var(--gold-2)); border-radius: 3px 3px 0 0; min-height: 1px; }
.curve .n { font-size: 11px; color: var(--muted); }
.curve .mv { font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); width: 100%; text-align: center; padding-top: 2px; }
.pipbar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; margin-top: 10px; }
.ac { position: relative; }
.ac-list { position: absolute; z-index: 50; left: 0; right: 0; top: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; max-height: 300px; overflow: auto; margin-top: 4px; }
.ac-list div { padding: 7px 10px; cursor: pointer; }
.ac-list div:hover, .ac-list div.sel { background: #2c3750; }
.progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.progress div { height: 100%; background: var(--gold); width: 0; transition: width .2s; }

/* ---------- modal / menus ---------- */
.modal-bg { position: fixed; inset: 0; background: #000a; z-index: 900; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: min(920px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 30px 80px #000c; }
.modal.narrow { width: min(440px, 100%); }
.modal header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal header h2 { margin: 0; font-size: 17px; flex: 1; }
.modal .body { padding: 14px 16px; overflow: auto; }
.modal footer { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.pick-grid .pick { cursor: pointer; border-radius: 6px; position: relative; }
.pick-grid .pick img { width: 100%; border-radius: 6px; display: block; aspect-ratio: 488/680; background: #222; }
.pick-grid .pick.sel img { box-shadow: 0 0 0 3px var(--gold); }
.pick-grid .pick .cap { font-size: 11px; color: var(--muted); text-align: center; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu { position: fixed; z-index: 1000; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 5px; min-width: 190px; box-shadow: 0 14px 40px #000b; max-height: 80vh; overflow: auto; }
.menu button { display: flex; width: 100%; text-align: left; background: none; border: 0; padding: 7px 10px; border-radius: 6px; cursor: pointer; gap: 8px; }
.menu button:hover { background: #2f3a52; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.menu .label { padding: 6px 10px 2px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

#preview { position: fixed; z-index: 1100; pointer-events: none; width: 300px; filter: drop-shadow(0 16px 40px #000c); }
#preview img { width: 100%; border-radius: 14px; display: block; }
#toasts { position: fixed; z-index: 1200; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { background: var(--panel-2); border: 1px solid var(--line); padding: 9px 14px; border-radius: 10px; box-shadow: 0 10px 30px #0009; animation: pop .2s ease-out; }
.reveal-pop { position: fixed; z-index: 1150; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; animation: pop .25s ease-out;
  background: #0d1016f2; border: 1px solid var(--line); border-radius: 18px; padding: 14px; box-shadow: 0 30px 90px #000; width: min(380px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; }
.reveal-pop img { width: min(300px, 100%, 50vh); border-radius: 14px; display: block; margin: 0 auto; }
.reveal-pop .cap { margin-top: 10px; font-weight: 600; }
.reveal-pop .acts { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.reveal-pop .timer { height: 3px; background: var(--gold); border-radius: 2px; margin-top: 10px; transform-origin: left; animation: shrink linear forwards; }
@keyframes shrink { to { transform: scaleX(0); } }
@keyframes pop { from { transform: translate(-50%, -50%) scale(.85); opacity: 0; } }
.toast { animation-name: fadeup; }
@keyframes fadeup { from { transform: translateY(10px); opacity: 0; } }

/* ---------- table ---------- */
.table-page { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.tbar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--line); flex: none; overflow-x: auto; }
.tbar .title { font-family: Cinzel, serif; color: var(--gold); font-size: 15px; white-space: nowrap; margin-right: 6px; }
.tbar .turn { font-size: 12px; color: var(--muted); white-space: nowrap; }
.watchers { display: flex; gap: 8px; align-items: center; font-size: 12px; white-space: nowrap; }
.spec-badge { background: #2a3550; border: 1px solid #3d4b6e; padding: 3px 9px; border-radius: 12px; color: #b8c8ff; }
.tmain { flex: 1; display: flex; min-height: 0; }
.grid4 { flex: 1; display: grid; grid-template: 1fr 1fr / 1fr 1fr; gap: 4px; padding: 4px; min-width: 0; min-height: 0; }
.grid4.focus .seat:not(.focused) { display: none; }
.grid4.focus { grid-template: 1fr / 1fr; }

.seat { --c: var(--seat0); position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; border-radius: 10px; overflow: hidden; overflow: clip;
  background: radial-gradient(ellipse at 50% 40%, #1a2b24 0%, var(--felt) 70%); border: 1px solid #23302b; }
.seat[data-i="1"] { --c: var(--seat1); } .seat[data-i="2"] { --c: var(--seat2); } .seat[data-i="3"] { --c: var(--seat3); }
.seat.dead .bf { filter: grayscale(.8) brightness(.6); }

.shead { display: flex; align-items: center; gap: 8px; padding: 5px 8px; background: #0b0e13d9; border-bottom: 2px solid var(--c); flex: none; z-index: 5; flex-wrap: wrap; row-gap: 4px; }
.shead .who { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 34%; }
.shead .who b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shead .who .sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.life { display: flex; align-items: center; gap: 2px; background: #000; border-radius: 8px; padding: 1px 2px; border: 1px solid #333; }
.life .val { font: 700 22px/1 Inter; min-width: 40px; text-align: center; cursor: pointer; font-variant-numeric: tabular-nums; }
.life .val.low { color: var(--danger); }
.life button { background: none; border: 0; width: 24px; height: 28px; cursor: pointer; font-size: 17px; color: var(--muted); border-radius: 6px; }
.life button:hover { background: #222; color: var(--text); }
.chips { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: #1d2330; border: 1px solid var(--line); border-radius: 14px; padding: 1px 7px 1px 2px; font-size: 12px; cursor: pointer; user-select: none; white-space: nowrap; }
.chip:hover { border-color: #4a5672; }
.chip img.face { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; object-position: 50% 22%; }
.chip .ico { width: 20px; text-align: center; }
.chip b { font-variant-numeric: tabular-nums; }
.chip.cmd { border-color: color-mix(in srgb, var(--src) 60%, transparent); }
.chip.cmd b.lethal { color: var(--danger); }
.chip.flag { background: #3a2e12; border-color: var(--gold-2); }
.shead .tools { margin-left: auto; display: flex; gap: 4px; }

.chip .cmd-ico { font-size: 11px; opacity: .8; margin-left: 4px; }
.chip.ghost-chip { opacity: .55; cursor: help; padding-left: 2px; }
.out-banner { position: absolute; left: 50%; top: 55%; transform: translate(-50%, -50%); z-index: 8; background: #120a0dcc; border: 1px solid #6b2a35; border-radius: 12px; padding: 10px 18px; display: grid; gap: 4px; justify-items: center; text-align: center; backdrop-filter: blur(2px); pointer-events: auto; }
.out-banner b { color: #ff9a9a; font-size: 16px; }
.out-banner span { color: var(--muted); font-size: 12px; }
.life-hist { display: grid; gap: 2px; max-height: 50vh; overflow: auto; }
.lh { display: grid; grid-template-columns: 44px 52px 1fr auto; gap: 8px; align-items: center; padding: 5px 6px; border-radius: 6px; font-size: 13px; }
.lh:nth-child(odd) { background: #ffffff06; }
.lh b { font-variant-numeric: tabular-nums; text-align: right; }
.lh b.neg { color: #ff8a8a; } .lh b.pos { color: #7be0a4; }
.lh .what { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #c9b27a; font-size: 12px; }
.lh .muted { font-size: 11px; white-space: nowrap; }
.cmdrs { display: flex; gap: 4px; align-items: center; }
.pips { display: inline-flex; gap: 2px; align-items: center; margin-left: 2px; vertical-align: middle; }
.pips img { display: block; filter: drop-shadow(0 1px 1px #0008); }
.deck-tile .pips { margin: 6px 0 0; }
.cmdrs .cz { position: relative; width: 30px; height: 30px; border-radius: 6px; background: #222 center 20% / cover; border: 1px solid var(--c); cursor: pointer; }
.cmdrs .cz .tax { position: absolute; right: -5px; bottom: -5px; background: var(--gold); color: #111; font-size: 10px; font-weight: 700; border-radius: 8px; padding: 0 4px; }

.bf { position: relative; flex: 1; min-height: 0; overflow: hidden; overflow: clip; } /* clip: never auto-scroll while dragging */
.bf.drop-hot { background: color-mix(in srgb, var(--c) 8%, transparent); }
.card { position: absolute; width: var(--cw, 64px); aspect-ratio: 488/680; border-radius: var(--card-r); background: #222 center / cover; box-shadow: 0 2px 6px #000a; cursor: grab; user-select: none; touch-action: none; transition: transform .12s; }
.card img { width: 100%; height: 100%; border-radius: var(--card-r); display: block; pointer-events: none; }
.card.tapped { transform: rotate(90deg); }
.card.token::after { content: "TOKEN"; position: absolute; top: 2px; left: 50%; transform: translateX(-50%); font-size: 8px; background: #000b; padding: 0 4px; border-radius: 4px; letter-spacing: .05em; }
.card .ctrs { position: absolute; left: 50%; top: 52%; transform: translate(-50%, -50%); display: grid; gap: 2px; justify-items: center; pointer-events: none; }
.card .ctrs span { background: #000d; border: 1px solid var(--gold-2); color: #fff; font-size: 11px; font-weight: 700; padding: 0 5px; border-radius: 8px; white-space: nowrap; }
.card.theirs { cursor: zoom-in; }
.card.dragging { opacity: .25; }
.card.sel { outline: 2px solid #8ab4ff; outline-offset: 2px; box-shadow: 0 0 12px #8ab4ff88; }
.card.attached { filter: brightness(.92); }
.selbox { position: absolute; border: 1px dashed #8ab4ff; background: #8ab4ff22; pointer-events: none; z-index: 50; border-radius: 3px; }
.selinfo { font-size: 12px; background: #1d2a44; border: 1px solid #34507e; padding: 3px 10px; border-radius: 12px; white-space: nowrap; }
.ghost-n { position: absolute; right: -8px; top: -8px; background: #8ab4ff; color: #0b1020; font-weight: 700; font-size: 12px; border-radius: 10px; padding: 1px 6px; }
body.attaching .bf .card { cursor: copy !important; }
body.attaching .bf .card:hover { outline: 2px solid var(--gold); outline-offset: 2px; }
.ghost { position: fixed; z-index: 800; pointer-events: none; opacity: .9; transform: rotate(3deg); box-shadow: 0 16px 30px #000c; }

.zones { display: flex; gap: 5px; padding: 4px 6px; background: #0b0e13b0; flex: none; align-items: center; flex-wrap: wrap; z-index: 4; }
.zone { position: relative; flex: none; display: flex; align-items: center; gap: 5px; padding: 3px 7px 3px 3px; border-radius: 8px; background: #161b24; border: 1px solid var(--line); cursor: pointer; font-size: 12px; }
.zone.drop-hot { border-color: var(--c); background: #233; }
.zone .pile { width: 24px; height: 33px; border-radius: 3px; background: #333 center / cover; flex: none; }
.zone b { font-variant-numeric: tabular-nums; }
.zone-actions { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; }

.hand { flex: none; height: calc(var(--hw, 76px) * .85 + 4px); position: relative; background: linear-gradient(transparent, #000a); z-index: 6; }
.hand.drop-hot { background: linear-gradient(transparent, color-mix(in srgb, var(--c) 30%, transparent)); }
.hand .hcards { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; padding: 0 10px; pointer-events: none; }
.hand .hcards .card { pointer-events: auto; }
.hand .card { position: relative; width: var(--hw, 76px); margin: 0 calc(var(--overlap, 0px) * -1); transform: translateY(calc(var(--hw, 76px) * .55)); transition: transform .15s; }
.hand .card:hover { transform: translateY(0) scale(1.08); z-index: 10; }
.hand .empty-hand { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12px; }

.seat-empty { flex: 1; display: grid; place-items: center; text-align: center; gap: 10px; color: var(--muted); }
.seat-empty .row { justify-content: center; }
.cam { position: absolute; inset: 0; display: grid; place-items: center; background: #000; }
.cam video { width: 100%; height: 100%; object-fit: contain; }
.cam .note { color: var(--muted); padding: 20px; text-align: center; }
.cam-tools { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 6px; z-index: 3; flex-wrap: wrap; justify-content: flex-end; }
.cam-tools select { width: auto; max-width: 180px; padding: 4px 6px; font-size: 12px; }
.bf.camera-bf { background: #000; }

.side { width: 290px; flex: none; display: flex; flex-direction: column; border-left: 1px solid var(--line); background: var(--panel); min-height: 0; }
.side.closed { display: none; }
.tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.tabs button { flex: 1; background: none; border: 0; padding: 9px 6px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; }
.tabs button.on { color: var(--text); border-bottom-color: var(--gold); }
.found { flex: 1; overflow-y: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 10px; }
.found-top { min-height: 26px; }
.found-help { font-size: 12.5px; line-height: 1.5; }
.fcard { display: grid; grid-template-columns: 110px 1fr; gap: 10px; align-items: start; background: #1b212d; border: 1px solid var(--line); border-radius: 10px; padding: 8px; animation: fadeup .25s ease-out; }
.fcard img { width: 110px; border-radius: 6px; display: block; }
.fmeta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fmeta b { line-height: 1.25; }
.fmeta .muted { font-size: 11.5px; }
.fmeta .row { gap: 4px; margin-top: 4px; }
.cam video { cursor: crosshair; }
.cam.busy video { cursor: progress; }
.cam .quad { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cam .quad polygon, .cam .quad circle { fill: none; stroke-width: 3; }
.cam .quad .ok { stroke: #57e28a; fill: #57e28a22; }
.cam .quad .bad { stroke: #e06363; stroke-dasharray: 6 4; }
.cam.busy::after { content: "Identifying…"; position: absolute; top: 8px; left: 50%; transform: translateX(-50%); background: #000c; padding: 4px 12px; border-radius: 14px; font-size: 12px; z-index: 2; }
.scan-btn { position: absolute; left: 8px; top: 8px; z-index: 3; background: #000b; }
.flip-btn { position: absolute; right: 8px; top: 8px; z-index: 3; background: #000b; }
.cam video { transition: transform .25s; }
.log { flex: 1; overflow-y: auto; padding: 8px 10px; font-size: 12.5px; display: flex; flex-direction: column; gap: 3px; }
.log .e { line-height: 1.35; }
.log .e .n { font-weight: 600; }
.log .e.sys { color: var(--gold); font-weight: 600; margin-top: 4px; }
.log .e.chat { background: #212838; padding: 4px 7px; border-radius: 8px; }
.log .cardref { color: #9ec7ff; cursor: help; text-decoration: underline dotted; }
.chat-in { padding: 8px; border-top: 1px solid var(--line); }

.seat-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: 1px; }

@media (max-width: 900px) {
  .editor { grid-template-columns: 1fr; }
  .editor aside { position: static; }
  .side { position: fixed; right: 0; top: 46px; bottom: 0; z-index: 700; width: min(320px, 90vw); box-shadow: -10px 0 30px #000a; }
  .grid4 { grid-template: 1fr 1fr 1fr 1fr / 1fr; overflow-y: auto; }
  .grid4 .seat { min-height: 300px; }
  .shead .who { max-width: 60%; }
}

/* phone pairing */
.pair { display: grid; gap: 10px; }
.pair .qr { background: #fff; border-radius: 12px; padding: 8px; width: min(260px, 70vw); margin: 0 auto; }
.pair .qr svg { display: block; width: 100%; height: auto; }
.pair ol { margin: 0; padding-left: 20px; line-height: 1.6; }
.pair-status { text-align: center; font-weight: 600; }

/* phone camera page */
.phonecam { position: fixed; inset: 0; background: #000; display: flex; flex-direction: column; }
.phonecam video { flex: 1; min-height: 0; width: 100%; object-fit: contain; background: #000; }
.pc-bar { display: flex; gap: 8px; align-items: center; padding: 10px 14px; padding-bottom: max(10px, env(safe-area-inset-bottom)); background: #0d1016; flex-wrap: wrap; }
.pc-top { padding-top: max(10px, env(safe-area-inset-top)); }
.pc-bar .grow { min-width: 0; }
.live-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #666; margin-right: 6px; vertical-align: 1px; }
.live-dot.on { background: #e5484d; box-shadow: 0 0 8px #e5484d; animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .45; } }
.pc-hint { display: none; text-align: center; color: var(--muted); font-size: 12px; padding: 6px; background: #0d1016; }
@media (orientation: portrait) { .pc-hint { display: block; } }

/* deck legality, prices, records */
.issue { display: flex; gap: 8px; padding: 6px 0; font-size: 13px; line-height: 1.35; }
.issue + .issue { border-top: 1px solid var(--line); }
.issue > b { width: 14px; flex: none; }
.issue.error > b { color: var(--danger); } .issue.warn > b { color: #e0b44a; } .issue.ok > b { color: var(--ok); }
.issue .names { color: var(--muted); font-size: 12px; margin-top: 2px; }
.deck-card.bad img { box-shadow: 0 0 0 2px var(--danger); }
.deck-card.bad::after { content: "!"; position: absolute; top: 6px; right: 6px; background: var(--danger); color: #fff; font-weight: 700; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; }
.dear { margin: 4px 0 8px; font-size: 12px; display: grid; gap: 2px; }
.dear div { display: flex; justify-content: space-between; gap: 8px; }
.dear span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: help; }
.wl { font-size: 12px; font-weight: 600; color: var(--gold); }
.deck-tile .pips { margin: 0; }

/* lobby friends */
.lobby { display: grid; grid-template-columns: 1fr 300px; gap: 24px; max-width: 1200px; align-items: start; }
.lobby-side { position: sticky; top: 12px; }
.friend { display: flex; gap: 10px; align-items: center; padding: 7px 0; }
.friend + .friend { border-top: 1px solid var(--line); }
.friend .muted { font-size: 12px; }
.on-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); margin-right: 5px; vertical-align: 1px; }
@media (max-width: 900px) { .lobby { grid-template-columns: 1fr; } .lobby-side { position: static; } }
.invite-card { position: fixed; right: 16px; bottom: 16px; z-index: 1300; background: var(--panel-2); border: 1px solid var(--gold-2); border-radius: 12px; padding: 12px 14px; display: grid; gap: 10px; box-shadow: 0 16px 40px #000c; animation: fadeup .25s ease-out; max-width: calc(100vw - 32px); }

/* history */
.kpis { display: flex; gap: 12px; flex-wrap: wrap; }
.kpis div { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 18px; display: grid; min-width: 110px; }
.kpis b { font-size: 26px; color: var(--gold); font-variant-numeric: tabular-nums; }
.kpis span { color: var(--muted); font-size: 12px; }
.tbl { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tbl th, .tbl td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.tbl th { color: var(--muted); font-weight: 600; font-size: 12px; }
.games { display: grid; gap: 12px; }
.game { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.ghead { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.gplayers { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.gp { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 8px; background: #ffffff05; }
.gp.won { background: #d4b06218; border: 1px solid #d4b06255; }
.gp.me b { color: var(--gold); }
.gp .place { width: 26px; text-align: center; font-weight: 700; color: var(--muted); }
.gp .muted { font-size: 12px; }
.cmdfaces { display: flex; }
.cmdfaces img, .cmdfaces .noface { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; object-position: 50% 22%; border: 2px solid var(--panel); background: #222; display: grid; place-items: center; }
.cmdfaces img + img { margin-left: -12px; }

/* the stack */
.gridwrap { position: relative; flex: 1; display: flex; min-width: 0; min-height: 0; }
.stack { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 30; background: #0d1016ee; border: 1px solid var(--gold-2); border-radius: 14px; padding: 8px 12px 12px; box-shadow: 0 20px 50px #000c; max-width: min(90%, 640px); backdrop-filter: blur(3px); }
.stack.drop-ready { border-style: dashed; min-width: 220px; min-height: 80px; }
.stack.drop-ready.drop-hot { background: #2a2414ee; }
.stack-head { font: 600 13px Cinzel, serif; color: var(--gold); display: flex; gap: 10px; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.stack-head .muted { font: 11px Inter, sans-serif; }
.stack-cards { display: flex; align-items: flex-end; padding-left: 30px; }
.scard { position: relative; width: 92px; margin-left: -30px; cursor: pointer; transition: transform .15s; }
.scard:hover { transform: translateY(-8px); z-index: 99 !important; }
.scard img { width: 100%; border-radius: 6px; display: block; box-shadow: 0 0 0 2px var(--c), 0 6px 16px #000a; }
.scard .sowner { position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); font-size: 10px; background: #000d; border: 1px solid var(--c); border-radius: 8px; padding: 0 6px; white-space: nowrap; }
.scard .stop { position: absolute; top: -8px; right: -6px; font-size: 10px; background: var(--gold); color: #111; font-weight: 700; border-radius: 8px; padding: 0 5px; }

/* targeting arrows */
#arrows { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 1000; }
#arrows .arrow path { fill: none; stroke-width: 4; stroke-linecap: round; filter: drop-shadow(0 2px 4px #000); stroke-dasharray: 2000; stroke-dashoffset: 2000; animation: drawin .45s ease-out forwards; }
#arrows .arrow circle { fill: none; stroke-width: 3; opacity: .9; }
#arrows .arrow.fade { opacity: 0; transition: opacity 1s; }
@keyframes drawin { to { stroke-dashoffset: 0; } }
body.targeting .seat, body.targeting .card, body.targeting .scard, body.targeting video { cursor: crosshair !important; }
body.targeting .card:hover, body.targeting .scard:hover { outline: 2px solid #ff6b6b; outline-offset: 2px; }

/* scry / surveil */
.arr-row { margin-bottom: 14px; }
.arr-label { font-weight: 600; margin-bottom: 6px; }
.arr-cards { display: flex; gap: 10px; flex-wrap: wrap; min-height: 40px; }
.arr-card { width: 120px; }
.arr-card img { width: 100%; border-radius: 6px; display: block; }
.arr-btns { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; justify-content: center; }
.arr-btns button { background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; font-size: 11px; cursor: pointer; }
.arr-btns button:hover { border-color: var(--gold-2); }
.win-pick { display: grid; gap: 8px; }
.win-pick .btn { justify-content: flex-start; }
