/* Human vs AI duel page. Colors only from theme.css tokens. */
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
[hidden] { display: none !important; }
.skip-link { position: absolute; top: -60px; left: 16px; background: var(--surface); padding: 12px; z-index: 5; }
.skip-link:focus { top: 10px; }

.du-main { max-width: 1320px; margin: 0 auto; padding: 20px 24px 48px; display: grid; gap: 18px; min-width: 0; }
.du-main > * { min-width: 0; }
.panel { padding: 18px; }
.panel h2 { margin: 0 0 12px; }
.du-hero h1 { margin: 4px 0 8px; font-size: 28px; letter-spacing: -.02em; }
.du-hero .lede { margin: 0; max-width: 860px; color: var(--ink-2); font-size: 15px; line-height: 1.75; }
.error-banner { padding: 12px 16px; }
footer p { color: var(--faint); font-size: 12px; line-height: 1.7; margin: 0; }
.du-note { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 8px 0 0; }
.du-empty { color: var(--muted); font-size: 13px; margin: 6px 0; }
.pos { color: var(--pos); }
.neg { color: var(--warn); }
.bad { color: var(--red-fg); }
kbd { font-family: var(--font-mono); font-size: 11px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; color: inherit; opacity: .8; }
.primary kbd { border-color: color-mix(in srgb, var(--on-ink) 40%, transparent); }

/* ------------------------------------------------------------ lobby */
.du-lobby { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); gap: 18px; align-items: start; }
.du-setup { display: grid; gap: 16px; }
.du-setup fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.du-setup legend { font-weight: 650; margin-bottom: 8px; padding: 0; }
.du-setup legend small { font-weight: 400; color: var(--muted); margin-left: 6px; }
.du-field { display: grid; gap: 6px; max-width: 360px; }
.du-field label, .du-seed label { font-weight: 650; }
.du-field input, .du-seed input { border: 1px solid var(--line-strong); border-radius: 7px; padding: 6px 10px; background: var(--surface); color: var(--ink); }
.du-levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.du-ais { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.du-level, .du-ai { display: grid; gap: 4px; align-content: start; justify-items: start; text-align: left; padding: 12px; min-height: 0; height: auto;
  white-space: normal; font-weight: 400; border-radius: 10px; }
.du-level[aria-pressed="true"], .du-ai[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink) inset; background: var(--surface-2); }
.du-level .n { font-size: 11.5px; color: var(--faint); font-weight: 600; letter-spacing: .04em; }
.du-level b, .du-ai b { font-size: 15px; }
.du-level .stars { color: var(--amber-mid); letter-spacing: 1px; font-size: 12px; }
.du-level small, .du-ai small { color: var(--muted); font-size: 12px; line-height: 1.5; }
.du-seed { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.du-seed input { width: 110px; }
.du-seed small { flex-basis: 100%; color: var(--muted); font-size: 12px; line-height: 1.6; }
.du-start { justify-self: start; min-height: 40px; padding: 0 22px; font-size: 15px; }
.du-resume { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; background: var(--amber-soft);
  border: 1px solid var(--amber-line); border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; }
.du-resume.done { background: var(--surface-2); border-color: var(--line-strong); }
.du-resume div { display: grid; gap: 2px; }
.du-resume span { color: var(--ink-2); font-size: 13px; }
.du-rules ol { margin: 0; padding-left: 20px; display: grid; gap: 8px; color: var(--ink-2); line-height: 1.6; font-size: 13.5px; }

/* ------------------------------------------------------------ scoreboard */
.du-score { position: sticky; top: 64px; z-index: 3; padding: 14px 18px; }
.du-vs { display: grid; grid-template-columns: 1fr minmax(220px, 1.2fr) 1fr; gap: 14px; align-items: center; }
.du-vs .side { display: grid; gap: 2px; min-width: 0; }
.du-vs .side.ai { text-align: right; }
.du-vs .side span { font-size: 12.5px; color: var(--muted); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.du-vs .side b { font-size: 30px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.du-vs .side.you b { color: var(--blue-fg); }
.du-vs .side.ai b { color: var(--orange-fg); }
.du-vs .side small { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.du-vs .mid { display: grid; gap: 4px; justify-items: center; text-align: center; }
.du-vs .clock { font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.du-vs .lead { font-size: 15px; font-weight: 700; }
.du-vs .track { position: relative; display: block; width: 100%; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: visible; }
.du-vs .track i { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: var(--ink); }
.du-vs .track em { position: absolute; top: -4px; width: 2px; height: 14px; background: var(--red-mid); }
.du-vs .mid small { font-size: 12px; color: var(--muted); }

/* ------------------------------------------------------------ arena */
.du-arena { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(260px, 1fr); gap: 18px; align-items: start; }
.du-gauges { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px 18px; }
.du-gauge { display: grid; grid-template-columns: 92px 1fr auto; gap: 8px; align-items: center; font-size: 12.5px; min-width: 0; }
.du-gauge > span { color: var(--muted); }
.du-gauge .g { position: relative; height: 10px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
.du-gauge .fill { position: absolute; inset: 0 auto 0 0; background: var(--storage); border-radius: 5px; }
.du-gauge .target { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink); opacity: .55; }
.du-gauge b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.du-gauge em { grid-column: 2 / 4; font-style: normal; font-size: 11px; color: var(--orange-fg); }
.du-gauge em.hot { color: var(--red-fg); }
.du-now { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 14px 0 6px; }
.du-now div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; display: grid; gap: 1px; min-width: 0; }
.du-now span, .du-preview span { font-size: 11.5px; color: var(--muted); }
.du-now b, .du-preview b { font-size: 18px; font-variant-numeric: tabular-nums; }
.du-now small, .du-preview small { font-size: 11px; color: var(--faint); }
.tier.peak { color: var(--red-fg); }
.tier.flat { color: var(--amber-fg); }
.tier.valley { color: var(--green-fg); }
.du-last, .du-plan { font-size: 12.5px; color: var(--ink-2); margin: 8px 0; line-height: 1.6; }
.du-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-top: 12px; }
.du-slider { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface-2); display: grid; gap: 6px; min-width: 0; }
.du-slider .head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.du-slider .head label { font-weight: 650; font-size: 13px; }
.du-slider output { font-variant-numeric: tabular-nums; font-weight: 650; font-size: 13px; color: var(--blue-fg); }
.du-slider input[type="range"] { width: 100%; accent-color: var(--blue-solid); min-height: 28px; }
.du-slider .ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); }
.du-slider .quick { display: flex; flex-wrap: wrap; gap: 4px; }
.du-slider .quick button { min-height: 26px; padding: 0 8px; font-size: 12px; }
.du-slider .switch { display: inline-flex; gap: 6px; align-items: center; font-size: 12.5px; font-weight: 500; }
.du-auto { margin: 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.6; }
.du-preview { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 14px; padding: 10px; border-radius: 10px; background: var(--blue-soft); border: 1px solid var(--blue-line); }
.du-preview div { display: grid; gap: 1px; min-width: 0; }
.du-warn { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; font-size: 12.5px; }
.du-warn li { padding: 6px 10px; border-radius: 8px; }
.du-warn li.warn { background: var(--amber-soft); color: var(--amber-fg); border: 1px solid var(--amber-line); }
.du-warn li.bad { background: var(--red-soft); color: var(--red-fg); border: 1px solid var(--red-line); }
.du-ok { margin: 8px 0 0; font-size: 12.5px; color: var(--green-fg); }
.du-go { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.du-go button { min-height: 38px; }
.du-hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.du-opp .du-gauge { grid-template-columns: 78px 1fr auto; }
.du-ai-events { margin-top: 10px; font-size: 12.5px; }
.du-ai-events > span { font-weight: 650; }
.du-ai-events ol { list-style: none; margin: 6px 0; padding: 0; display: grid; gap: 4px; }
.du-ai-events li { display: flex; gap: 8px; }
.du-ai-events time, .du-log time, .du-trail time { color: var(--faint); font-variant-numeric: tabular-nums; flex: none; }
.du-ai-events small { color: var(--faint); font-size: 11.5px; line-height: 1.5; display: block; }

/* ------------------------------------------------------------ charts and log */
.du-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.du-chart { margin: 0; min-width: 0; }
.du-chart figcaption { font-weight: 650; font-size: 13px; margin-bottom: 4px; }
.du-chart svg { width: 100%; height: auto; display: block; }
.du-chart text { fill: var(--faint); font-size: 10.5px; }
.du-chart path { fill: none; stroke-width: 2.4; stroke-linejoin: round; }
.du-chart path.thin { stroke-width: 1.6; }
.du-chart path.you { stroke: var(--blue-mid); }
.du-chart path.ai { stroke: var(--orange-mid); }
.du-chart .zero { stroke: var(--line-strong); }
.du-chart .inj { stroke: var(--red-mid); stroke-dasharray: 3 3; }
.du-chart .red { stroke: var(--red-mid); stroke-dasharray: 5 4; opacity: .7; }
.du-chart .now { stroke: var(--ink); opacity: .45; }
.du-chart rect.past { fill: var(--surface-3); }
.du-chart rect.fc.peak { fill: var(--red-soft); stroke: var(--red-line); }
.du-chart rect.fc.flat { fill: var(--amber-soft); stroke: var(--amber-line); }
.du-chart rect.fc.valley { fill: var(--green-soft); stroke: var(--green-line); }
.du-legend { font-size: 11.5px; color: var(--muted); margin: 4px 0 0; line-height: 1.8; }
.du-legend .k { display: inline-block; width: 14px; height: 4px; border-radius: 2px; margin: 0 4px 1px 8px; vertical-align: middle; }
.du-legend .k.you { background: var(--blue-mid); }
.du-legend .k.ai { background: var(--orange-mid); }
.du-legend .k.inj, .du-legend .k.red { background: var(--red-mid); }
.du-legend .k.peak { height: 10px; background: var(--red-soft); border: 1px solid var(--red-line); }
.du-legend .k.flat { height: 10px; background: var(--amber-soft); border: 1px solid var(--amber-line); }
.du-legend .k.valley { height: 10px; background: var(--green-soft); border: 1px solid var(--green-line); }
.du-log, .du-trail { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 12.5px; }
.du-log li, .du-trail li { display: flex; gap: 10px; line-height: 1.55; }
.du-log li.bad { color: var(--red-fg); }
.du-log li.warn { color: var(--amber-fg); }
.du-leave { display: flex; gap: 8px; justify-content: flex-end; margin: 0; }

/* ------------------------------------------------------------ result */
.du-result { border-radius: 14px; padding: 20px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--elev-2); display: grid; gap: 16px; }
.du-result.player { border-color: var(--blue-line); background: linear-gradient(180deg, var(--blue-soft), var(--surface) 140px); }
.du-result.ai { border-color: var(--orange-line); background: linear-gradient(180deg, var(--orange-soft), var(--surface) 140px); }
.du-result-head { text-align: center; display: grid; gap: 4px; }
.du-result-head h2 { margin: 0; font-size: 26px; }
.du-result-head .big { margin: 0; font-size: 20px; font-weight: 700; display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.du-result-head .vs { color: var(--faint); font-weight: 400; }
.du-result-head .margin { margin: 0; font-weight: 700; }
.du-rank { margin: 0; color: var(--ink-2); }
.du-reveal { border: 1px dashed var(--red-line); border-radius: 10px; padding: 12px 14px; background: var(--red-soft); display: grid; gap: 2px; }
.du-reveal span { font-size: 11.5px; color: var(--red-fg); font-weight: 650; letter-spacing: .04em; }
.du-reveal b { font-size: 16px; }
.du-reveal p { margin: 0; color: var(--ink-2); font-size: 13px; }
.du-result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.du-ai-trail summary { font-weight: 650; }
.du-ai-trail .du-trail { margin-top: 8px; }
.du-again { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.du-again small { flex-basis: 100%; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }

/* ------------------------------------------------------------ tables and board */
.du-table-wrap { overflow-x: auto; }
.du-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.du-table caption { text-align: left; font-size: 12px; color: var(--muted); padding-bottom: 6px; }
.du-table th, .du-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.du-table .num, .du-table.compact td { text-align: right; }
.du-table.compact th { font-weight: 500; }
.du-table tr.sum th, .du-table tr.sum td { font-weight: 700; }
.du-table tr.me { background: var(--blue-soft); }
.du-table .rank { font-weight: 700; width: 36px; }
.du-table .who { font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.du-table .seed, .du-table .when { color: var(--faint); }
.badge { display: inline-block; margin-left: 6px; font-size: 11px; padding: 0 6px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--muted); font-weight: 600; }
.badge.win { color: var(--green-fg); border-color: var(--green-line); background: var(--green-soft); }
.badge.lose { color: var(--orange-fg); border-color: var(--orange-line); background: var(--orange-soft); }
.du-board-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.du-board-filters label { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; }
.du-board-filters select { border: 1px solid var(--line-strong); border-radius: 7px; padding: 4px 8px; background: var(--surface); color: var(--ink); max-width: 100%; }
.du-board-stat { color: var(--muted); font-size: 12.5px; }

/* ------------------------------------------------------------ narrow screens */
@media (max-width: 960px) {
  .du-lobby, .du-arena { grid-template-columns: minmax(0, 1fr); }
  .du-score { top: 0; }
}
@media (max-width: 640px) {
  .du-main { padding: 14px 14px 40px; }
  .du-hero h1 { font-size: 22px; }
  .du-vs { grid-template-columns: 1fr 1fr; }
  .du-vs .mid { grid-column: 1 / -1; grid-row: 2; }
  .du-vs .side b { font-size: 22px; }
  .du-now, .du-preview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .du-gauge { grid-template-columns: 80px 1fr auto; }
  .du-go button { flex: 1 1 140px; }
}
