:root {
  --bg: #0b0d12;
  --bg-elev: #14171e;
  --bg-card: #171a21;
  --bg-hover: #1c2029;
  --border: #262a33;
  --border-strong: #3a4050;
  --fg: #e6e7ea;
  --fg-dim: #a2a6b0;
  --fg-faint: #6a6f7a;
  --accent: #8ec5ff;
  --pos: #5eeb8a;
  --neg: #eb6b6b;
  --warn: #e9c35e;
  --ink: #0b0d12;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: inherit;
  padding: 6px 12px;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}
button:hover { background: var(--bg-hover); border-color: var(--border-strong); }
button.primary { background: #1a3a5a; border-color: #2d5d8f; color: #d8ecff; }
button.primary:hover { background: #204d75; }
button.ghost { background: transparent; }
button.small { padding: 3px 8px; font-size: 12px; }
button.danger { color: var(--neg); border-color: #3b1c1c; }
button.danger:hover { background: #2a1818; }
input, select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: inherit;
  padding: 6px 10px;
  border-radius: 6px;
  font: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--border-strong); }

/* ---------- Shell ---------- */

header.app {
  padding: 14px 24px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: center;
  position: sticky; top: 0; z-index: 10;
}
header.app h1 {
  margin: 0;
  font-size: 16px;
  letter-spacing: .02em;
  font-weight: 600;
}
header.app .sub {
  color: var(--fg-dim);
  font-size: 12px;
}
header.app .spacer { flex: 1; }

main { padding: 20px 24px 40px; max-width: 1400px; margin: 0 auto; }

/* ---------- Filters bar ---------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.filters .sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.filters label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--fg-dim); }
.filters input[type=checkbox] { accent-color: var(--accent); }
.filters .count-badge {
  display: inline-block;
  padding: 1px 6px;
  background: #1c2029;
  border-radius: 10px;
  font-size: 11px;
  color: var(--fg-dim);
}

/* ---------- Lobby grid ---------- */

#grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
#grid.compact { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

.tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.tile:hover { border-color: var(--border-strong); }
.tile.hot { border-color: #3d6a3d; box-shadow: 0 0 0 1px #5eeb8a44; }
.tile.cold { border-color: #6a3d3d; }
.tile.catalog { opacity: 0.72; }
.tile.catalog:hover { opacity: 1; }
.tile.catalog .tc { color: var(--fg-faint); font-size: 14px; }

/* Health dot — indicates last frame age */
.health-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: 1px;
}
.health-dot.ok { background: var(--pos); box-shadow: 0 0 6px #5eeb8a55; }
.health-dot.slow { background: var(--warn); }
.health-dot.stale { background: var(--neg); }
.health-dot.idle { background: var(--fg-faint); }

/* Welcome empty-state panel */
.welcome { padding: 32px 24px 20px; max-width: 1400px; margin: 0 auto; }
.welcome.hidden { display: none; }
.welcome-card {
  background: linear-gradient(140deg, #142035, #0f1722);
  border: 1px solid #2d4059;
  border-radius: 14px;
  padding: 32px 36px;
  text-align: center;
}
.welcome-card .welcome-mark { font-size: 44px; margin-bottom: 8px; }
.welcome-card h2 { margin: 0 0 8px; font-size: 22px; }
.welcome-card p { color: var(--fg-dim); max-width: 520px; margin: 0 auto 18px; line-height: 1.55; }
.welcome-card .big-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 24px;
  background: var(--accent);
  color: var(--ink);
  border-radius: 8px;
  font-weight: 700;
  text-decoration: none;
  font-size: 15px;
}
.welcome-card .big-cta:hover { filter: brightness(1.1); text-decoration: none; }
.welcome-card .welcome-steps {
  display: flex; justify-content: center; gap: 24px; flex-wrap: wrap;
  margin-top: 18px; color: var(--fg-dim); font-size: 13px;
}

/* Settings modal */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs .tab {
  background: transparent;
  border: none;
  color: var(--fg-dim);
  padding: 8px 14px;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  font: inherit;
}
.tabs .tab.active { color: var(--fg); border-bottom: 2px solid var(--accent); }
.tabs .tab:hover:not(.active) { background: var(--bg-hover); }
.tab-pane { display: grid; gap: 12px; }
.tab-pane.hidden { display: none; }
.tab-pane label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: var(--fg-dim); text-transform: uppercase; letter-spacing: .04em;
}
.tab-pane label:has(input[type="checkbox"]) {
  flex-direction: row; align-items: center; gap: 8px;
  text-transform: none; letter-spacing: 0; color: var(--fg); font-size: 13px;
}
.tab-pane select, .tab-pane input[type="number"] {
  width: 100%;
}
.weights-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 8px; }
.weights-grid > label {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 10px; text-transform: uppercase; color: var(--fg-dim);
}
.weights-grid input {
  width: 100%; text-align: center; font-variant-numeric: tabular-nums;
  background: var(--bg-card); border: 1px solid var(--border); color: var(--fg);
  padding: 4px 2px; border-radius: 4px;
}
.rules-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }

/* Header menu dropdown */
.menu-wrap { position: relative; }
.menu {
  position: absolute;
  right: 0; top: calc(100% + 6px);
  min-width: 260px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  padding: 6px;
  z-index: 20;
  display: flex;
  flex-direction: column;
}
.menu a, .menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--fg);
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}
.menu a:hover, .menu button:hover { background: var(--bg-hover); text-decoration: none; }

/* Health pill in header */
#health-pill { font-size: 12px; padding: 4px 10px; border-radius: 12px; }
#health-pill.status-pill-ok { background: #193a24; color: var(--pos); }
#health-pill.status-pill-wait { background: #37321b; color: var(--warn); }
#health-pill.status-pill-stale { background: #3b1c1c; color: var(--neg); }
.tile .thumb {
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #1a2533, #0f1a25);
  display: flex; align-items: center; justify-content: center;
  color: var(--fg-faint);
  font-size: 11px;
}
.tile .thumb img { width: 100%; height: 100%; object-fit: cover; }
.tile .body { padding: 10px 12px; }
.tile .name {
  font-weight: 600;
  font-size: 14px;
  margin: 0 0 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile .id {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 10px;
  color: var(--fg-faint);
  margin: 0 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile .metrics {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}
.tile .tc {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.tile .tc small { font-size: 10px; font-weight: 500; color: var(--fg-faint); margin-left: 4px; }
.tile .min-bet {
  font-size: 12px;
  color: var(--fg-dim);
  padding: 2px 8px;
  background: #1c2029;
  border-radius: 10px;
}
.tile .progress {
  height: 6px;
  background: #1c2029;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.tile .progress .fill { height: 100%; background: linear-gradient(90deg, var(--accent), #5eebbc); }
.tile.hot .progress .fill { background: linear-gradient(90deg, var(--pos), #a4f0ba); }
.tile.cold .progress .fill { background: linear-gradient(90deg, var(--neg), #f0a4a4); }
.tile .row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--fg-dim);
  margin-top: 4px;
}
.tile .badges {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  flex-direction: column;
  align-items: flex-end;
}
.tile .badges .b {
  font-size: 10px;
  padding: 2px 6px;
  background: #0e151ed0;
  border: 1px solid var(--border);
  color: var(--fg-dim);
  border-radius: 4px;
  backdrop-filter: blur(4px);
}
.tile .badges .b.warn { color: var(--warn); border-color: #4d3e1c; }
.tile .badges .b.err { color: var(--neg); border-color: #4d1c1c; }
.tile .actions-hover {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity .15s;
}
.tile:hover .actions-hover { opacity: 1; }
.tile .actions-hover button {
  padding: 2px 6px;
  font-size: 11px;
  background: #0e151ed0;
  backdrop-filter: blur(4px);
}

.tc.pos { color: var(--pos); }
.tc.neg { color: var(--neg); }
.tc.zero { color: var(--fg-dim); }

.status {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.status-running { background: #193a24; color: var(--pos); }
.status-starting { background: #37321b; color: var(--warn); }
.status-stopped { background: #2b2f39; color: var(--fg-dim); }
.status-error { background: #3b1c1c; color: var(--neg); }

/* ---------- Modal (add table) ---------- */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 24px;
  width: min(460px, 92vw);
}
.modal h2 { margin: 0 0 12px; font-size: 16px; }
.modal form { display: grid; gap: 10px; }
.modal .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

/* ---------- Detail page (spy view) ---------- */

/*
  Spy hero strip — gc.com parity: small dealer thumbnail + title block on the
  left, oversized True Count card on the right. The TC value is the visual
  anchor of the page, mirroring how gc.com leads with a single big number.
  Everything else is sized down so it doesn't fight for attention.
*/
.spy-hero {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 16px;
  align-items: stretch;
  margin-bottom: 12px;
}
@media (max-width: 760px) { .spy-hero { grid-template-columns: 1fr; } }

.spy-id {
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}
.spy-id .dealer-thumb {
  width: 120px;
  height: 80px;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.spy-title { flex: 1; min-width: 0; }
.spy-title h1 { margin: 0 0 6px; font-size: 22px; line-height: 1.1; }
.spy-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 13px;
  color: var(--fg-dim);
  margin-bottom: 6px;
}
.spy-sub .provider { color: var(--fg-dim); }
.spy-sub .min-bet {
  padding: 1px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 11px;
  color: var(--fg-dim);
  background: #10141c;
}

.spy-tc {
  background: linear-gradient(180deg, #14181f, #0f1218);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  position: relative;
  overflow: hidden;
}
.spy-tc::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at top right, rgba(94,235,138,0), transparent 60%);
  pointer-events: none;
}
.spy-tc.spy-tc-pos { border-color: #2d5d3f; }
.spy-tc.spy-tc-pos::before { background: radial-gradient(ellipse at top right, rgba(94,235,138,.15), transparent 60%); }
.spy-tc.spy-tc-neg { border-color: #5d2d2d; }
.spy-tc.spy-tc-neg::before { background: radial-gradient(ellipse at top right, rgba(235,107,107,.12), transparent 60%); }
.spy-tc-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--fg-faint);
}
.spy-tc-value {
  font-size: 48px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin: 4px 0;
  color: var(--fg);
}
.spy-tc-value.pos { color: var(--pos); }
.spy-tc-value.neg { color: var(--neg); }
.spy-tc-value.zero { color: var(--fg-dim); }
.spy-tc-sub { font-size: 11px; color: var(--fg-dim); }

.rules-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.rules-chips .chip {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--fg-dim);
  background: #10141c;
}
.rules-chips .chip.on { color: var(--accent); border-color: #2d5d8f; background: #0f2233; }
.rules-chips .chip.off { color: #6a6f7a; }

/*
  Shoe progress strip — thin, full-width. gc.com shows just the bar; we keep
  the cut-card marker so users can spot the cut-card pen at a glance.
*/
.shoe-strip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
}

/*
  Compact KPI chip-strip — secondary metrics (Hi-Lo RC, decks remaining,
  ten density, insurance EV) in a single row. Each chip is small and quiet
  so the hero TC stays prominent.
*/
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
@media (max-width: 720px) { .kpi-strip { grid-template-columns: repeat(2, 1fr); } }
.kpi-chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.kpi-chip .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--fg-faint);
}
.kpi-chip .value {
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}
.kpi-chip .value.pos { color: var(--pos); }
.kpi-chip .value.neg { color: var(--neg); }
.kpi-chip .sub { font-size: 10px; color: var(--fg-dim); }

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.panel h3 {
  margin: 0;
  font-size: 11px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.panel-head h3 { margin: 0; }
/* Feature panel (matrix) — slightly more breathing room since gc.com makes
   it the centerpiece of the page. */
.panel-feature { padding: 16px 18px; }
.panel-feature .matrix-wrap { margin-top: 4px; }

/*
  Collapsible panels via <details>/<summary>. Used for the live felt and the
  "Подробнее" zone. gc.com hides everything but the matrix, but the user
  invested in our richer data, so we keep it accessible behind a single click.
*/
.panel-collapsible { padding: 0; }
.panel-collapsible > summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}
.panel-collapsible > summary::-webkit-details-marker { display: none; }
.panel-collapsible > summary::before {
  content: "▶";
  font-size: 9px;
  color: var(--fg-faint);
  transition: transform .15s;
}
.panel-collapsible[open] > summary::before { transform: rotate(90deg); }
.panel-collapsible > summary .sum-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--fg-dim);
  font-weight: 600;
}
.panel-collapsible > summary .sum-hint {
  margin-left: auto;
  font-size: 10px;
}
.panel-collapsible > summary:hover .sum-title { color: var(--fg); }
.panel-collapsible > *:not(summary) { padding: 0 14px 14px; }
/* The live felt has its own internal padding, so undo the wrapper padding for it */
.panel-collapsible > .live-table { padding: 0 14px 14px; }

.more-zone { margin-top: 8px; }
.more-zone-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--fg-faint);
  margin: 18px 0 8px;
  font-weight: 600;
}
.more-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (max-width: 760px) { .more-grid { grid-template-columns: 1fr; } }
.more-grid .panel-collapsible { margin-bottom: 0; }

.shoe-bar {
  height: 12px;
  background: #1c2029;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border);
}
.shoe-bar .fill { height: 100%; background: linear-gradient(90deg, var(--accent), #5eebbc); }
.shoe-bar .cut-marker {
  position: absolute;
  top: -2px; bottom: -2px;
  width: 2px;
  background: var(--neg);
  opacity: .7;
}
.shoe-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--fg-dim); margin-top: 6px; }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 6px 0; }
.kpi .label { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--fg-faint); }
.kpi .value { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi .value.small { font-size: 16px; }
.kpi .sub { font-size: 11px; color: var(--fg-dim); }

.streak-list { display: grid; gap: 4px; font-size: 13px; }
.streak-list .line { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed #1c2029; }
.streak-list .line:last-child { border-bottom: none; }
.streak-list .line .v { font-variant-numeric: tabular-nums; font-weight: 600; }

.comp-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.comp-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 2px;
  background: #10141c;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
  min-width: 0;
}
.comp-cell.rich { border-color: #3d6a3d; background: #132114; }
.comp-cell.poor { border-color: #6a3d3d; background: #211313; }
.comp-cell .r { font-size: 11px; color: var(--fg-dim); margin-bottom: 2px; }
.comp-cell .n { font-size: 14px; font-weight: 600; }
.comp-cell .p { font-size: 9px; color: var(--fg-faint); margin-top: 1px; }

/* ---------- Live table view (felt-green hero) ---------- */

/*
  The live felt is the page's primary surface. We pull it forward visually
  with a dark felt-green gradient that reads as a casino table at a glance,
  and we let the cards breathe — corner-labels, big centered pip, gentle
  hover lift. Animations are scoped to .lt-card.is-new so re-renders of
  pre-existing cards stay still (only the just-dealt card flutters in).
*/
.live-felt {
  background:
    radial-gradient(ellipsis 80% 60% at 50% -10%, rgba(255,255,255,0.04), transparent 70%),
    linear-gradient(180deg, #0f2a1f 0%, #091a13 100%);
  border-color: #1f4032;
  padding: 18px 18px 20px;
}
.felt-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
}
.felt-head h3 {
  margin: 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #88c5a8;
}

/* Live heartbeat — ticks every second so the user has a concrete
   signal "the connection is alive" even if no card has been dealt
   recently. Three colour states: fresh / slow / stalled. */
.lt-heartbeat {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, Menlo, monospace;
  padding: 3px 9px;
  border-radius: 999px;
  background: #0f2419;
  color: #88c5a8;
  border: 1px solid #1f4032;
  white-space: nowrap;
}
.lt-heartbeat.fresh {
  background: #143324;
  color: #6ee08c;
  border-color: #2c5a45;
}
.lt-heartbeat.slow {
  background: #2c2410;
  color: #f0c968;
  border-color: #4d4017;
}
.lt-heartbeat.stalled {
  background: #2c1414;
  color: #ff8888;
  border-color: #5a1f1f;
  animation: heartbeat-pulse 1.4s ease-in-out infinite;
}
@keyframes heartbeat-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 90, 90, 0.4); }
  50%      { box-shadow: 0 0 0 6px rgba(255, 90, 90, 0); }
}

/* Stale banner — appears prominently when no frames in 30s+. */
.lt-stale-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin: 0 0 12px;
  border-radius: 8px;
  background: linear-gradient(180deg, #3a2e18, #2c2410);
  border: 1px solid #4d4017;
  color: #f0c968;
  font-size: 13px;
  font-weight: 600;
}
.lt-stale-banner[hidden] { display: none; }
.lt-stale-banner.severe {
  background: linear-gradient(180deg, #3b1c1c, #2c1414);
  border-color: #5a1f1f;
  color: #ff9d9d;
}
.lt-stale-icon { font-size: 16px; }

/* Subtle border pulse triggered programmatically when any WS message
   arrives — proves the stream is alive between card events. */
.live-felt.is-pulsing {
  animation: felt-pulse 600ms ease-out 1;
}
@keyframes felt-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(110, 224, 140, 0.35); }
  100% { box-shadow: 0 0 0 12px rgba(110, 224, 140, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .lt-heartbeat.stalled,
  .live-felt.is-pulsing { animation: none; }
}

.live-table .lt-dealer {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 16px;
  background:
    radial-gradient(ellipsis 50% 100% at 50% 0%, rgba(255,255,255,0.05), transparent 75%),
    linear-gradient(180deg, #133127, #0d2018);
  border: 1px solid #1f4032;
  border-radius: 10px;
  margin-bottom: 14px;
  box-shadow: 0 4px 14px -6px rgba(0, 0, 0, 0.6) inset;
}
.live-table .lt-dealer-label { min-width: 120px; }
.live-table .lt-role {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #6b9b80;
}
.live-table .lt-name { font-weight: 600; font-size: 14px; color: #e6e8ea; }
.live-table .lt-dealer .lt-cards { flex: 1; min-height: 92px; }
.live-table .lt-dealer .lt-score {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 64px;
  text-align: right;
  color: #f0c968;
}

.lt-seats {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}
@media (max-width: 1280px) {
  .lt-seats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .lt-seats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.lt-seat {
  background: linear-gradient(180deg, #0f2419, #0b1a12);
  border: 1px solid #1c3729;
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 140px;
}
.lt-seat.occupied {
  border-color: #2c5a45;
  background: linear-gradient(180deg, #122e22, #0c1f17);
}
/* Empty seats stay visible (so the row layout doesn't collapse) but
   are visually de-emphasized — half-opacity, no card-empty dashes. */
.lt-seat.empty {
  min-height: 0;
  opacity: 0.45;
  background: transparent;
  border-style: dashed;
}
.lt-seat.empty .lt-hand-empty { display: none; }
.lt-seat.empty .lt-player { color: var(--fg-faint); }
.lt-seathead {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 11px;
  border-bottom: 1px dashed #1f4032;
  padding-bottom: 4px;
}
.lt-seathead .lt-num {
  color: #6b9b80;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.lt-seathead .lt-player {
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #d4d6d8;
}
.lt-seathead .lt-country { font-size: 10px; color: #6b9b80; }

.lt-hand {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lt-hand + .lt-hand {
  border-top: 1px dashed #1f4032;
  padding-top: 6px;
  margin-top: 2px;
}

.lt-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 92px;
}

/*
  Card itself — proper playing-card proportions (~5:7), corner labels,
  centered pip, soft cream gradient for the face. We use box-shadow with
  multiple stops to suggest a real card sitting on felt: tight ambient
  shadow + soft lift + subtle inset highlight on top.
*/
.lt-card {
  position: relative;
  display: inline-block;
  width: 58px;
  height: 84px;
  background: linear-gradient(160deg, #fafaf3, #ebe5d4);
  border: 1px solid #a39a83;
  border-radius: 6px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-weight: 700;
  user-select: none;
  flex-shrink: 0;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 4px 10px -4px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.lt-card:hover {
  transform: translateY(-2px) rotate(-1deg);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 8px 16px -4px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.12) inset;
}
.lt-card .corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  line-height: 1;
}
.lt-card .corner.tl { top: 5px; left: 6px; }
.lt-card .corner.br {
  bottom: 5px;
  right: 6px;
  transform: rotate(180deg);
  transform-origin: center;
}
.lt-card .corner .r { font-size: 14px; letter-spacing: -0.02em; }
.lt-card .corner .s { font-size: 11px; }
.lt-card .pip {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  line-height: 1;
  opacity: 0.92;
}
.lt-card.lt-red { color: #b9341e; }
.lt-card.lt-black { color: #1a1d24; }

/* Newest card pulses gently to draw the eye */
.lt-card.is-newest {
  animation: card-newest-pulse 1.6s ease-out 1;
}
@keyframes card-newest-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(240, 201, 104, 0.55),
                     0 4px 10px -4px rgba(0, 0, 0, 0.45),
                     0 0 0 1px rgba(255, 255, 255, 0.08) inset; }
  60%  { box-shadow: 0 0 0 8px rgba(240, 201, 104, 0),
                     0 4px 10px -4px rgba(0, 0, 0, 0.45),
                     0 0 0 1px rgba(255, 255, 255, 0.08) inset; }
  100% { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5),
                     0 4px 10px -4px rgba(0, 0, 0, 0.45),
                     0 0 0 1px rgba(255, 255, 255, 0.08) inset; }
}

/* Just-dealt card: slides in from above + slight rotate, then settles */
.lt-card.is-new {
  animation: card-deal-in 380ms cubic-bezier(0.18, 0.88, 0.36, 1) 1;
}
@keyframes card-deal-in {
  0% {
    opacity: 0;
    transform: translate(40px, -60px) rotate(-18deg) scale(0.85);
  }
  60% {
    opacity: 1;
    transform: translate(2px, 2px) rotate(2deg) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translate(0, 0) rotate(0) scale(1);
  }
}
@media (prefers-reduced-motion: reduce) {
  .lt-card.is-new,
  .lt-card.is-newest { animation: none; }
}

.lt-empty {
  font-size: 11px;
  color: #6b9b80;
  padding: 8px 4px;
  font-style: italic;
}

.lt-handmeta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 12px;
}
.lt-handmeta .lt-score {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 16px;
  color: #f0c968;
}
.lt-result {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 2px 8px;
  border-radius: 10px;
  background: #1c2029;
  color: var(--fg-dim);
  font-weight: 700;
}
.lt-result.win { background: #193a24; color: var(--pos); }
.lt-result.lose, .lt-result.bust { background: #3b1c1c; color: var(--neg); }
.lt-result.push { background: #37321b; color: var(--warn); }
.lt-result.blackjack { background: #14283f; color: var(--accent); }

/*
  Trace: inline timeline of [card] → action → [card] → action → … → result.
  Lives directly under each hand so the player's narrative is readable at
  a glance, no jumping to the decisions table. The arrow is a thin line
  with the action chip floating mid-arrow; flex-wrap so long traces wrap
  on narrow screens instead of horizontal-scrolling.
*/
.lt-trace {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  padding-top: 8px;
  border-top: 1px dashed #1f4032;
}
/* Mini trace cards: just enough room for the corner label + a hint of pip.
   Width is sized so "10" fits without truncation; we drop the second
   corner and shrink the centered pip so the timeline stays compact. */
.lt-trace .lt-card {
  width: 26px;
  height: 36px;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
.lt-trace .lt-card .corner.tl { top: 2px; left: 3px; }
.lt-trace .lt-card .corner.br { display: none; } /* mini cards: corner-tl only */
.lt-trace .lt-card .corner .r { font-size: 11px; letter-spacing: -0.05em; }
.lt-trace .lt-card .corner .s { font-size: 8px; }
.lt-trace .lt-card .pip { font-size: 14px; opacity: 0.55; }
.lt-trace-arrow {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 44px;
  padding: 0 4px;
  color: #5d8a72;
}
.lt-trace-arrow::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, #5d8a72 30%, #5d8a72 70%, transparent);
}
.lt-trace-arrow::after {
  content: "▸";
  position: absolute;
  right: 0;
  top: 50%;
  transform: translate(0, -50%);
  font-size: 10px;
  color: #5d8a72;
}
.lt-trace-action {
  position: relative;
  z-index: 1;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 4px;
  font-family: ui-monospace, Menlo, monospace;
  white-space: nowrap;
}
.lt-trace-action.lt-dec-H { background: #1f4d24; color: #9deb9d; box-shadow: 0 0 0 1px #2c6a32; }
.lt-trace-action.lt-dec-S { background: #4d4017; color: #ffd97a; box-shadow: 0 0 0 1px #6a571f; }
.lt-trace-action.lt-dec-D { background: #1f3d6a; color: #a4d0ff; box-shadow: 0 0 0 1px #2c5491; }
.lt-trace-action.lt-dec-P { background: #4a1f6a; color: #e1aaff; box-shadow: 0 0 0 1px #672c91; }
.lt-trace-action.lt-dec-R { background: #5a1f1f; color: #ff9d9d; box-shadow: 0 0 0 1px #7a2c2c; }
.lt-trace-acc {
  font-size: 9px;
  font-weight: 700;
  margin-left: 4px;
  padding: 1px 4px;
  border-radius: 3px;
  vertical-align: middle;
  font-family: ui-monospace, Menlo, monospace;
}
.lt-trace-acc.acc-good { background: #0f2419; color: #7fdc8a; }
.lt-trace-acc.acc-ok   { background: #1d2014; color: #c8d97a; }
.lt-trace-acc.acc-warn { background: #2c2010; color: #f0b450; }
.lt-trace-acc.acc-bad  { background: #2c1414; color: #ff8888; }
.lt-trace-end {
  font-size: 11px;
  font-weight: 700;
  color: #f0c968;
  font-variant-numeric: tabular-nums;
  padding-left: 6px;
}

/* Legacy chip row — kept as a fallback when trace isn't applicable */
.lt-decisions { display: flex; flex-wrap: wrap; gap: 3px; }
.lt-dec {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  font-family: ui-monospace, Menlo, monospace;
  letter-spacing: .04em;
}
.lt-dec-H { background: #7ecb7e55; color: #9deb9d; }
.lt-dec-S { background: #f0c96855; color: #ffd97a; }
.lt-dec-D { background: #5ea3eb55; color: #a4d0ff; }
.lt-dec-P { background: #c078eb55; color: #e1aaff; }
.lt-dec-R { background: #eb6b6b55; color: #ff9d9d; }

.lt-dec-acc {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  margin-left: 2px;
  border-radius: 3px;
  font-family: ui-monospace, Menlo, monospace;
  letter-spacing: .02em;
  vertical-align: baseline;
}
.lt-dec-acc.acc-good { background: #19381f; color: #7fdc8a; }
.lt-dec-acc.acc-ok   { background: #2a3320; color: #c8d97a; }
.lt-dec-acc.acc-warn { background: #3a2e18; color: #f0b450; }
.lt-dec-acc.acc-bad  { background: #3b1c1c; color: #ff8888; }

/* ---------- Strategy matrix ---------- */

.matrix-tabs { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.matrix-tabs button { border-radius: 6px; padding: 5px 12px; font-size: 13px; }
.matrix-tabs button.active { background: var(--bg-hover); border-color: var(--border-strong); color: var(--fg); }
.matrix-tabs button.ghost { padding: 5px 10px; opacity: .7; }
.matrix-tabs button.ghost:hover { opacity: 1; }

.matrix-wrap { overflow-x: auto; }
table.matrix {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  min-width: 460px;
}
table.matrix th, table.matrix td {
  padding: 6px 0;
  text-align: center;
  border: 1px solid #10141c;
}
table.matrix thead th {
  background: #10141c;
  color: var(--fg-dim);
  font-weight: 500;
  font-size: 11px;
}
table.matrix tbody th {
  background: #10141c;
  color: var(--fg-dim);
  padding-left: 6px;
  padding-right: 6px;
  font-weight: 500;
  width: 44px;
}
td.act { font-weight: 700; cursor: help; position: relative; }
td.act.S { background: #f0c96855; color: #ffd97a; }
td.act.H { background: #7ecb7e55; color: #9deb9d; }
td.act.D { background: #5ea3eb55; color: #a4d0ff; }
td.act.P { background: #c078eb55; color: #e1aaff; }
td.act.R { background: #eb6b6b55; color: #ff9d9d; }
td.act.deviation { outline: 1px dashed var(--accent); outline-offset: -2px; }

.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; font-size: 11px; color: var(--fg-dim); }
.legend .sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; margin-right: 4px; vertical-align: -3px; }

.tooltip {
  position: absolute;
  z-index: 100;
  background: #05080d;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 11px;
  color: var(--fg);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,.6);
}
.tooltip .ev { display: flex; justify-content: space-between; gap: 16px; font-variant-numeric: tabular-nums; }
.tooltip .ev.best { color: var(--pos); font-weight: 600; }

/* ---------- Event log / tables ---------- */

table.plain { width: 100%; border-collapse: collapse; font-size: 12px; }
table.plain th, table.plain td { padding: 5px 8px; text-align: left; border-bottom: 1px solid #1c2029; }
table.plain th { color: var(--fg-dim); font-weight: 500; }
.win { color: var(--pos); }
.lose { color: var(--neg); }
.push { color: var(--warn); }
.blackjack { color: var(--accent); font-weight: 600; }
.bust { color: var(--neg); }

#event-log {
  max-height: 280px;
  overflow-y: auto;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11px;
  margin: 0;
  padding: 0;
  list-style: none;
}
#event-log li { padding: 2px 0; color: var(--fg-dim); }
#event-log li .k { color: var(--accent); margin-right: 6px; }

/* misc */
.muted { color: var(--fg-dim); }
.mono { font-family: ui-monospace, Menlo, monospace; }
.hidden { display: none !important; }
.no-data { color: var(--fg-faint); font-size: 12px; padding: 16px; text-align: center; }

/* rules editor (modal) */
.rules-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.rules-grid label { display: flex; align-items: center; gap: 8px; font-size: 13px; }

/* Closed catalog tile — gc.com parity: still render the tile so users see the
   full universe, but visually de-emphasize and disable the connect action. */
.tile.catalog.closed { opacity: 0.45; filter: grayscale(0.6); cursor: not-allowed; }
.tile.catalog.closed:hover { opacity: 0.6; border-color: var(--border); }
.tile .badges .b.dim { color: var(--fg-faint); border-color: #2b2f39; background: #10141cb0; }
.tile.catalog.closed button[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Deviations tab on detail page — chip-style table; .active rows pop with the
   same accent the matrix uses for deviation outlines so visual language matches. */
.dev-table th, .dev-table td { padding: 6px 8px; font-size: 12px; }
.dev-table tr.dev-row.active td { background: #0f2233; }
.dev-table tr.dev-row.active td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
