:root {
  --bg: #07111f;
  --panel: #0c1a2e;
  --panel-2: #122240;
  --line: #1e2f4c;
  --text: #e8eefc;
  --dim: #8fa3c4;
  --accent: #4c9aff;
  --accent-2: #8b6cf6;
  --gold: #f0c869;
  --good: #46c26e;
  --bad: #f85149;
  --warn: #d29922;
  --club: #4ec9a5;
  --diamond: #58a6ff;
  --heart: #f85149;
  --spade: #e6edf3;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "DM Sans", ui-sans-serif, -apple-system, "SF Pro Text", system-ui, sans-serif;
}
.mono, #table-status, .brow-label, #deck-count, .pile-count, .plog-act, .insight .mv {
  font-family: "DM Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

/* ---------- header ---------- */

header {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 11px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 17, 31, 0.92);
  flex-wrap: wrap;
}

.brand {
  display: flex; align-items: baseline; gap: 10px;
  text-decoration: none; color: inherit;
}
.brand-mark {
  align-self: center;
  width: 30px; height: 30px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; color: #071224;
  background: linear-gradient(140deg, #8b6cf6 0%, #4c9aff 90%);
  box-shadow: 0 2px 10px rgba(76, 154, 255, 0.35);
}
h1 {
  font-size: 18px; font-weight: 900; margin: 0; letter-spacing: -0.02em;
  color: #f2f6ff;
}
h1 em { font-style: normal; color: var(--accent); }
.brand-solver {
  font-weight: 650; color: var(--gold);
  letter-spacing: 0.01em;
}

h2 {
  font-size: 13px; font-weight: 600; margin: 0;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--dim);
}

nav { display: flex; gap: 4px; }

.tab {
  background: none; border: 1px solid transparent; color: var(--dim);
  padding: 6px 16px; border-radius: 10px; cursor: pointer;
  font-size: 13px; font-weight: 600; font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--panel-2); border-color: var(--line); color: #fff; }

.vfl {
  margin-left: auto; display: flex; align-items: center; gap: 6px;
  font-variant-numeric: tabular-nums;
}
.vfl-lbl { font-size: 11px; color: var(--dim); margin-right: 2px; }
.vfl-chip {
  font-family: "DM Mono", ui-monospace, monospace; font-size: 10.5px;
  color: var(--dim);
  padding: 3px 8px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line);
}
.vfl-chip b { color: var(--text); font-weight: 500; margin-left: 5px; }

/* ---------- layout ---------- */

main { padding: 16px 20px 40px; max-width: 1500px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; margin-top: 16px; }
@media (max-width: 1080px) { .split { grid-template-columns: minmax(0, 1fr); } }

.col-main, .col-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.panel-head {
  display: flex; align-items: baseline; gap: 12px; padding: 10px 14px;
  border-bottom: 1px solid var(--line); background: var(--panel-2);
}
.meta { color: var(--dim); font-size: 12px; margin-left: auto; font-variant-numeric: tabular-nums; }

/* ---------- controls ---------- */

.controls { display: flex; gap: 10px; align-items: flex-end; margin-bottom: 16px; flex-wrap: wrap; }
.controls label {
  display: flex; flex-direction: column; gap: 4px; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--dim);
}
.controls label.grow { flex: 1; min-width: 260px; }

input, select, button {
  font: inherit; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
}
input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=text] { font-family: ui-monospace, "SF Mono", Menlo, monospace; width: 100%; }
input[type=number] { width: 84px; }

button { cursor: pointer; }
button:hover { border-color: var(--dim); }
button.primary {
  background: linear-gradient(100deg, #8b6cf6 0%, #5f86ff 55%, #4c9aff 100%);
  border: 1px solid transparent; color: #fff; font-weight: 700;
  border-radius: 10px;
  text-shadow: 0 1px 2px rgba(20, 20, 60, 0.35);
}
button.primary:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.45; cursor: default; }

.error {
  background: #2d1418; border: 1px solid var(--bad); color: #ffb4ae;
  padding: 9px 12px; border-radius: var(--radius); margin-bottom: 14px; font-size: 13px;
}

/* Fantasyland tab controls share the play menu's table styling */
#view-fantasyland .controls {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 16px;
}
#view-fantasyland .controls input,
#view-fantasyland .controls select {
  background: var(--panel-2);
  border-color: var(--line);
  border-radius: 10px;
}

/* =====================================================================
   Fantasyland tab (mono card chips, unchanged)
   ===================================================================== */

.card {
  display: inline-flex; align-items: center; justify-content: center; gap: 1px;
  min-width: 30px; height: 40px; padding: 0 5px;
  background: linear-gradient(165deg, #ffffff 0%, #f2f4f8 100%);
  border: 1px solid rgba(4, 10, 24, 0.25); border-radius: 6px;
  box-shadow: 0 1px 3px rgba(4, 10, 24, 0.35);
  font-family: "DM Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 15px; font-weight: 800; line-height: 1;
}
.card.sm { height: 27px; min-width: 24px; font-size: 12px; border-radius: 5px; }
.card.c, .card.s { color: #1c2333; }
.card.d, .card.h { color: #dd2440; }
.card.ghost { opacity: 0.35; filter: grayscale(0.6); }

.hand { display: flex; flex-wrap: wrap; gap: 4px; }

.board { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.row {
  display: grid; grid-template-columns: 62px auto 1fr auto;
  align-items: center; gap: 12px; padding: 8px 10px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
}
.row-name { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.row-desc { color: var(--dim); font-size: 12px; }
.row-roy { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; }
.row-roy.zero { color: var(--dim); font-weight: 400; }
.row-roy.pos { color: var(--warn); }
.row.discard { background: transparent; border-style: dashed; }

.totals { display: flex; gap: 18px; padding: 10px 12px; border-top: 1px solid var(--line); margin-top: 2px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .k { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.06em; }
.stat .v { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .v.good { color: var(--good); }
.stat .v.warn { color: var(--warn); }
.stat .v.bad { color: var(--bad); }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
}
.badge.stay { background: rgba(63,185,80,0.16); color: var(--good); border: 1px solid rgba(63,185,80,0.4); }
.badge.nostay { background: rgba(139,152,165,0.12); color: var(--dim); border: 1px solid var(--line); }

.alts { display: flex; flex-direction: column; }
.alt {
  display: grid; grid-template-columns: 34px 1fr 96px 78px 64px;
  align-items: center; gap: 12px; padding: 9px 14px;
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.alt:last-child { border-bottom: none; }
.alt:hover { background: var(--panel-2); }
.alt.best {
  background: rgba(76,154,255,0.08);
  box-shadow: inset 3px 0 0 var(--accent);
}
.alt-rank { color: var(--dim); font-variant-numeric: tabular-nums; font-size: 12px; }
.alt-rows { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.alt-line { display: flex; gap: 3px; align-items: center; }
.alt-tag { color: var(--dim); font-size: 10px; width: 12px; flex: none; text-transform: uppercase; }
.alt-desc { color: var(--dim); font-size: 11px; }
.alt-num { font-variant-numeric: tabular-nums; text-align: right; font-size: 13px; }
.alt-loss { font-variant-numeric: tabular-nums; text-align: right; font-size: 13px; color: var(--bad); }
.alt-loss.zero { color: var(--good); }

.stay, .equity { padding: 12px 14px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--dim); }
.kv .v { font-variant-numeric: tabular-nums; font-weight: 600; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 13px; }
th { text-align: right; color: var(--dim); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; padding: 4px 0; }
th:first-child, td:first-child { text-align: left; }
td { text-align: right; padding: 4px 0; border-top: 1px solid var(--line); }
tr.hl td { color: var(--accent); font-weight: 600; }

.note { color: var(--dim); font-size: 12px; margin-top: 10px; line-height: 1.45; }

.plog { padding: 6px 0; max-height: 560px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.plog::-webkit-scrollbar { width: 8px; }
.plog::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.plog-row { padding: 7px 14px; border-bottom: 1px solid var(--line); font-size: 12px; }
.plog-row:last-child { border-bottom: none; }
.plog-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--dim); font-size: 11px; }
.plog-seat {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 5px; margin-right: 6px;
  font-size: 9px; font-weight: 800; color: #0b1220;
  background: linear-gradient(150deg, #8ab8ff, #5d86e8);
  vertical-align: -3px;
}
.plog-seat.s1 { background: linear-gradient(150deg, #ffc46b, #e88f4d); }
.plog-seat.s2 { background: linear-gradient(150deg, #7be0b0, #45b585); }
.plog-act { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px; margin-top: 2px; }
.plog-num { font-variant-numeric: tabular-nums; }

/* =====================================================================
   Play tab — the table (navy, center-action)
   ===================================================================== */

#felt, #train-felt {
  --cw: 46px;
  position: relative;
  border-radius: 30px;
  padding: 54px 22px 96px;
  background:
    radial-gradient(circle at 18% 22%, rgba(255,255,255,0.045) 0 1px, transparent 1.5px) 0 0 / 26px 26px,
    radial-gradient(circle at 70% 60%, rgba(255,255,255,0.035) 0 1px, transparent 1.5px) 13px 13px / 26px 26px,
    radial-gradient(ellipse 120% 100% at 50% 8%, #33589e 0%, #2a4a8a 38%, #1d3565 72%, #152648 100%);
  box-shadow:
    inset 0 0 0 1px rgba(150,185,255,0.14),
    inset 0 0 0 7px rgba(9, 16, 32, 0.55),
    inset 0 0 0 8px rgba(150,185,255,0.10),
    inset 0 30px 110px rgba(0,0,0,0.38),
    0 14px 48px rgba(0,0,0,0.5);
  border: 1px solid #2e4577;
}
#felt-mark {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-weight: 900; font-size: 26px; letter-spacing: -0.02em;
  color: rgba(215, 230, 255, 0.06);
  pointer-events: none; user-select: none; z-index: 0;
}
#felt-mark em { font-style: normal; }
#felt.three, #train-felt.three { --cw: 38px; }

#table-status {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase;
  color: rgba(195, 213, 248, 0.72); white-space: nowrap;
  background: rgba(8, 14, 28, 0.55);
  border: 1px solid rgba(150, 185, 255, 0.13);
  padding: 5px 14px; border-radius: 999px;
  backdrop-filter: blur(4px);
  transition: color 0.3s ease, border-color 0.3s ease;
}
#table-status.done {
  color: var(--gold);
  border-color: rgba(240, 200, 105, 0.4);
  background: rgba(240, 200, 105, 0.08);
}

/* deck: center of the table, a small stack */
#deck-spot {
  position: absolute; top: 48px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; z-index: 5;
}
#deck-spot .pcard { width: calc(var(--cw) * 0.78); }
#deck-spot .pcard.shadowcard {
  position: absolute; left: 3px; top: 3px; filter: brightness(0.75);
}
#deck-spot .pcard:not(.shadowcard) { position: relative; }
#deck-count {
  font-size: 11px; color: rgba(180,200,240,0.6); font-weight: 500;
}

#seats-row {
  display: flex; gap: 18px; justify-content: center; align-items: flex-start;
  margin-top: 44px;
}

.seatp {
  position: relative;
  flex: 1 1 0; min-width: 0; max-width: 560px;
  border-radius: 18px; padding: 14px 14px 10px;
  background: rgba(8, 14, 28, 0.45);
  box-shadow: inset 0 0 0 1px rgba(140,170,255,0.08);
  transition: box-shadow 0.35s ease, background 0.35s ease;
}
.seatp.acting {
  background: rgba(76,154,255,0.09);
  box-shadow: inset 0 0 0 1.5px rgba(96,165,255,0.55), 0 0 34px rgba(76,154,255,0.14);
}
.seatp.thinking { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: inset 0 0 0 1.5px rgba(96,165,255,0.55), 0 0 22px rgba(76,154,255,0.12); }
  50% { box-shadow: inset 0 0 0 1.5px rgba(120,180,255,0.9), 0 0 44px rgba(76,154,255,0.32); }
}

.seatp-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
  flex-wrap: wrap; min-height: 30px;
}
.avatar {
  width: 30px; height: 30px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; color: #0b1220;
  background: linear-gradient(150deg, #8ab8ff, #5d86e8);
  box-shadow: 0 0 0 2px rgba(10,18,36,0.85), 0 0 0 3.5px rgba(150,185,255,0.28), 0 2px 8px rgba(0,0,0,0.4);
  flex: none;
}
.seatp:nth-child(2) .avatar { background: linear-gradient(150deg, #ffc46b, #e88f4d); }
.seatp:nth-child(3) .avatar { background: linear-gradient(150deg, #7be0b0, #45b585); }
.seatp-name { font-weight: 700; font-size: 13.5px; color: rgba(235,242,255,0.95); letter-spacing: 0.01em; }

.chip {
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 20px;
  background: rgba(140,170,255,0.14); color: rgba(210,225,255,0.9);
}
.chip.act { background: #4c9aff; color: #071224; }
.chip.fl {
  background: linear-gradient(150deg, #f6d47f, #dfa94a); color: #2a1e00;
  font-family: "DM Mono", ui-monospace, monospace; font-weight: 500;
  box-shadow: 0 1px 8px rgba(240, 200, 105, 0.3);
}
.chip.foul { background: #e5484d; color: #fff; }
.chip.win { background: #46c26e; color: #04170a; }
.chip.lose { background: rgba(229,72,77,0.28); color: #ffb9b5; }
.chip.roy { background: rgba(240,200,105,0.16); color: #f0c869; }

/* board zone wraps the three rows so the foul mask covers exactly them */
.board-zone { position: relative; border-radius: 12px; }
.foul-mask {
  position: absolute; inset: -4px;
  background: rgba(229, 72, 77, 0.20);
  border: 1.5px solid rgba(229, 72, 77, 0.55);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  animation: foulin 0.45s cubic-bezier(0.16,1,0.3,1) both;
  pointer-events: none; z-index: 8;
  backdrop-filter: saturate(0.7);
}
.foul-mask span {
  font-weight: 900; font-size: 30px; letter-spacing: 0.35em; padding-left: 0.35em;
  color: rgba(255, 92, 92, 0.9);
  text-shadow: 0 2px 14px rgba(0,0,0,0.6);
  transform: rotate(-9deg);
  border: 3px solid rgba(255, 92, 92, 0.75); border-radius: 10px;
  padding: 4px 10px 4px 18px;
  background: rgba(20, 8, 10, 0.35);
}
@keyframes foulin { from { opacity: 0; transform: scale(1.12); } to { opacity: 1; transform: scale(1); } }

/* board rows: chip labels like OFCPlay */
.brow { display: flex; gap: 6px; justify-content: center; margin: 7px 0; position: relative; padding-left: 58px; padding-right: 58px; }
.brow-label {
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  font-size: 8px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase;
  color: rgba(208, 222, 250, 0.78);
  background: rgba(10, 18, 36, 0.85); border: 1px solid rgba(150,185,255,0.14);
  padding: 3px 8px; border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
}
.slot {
  width: var(--cw); height: calc(var(--cw) * 1.4);
  border-radius: calc(var(--cw) * 0.12);
  border: 1.5px dashed rgba(150,175,220,0.22);
  background: rgba(10, 18, 36, 0.35);
  box-shadow: inset 0 1px 8px rgba(0,0,0,0.3);
  position: relative;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.slot .pcard { position: absolute; inset: 0; width: 100%; }
.slot.landing { border-color: rgba(120,180,255,0.9); box-shadow: inset 0 0 14px rgba(76,154,255,0.35), 0 0 18px rgba(76,154,255,0.2); }
.brow.rowwin .slot { border-color: rgba(70,194,110,0.6); }
.brow.rowlose .slot { border-color: rgba(229,72,77,0.5); }

/* footer: discard pile + fan */
.seatp-foot {
  position: relative;
  margin-top: 14px; min-height: calc(var(--cw) * 1.62);
}
.pile {
  position: absolute; left: 4px; bottom: 2px; z-index: 3;
  width: calc(var(--cw) * 1.6); height: calc(var(--cw) * 1.45);
}
.pile .pcard { position: absolute; bottom: 0; left: 0; transition: transform 0.3s cubic-bezier(0.16,1,0.3,1); }
.pile-count {
  position: absolute; right: 2px; bottom: -4px; z-index: 5;
  font-size: 10px; color: rgba(180,200,240,0.6);
}
.pile:hover .pcard { transform: translateX(calc(var(--i) * var(--cw) * 0.5)) translateY(-6px) rotate(0deg) !important; z-index: 40 !important; }
.pile .pcard.dead .pc-face { filter: grayscale(0.45) brightness(0.82); }

.fan {
  position: relative; height: calc(var(--cw) * 1.62);
  width: 72%; margin: 0 auto; min-width: 0;
}
.fan .pcard {
  position: absolute; bottom: 4px;
  transition: transform 0.25s cubic-bezier(0.16,1,0.3,1);
  transform-origin: 50% 130%;
}
.fan .pcard:hover { transform: translateY(-10px) rotate(0deg) !important; z-index: 30 !important; }

/* per-seat live internals: the bot's own read of this board */
.seatp-stats { margin: 12px 2px 0; min-height: 22px; }
.st-trio {
  display: flex; justify-content: center; gap: 10px; margin-bottom: 8px;
  max-width: 420px; margin-left: auto; margin-right: auto;
}
.st-tile {
  flex: 1 1 0; text-align: center;
  background: rgba(8,14,28,0.55); border: 1px solid rgba(140,170,255,0.10);
  border-radius: 12px; padding: 7px 6px 6px;
}
.st-num {
  font-size: 19px; font-weight: 800; line-height: 1.05;
  color: rgba(232,240,255,0.95); font-variant-numeric: tabular-nums;
}
.st-num.bad { color: #ff7b73; }
.st-num.warn { color: #f0c869; }
.st-num.good { color: #6ee787; }
.st-lbl {
  font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase;
  color: rgba(180,200,240,0.5); margin-top: 2px;
}
.st-draws { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; font-size: 11px; margin-top: 6px; }

/* per-row expected-hand table — same width as the stat trio above */
.st-rows {
  display: flex; flex-direction: column; gap: 3px;
  max-width: 420px; margin: 0 auto;
}
.st-row {
  display: grid; grid-template-columns: 52px 1fr auto;
  align-items: baseline; gap: 8px;
  font-size: 11.5px; padding: 3px 10px; border-radius: 8px;
  background: rgba(8,14,28,0.4);
}
.st-row.r0 { box-shadow: inset 2px 0 0 rgba(240,200,105,0.5); }
.st-row.r1 { box-shadow: inset 2px 0 0 rgba(120,170,255,0.5); }
.st-row.r2 { box-shadow: inset 2px 0 0 rgba(110,231,135,0.5); }
.st-row-tag {
  font-size: 8.5px; letter-spacing: 0.12em; text-transform: uppercase;
  color: rgba(180,200,240,0.5);
}
.st-row-hand { color: rgba(228,238,255,0.92); font-weight: 650; }
.st-row-nums { color: rgba(180,200,240,0.6); font-variant-numeric: tabular-nums; white-space: nowrap; }
.st-row-nums .pct { color: #8fd0ff; font-weight: 800; }
.st-row-nums i { font-style: normal; font-size: 10.5px; }
.st-row-nums b.bad { color: #ff7b73; }
.st-chip {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.02em;
  padding: 3px 10px; border-radius: 14px;
  background: rgba(140,170,255,0.10); color: rgba(205,220,250,0.85);
  border: 1px solid rgba(140,170,255,0.14);
}
.st-chip b { font-variant-numeric: tabular-nums; }
.st-chip .pct { color: #8fd0ff; font-weight: 800; }
.st-chip.r0 .pct { color: #f0c869; }
.st-chip.r2 .pct { color: #6ee787; }
.st-chip i { font-style: normal; color: rgba(180,200,240,0.5); font-size: 9.5px; }
.st-chip.r0 { border-color: rgba(240,200,105,0.35); }
.st-chip.r2 { border-color: rgba(110,231,135,0.25); }
.st-chip.fl { background: rgba(240,200,105,0.12); color: #f0c869; border-color: rgba(240,200,105,0.3); }
.st-dim { color: rgba(180,200,240,0.35); }

/* candidate-action mini boards: front | middle | back laid out side by side,
   every board the same fixed 3+5+5 grid so candidates align column-for-column */
.mini-board {
  --mw: 24px;
  display: flex; flex-direction: row; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 10px;
  background: rgba(10,16,32,0.5);
  width: fit-content;
}
.mini-row { display: flex; gap: 3px; }
.mini-row + .mini-row {
  padding-left: 10px;
  border-left: 1px solid rgba(150,175,220,0.14);
}
.mini-slot {
  width: var(--mw); height: calc(var(--mw) * 1.4);
  border-radius: 4px; border: 1px dashed rgba(150,175,220,0.18);
}
.mini-slot .pcard.mini { width: 100%; height: 100%; }
.pcard.mini .pc-corner { font-size: calc(var(--mw) * 0.52); top: 6%; left: 12%; }
.pcard.mini .pc-corner .s { display: block; font-size: calc(var(--mw) * 0.44); margin-top: 8%; }
.pcard.mini .pc-pip, .pcard.mini .pc-corner.br { display: none; }
.pcard.mini.old .pc-face { filter: grayscale(0.7) brightness(0.62); }
.pcard.mini.new .pc-face { box-shadow: 0 0 0 1.5px rgba(240,244,255,0.85), 0 1px 3px rgba(0,0,0,0.5); }
.mini-discard {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding-left: 10px;
  border-left: 1px solid rgba(150,175,220,0.14);
}
.mini-discard .pcard.mini {
  width: var(--mw); height: calc(var(--mw) * 1.4);
}
.mini-discard > span {
  font-size: 8.5px; letter-spacing: 0.1em; text-transform: uppercase;
  color: rgba(180,200,240,0.45);
}
.alt { grid-template-columns: 34px 1fr 96px 78px 64px; }
/* below ~1100px the 13-slot strip won't fit beside the numbers; stack rows again */
@media (max-width: 1100px) {
  .mini-board { flex-direction: column; align-items: flex-start; gap: 3px; }
  .mini-row + .mini-row { padding-left: 0; border-left: none; }
  .mini-discard { flex-direction: row; padding-left: 0; border-left: none; }
}

/* ---------- the playing card (OFCPlay-style index) ---------- */

.pcard {
  width: var(--cw); aspect-ratio: 5 / 7;
  perspective: 700px; user-select: none;
}
.pc-in {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.35s cubic-bezier(0.3, 0.8, 0.3, 1);
}
.pc-in.flipped { transform: rotateY(180deg); }
.pc-face, .pc-back {
  position: absolute; inset: 0;
  border-radius: 11%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 2px 5px rgba(4, 10, 24, 0.5), 0 0 0 1px rgba(4, 10, 24, 0.18);
}
.pc-face {
  background: linear-gradient(165deg, #ffffff 0%, #f4f5f7 100%);
}
.pc-back {
  transform: rotateY(180deg);
  background:
    radial-gradient(circle at 50% 45%, rgba(255,255,255,0.16) 0 18%, transparent 19%),
    repeating-linear-gradient(45deg, rgba(255,255,255,0.10) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,0.08) 0 2px, transparent 2px 7px),
    linear-gradient(160deg, #3b64c4 0%, #24418a 100%);
  border: calc(var(--cw) * 0.055) solid #eef1f6;
}

/* index: bold rank top-left, big suit pip low-center — the OFCPlay card */
.pc-corner {
  position: absolute; top: 5%; left: 10%;
  display: flex; flex-direction: column; align-items: center; line-height: 0.9;
  font-weight: 900; font-size: calc(var(--cw) * 0.38);
  letter-spacing: -0.04em;
  font-family: "DM Sans", ui-sans-serif, system-ui, sans-serif;
}
.pc-corner .s { display: none; }
.pc-corner.br { display: none; }
.pc-pip {
  position: absolute; left: 50%; bottom: 9%;
  transform: translateX(-50%);
  font-size: calc(var(--cw) * 0.56); line-height: 1; opacity: 0.95;
}

/* classic two-colour deck */
.pcard.s-h .pc-face, .pcard.s-d .pc-face { color: #dd2440; }
.pcard.s-c .pc-face, .pcard.s-s .pc-face { color: #1c2333; }

.deckcard .pc-in { transition: none; }

/* flying clones */
#fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 200; }
#fx-layer .pcard { position: absolute; will-change: transform; }
#fx-layer .pcard .pc-face, #fx-layer .pcard .pc-back {
  box-shadow: 0 14px 32px rgba(0,0,0,0.55), 0 0 0 1px rgba(0,0,0,0.25);
}

/* ---------- action dock: centered, on the table ---------- */

#action-dock {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; z-index: 10;
}
.dock-btn {
  border-radius: 999px; padding: 12px 26px;
  font-weight: 700; font-size: 14.5px; letter-spacing: 0.01em;
  background: rgba(16, 26, 48, 0.85); color: rgba(220,232,255,0.92);
  border: 1px solid rgba(140,170,255,0.22);
  box-shadow: 0 4px 18px rgba(0,0,0,0.35);
  transition: transform 0.15s cubic-bezier(0.16,1,0.3,1), box-shadow 0.2s ease, filter 0.2s ease;
  backdrop-filter: blur(6px);
}
.dock-btn:hover { transform: translateY(-1px); border-color: rgba(160,190,255,0.45); }
.dock-btn:active { transform: translateY(0) scale(0.98); }
.dock-btn.primary {
  background: linear-gradient(100deg, #8b6cf6 0%, #5f86ff 55%, #4c9aff 100%);
  color: #fff; border-color: transparent;
  box-shadow: 0 6px 24px rgba(112, 118, 255, 0.45);
  padding: 13px 34px; font-size: 15.5px;
  text-shadow: 0 1px 2px rgba(20, 20, 60, 0.35);
}
.dock-btn.primary:hover { filter: brightness(1.08); box-shadow: 0 8px 30px rgba(112, 118, 255, 0.6); }
.dock-btn.ghost { background: rgba(16,26,48,0.55); }
.dock-btn:disabled { opacity: 0.4; transform: none; cursor: default; box-shadow: none; }
.db-ico { font-size: 12px; margin-right: 4px; }
.dock-btn.solving .db-ico { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* end-of-hand score, one per seat panel */
.seat-score {
  position: absolute; right: 16px; bottom: 12px;
  font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums;
  color: rgba(220, 232, 255, 0.9);
  animation: fadeup 0.5s ease both;
}
@keyframes fadeup { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.seat-score.pos { color: #6ee787; }
.seat-score.neg { color: #ff8d85; }

/* insight strip */
.insight {
  margin-top: 12px; padding: 10px 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: inset 3px 0 0 var(--accent);
  display: flex; gap: 20px; align-items: baseline; flex-wrap: wrap;
  font-size: 13px;
}
.insight[hidden] { display: none; }
.insight .who { font-weight: 700; }
.insight .mv { font-size: 12px; }
.insight .kv2 { color: var(--dim); font-variant-numeric: tabular-nums; }
.insight .kv2 b { color: var(--text); }

@media (prefers-reduced-motion: reduce) {
  .pc-in, .fan .pcard, .pile .pcard, .dock-btn { transition: none !important; }
  .seatp.thinking { animation: none; }
}
.st-chip em { font-style: normal; font-weight: 800; font-size: 9px; opacity: 0.55; letter-spacing: 0.08em; }
.plog-row.clickable { cursor: pointer; }
.plog-row.clickable:hover { background: var(--panel-2); box-shadow: inset 2px 0 0 var(--accent); }
.st-row.open .st-row-hand.dim { color: rgba(180,200,240,0.4); font-weight: 400; font-style: italic; }
.st-row-hand .lean { font-style: normal; font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; color: rgba(180,200,240,0.5); margin-right: 3px; }


/* ---------- themed in-game menu row ---------- */
.game-menu {
  background: rgba(16, 26, 48, 0.6);
  border: 1px solid rgba(140,170,255,0.14);
  border-radius: 14px;
  padding: 10px 16px;
  display: flex; gap: 22px;
  width: fit-content; margin: 0 auto 16px;
  backdrop-filter: blur(6px);
}
.game-menu label {
  color: rgba(180,200,240,0.55);
  font-size: 10px; letter-spacing: 0.12em;
}
.game-menu select {
  background: rgba(8,14,28,0.8);
  border: 1px solid rgba(140,170,255,0.22);
  border-radius: 10px;
  color: rgba(225,235,255,0.95);
  font-weight: 650; font-size: 13.5px;
  padding: 7px 12px; min-width: 110px;
  cursor: pointer;
}
.game-menu select:hover { border-color: rgba(160,190,255,0.45); }

/* breathing room below the hand fans */
.seatp { padding-bottom: 18px; }
.seatp-foot { margin-bottom: 8px; }

/* candidates meta doubles as back-to-live */
#play-actions-meta { cursor: pointer; }
#play-actions-meta:hover { color: var(--accent); }

/* ---------- solve progress in the action dock ---------- */
#action-dock { flex-wrap: nowrap; white-space: nowrap; max-width: calc(100% - 32px); }
.solve-progress {
  display: flex; align-items: center; gap: 10px;
  width: 250px; flex: none; padding: 6px 10px;
  border-radius: 12px;
  background: rgba(8, 14, 30, 0.72);
  border: 1px solid rgba(150, 175, 220, 0.16);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
/* keep the dock from re-centering when the capsule comes and goes */
.solve-progress[hidden] { display: flex; visibility: hidden; }
.sp-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.sp-stop {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; line-height: 1; padding: 0;
  background: rgba(150, 175, 220, 0.12); color: rgba(200, 216, 245, 0.8);
  border: 1px solid rgba(150, 175, 220, 0.22); cursor: pointer;
}
.sp-stop:hover { background: rgba(229, 72, 77, 0.25); border-color: rgba(229, 72, 77, 0.5); color: #ffb4ae; }
.sp-bar {
  height: 5px; border-radius: 3px; overflow: hidden;
  background: rgba(150, 175, 220, 0.14);
}
.sp-fill {
  height: 100%; width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, #5b8def, #6ee787);
  transition: width 0.15s linear;
}
.sp-text {
  font-family: 'DM Mono', monospace; font-size: 10.5px;
  color: rgba(200, 216, 245, 0.75);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.engine-badge {
  font-family: 'DM Mono', monospace; font-size: 10px;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid rgba(150, 175, 220, 0.2);
  color: rgba(190, 208, 240, 0.6);
  background: rgba(8, 14, 30, 0.6);
  cursor: help;
}
.engine-badge.wasm {
  color: #6ee787; border-color: rgba(110, 231, 135, 0.35);
  background: rgba(110, 231, 135, 0.08);
}
.engine-badge.srv {
  color: #78aaff; border-color: rgba(120, 170, 255, 0.3);
  background: rgba(120, 170, 255, 0.07);
}

/* ---------- training tab ---------- */
#tr-results-panel { margin-top: 16px; }
#train-felt { padding: 54px 22px 118px; }
#tr-status {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase;
  color: rgba(195, 213, 248, 0.72); white-space: nowrap;
  background: rgba(8, 14, 28, 0.55);
  border: 1px solid rgba(150, 185, 255, 0.13);
  padding: 5px 14px; border-radius: 999px;
}
#tr-seats { display: flex; gap: 18px; justify-content: center; align-items: flex-start; margin-top: 26px; }
#tr-seats .seatp.hero { background: rgba(76,154,255,0.09); box-shadow: inset 0 0 0 1.5px rgba(96,165,255,0.55); }

/* trainee's open slots invite a click */
.slot.droppable { cursor: pointer; }
.slot.droppable:hover { border-color: rgba(120,180,255,0.85); box-shadow: inset 0 0 12px rgba(76,154,255,0.3); }
.slot .pcard.placed-new { cursor: pointer; }
.slot .pcard.placed-new .pc-face {
  box-shadow:
    0 0 0 2px #4c9aff,
    0 0 12px rgba(76, 154, 255, 0.65),
    0 0 26px rgba(76, 154, 255, 0.3),
    0 2px 5px rgba(4, 10, 24, 0.5);
}
.slot .pcard.placed-best .pc-face {
  box-shadow:
    0 0 0 2px #46c26e,
    0 0 12px rgba(70, 194, 110, 0.65),
    0 0 26px rgba(70, 194, 110, 0.3),
    0 2px 5px rgba(4, 10, 24, 0.5);
}


/* verdict: st-trio-style tiles inline with the dock, left of the buttons */
#tr-dock {
  position: absolute; left: 26px; right: 26px; bottom: 18px;
  display: flex; justify-content: center; align-items: flex-end;
  gap: 26px; z-index: 10;
}
.tr-verdict-inline { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.tr-verdict-inline[hidden] { display: none; }
.tr-verdict-inline .headline {
  font-weight: 800; font-size: 13.5px; letter-spacing: 0.01em;
  display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap;
}
.tr-verdict-inline .headline .session {
  font-weight: 500; font-size: 11px; color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.tr-verdict-inline .headline.good { color: #6ee787; }
.tr-verdict-inline .headline.ok { color: var(--gold); }
.tr-verdict-inline .headline.bad { color: #ff8d85; }
.tr-tiles { display: flex; gap: 8px; }
.tr-tile {
  min-width: 86px; text-align: center;
  background: rgba(8,14,28,0.72); border: 1px solid rgba(140,170,255,0.12);
  border-radius: 12px; padding: 7px 10px 6px;
}
.tr-tile .num {
  font-size: 18px; font-weight: 800; line-height: 1.05;
  color: rgba(232,240,255,0.95); font-variant-numeric: tabular-nums;
}
.tr-tile .num.good { color: #6ee787; }
.tr-tile .num.warn { color: var(--gold); }
.tr-tile .num.bad { color: #ff7b73; }
.tr-tile .lbl {
  font-size: 8.5px; letter-spacing: 0.11em; text-transform: uppercase;
  color: rgba(180,200,240,0.5); margin-top: 2px; white-space: nowrap;
}
.tr-dock-side { display: flex; flex-direction: column; align-items: center; gap: 9px; flex: none; }
.tr-dock-btns { display: flex; gap: 12px; }
.tr-auto {
  display: flex; align-items: center; gap: 7px;
  font-size: 11px; color: rgba(190, 208, 240, 0.65);
  cursor: pointer; user-select: none;
}
.tr-auto[hidden] { display: none; }
.tr-auto input { position: absolute; opacity: 0; width: 0; height: 0; }
.tr-switch {
  width: 34px; height: 20px; border-radius: 999px; flex: none;
  background: rgba(150, 175, 220, 0.22);
  border: 1px solid rgba(150, 175, 220, 0.25);
  position: relative; transition: background 0.2s ease, border-color 0.2s ease;
}
.tr-switch::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #e8eefc; box-shadow: 0 1px 3px rgba(0,0,0,0.4);
  transition: transform 0.2s cubic-bezier(0.16,1,0.3,1);
}
.tr-auto input:checked + .tr-switch {
  background: linear-gradient(100deg, #8b6cf6, #4c9aff);
  border-color: transparent;
}
.tr-auto input:checked + .tr-switch::after { transform: translateX(14px); }
.tr-auto input:focus-visible + .tr-switch { outline: 2px solid var(--accent); outline-offset: 2px; }


/* the user's row in the ranking */
.alt.mine { background: rgba(240, 200, 105, 0.08); box-shadow: inset 3px 0 0 var(--gold); }
.alt.mine .alt-rank::after { content: 'YOU'; display: block; font-size: 8px; font-weight: 800; letter-spacing: 0.08em; color: var(--gold); }
.alt-sep { text-align: center; color: var(--dim); font-size: 11px; padding: 4px 0; border-bottom: 1px solid var(--line); }

.tr-discards { display: flex; align-items: center; gap: 4px; margin-top: 10px; font-size: 11px; --mw: 22px; }
.tr-discards .pcard.mini { width: var(--mw); height: calc(var(--mw) * 1.4); }

/* ---------- boot loader ---------- */
#boot {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  transition: opacity 0.5s ease;
}
#boot.gone { opacity: 0; pointer-events: none; }
.boot-inner { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.boot-brand {
  display: flex; align-items: center; gap: 12px;
  font-size: 26px; font-weight: 900; letter-spacing: -0.02em; color: #f2f6ff;
}
.boot-brand em { font-style: normal; color: var(--accent); }
.boot-brand .brand-solver { font-size: 26px; }
.boot-brand .brand-mark { width: 40px; height: 40px; font-size: 22px; border-radius: 12px; }
.boot-bar {
  width: 300px; height: 6px; border-radius: 3px; overflow: hidden;
  background: var(--panel-2);
}
.boot-fill {
  height: 100%; width: 3%;
  background: linear-gradient(90deg, #8b6cf6, #4c9aff);
  border-radius: 3px;
  transition: width 0.25s ease;
}
.boot-text {
  font-family: "DM Mono", ui-monospace, monospace; font-size: 11px;
  letter-spacing: 0.08em; color: var(--dim);
}

/* ---------- training refinements ---------- */
.menu-cta { align-self: center; padding: 10px 24px; font-size: 14px; }
#tr-empty {
  text-align: center; padding: 70px 20px 60px;
  color: rgba(200, 216, 245, 0.65); font-size: 14.5px; line-height: 1.7;
}
#tr-empty b { color: #fff; }
#tr-empty[hidden] { display: none; }
.tr-empty-mark {
  font-size: 40px; margin-bottom: 10px;
  color: rgba(150, 185, 255, 0.25);
}
.tr-handbar {
  display: flex; justify-content: center; align-items: center; gap: 16px;
  margin-top: 18px; min-height: calc(var(--cw) * 1.55);
}
.tr-hand { display: flex; gap: 10px; }
.tr-reset-inline {
  border-radius: 999px; padding: 8px 16px; font-size: 12.5px; font-weight: 600;
  background: rgba(16, 26, 48, 0.6); color: rgba(210, 224, 250, 0.85);
  border: 1px solid rgba(140, 170, 255, 0.22);
}
.tr-reset-inline:hover { border-color: rgba(160, 190, 255, 0.5); }
.tr-reset-inline:disabled { opacity: 0.35; }
.tr-hand .pcard { cursor: grab; transition: transform 0.15s cubic-bezier(0.16,1,0.3,1); }
.tr-hand .pcard:hover { transform: translateY(-6px); }
.tr-hand .pcard.sel { transform: translateY(-12px); }
.tr-hand .pcard.sel .pc-face { box-shadow: 0 0 0 2px #4c9aff, 0 6px 18px rgba(76,154,255,0.5); }
.tr-handcard { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.tr-discard-tag {
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 8.5px; letter-spacing: 0.12em; text-transform: uppercase;
  color: rgba(255, 170, 160, 0.85);
  background: rgba(229, 72, 77, 0.14); border: 1px solid rgba(229, 72, 77, 0.3);
  padding: 2px 8px; border-radius: 999px;
}

/* neon guidance: slots that can take the selected / dragged card */
.slot.glow {
  border-color: rgba(80, 200, 255, 0.95);
  border-style: solid;
  box-shadow:
    inset 0 0 12px rgba(64, 190, 255, 0.35),
    0 0 14px rgba(64, 190, 255, 0.5),
    0 0 30px rgba(64, 190, 255, 0.22);
  animation: slotglow 1.1s ease-in-out infinite;
}
@keyframes slotglow {
  0%, 100% { box-shadow: inset 0 0 12px rgba(64,190,255,0.35), 0 0 14px rgba(64,190,255,0.5), 0 0 30px rgba(64,190,255,0.22); }
  50% { box-shadow: inset 0 0 16px rgba(64,190,255,0.55), 0 0 22px rgba(64,190,255,0.75), 0 0 44px rgba(64,190,255,0.35); }
}
.slot.dragover {
  border-color: #7fdcff;
  box-shadow: inset 0 0 20px rgba(64, 190, 255, 0.7), 0 0 26px rgba(64, 190, 255, 0.85);
  animation: none;
}
@media (prefers-reduced-motion: reduce) { .slot.glow { animation: none; } }
