@import url('https://fonts.googleapis.com/css2?family=Titillium+Web:wght@600;700;900&family=Inter:wght@400;500;600;700&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0D1117; --panel: #161B22; --panel2: #1F2630; --line: #2A313C;
  --text: #E6EDF3; --muted: #8B949E; --accent: #F97316;
  --up: #3FB950; --down: #F85149; --flat: #8B949E;
}

body {
  background: var(--bg); color: var(--text); font-family: 'Inter', sans-serif;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 960px; margin: 0 auto; padding: 28px 20px 60px; }

.brand { font-family: 'Titillium Web'; font-weight: 700; font-size: 22px; letter-spacing: .3px; }
.brand span { color: var(--accent); }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }

.search-box { display: flex; gap: 8px; margin: 24px 0; }
.search-box input {
  flex: 1; background: var(--panel); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 12px 14px; font-size: 15px; font-family: inherit;
}
.search-box input:focus { outline: none; border-color: var(--accent); }
.search-box button {
  background: var(--accent); border: none; color: #1a1005; font-weight: 700;
  border-radius: 10px; padding: 0 20px; cursor: pointer; font-size: 15px;
}
.search-box button:disabled { opacity: .6; cursor: default; }

.hint { color: var(--muted); font-size: 13px; margin-top: -14px; margin-bottom: 8px; }

/* Standalone note (e.g. the "saved history" disclaimer) — unlike .hint above, this isn't
   pulled tight underneath a specific control, so it needs normal (non-negative) spacing. */
.disclaimer { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 8px 0 14px; }

.spinner {
  display: inline-block; width: 13px; height: 13px; vertical-align: -2px;
  border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.results { display: flex; flex-direction: column; gap: 8px; }
.result-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 16px; cursor: pointer;
}
.result-row:hover { border-color: var(--accent); }
.result-row .name { font-weight: 600; }
.result-row .id { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.state { color: var(--muted); padding: 20px 0; }
.state.error { color: var(--down); }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 24px 26px; margin-bottom: 20px;
}

/* Driver hero */
.hero { display: flex; gap: 22px; align-items: stretch; }
.posbox {
  min-width: 132px; border-radius: 16px; background: linear-gradient(160deg, var(--panel2), var(--panel));
  border: 1px solid var(--line); border-left: 5px solid var(--accent);
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 14px 10px;
}
.posbox .label { font-size: 12px; letter-spacing: 2px; color: var(--muted); text-transform: uppercase; }
.posbox .pnum { font-family: 'Titillium Web'; font-weight: 900; font-size: 42px; line-height: 1; color: var(--accent); }
.posbox .pclass { font-size: 13px; color: var(--muted); margin-top: 4px; }
.herometa { flex: 1; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.herometa .name { font-family: 'Titillium Web'; font-weight: 700; font-size: 30px; line-height: 1.05; }
.herometa .sub { font-size: 14px; color: var(--muted); margin-top: 4px; }

/* Mobile-friendly fallback; matched to the Discord card's fixed 4/5-column grid at
   desktop widths via .cols-4 / .cols-5 below. */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin-top: 20px; }
.tile { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 12px 11px; }
.tile .t { font-size: 11px; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }
.tile .v { font-family: 'Titillium Web'; font-weight: 700; font-size: 22px; margin-top: 5px; line-height: 1.1; }
.tile .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile.wide3 { grid-column: span 3; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tile.wide3 .v { font-size: 16px; }
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--flat); }
.tile .sub.up { color: var(--up); } .tile .sub.down { color: var(--down); } .tile .sub.flat { color: var(--flat); }

@media (min-width: 620px) {
  .tiles.cols-4 { grid-template-columns: repeat(4, 1fr); }
  .tiles.cols-5 { grid-template-columns: repeat(5, 1fr); }
}

.chips-label { display: flex; align-items: center; gap: 8px; }
.chips-label .loadStatus { display: flex; align-items: center; }
.chips-label .loadStatus:empty { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; font-size: 13px; cursor: pointer; transition: border-color .15s, background .15s; }
.chip:hover { border-color: var(--accent); }
.chip.primary { border-color: var(--accent); background: rgba(249, 115, 22, 0.14); }
.chip b { color: var(--muted); font-weight: 500; margin-right: 5px; }

.section-title { margin: 24px 0 8px; font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }

.charts { display: flex; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.charts svg { flex: 1; min-width: 280px; height: auto; }

/* On narrow viewports the race tables scroll horizontally instead of squeezing columns down
   into wrapped, multi-line cells — min-width forces the table to keep its natural layout so
   overflow-x on the wrapper is what handles the narrow screen, not the table itself reflowing.
   At the app's own max width (960px), fixed layout + these widths comfortably sum to under
   that, so the Safety column never needs a scroll to reach — long series/track/car names
   truncate with an ellipsis (see .truncate) instead of stretching the table wider. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.race-table { table-layout: fixed; width: 100%; min-width: 800px; }
.race-table col.c-date { width: 100px; }
.race-table col.c-track { width: 260px; }
.race-table col.c-car { width: 150px; }
.race-table col.c-pos { width: 55px; }
.race-table col.c-inc { width: 45px; }
.race-table col.c-rating { width: 70px; }

/* Full field-standings table on the race report page (every driver, not just the tracked one). */
.field-table { table-layout: fixed; width: 100%; min-width: 760px; }
.field-table col.c-pos { width: 40px; }
.field-table col.c-driver { width: 190px; }
.field-table col.c-car { width: 150px; }
.field-table col.c-startfinish { width: 55px; }
.field-table col.c-inc { width: 45px; }
.field-table col.c-laps { width: 55px; }
.field-table col.c-rating { width: 75px; }
.field-table tr.tracked-row td { background: rgba(249, 115, 22, 0.08); }
.field-table tr.tracked-row td:first-child { border-left: 2px solid var(--accent); }
.field-table .name-line { font-weight: 600; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th.num, td.num { text-align: right; }
td { font-size: 13.5px; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tr.raceRow { cursor: pointer; }
tr.raceRow:hover td { background: var(--panel2); }
.idtext { color: var(--muted); font-variant-numeric: tabular-nums; }

/* Long series/track names truncate instead of forcing a fixed-width column wider than its
   allotted space — full text is still available via the title tooltip. */
.truncate { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Car names wrap onto a second line instead of truncating — same idea as the Date/Series-Track
   columns already having two lines, just via natural wrap instead of an explicit line break. */
.wrap-text { white-space: normal; overflow-wrap: break-word; line-height: 1.3; }

.loadmore { display: block; margin: 14px auto 0; background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 8px 18px; cursor: pointer; font-size: 13px; }
.loadmore:hover:not(:disabled) { border-color: var(--accent); }
.loadmore:disabled { opacity: .5; cursor: default; }

/* Race card */
.race-hero { display: flex; gap: 22px; align-items: stretch; }
.race-hero .medal { font-size: 30px; }
.race-hero .series { font-weight: 600; font-size: 18px; margin-top: 8px; }
.race-hero .track { font-size: 14px; color: var(--muted); margin-top: 3px; }

.carphoto { margin-top: 18px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); height: 220px; position: relative; background: var(--panel); }
.carphoto img { width: 100%; height: 100%; object-fit: cover; object-position: center 55%; display: block; }
.carphoto .carphoto-tag { position: absolute; left: 12px; bottom: 10px; background: rgba(13,17,23,0.72); backdrop-filter: blur(2px); border-radius: 8px; padding: 5px 11px; font-size: 13px; font-weight: 700; color: var(--text); }
.carphoto .carphoto-tag .carnum { color: var(--accent); font-weight: 800; }

/* Non-interactive info pills (split/weather/etc) — visually matches .chip but not clickable. */
.strip { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.strip .tag { background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; font-size: 13px; color: var(--text); }
.strip .tag b { color: var(--muted); font-weight: 500; margin-right: 5px; }

.roster { margin-top: 8px; }
.roster .row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.roster .row:last-child { border-bottom: none; }
.roster .row.tracked b { color: var(--accent); }

.footer-note { color: var(--muted); font-size: 12px; margin-top: 24px; text-align: center; }
