/* Ludicrous — committed dark theme (card-room). Palette per docs/dataviz. */
:root {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232322;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid-line: #2c2c2a;
  --border: rgba(255, 255, 255, 0.10);
  --s1: #3987e5;  /* categorical slots (validated, dark surface) */
  --s2: #d95926;
  --s3: #199e70;
  --s4: #c98500;
  --s5: #d55181;
  --good: #0ca30c;
  --war: #c98500;
  --field: rgba(137, 135, 129, 0.28);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.14em;
}
h1 span { color: var(--muted); font-weight: 400; letter-spacing: 0.04em; }

#setup {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-left: auto;
}
#setup label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

input, select {
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 8px;
  font: inherit;
}
input[type="number"] { width: 72px; }
#seed { width: 96px; }

.btn {
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 14px;
  font: inherit;
  cursor: pointer;
}
.btn:hover { background: #2c2c2a; }
.btn.primary { background: var(--s1); border-color: transparent; }
.btn.primary:hover { background: #4d95ea; }
.btn.icon { padding: 7px 10px; min-width: 40px; }
.btn:disabled { opacity: 0.5; cursor: default; }

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}

.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
}
.hint { text-transform: none; letter-spacing: 0; }

/* --- stat tiles --- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
}
.tile .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.tile .value {
  font-size: 22px;
  font-weight: 600;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note { color: var(--ink-2); }
.note.warn { border-color: rgba(201, 133, 0, 0.55); color: #e5c894; }
#maxRounds { width: 108px; }

/* --- playback --- */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.controls .speed {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
#scrubber { flex: 1 1 160px; min-width: 120px; accent-color: var(--s1); padding: 0; border: 0; background: none; }
.round-label {
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  font-size: 13px;
  min-width: 15ch;
  text-align: right;
}
.chk { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.chk input { accent-color: var(--s1); }

.banner {
  margin-top: 10px;
  font-size: 15px;
  color: var(--ink-2);
  min-height: 22px;
}
.banner .war-flash { color: var(--war); font-weight: 700; }
.banner .win-name { color: var(--ink); font-weight: 600; }

/* --- player grid --- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 10px 8px;
}
.grid.bj { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.player { text-align: center; min-width: 0; }
.player .pname {
  font-size: 11px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player img {
  width: 100%;
  max-width: 88px;
  height: auto;
  border-radius: 5px;
  display: block;
  margin: 3px auto 2px;
}
.player .pmeta {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.player.out { opacity: 0.32; filter: grayscale(1); }
.player.war img { outline: 2px solid var(--war); outline-offset: 1px; }
.player.winner img { outline: 2px solid var(--good); outline-offset: 1px; }

/* --- chart --- */
#chartWrap { position: relative; height: 260px; }
#chartWrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#overlay { cursor: crosshair; }
#tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
  z-index: 2;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}
#tooltip .t-round { color: var(--muted); }
#tooltip .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
}
#tooltip .t-val { font-variant-numeric: tabular-nums; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-2);
}
.legend .chip { display: flex; align-items: center; gap: 6px; }
.legend .chip i {
  width: 14px;
  height: 3px;
  border-radius: 2px;
  display: inline-block;
}

/* --- elimination feed --- */
.elim-feed {
  margin: 0;
  padding-left: 44px;
  max-height: 300px;
  overflow-y: auto;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.elim-feed li { padding: 1px 0; }
.elim-feed .rnd { color: var(--muted); }

/* --- mode toggle --- */
.mode-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  align-self: end;
}
.mode-toggle button {
  background: var(--surface);
  color: var(--muted);
  border: 0;
  padding: 7px 14px;
  font: inherit;
  cursor: pointer;
}
.mode-toggle button.active {
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 600;
}

/* --- blackjack --- */
.strat-wrap { display: flex; flex-direction: column; gap: 4px; }
.strat-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.strat-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.strat-chips button {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 11px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.strat-chips button.on { background: var(--s1); color: #fff; border-color: transparent; }

.dealer-area {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.dealer-area .dlabel {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.dealer-area .hand-cards img { width: 52px; }
.dealer-area .dtotal { font-size: 15px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.hand-cards { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; min-height: 52px; }
.hand-cards img { width: 38px; height: auto; border-radius: 3px; display: block; }
/* one .bjhand per hand at the seat; the border only appears once a split
   makes a second hand, tinted by that hand's outcome */
.hand-cards .bjhand { display: inline-flex; flex-wrap: wrap; gap: 3px; justify-content: center; }
.hand-cards .bjhand:not(:only-child) {
  padding: 3px; border: 1px solid rgba(137, 135, 129, .4); border-radius: 6px;
}
.hand-cards .bjhand.h-win:not(:only-child) { border-color: var(--good); }
.hand-cards .bjhand.h-lose:not(:only-child) { border-color: #e66767; }

.player .pstrat {
  font-size: 10px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player .outcome { font-weight: 600; }
.player .outcome.o-win { color: var(--good); }
.player .outcome.o-lose { color: #e66767; }
.player .outcome.o-push { color: var(--muted); }

/* --- batch charts & table --- */
.chart-wrap { position: relative; height: 240px; }
.chart-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}
.tip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
  z-index: 2;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  top: 12px;
}
.tip .t-label { color: var(--muted); }
.tip .t-val { font-variant-numeric: tabular-nums; }

.outliers {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.outliers th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 500;
  padding: 4px 10px;
  border-bottom: 1px solid var(--border);
}
.outliers td { padding: 5px 10px; color: var(--ink-2); }
.outliers tbody tr:hover { background: var(--surface-2); }
.outliers .otype { color: var(--muted); font-size: 12px; }
.outliers .btn { padding: 3px 10px; font-size: 12px; }

.welcome {
  max-width: 560px;
  margin: 80px auto;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
}

.error {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #3a1414;
  border: 1px solid #e66767;
  color: #ffd7d7;
  padding: 10px 18px;
  border-radius: 10px;
  z-index: 10;
}
