/* Skyline GT — night city. Taillight red is the only accent; sodium amber is the city's own light. */
:root {
  --night: #060a14;
  --night2: #0c1426;
  --ink: #e9edf5;
  --dim: #8d97ab;
  --faint: #4a5368;
  --line: rgba(160, 180, 220, .14);
  --red: #ff3b30;
  --red2: #ff6a55;
  --amber: #ffb547;
  --glass: rgba(14, 20, 36, .82);
  --mono: "Geist Mono", ui-monospace, Menlo, Consolas, monospace;
  --sans: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ja: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--night); color: var(--ink); font-family: var(--sans); }
body { overflow: hidden; }
button { font: inherit; color: inherit; }

.wrap { height: 100vh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto auto; padding: 14px 22px 8px; gap: 8px;
  background: radial-gradient(1200px 500px at 30% -10%, #16234a 0%, transparent 60%), linear-gradient(#070c1a, #04070e); }

/* ---------- header ---------- */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.mark h1 { margin: 0; font-size: clamp(28px, 3.4vw, 46px); font-weight: 800; letter-spacing: .32em; line-height: 1; }
.mark h1 em { font-style: normal; color: var(--red); letter-spacing: .12em; text-shadow: 0 0 18px rgba(255, 59, 48, .55); }
.mark .sub { margin-top: 6px; font-family: var(--mono); font-size: 12px; color: var(--dim); letter-spacing: .14em; }
.mark .sub [lang=ja] { font-family: var(--ja); letter-spacing: .3em; color: #c9d1e2; margin-right: 10px; }
.metrics { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.metrics .lab { font-family: var(--mono); font-size: 10.5px; letter-spacing: .18em; color: var(--dim); margin-right: 4px; }
.pill { border: 1px solid var(--line); background: rgba(255, 255, 255, .03); border-radius: 999px; padding: 6px 13px; font-size: 13px; cursor: pointer; color: #c6cede; transition: background .2s, border-color .2s, color .2s; }
.pill:hover { border-color: rgba(255, 255, 255, .35); color: #fff; }
.pill[aria-checked=true] { background: var(--red); border-color: var(--red); color: #fff; box-shadow: 0 0 16px rgba(255, 59, 48, .45); }

/* ---------- stage ---------- */
.floor { display: grid; grid-template-columns: minmax(0, 1fr) 372px; gap: 14px; min-height: 0; }
.stage { position: relative; min-height: 0; border-radius: 14px; overflow: hidden; background: var(--night2); box-shadow: inset 0 0 0 1px var(--line); }
#city { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#labels { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
#labels text { font-family: var(--mono); font-size: 11px; fill: #9aa6bf; letter-spacing: .06em; }
#labels text.on { fill: #fff; font-weight: 600; }
#labels text.val { fill: #ffd0c9; font-size: 11px; }
#labels .gl { stroke: rgba(255, 255, 255, .16); stroke-dasharray: 2 3; }
.road { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); height: min(40%, 250px); max-width: 29%; aspect-ratio: 296 / 222; pointer-events: none; }
.road .rider { position: absolute; inset: 0; transform-origin: 50% 100%; transition: transform 1.1s cubic-bezier(.55, 0, .3, 1), opacity 1.1s ease, filter 1.1s ease; will-change: transform, opacity; }
.road .rider svg { width: 100%; height: 100%; display: block; overflow: visible; }
.road .rider.leaving { transform: translateY(-46%) scale(.18); opacity: 0; filter: blur(1px); }
.road .rider.arriving { transform: translateY(18%) scale(1.25); opacity: 0; }
.road .rider .glow, .road .rider .glow2 { animation: brake 3.6s ease-in-out infinite; }
@keyframes brake { 0%, 100% { opacity: .78; } 45% { opacity: 1; } 55% { opacity: .9; } }
.chapter { position: absolute; left: 18px; top: 14px; max-width: min(520px, 62%); font-size: 14px; line-height: 1.45; color: #dfe6f3; pointer-events: none; opacity: 0; transform: translateY(-6px); transition: opacity .5s, transform .5s; text-shadow: 0 1px 8px rgba(0, 0, 0, .8); }
.chapter.on { opacity: 1; transform: none; }
.chapter b { display: block; font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: .18em; color: var(--red2); margin-bottom: 3px; }
.axisnote { position: absolute; right: 14px; top: 12px; font-family: var(--mono); font-size: 10.5px; color: var(--dim); letter-spacing: .06em; text-align: right; max-width: 46%; pointer-events: none; line-height: 1.5; }
.axisnote i { font-style: normal; color: #c6cede; }

/* ---------- panel ---------- */
.panel { min-height: 0; overflow: auto; border-radius: 14px; background: var(--glass); box-shadow: inset 0 0 0 1px var(--line); padding: 16px 18px 18px; position: relative; scrollbar-width: thin; scrollbar-color: #2a3550 transparent; }
.panel .ja { position: absolute; right: 12px; top: 14px; writing-mode: vertical-rl; font-family: var(--ja); font-size: 30px; letter-spacing: .12em; color: rgba(255, 255, 255, .1); pointer-events: none; line-height: 1; max-height: 200px; overflow: hidden; }
.panel h2 { margin: 0; font-size: 44px; font-weight: 800; letter-spacing: .02em; line-height: 1; }
.panel h2 small { font-size: 15px; font-weight: 500; color: var(--dim); margin-left: 8px; letter-spacing: 0; }
.panel h2, .panel .nick, .panel .meta { padding-right: 38px; }
.panel .nick { margin-top: 4px; font-size: 15px; color: #ffd0c9; }
.panel .meta { margin-top: 6px; font-size: 12px; color: var(--dim); line-height: 1.5; }
.panel .rule { height: 2px; background: linear-gradient(90deg, var(--red), transparent); margin: 12px 0 10px; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs button { border: 1px solid var(--line); background: none; border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer; color: #b6bfd0; }
.tabs button[aria-selected=true] { border-color: var(--red); color: #fff; background: rgba(255, 59, 48, .14); }
.sec { margin: 12px 0 6px; display: flex; justify-content: space-between; align-items: baseline; font-family: var(--mono); font-size: 10.5px; letter-spacing: .18em; color: var(--red2); font-weight: 600; }
.sec span { color: var(--faint); letter-spacing: .06em; font-weight: 400; }
.cmp { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.cmp th { text-align: right; font-weight: 600; color: #fff; font-size: 12px; padding: 0 0 5px; vertical-align: bottom; }
.cmp th:first-child { text-align: left; color: var(--dim); font-weight: 400; }
.cmp td { padding: 4px 0; border-top: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
.cmp td:first-child { text-align: left; color: var(--dim); }
.cmp td small { color: var(--faint); }
.big { display: flex; gap: 14px; flex-wrap: wrap; }
.big div { flex: 1 1 90px; }
.big b { display: block; font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.big span { font-size: 11.5px; color: var(--dim); }
.lights { display: flex; gap: 10px; align-items: center; font-size: 12.5px; color: #cdd5e4; line-height: 1.45; }
.lights .dots { flex: none; display: flex; gap: 4px; }
.lights .dots i { width: 12px; height: 12px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #fff2ec, #ff4a3a 45%, #a10d18); box-shadow: 0 0 10px rgba(255, 59, 48, .8); }
.lights .dots i.sq { border-radius: 2px; width: 22px; height: 8px; }
.lights .dots i.off { background: #3a1a1e; box-shadow: none; }
.miles { margin: 0; padding: 0; list-style: none; font-size: 12.5px; line-height: 1.45; color: #cdd5e4; }
.miles li { padding: 5px 0 5px 14px; border-top: 1px solid var(--line); position: relative; }
.miles li::before { content: ""; position: absolute; left: 2px; top: 11px; width: 6px; height: 6px; border-radius: 50%; background: var(--red); }
.src { font-size: 11px; color: var(--faint); line-height: 1.5; word-break: break-word; }
.src a { color: #7f8aa3; }
.ledger { display: flex; flex-wrap: wrap; gap: 3px; margin: 6px 0 4px; }
.ledger i { width: 11px; height: 11px; border-radius: 50%; background: #2a3045; cursor: default; }
.ledger i.win { background: radial-gradient(circle at 40% 35%, #fff2ec, #ff4a3a 45%, #a10d18); box-shadow: 0 0 6px rgba(255, 59, 48, .7); }
.ledger i.pod { background: #8a5a2a; }
.races { width: 100%; border-collapse: collapse; font-size: 12px; }
.races td { padding: 4px 4px 4px 0; border-top: 1px solid var(--line); vertical-align: top; }
.races td:first-child { font-family: var(--mono); font-size: 11px; color: var(--dim); white-space: nowrap; }
.races td.r { text-align: right; white-space: nowrap; color: #ffd0c9; }
.races a { color: inherit; text-decoration: none; }
.races a:hover { text-decoration: underline; }
.empty { font-size: 12.5px; color: var(--dim); line-height: 1.5; padding: 6px 0; }
#scatter { width: 100%; height: auto; display: block; }
#scatter text { font-family: var(--mono); font-size: 9.5px; fill: #8792a8; }
#scatter .eg { fill: rgba(255, 181, 71, .08); }
#scatter .egl { stroke: var(--amber); stroke-dasharray: 3 3; }

/* ---------- generation strip ---------- */
.gens { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 4px; }
.gens button { background: none; border: 1px solid transparent; border-radius: 10px; padding: 4px 2px 5px; cursor: pointer; text-align: center; transition: background .2s, border-color .2s; min-width: 0; }
.gens button:hover { background: rgba(255, 255, 255, .04); }
.gens button[aria-pressed=true] { background: rgba(255, 59, 48, .1); border-color: rgba(255, 59, 48, .5); }
.gens button svg { width: 100%; height: auto; max-height: 56px; display: block; }
.gens button .c { display: block; font-size: 12.5px; font-weight: 700; margin-top: 2px; }
.gens button .y { display: block; font-family: var(--mono); font-size: 9.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gens button.epi { opacity: .62; }
.gens button.epi .c::after { content: " *"; color: var(--dim); }
.pick { margin: 0; text-align: center; font-size: 13px; color: #c6cede; }
.pick span { color: var(--dim); }
.drive { border: 1px solid var(--line); background: rgba(255, 255, 255, .04); border-radius: 999px; padding: 4px 12px; margin-right: 8px; cursor: pointer; }
.drive[aria-pressed=true] { background: var(--red); border-color: var(--red); }
footer { text-align: center; font-size: 11px; color: var(--faint); line-height: 1.5; white-space: pre-line; }
footer a { color: #7f8aa3; }
footer .err { color: var(--red2); }

.tip { position: fixed; z-index: 10; pointer-events: none; background: rgba(8, 12, 24, .95); border: 1px solid rgba(255, 255, 255, .14); border-radius: 8px; padding: 8px 10px; font-size: 12px; line-height: 1.45; max-width: 300px; opacity: 0; transition: opacity .12s; box-shadow: 0 8px 28px rgba(0, 0, 0, .5); }
.tip.on { opacity: 1; }
.tip b { font-size: 13px; }
.tip .k { color: var(--dim); }

@media (max-width: 1000px) {
  body { overflow: auto; }
  .wrap { height: auto; min-height: 100vh; padding: 12px 16px; }
  .floor { grid-template-columns: 1fr; }
  .stage { height: 62vw; min-height: 300px; }
  .panel { max-height: none; }
  .gens { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .head { flex-direction: column; align-items: flex-start; }
  .metrics { justify-content: flex-start; }
  .axisnote { top: auto; bottom: 8px; right: 8px; max-width: 30%; font-size: 9px; }
  .chapter { font-size: 12px; max-width: 70%; }
}
@media (prefers-reduced-motion: reduce) {
  .road .rider { transition: opacity .3s; }
  .road .rider .glow, .road .rider .glow2 { animation: none; }
}
details.note { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
details.note summary { cursor: pointer; font-size: 12px; color: #b6bfd0; }
details.note p { margin: 6px 0 0; }
