/* ══ PONOS RACING — LIVE TIMING ══════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@500;600;700&family=Noto+Sans+JP:wght@400;500;700&display=swap');

:root {
  --bg: #07090c;
  --panel: #10141a;
  --panel2: #171c24;
  --line: #1f2630;
  --txt: #eef1f5;
  --dim: #8a93a0;
  --accent: #ee732d;
  --accent-hi: #ff8a45;
  --accent-glow: rgba(238, 115, 45, .45);
  --green: #2edc7a;
  --purple: #c07dff;
  --yellow: #ffd21e;
  --red: #ff3b30;
  --num: "Rajdhani", "Segoe UI", sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scrollbar-color: #333a44 #0a0c10; }
body {
  background:
    radial-gradient(1200px 500px at 15% -10%, rgba(238,115,45,.07), transparent 60%),
    radial-gradient(900px 400px at 110% 0%, rgba(238,115,45,.05), transparent 60%),
    var(--bg);
  color: var(--txt);
  font-family: "Noto Sans JP", "Segoe UI", "Hiragino Sans", sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
}

/* ── flag banner ── */
#flag-banner {
  text-align: center; font-family: var(--num); font-weight: 700;
  letter-spacing: .45em; text-indent: .45em; font-size: .95rem;
  padding: 6px 0; color: #000; transition: background .3s, box-shadow .3s;
  text-transform: uppercase;
}
.flag-none   { background: #262c35; color: #8a93a0 !important; }
.flag-green  { background: linear-gradient(90deg, #14b85c, #2edc7a 30%, #2edc7a 70%, #14b85c); box-shadow: 0 0 24px rgba(46,220,122,.5); }
.flag-yellow { background: linear-gradient(90deg, #d9b000, var(--yellow) 30%, var(--yellow) 70%, #d9b000); box-shadow: 0 0 24px rgba(255,210,30,.45); animation: flagpulse 1.4s ease-in-out infinite; }
.flag-red    { background: linear-gradient(90deg, #c41f16, var(--red) 30%, var(--red) 70%, #c41f16); color: #fff !important; box-shadow: 0 0 24px rgba(255,59,48,.55); animation: flagpulse 1.1s ease-in-out infinite; }
.flag-sc     { background: repeating-linear-gradient(-45deg, var(--yellow) 0 26px, #b98f00 26px 52px); animation: scmove 1.2s linear infinite; }
.flag-finish { background: repeating-conic-gradient(#f2f2f2 0% 25%, #0a0a0a 0% 50%) 0 0/28px 28px; }
.flag-finish span, .flag-sc span { color: #fff; text-shadow: 0 1px 3px #000, 0 0 10px #000; }
@keyframes flagpulse { 50% { filter: brightness(.72); } }
@keyframes scmove { to { background-position: 52px 0; } }

/* ── header ── */
.topbar {
  position: relative; display: flex; align-items: center; gap: 22px;
  padding: 12px 22px;
  background: linear-gradient(105deg, #0c0e12 0%, #12141a 55%, #1c130b 80%, #2a170a 100%);
  border-bottom: 2px solid var(--accent);
  box-shadow: 0 4px 24px rgba(0,0,0,.6);
  overflow: hidden;
}
.topbar::before {
  content: ""; position: absolute; right: -60px; top: -40px; width: 320px; height: 200px;
  background: linear-gradient(115deg, transparent 40%, rgba(238,115,45,.16) 40%, rgba(238,115,45,.16) 55%, transparent 55%,
              transparent 62%, rgba(238,115,45,.10) 62%, rgba(238,115,45,.10) 72%, transparent 72%);
  pointer-events: none;
}
.logo { height: 48px; width: auto; flex-shrink: 0; filter: drop-shadow(0 0 12px rgba(238,115,45,.35)); }
.session { flex: 1; min-width: 0; }
.session-name {
  font-family: var(--num); font-size: 1.75rem; font-weight: 700; letter-spacing: .04em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.15;
  text-transform: uppercase;
}
.session-sub {
  font-family: var(--num); font-size: 1.08rem; color: #a8b2be;
  display: flex; align-items: center; gap: 16px; margin-top: 4px; letter-spacing: .05em;
}
#race-type-label {
  color: #000; background: var(--accent); font-weight: 700; padding: 2px 12px; font-size: .95rem;
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
}
.right-box { text-align: right; flex-shrink: 0; font-family: var(--num); }
.conn { color: var(--dim); font-size: .8rem; letter-spacing: .08em; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot.on  { background: var(--green); box-shadow: 0 0 8px var(--green); animation: flagpulse 2s infinite; }
.dot.off { background: var(--red); box-shadow: 0 0 8px var(--red); }
.localtime { font-size: 1.05rem; font-weight: 600; color: var(--txt); letter-spacing: .1em; margin-top: 1px; }

/* ── telop ── */
.telop[hidden] { display: none; }
.telop {
  display: flex; align-items: center; gap: 10px; overflow: hidden;
  background: linear-gradient(90deg, var(--accent-dark, #b9541b), var(--accent));
  color: #000; font-weight: 700; padding: 5px 18px; font-size: .88rem;
  box-shadow: inset 0 -6px 14px rgba(0,0,0,.25);
}
.telop::before { content: "📢"; }

/* ── toolbar ── */
.toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 16px; background: var(--panel);
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.class-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.class-tab {
  font-family: var(--num); font-weight: 600; letter-spacing: .05em;
  border: 1px solid var(--line); background: var(--panel2); color: var(--dim);
  padding: 3px 14px; font-size: .8rem; cursor: pointer; user-select: none;
  clip-path: polygon(7px 0, 100% 0, calc(100% - 7px) 100%, 0 100%);
  transition: all .15s;
}
.class-tab:hover { border-color: var(--accent); color: var(--txt); }
.class-tab.active {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  border-color: var(--accent); color: #000; font-weight: 700;
  box-shadow: 0 0 14px var(--accent-glow);
}
.sort-box { font-size: .78rem; color: var(--dim); display: flex; align-items: center; gap: 6px; font-family: var(--num); letter-spacing: .06em; }
.sort-box select {
  background: var(--panel2); color: var(--txt); border: 1px solid var(--line);
  border-radius: 4px; padding: 3px 8px; font-size: .8rem; font-family: var(--num);
}

/* ── table ── */
main { flex: 1; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
thead th {
  position: sticky; top: 0; z-index: 2;
  background: linear-gradient(180deg, #171a20, #11141a);
  color: var(--dim); font-family: var(--num); font-weight: 600;
  padding: 9px 7px; font-size: .82rem; letter-spacing: .12em; text-transform: uppercase;
  border-bottom: 2px solid var(--accent); white-space: nowrap;
}
/* rotating best-info headers (Best/S1/S2/S3/Spd) */
thead th.c-best { min-width: 92px; }
thead th.c-s1, thead th.c-s2, thead th.c-s3, thead th.c-s4 { min-width: 84px; }
/* a fourth timed sector squeezes the row: trade team-name width for it */
body.s4 thead th.c-s1, body.s4 thead th.c-s2,
body.s4 thead th.c-s3, body.s4 thead th.c-s4 { min-width: 76px; }
body.s4 td.c-team { max-width: 118px; overflow: hidden; text-overflow: ellipsis; }
body.s4 td.c-driver .drv-nm { max-width: 190px; display: inline-block;
  overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
thead th.c-spd { min-width: 72px; }
.th-roll {
  display: inline-block; max-width: 110px; overflow: hidden; text-overflow: ellipsis;
  vertical-align: bottom; animation: thfade .45s ease;
}
.th-roll.th-val { color: var(--accent-hi); text-transform: none; letter-spacing: .04em; }
.th-roll.th-drv { color: #cfd6de; text-transform: none; letter-spacing: .02em; font-size: .72rem; }
@keyframes thfade { from { opacity: 0; transform: translateY(-5px); } }
tbody td {
  padding: 7px 7px; text-align: center; border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums; white-space: nowrap;
  font-family: var(--num); font-weight: 500; font-size: 1.05rem;
}
tbody tr { transition: background .15s; }
tbody tr:nth-child(odd) { background: #0d1015; }
tbody tr:hover { background: #1b212b; box-shadow: inset 3px 0 0 var(--accent); }
/* Every feed message rebuilds the rows, which restarts these animations from
   full brightness — during a fast replay that pinned half the table bright
   orange permanently. The --*-age custom properties carry how old each event
   is so the animation resumes part-way through instead. */
tbody tr.updated { animation: rowflash 1.2s ease-out; animation-delay: var(--row-age, 0s); }
@keyframes rowflash {
  0% { background: rgba(238,115,45,.4); box-shadow: inset 4px 0 0 var(--accent-hi); }
  100% { background: transparent; }
}

/* pos badges */
td.c-pos { font-weight: 700; }
.pos-badge {
  display: inline-block; min-width: 34px; padding: 1px 6px;
  font-family: var(--num); font-weight: 700; font-size: .95rem;
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
  background: #1d232d; color: var(--txt);
}
.p1 .pos-badge {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  color: #000; box-shadow: 0 0 16px var(--accent-glow);
}
.p2 .pos-badge { background: #3a4250; color: #fff; }
.p3 .pos-badge { background: #2b323e; color: #e8eaed; }
tr.p1 td { border-bottom-color: rgba(238,115,45,.35); }
/* The position cell is built from fixed-width slots so nothing in it — a
   two-digit class position, an arrow chip appearing — can re-centre the cell
   and shove every column to its right. */
.cls-pos {
  display: inline-block; width: 28px; text-align: left; margin-left: 4px;
  color: #99a3b1; font-size: .8rem; font-weight: 600;
}
.pos-move { display: inline-block; width: 0; }
body.broadcast .pos-move { width: 36px; text-align: left; vertical-align: middle; }
body.broadcast td.c-pos { min-width: 132px; }

/* car no */
td.c-no .no-chip {
  display: inline-block; min-width: 44px; padding: 1px 7px;
  font-family: var(--num); font-weight: 700; font-size: 1rem;
  color: var(--accent-hi); border: 1px solid rgba(238,115,45,.5);
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
  background: rgba(238,115,45,.08);
}

/* driver / team */
td.c-driver, td.c-team {
  text-align: left; max-width: 230px; overflow: hidden; text-overflow: ellipsis;
  font-family: "Noto Sans JP", sans-serif; font-size: .84rem;
}
td.c-driver { font-weight: 700; }
td.c-team { color: #b7c0cc; font-weight: 500; }

/* class chip */
.class-chip[hidden] { display: none; }
.class-chip {
  display: inline-block; padding: 1px 9px; font-size: .7rem; font-weight: 700;
  font-family: var(--num); letter-spacing: .04em; color: #000; background: #888;
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
}

td.c-laps { font-weight: 700; font-size: .95rem; }
td.c-gap, td.c-int { color: var(--dim); font-size: .84rem; }
td.c-last, td.c-best { font-weight: 600; }
td.c-s1, td.c-s2, td.c-s3, td.c-s4 { color: #aab2bd; font-size: .82rem; }
td.c-spd { color: #7fb7e6; font-size: .82rem; }
/* green = personal best / purple = overall best (must win over column colors) */
tbody td.t-pb { color: var(--green); text-shadow: 0 0 10px rgba(46,220,122,.5); font-weight: 700; }
tbody td.t-ob { color: var(--purple); text-shadow: 0 0 10px rgba(192,125,255,.55); font-weight: 700; }
/* still showing last lap's number — dim it until this lap's value lands */
tbody td.stale { color: #4d5561; text-shadow: none; font-weight: 500; }
/* the sector just posted lights up on its own; the row only flashes at the line */
tbody td.sec-flash { animation: secflash 1.3s ease-out; animation-delay: var(--sec-age, 0s); }
/* the updated value itself flashes — boxing the whole cell read as a block of
   colour rather than as "this number just changed". Only text-shadow and
   brightness are animated so a purple/green best-time cell keeps its colour. */
@keyframes secflash {
  0%   { text-shadow: 0 0 8px #fff, 0 0 18px var(--accent-hi); filter: brightness(1.9); }
  45%  { text-shadow: 0 0 5px var(--accent-glow); filter: brightness(1.25); }
  100% { text-shadow: none; filter: none; }
}

/* marked rows (single click) */
tbody tr { cursor: pointer; user-select: none; }
tbody tr.marked,
tbody tr.marked:nth-child(odd) {
  background: rgba(79, 195, 247, .13);
  box-shadow: inset 4px 0 0 #4fc3f7;
}
tbody tr.marked:hover { background: rgba(79, 195, 247, .22); }
tbody tr.marked td.c-driver { color: #9fdcff; }

/* Cars in the pits are NOT dimmed: their times stay as readable as anyone
   else's, and the PIT badge already says where they are. */
.pit-badge {
  background: var(--red); color: #fff; font-size: .66rem; font-weight: 800;
  font-family: var(--num); letter-spacing: .06em; padding: 1px 8px;
  clip-path: polygon(5px 0, 100% 0, calc(100% - 5px) 100%, 0 100%);
  animation: flagpulse 1.4s infinite;
}
.pit-count { color: #99a3b1; font-size: .84rem; }

/* ── footer bests ── */
.bests[hidden] { display: none; }
.bests {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 20px; font-family: var(--num);
  background: linear-gradient(90deg, #14101c, #100c16 40%, var(--panel));
  border-top: 1px solid rgba(192,125,255,.35); font-size: .95rem; font-weight: 600;
}
.bests-title {
  color: #000; background: linear-gradient(180deg, #d3a5ff, var(--purple));
  padding: 1px 12px; font-size: .74rem; font-weight: 700; letter-spacing: .18em;
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
  box-shadow: 0 0 14px rgba(192,125,255,.4);
}
#best-lap-info { color: var(--purple); text-shadow: 0 0 12px rgba(192,125,255,.4); }

/* ── responsive ── */
@media (max-width: 1080px) {
  .c-s1, .c-s2, .c-s3, .c-s4, .c-spd, .c-team { display: none; }
  .logo { height: 36px; }
  .session-name { font-size: 1.1rem; }
}
@media (max-width: 600px) {
  .c-int, .c-last, .c-pit { display: none; }
  table { font-size: .78rem; }
  td.c-driver { max-width: 130px; }
  .topbar { gap: 12px; padding: 8px 12px; }
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: #0a0c10; }
::-webkit-scrollbar-thumb { background: #2b323e; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-dark, #b9541b); }

/* ══ Broadcast design (F1/WEC broadcast style) ══════════════ */
/* hidden in Classic — Broadcast reveals them */
.segbar { display: none; }
.trend { display: none; }

body.broadcast { background: #090c12; }
body.broadcast main { background: #090c12; padding: 6px 8px; }
body.broadcast tbody td {
  padding: 10px 7px; font-size: 1.12rem; border-bottom: 2px solid #090c12;
}
body.broadcast tbody tr:nth-child(odd),
body.broadcast tbody tr:nth-child(even) { background: #12161f; }
body.broadcast tbody tr:hover { background: #1b2130; box-shadow: none; }
body.broadcast thead th { background: #0d1017; font-size: .84rem; }

/* F1-style solid position box + rectangular chips */
body.broadcast .pos-badge {
  clip-path: none; border-radius: 4px; background: #e9ecf0; color: #0b0e14;
  min-width: 46px; font-size: 1.22rem; padding: 3px 7px; box-shadow: none;
}
body.broadcast tr.p1 .pos-badge {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  color: #000; box-shadow: 0 0 14px var(--accent-glow);
}
body.broadcast tr.p2 .pos-badge, body.broadcast tr.p3 .pos-badge { background: #c3c9d2; color: #0b0e14; }
body.broadcast td.c-no .no-chip {
  clip-path: none; border-radius: 4px; border-width: 2px; font-size: 1.16rem; min-width: 54px;
}
body.broadcast .class-chip { clip-path: none; border-radius: 3px; font-size: .8rem; padding: 3px 11px; }

/* driver name big & bold, sector progress bar underneath-inline */
body.broadcast td.c-driver {
  font-family: var(--num); font-size: 1.24rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em; max-width: 280px;
}
body.broadcast td.c-team { font-size: .92rem; color: #c3ccd8; }
body.broadcast .segbar { display: inline-flex; gap: 3px; margin-left: 12px; vertical-align: 3px; }
body.broadcast .segbar i { width: 22px; height: 5px; border-radius: 2px; background: #262e3e; }
body.broadcast .segbar i.on { background: #b9c2cf; }
body.broadcast .segbar i.on.t-pb { background: var(--green); box-shadow: 0 0 6px rgba(46,220,122,.6); }
body.broadcast .segbar i.on.t-ob { background: var(--purple); box-shadow: 0 0 6px rgba(192,125,255,.6); }
body.broadcast .segbar i.seg-hit { animation: seghit 1.3s ease-out; animation-delay: var(--sec-age, 0s); }
@keyframes seghit {
  0%   { background: #fff; box-shadow: 0 0 12px #fff; transform: scaleY(1.9); }
  100% { transform: scaleY(1); }
}

/* whole row flashes only when the lap time updates at the control line */
body.broadcast tbody tr.updated { animation: rowline 1.3s ease-out; animation-delay: var(--row-age, 0s); }
@keyframes rowline {
  0%   { background: rgba(238,115,45,.45); box-shadow: inset 5px 0 0 #fff; }
  60%  { background: rgba(238,115,45,.16); }
  100% { background: transparent; }
}
body.broadcast tbody td.stale { color: #3f4753; }

/* key numbers pop */
body.broadcast td.c-laps { font-size: 1.05rem; }
body.broadcast td.c-gap { color: #fff; font-weight: 700; font-size: 1.05rem; }
body.broadcast td.c-int { color: #cdd4dd; font-weight: 600; font-size: 1.05rem; }
body.broadcast td.c-last, body.broadcast td.c-best { font-size: 1rem; }
body.broadcast .trend { display: inline; margin-left: 5px; font-size: .7rem; vertical-align: 1px; }
body.broadcast .trend.up { color: var(--green); }
body.broadcast .trend.down { color: #ff6a5e; }

/* battle: interval ≤ 1.0s — both cars pulse red, chaser gets ⚔ */
body.broadcast tr.battle td {
  background: linear-gradient(90deg, rgba(255,59,48,.16), rgba(255,59,48,.05) 45%, transparent 75%);
}
body.broadcast tr.battle { animation: battlepulse 1.5s ease-in-out infinite; }
@keyframes battlepulse {
  0%, 100% { box-shadow: inset 4px 0 0 var(--red); }
  50% { box-shadow: inset 4px 0 0 rgba(255,59,48,.25); }
}
body.broadcast tr.battle-chaser td.c-int {
  color: #ff5f52; font-weight: 800; text-shadow: 0 0 12px rgba(255,59,48,.55);
}
body.broadcast tr.battle-chaser td.c-int::before { content: "⚔ "; font-size: .85rem; }

/* marked rows still visible on top of broadcast zebra */
body.broadcast tbody tr.marked,
body.broadcast tbody tr.marked:nth-child(odd),
body.broadcast tbody tr.marked:nth-child(even) { background: rgba(79,195,247,.14); }

/* ══ car detail window ══ */
.car-page { background: var(--bg); }
.car-head {
  display: flex; align-items: center; gap: 14px; padding: 12px 16px;
  background: linear-gradient(105deg, #0c0e12 0%, #12141a 60%, #241408 100%);
  border-bottom: 2px solid var(--accent);
}
.no-chip.big { font-size: 1.5rem; min-width: 64px; padding: 3px 10px; text-align: center; }
.car-id { flex: 1; min-width: 0; }
.car-driver { font-weight: 700; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.car-team { color: var(--dim); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.car-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.cstat { background: var(--panel2); border-radius: 6px; padding: 6px 10px; text-align: center; }
.cstat .k { font-family: var(--num); font-size: .66rem; color: var(--dim); letter-spacing: .14em; text-transform: uppercase; }
.cstat .v { font-family: var(--num); font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.cstat.best .v { color: var(--purple); text-shadow: 0 0 10px rgba(192,125,255,.4); }
.car-main { padding: 0 0 20px; }
#laps { width: 100%; border-collapse: collapse; }
#laps thead th {
  position: sticky; top: 0; background: linear-gradient(180deg, #171a20, #11141a);
  color: var(--dim); font-family: var(--num); font-size: .7rem; letter-spacing: .12em;
  text-transform: uppercase; padding: 7px 6px; border-bottom: 2px solid var(--accent);
}
#laps td {
  text-align: center; padding: 4px 6px; border-bottom: 1px solid var(--line);
  font-family: var(--num); font-size: .88rem; font-variant-numeric: tabular-nums;
}
#laps tbody tr:nth-child(odd) { background: #0d1015; }
#laps td.lp { color: var(--dim); }
#laps td.lt { font-weight: 700; }
#laps td.sp { color: #7fb7e6; font-size: .8rem; }
#laps tr.lap-best td.lt { color: var(--purple); text-shadow: 0 0 10px rgba(192,125,255,.5); }
#laps tr.lap-best { background: rgba(192,125,255,.08) !important; }
#laps tr.lap-prog td { color: var(--accent-hi); opacity: .8; }
#laps tr.lap-prog td.lp { color: var(--accent); font-weight: 700; }
.car-note { color: var(--dim); font-size: .8rem; text-align: center; padding: 18px 10px; }
.car-note[hidden] { display: none; }

/* ══ login page ══ */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    linear-gradient(115deg, transparent 55%, rgba(238,115,45,.06) 55%, rgba(238,115,45,.06) 62%, transparent 62%,
      transparent 68%, rgba(238,115,45,.04) 68%, rgba(238,115,45,.04) 78%, transparent 78%),
    radial-gradient(900px 500px at 30% 20%, #1a120c 0%, var(--bg) 65%);
}
.login-card {
  background: linear-gradient(180deg, #12161d, #0e1116);
  border: 1px solid var(--line); border-top: 3px solid var(--accent);
  border-radius: 12px; padding: 42px 46px; width: min(92vw, 400px); text-align: center;
  box-shadow: 0 18px 60px rgba(0,0,0,.65), 0 0 40px rgba(238,115,45,.07);
}
.login-card img { width: 210px; margin-bottom: 18px; filter: drop-shadow(0 0 14px rgba(238,115,45,.3)); }
.login-card h1 {
  font-family: var(--num); font-size: 1rem; color: var(--dim); font-weight: 600;
  margin-bottom: 24px; letter-spacing: .35em; text-indent: .35em;
}
.login-card input {
  width: 100%; padding: 11px 13px; border-radius: 7px; border: 1px solid var(--line);
  background: #0a0d11; color: var(--txt); font-size: 1rem; margin-bottom: 14px;
  transition: border-color .2s, box-shadow .2s;
}
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(238,115,45,.18); }
.login-card button {
  width: 100%; padding: 11px; border: none; border-radius: 7px;
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  color: #000; font-weight: 800; font-size: .95rem; cursor: pointer;
  font-family: var(--num); letter-spacing: .3em; text-indent: .3em;
  transition: filter .15s, box-shadow .15s;
}
.login-card button:hover { filter: brightness(1.12); box-shadow: 0 0 22px var(--accent-glow); }
.login-err { color: var(--red); font-size: .8rem; min-height: 1.2em; margin-top: 12px; }

/* ══ race-motion cues (Broadcast) ══════════════════════════════ */
/* net places gained/lost against the grid position */
.pos-delta { display: none; }
body.broadcast .pos-delta {
  display: inline-block; margin-left: 5px; font-family: var(--num);
  font-size: .62rem; font-weight: 800; vertical-align: 1px;
}
body.broadcast .pos-delta.up { color: var(--green); }
body.broadcast .pos-delta.down { color: #ff6a5e; }

/* An overtake just happened. Only the position cell lights up — washing the
   whole row turned the table into a wall of green whenever the order churned.
   --flash-age carries the age of the change (a custom property, so it reaches
   the cell), letting the animation resume mid-way instead of restarting from
   full brightness every time a feed message re-renders the row. */
body.broadcast tbody tr.moved-up td.c-pos,
body.broadcast tbody tr.moved-down td.c-pos {
  animation-duration: 1.8s; animation-timing-function: ease-out;
  animation-delay: var(--pos-age, 0s);
}
body.broadcast tbody tr.moved-up td.c-pos { animation-name: movedup; }
body.broadcast tbody tr.moved-down td.c-pos { animation-name: moveddown; }
/* a short blink, not a lingering wash: during a fast replay the order churns
   constantly and a slow fade left most of the column tinted all the time */
@keyframes movedup {
  0%, 22% { background: rgba(46,220,122,.5); box-shadow: inset 4px 0 0 var(--green); }
  60%, 100% { background: transparent; box-shadow: none; }
}
@keyframes moveddown {
  0%, 22% { background: rgba(255,59,48,.42); box-shadow: inset 4px 0 0 var(--red); }
  60%, 100% { background: transparent; box-shadow: none; }
}

/* Header keeps its column label, with the rolling session-best info under it.
   The rolling line is taken OUT OF FLOW (the th is already sticky, so it is a
   containing block): while it was in flow, every rotation between label-only,
   a lap time and a car number resized the header and nudged the whole table. */
thead th { padding-bottom: 24px; }
thead th .th-lbl { display: block; }
thead th .th-roll {
  position: absolute; left: 4px; right: 4px; bottom: 5px; margin: 0;
  display: block; max-width: none; height: 15px; line-height: 15px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ══ live track map (Broadcast only) ═══════════════════════════ */
/* A right rail rather than a floating overlay: as an overlay it sat on top of
   the last few cars, and those are exactly the rows nobody wants covered. */
.stage { flex: 1; display: flex; min-height: 0; }
.stage main { flex: 1; min-width: 0; }

.track-panel { display: none; }
body.broadcast .track-panel {
  display: block; width: 320px; flex-shrink: 0; overflow-y: auto;
  padding: 10px 11px 8px; font-family: var(--num);
  background: #0a0d13; border-left: 1px solid var(--line);
}
.tp-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.tp-name { font-size: .82rem; font-weight: 700; letter-spacing: .07em; color: var(--accent-hi); }
.tp-rate {
  font-size: .64rem; font-weight: 800; color: #000; background: var(--accent);
  padding: 0 5px; border-radius: 3px;
}
.tp-meta { font-size: .66rem; letter-spacing: .05em; color: var(--dim); margin-top: 1px; }
.tp-map { display: block; width: 100%; height: auto; margin: 5px 0 3px; }
.tp-line { fill: none; stroke: #3a4353; stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round; }
.tp-sf { stroke: #fff; stroke-width: 1.4; }
.tp-cars .mc circle { stroke: #05070b; stroke-width: .9; }
.tp-cars .mc text { font-weight: 700; text-anchor: middle; letter-spacing: -.1px; }
.tp-cars .mc.lead circle { stroke: #fff; stroke-width: 1.3; }
.tp-cars .mc.mk circle { stroke: #4fc3f7; stroke-width: 1.5; }
.tp-cars .mc.pit { opacity: .35; }
.tp-foot { font-size: .58rem; color: #5d6675; letter-spacing: .02em; }

/* the table needs the width more than the map does on narrow screens */
@media (max-width: 1200px) { body.broadcast .track-panel { display: none; } }
body.broadcast .track-panel[hidden] { display: none; }

/* ══ weather strip (header) ═══════════════════════════════════ */
.wx {
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
  margin-left: auto; padding: 5px 16px; font-family: var(--num);
  border-left: 1px solid var(--line); border-right: 1px solid var(--line);
}
.wx[hidden] { display: none; }
.wx-ico { font-size: 2.5rem; line-height: 1; }
.wx-block { display: flex; flex-direction: column; line-height: 1.15; }
.wx-air { font-size: 2rem; font-weight: 700; color: var(--txt); letter-spacing: .02em; }
.wx-sub { font-size: .98rem; color: #c3ccd8; letter-spacing: .02em; }
.wx-fc {
  font-size: .92rem; color: #b7c0cc; letter-spacing: .02em;
  max-width: 220px; line-height: 1.35;
}
@media (max-width: 1450px) { .wx-fc { display: none; } }
@media (max-width: 1100px) { .wx { display: none; } }

/* hourly forecast, under the track map in the right rail */
.tp-wx { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.tp-wx[hidden] { display: none; }
.tp-wx-title { font-size: .64rem; letter-spacing: .12em; color: var(--dim); text-transform: uppercase; }
.tp-wx-row { display: flex; gap: 2px; margin-top: 5px; }
.tp-wx-cell {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 4px 0; background: #101520; border-radius: 4px; line-height: 1.1;
}
.tp-wx-cell .h { font-size: .6rem; color: var(--dim); }
.tp-wx-cell .i { font-size: .85rem; }
.tp-wx-cell .t { font-size: .72rem; font-weight: 700; }
.tp-wx-cell .p { font-size: .56rem; color: var(--dim); }
.tp-wx-cell .p.wet { color: #4fc3f7; font-weight: 700; }

/* places just taken/lost — bright chip, shown until the car completes a lap */
.move-badge { display: none; }
body.broadcast .move-badge {
  display: inline-block; margin-left: 5px; padding: 0 5px; border-radius: 3px;
  font-family: var(--num); font-size: .68rem; font-weight: 800;
  vertical-align: 1px; letter-spacing: .02em;
}
body.broadcast .move-badge.up { background: var(--green); color: #05210f; }
body.broadcast .move-badge.down { background: var(--red); color: #fff; }

/* ══ lap counter / laps to go ═════════════════════════════════ */
/* The feed never fills F.togo; this is derived from S.TIME_LAP (the race
   distance in laps) minus the leader's lap count. */
.lapcount { font-weight: 700; color: var(--txt); letter-spacing: .05em; font-size: 1.25rem; }
.lapcount .of { color: var(--dim); font-weight: 600; }
.togo-tag {
  margin-left: 9px; padding: 2px 10px; border-radius: 4px;
  background: #2b323e; color: #dfe4ea; font-size: .98rem; font-weight: 800;
  letter-spacing: .07em;
}
.togo-tag.final { background: var(--yellow); color: #191100; animation: flagpulse 1.1s infinite; }
body.broadcast .lapcount { font-size: 1.6rem; }
body.broadcast .togo-tag { background: var(--accent); color: #000; }
body.broadcast .togo-tag.final { background: var(--yellow); color: #191100; }

.tool-link {
  color: var(--dim); font-family: var(--num); font-size: .8rem; letter-spacing: .06em;
  text-decoration: none; border-bottom: 1px solid var(--line); padding-bottom: 1px;
}
.tool-link:hover { color: var(--accent-hi); border-color: var(--accent); }

/* the shared page nav sits with the other toolbar controls */
.sort-box .pnav { margin-right: 12px; }

/* ══ tablet variant ══════════════════════════════════════════
   A tablet gets this table rather than the phone cards, but with touch-sized
   rows and controls. Set by the boot script on <html> from the screen's short
   side, so rotating does not reclassify the device. */
html.tablet tbody td { padding: 11px 6px; font-size: 1rem; }
html.tablet thead th { padding: 11px 6px; font-size: .78rem; }
html.tablet .class-tab { padding: 8px 20px; font-size: .88rem; }
html.tablet .sort-box { gap: 9px; font-size: .84rem; }
html.tablet .sort-box select { padding: 7px 11px; font-size: .88rem; }
html.tablet .pnav a { padding: 9px 17px; font-size: .9rem; }
html.tablet .toolbar { padding: 11px 14px; }
html.tablet .pos-badge { min-width: 46px; font-size: 1.2rem; }
html.tablet td.c-no .no-chip { min-width: 54px; font-size: 1.12rem; }
/* the click/double-click hint is mouse wording; on a tablet it is a tap */
html.tablet .sort-box > span:first-child { display: none; }

/* a tablet has room for the map — the desktop rule hides it under 1200px */
@media (min-width: 820px) {
  html.tablet body.broadcast .track-panel { display: block; width: 280px; }
}
/* and the columns have to give that width back */
html.tablet .c-team { display: none; }
@media (max-width: 1250px) { html.tablet .c-s3, html.tablet .c-s4 { display: none; } }
@media (max-width: 1100px) { html.tablet .c-s2, html.tablet .c-spd { display: none; } }
@media (max-width: 900px)  { html.tablet .c-s1, html.tablet .c-pit { display: none; } }

/* 仮想(理論値)ベスト toggle */
.tool-btn {
  font-family: var(--num); font-size: .8rem; font-weight: 700; letter-spacing: .06em;
  border: 1px solid var(--line); background: var(--panel2); color: var(--dim);
  padding: 4px 12px; border-radius: 4px; cursor: pointer;
}
.tool-btn.active {
  background: linear-gradient(180deg, #7ad7ff, #3fb6e8);
  border-color: #3fb6e8; color: #04121b;
}
td.c-best.t-vb { color: #7ad7ff; font-weight: 700; }
html.tablet .tool-btn { padding: 7px 15px; font-size: .88rem; }

/* tablet: the weather block gets the same uplift as the rest of the table */
html.tablet .wx-air { font-size: 1.5rem; }
html.tablet .wx-sub { font-size: .82rem; }

/* tablet keeps the same uplift, just a shade tighter */
html.tablet .session-name { font-size: 1.5rem; }
html.tablet .session-sub { font-size: .98rem; }
html.tablet body.broadcast .lapcount { font-size: 1.4rem; }

/* ── wide screens: use the extra glass rather than leaving it empty ── */
@media (min-width: 1600px) {
  body.broadcast tbody td { font-size: 1.22rem; padding: 12px 8px; }
  body.broadcast thead th { font-size: .92rem; }
  body.broadcast td.c-driver { font-size: 1.38rem; }
  body.broadcast td.c-team { font-size: 1rem; }
  body.broadcast .pos-badge { font-size: 1.35rem; min-width: 52px; }
  body.broadcast td.c-no .no-chip { font-size: 1.3rem; min-width: 60px; }
  body.broadcast .class-chip { font-size: .88rem; }
  body.broadcast .track-panel { width: 380px; }
  .session-name { font-size: 2rem; }
  .session-sub { font-size: 1.2rem; }
  body.broadcast .lapcount { font-size: 1.85rem; }
  .togo-tag { font-size: 1.1rem; }
  .wx-air { font-size: 2.3rem; }
  .wx-sub { font-size: 1.06rem; }
  .wx-ico { font-size: 2.9rem; }
  .class-tab { font-size: .92rem; padding: 5px 18px; }
  .pnav a { font-size: .95rem; padding: 8px 18px; }
}
/* track-map markers glide between updates rather than jumping */
.tp-cars .mc { transition: transform .28s linear; }
@media (prefers-reduced-motion: reduce) { .tp-cars .mc { transition: none; } }
/* out lap: what the stop just cost, kept until the next lap is completed */
.ol-badge{background:#4a7fb5;color:#04121b;font-family:var(--num);font-size:.68rem;
  font-weight:800;letter-spacing:.06em;padding:1px 6px;border-radius:3px}
.ol-time{font-family:var(--num);font-size:.82rem;color:#9fdcff;font-weight:700}
