:root {
  color-scheme: dark;
  --page: #0b0b0b;
  --surface: #191919;
  --surface-2: #222222;
  --ink: #efefef;
  --ink-2: #9c9c9c;
  --border: rgba(255, 255, 255, 0.10);
  --grid: #303030;
  --axis: #6a6a6a;
  --series: #338ced;
  --dot: #9c9c9c;
  --good: #53c556;
  --bad: #eb6263;
  --warn: #fbb315;
  --safe-l: max(14px, env(safe-area-inset-left));
  --safe-r: max(14px, env(safe-area-inset-right));
}

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding-bottom: calc(32px + env(safe-area-inset-bottom));
}

a { color: inherit; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 18px; line-height: 1.2; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
.muted { color: var(--ink-2); font-size: 13px; }

.top, main {
  max-width: 980px;
  margin: 0 auto;
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
}
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: calc(14px + env(safe-area-inset-top));
  padding-bottom: 12px;
}

.example-banner {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--warn);
  color: #0b0b0b;
  text-align: center;
  padding: calc(8px + env(safe-area-inset-top)) var(--safe-r) 8px var(--safe-l);
  font-size: 13px;
}
.example-banner strong { display: block; font-size: 16px; letter-spacing: 0.08em; }
.example-banner:not([hidden]) + .top { padding-top: 14px; }

.btn {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-quiet { background: transparent; color: var(--ink-2); }
:focus-visible { outline: 2px solid var(--series); outline-offset: 2px; }

.notice {
  background: var(--surface);
  border: 1px dashed #555;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}
.notice strong { display: block; margin-bottom: 2px; }
.notice-error { border: 1px solid var(--bad); }

/* Filters */
.filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.field { display: block; min-width: 0; }
.field span { display: block; color: var(--ink-2); font-size: 12px; margin-bottom: 3px; }
.field input, .field select {
  display: block;
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* below 16px, iOS zooms on focus */
}
.field input[type="date"] { -webkit-appearance: none; appearance: none; line-height: 42px; }
.field input[type="date"]::-webkit-date-and-time-value { text-align: left; margin: 0; }
.filters .btn { grid-column: 1 / -1; justify-self: end; min-height: 32px; margin-top: -4px; padding: 0 4px; border: 0; font-size: 13px; text-decoration: underline; }
.filter-error { grid-column: 1 / -1; color: var(--bad); font-size: 13px; }

.section-head { margin-bottom: 10px; }
.footnote { margin-top: 10px; }

/* Leaderboard: stacked cards on a phone */
.board, .board tbody { display: block; width: 100%; }
.board thead {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.board tr {
  display: grid;
  grid-template-columns: 1.35fr 1fr 1.1fr 1.1fr;
  gap: 10px 8px;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
}
.board tr:active { background: var(--surface-2); }
.board td { display: block; min-width: 0; font-variant-numeric: tabular-nums; }
.board td[data-label]::before {
  content: attr(data-label);
  display: block;
  color: var(--ink-2);
  font-size: 11px;
}
.board .c-name   { grid-column: 1 / 3; grid-row: 1; font-weight: 600; font-size: 16px; }
.board .c-status { grid-column: 3 / 5; grid-row: 1; justify-self: end; }
.board .c-avg    { grid-column: 1; grid-row: 2; font-size: 18px; font-weight: 700; }
.board .c-plays  { grid-column: 2; grid-row: 2; }
.board .c-win    { grid-column: 3; grid-row: 2; }
.board .c-roi    { grid-column: 4; grid-row: 2; }
.board .c-range  { grid-column: 1 / -1; grid-row: 3; font-size: 13px; }
.board .c-range::before { display: inline !important; margin-right: 8px; }
.rank { color: var(--ink-2); font-weight: 400; margin-right: 8px; }
.row-link { text-decoration: none; }
.row-link::after { content: "›"; color: var(--ink-2); margin-left: 6px; }

.pos { color: var(--good); }
.neg { color: var(--bad); }

.badge {
  display: inline-block;
  white-space: nowrap;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid;
}
.badge-beating { color: var(--good); background: rgba(83, 197, 86, 0.12); border-color: rgba(83, 197, 86, 0.45); }
.badge-dead    { color: var(--bad);  background: rgba(235, 98, 99, 0.12); border-color: rgba(235, 98, 99, 0.45); }
.badge-few     { color: var(--ink-2); background: transparent; border-color: #555; }

.tag-example {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--warn);
  color: #0b0b0b;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  vertical-align: 2px;
}

/* Dead models */
.dead { margin-top: 32px; }
.dead ul, .plays { list-style: none; margin: 10px 0 0; padding: 0; }
.dead li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid rgba(235, 98, 99, 0.35);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
}
.dead li small { display: block; color: var(--ink-2); }

/* Detail */
.back { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; color: var(--series); }
.detail-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 10px; }
.verdict { font-size: 16px; margin-bottom: 12px; }
.warning {
  border: 1px solid rgba(235, 98, 99, 0.6);
  background: rgba(235, 98, 99, 0.10);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.showing { margin: -8px 0 10px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0 0 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 9px 10px; }
.stat dt { color: var(--ink-2); font-size: 11px; }
.stat dd { margin: 0; font-size: 17px; font-weight: 650; overflow-wrap: anywhere; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 20px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 6px 0 8px; color: var(--ink-2); font-size: 12px; }
.key-line, .key-dot { display: inline-block; vertical-align: middle; margin-right: 5px; }
.key-line { width: 16px; height: 2px; background: var(--series); }
.key-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dot); opacity: 0.7; }
.chart svg { display: block; width: 100%; touch-action: pan-y; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
.chart text { fill: var(--ink-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .zero { stroke: var(--axis); stroke-width: 1.5; }
.chart .line { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--dot); opacity: 0.55; }
.chart .mark { fill: var(--series); stroke: var(--surface); stroke-width: 2; }
.chart .cross { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 3 3; }
.readout { margin-top: 8px; font-size: 13px; min-height: 2.8em; font-variant-numeric: tabular-nums; }

.plays li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
  margin-bottom: 8px;
}
.play-main { min-width: 0; overflow-wrap: anywhere; }
.play-main strong { display: block; }
.play-clv { text-align: right; white-space: nowrap; font-weight: 700; font-variant-numeric: tabular-nums; }
.play-clv small { display: block; color: var(--ink-2); font-weight: 400; font-size: 11px; }
.more { width: 100%; }

/* Wider screens: a real table */
@media (min-width: 760px) {
  .filters { grid-template-columns: 2fr 1fr 1.3fr 1.3fr auto; align-items: end; }
  .filters .btn { grid-column: auto; margin: 0; min-height: 44px; }
  .filter-error { grid-column: auto; }
  .filter-error { grid-column: 1 / -1; }
  .filters.detail-mode { grid-template-columns: 1fr 1fr auto; }

  .board { display: table; border-collapse: collapse; background: var(--surface); }
  .board thead { display: table-header-group; position: static; width: auto; height: auto; clip-path: none; }
  .board tbody { display: table-row-group; }
  .board tr { display: table-row; background: transparent; border: 0; }
  .board th, .board td { display: table-cell; padding: 11px 10px; border-bottom: 1px solid var(--grid); text-align: right; vertical-align: middle; }
  .board th { color: var(--ink-2); font-size: 12px; font-weight: 500; white-space: nowrap; }
  .board th:first-child, .board td.c-name, .board th:last-child, .board td.c-status { text-align: left; }
  .board td[data-label]::before { content: none; }
  .board .c-range::before { display: none !important; }
  .board .c-avg, .board .c-name { font-size: 15px; }
  .board tbody tr:hover { background: var(--surface-2); }

  .stats { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
