/* Themed on the game's own screens: the red menu banner, checker-plate backdrop, blue HUD tabs, yellow key prompts,
   and the in-race minimap. Flat, square-edged, high contrast. */
:root {
  --red: #c8101a;
  --red-dk: #7d0a10;
  --steel-2: #24272c;
  --steel-3: #2e3238;
  --line: #3d424a;
  --text: #f2f3f5;
  --muted: #9ba1ab;
  --yellow: #ffcc00;
  --blue: #1d4fd6;
  --blue-dk: #0b2a86;
  --gold: #ffcc00; --silver: #d6dbe3; --bronze: #d98a4a;
  --map-bg: #a9bcae;
  --cond: 'Barlow Condensed', 'Arial Narrow', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  color: var(--text);
  font: 15px/1.4 Barlow, system-ui, sans-serif;
  background-color: #141619;
  /* checker plate: small raised diamonds */
  background-image:
    repeating-linear-gradient(45deg, rgba(255,255,255,.035) 0 2px, transparent 2px 14px),
    repeating-linear-gradient(-45deg, rgba(0,0,0,.35) 0 2px, transparent 2px 14px),
    linear-gradient(180deg, #202328, #121417 70%);
  background-attachment: fixed;
}
button, select, input { font: inherit; color: inherit; }
.narrow { display: none; }

/* ---------- the red banner (as the game's menu title bar) ---------- */
.banner {
  background: linear-gradient(180deg, #e3141f 0%, var(--red) 55%, var(--red-dk) 100%);
  border-bottom: 3px solid #fff;
  box-shadow: 0 3px 0 #000, 0 8px 18px rgba(0,0,0,.5);
}
.bannerIn { max-width: 1480px; margin: 0 auto; padding: 10px 20px 9px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; flex-direction: column; min-width: 0; }
.brand .jp {
  font: 900 30px/1.05 'Noto Sans JP', sans-serif; letter-spacing: .04em; color: #fff;
  -webkit-text-stroke: 1.5px #000; paint-order: stroke fill; text-shadow: 3px 3px 0 #000;
}
.brand .en { font: italic 700 15px var(--cond); letter-spacing: .12em; text-transform: uppercase; color: #ffe0e0; margin-top: 2px; }
.status { margin-left: auto; display: flex; align-items: center; gap: 12px; font: 600 14px var(--cond); letter-spacing: .06em; text-transform: uppercase; color: #ffe0e0; }

/* yellow key prompt buttons ("[X] OK") */
.key {
  background: #111; color: var(--yellow); border: 2px solid var(--yellow); padding: 4px 14px; cursor: pointer;
  font: italic 800 16px var(--cond); letter-spacing: .08em; text-transform: uppercase;
}
.key:hover:not(:disabled) { background: var(--yellow); color: #111; }
.key:disabled { opacity: .4; cursor: default; }

/* ---------- section tabs (the HUD's slanted labels) ---------- */
.tab {
  display: inline-block; position: relative; padding: 3px 26px 3px 12px; margin-bottom: 8px;
  font: italic 800 17px var(--cond); letter-spacing: .1em; text-transform: uppercase; color: #fff;
  background: linear-gradient(90deg, #3a3f47, #2a2e34);
  clip-path: polygon(0 0, 100% 0, calc(100% - 14px) 100%, 0 100%);
}
.tab-blue { background: linear-gradient(90deg, var(--blue), var(--blue-dk)); padding-right: 34px; }
.count { color: var(--muted); font: 600 14px var(--cond); letter-spacing: .06em; text-transform: uppercase; }

/* ---------- layout ---------- */
.bar { display: none; }
.grid { max-width: 1480px; margin: 18px auto 0; display: grid; grid-template-columns: 230px minmax(0, 1fr) 360px; gap: 18px; padding: 0 20px 16px; align-items: start; }
.grid > *, .side > * { min-width: 0; }
.side { display: flex; flex-direction: column; gap: 18px; }
.courses, .board, .filters, .mapPanel { background: rgba(20, 22, 26, .88); border: 1px solid var(--line); border-top: 3px solid var(--red); padding: 12px; }

/* ---------- course select ---------- */
.courses ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.courses li button {
  width: 100%; text-align: left; cursor: pointer; display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 2px 8px;
  background: var(--steel-2); border: 1px solid var(--line); border-left: 4px solid transparent; padding: 8px 10px;
}
.courses li button:hover { background: var(--steel-3); }
.courses li button .arrow { color: transparent; font-size: 11px; }
.courses li button.on { background: linear-gradient(90deg, var(--red), var(--red-dk)); border-color: #e3141f; border-left-color: var(--yellow); }
.courses li button.on .arrow { color: var(--yellow); }
.courses .cname { font: italic 800 21px/1 var(--cond); letter-spacing: .06em; text-transform: uppercase; }
.courses .kanji { font: 900 15px 'Noto Sans JP', sans-serif; color: var(--muted); }
.courses li button.on .kanji { color: #ffd6d6; }
.courses .cmeta { grid-column: 2 / 4; font-size: 12px; color: var(--muted); }
.courses li button.on .cmeta { color: #ffe0e0; }
.courses .hit { color: var(--yellow); font-weight: 600; }

/* ---------- ranking table ---------- */
.boardHead { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tableWrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 6px 10px; font: italic 700 13px var(--cond); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); border-bottom: 2px solid var(--line); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid #2a2d33; white-space: nowrap; }
tbody tr { cursor: pointer; }
tbody tr:nth-child(even) td { background: rgba(255,255,255,.025); }
tbody tr:hover td { background: rgba(255,255,255,.06); }
tbody tr.sel td { background: rgba(29, 79, 214, .16); }
.c-map { width: 44px; text-align: center; } td.c-map { text-align: center; }
.c-rank { width: 56px; }
td.c-rank { font: italic 800 22px/1 var(--cond); color: var(--muted); }
tr.r1 td.c-rank { color: var(--gold); } tr.r2 td.c-rank { color: var(--silver); } tr.r3 td.c-rank { color: var(--bronze); }
td.c-rank .ord { font-size: 13px; margin-left: 1px; vertical-align: 6px; }
td.c-time { font: italic 800 22px/1 var(--cond); letter-spacing: .04em; font-variant-numeric: tabular-nums; color: #fff; }
tr.r1 td.c-time { color: var(--yellow); }
td.c-gap { font: italic 700 16px var(--cond); color: #ff7b7b; font-variant-numeric: tabular-nums; }
td.c-car { font: 600 14px var(--cond); letter-spacing: .04em; color: #c9ced6; text-transform: uppercase; }
td.c-date { color: var(--muted); font-size: 13px; }
.who { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.who .pic { width: 72px; height: 40px; flex: none; background-color: #0d0e10; border: 1px solid var(--line); background-size: 400% 300%; background-repeat: no-repeat; }
.who .ph { width: 72px; height: 40px; flex: none; border: 1px dashed #33373e; }
.badge { font: italic 700 11px var(--cond); letter-spacing: .08em; text-transform: uppercase; padding: 1px 6px; background: var(--blue); color: #fff; }
.swatch { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border: 1px solid #000; }
.empty { color: var(--muted); padding: 24px 6px; font: italic 700 18px var(--cond); letter-spacing: .06em; text-transform: uppercase; }
input[type=checkbox] { accent-color: var(--yellow); width: 16px; height: 16px; cursor: pointer; }

/* ---------- search / filters ---------- */
.fBody { display: grid; gap: 9px; }
.filters input[type=search], .filters select, .player select {
  width: 100%; background: #0e0f12; border: 1px solid var(--line); padding: 7px 10px; border-radius: 0;
}
.filters input[type=search]:focus, .filters select:focus { outline: 2px solid var(--yellow); outline-offset: -1px; }
.row { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 8px; }
.lbl { font: italic 700 14px var(--cond); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.seg { display: flex; border: 1px solid var(--line); }
.seg button { flex: 1; background: #0e0f12; border: 0; padding: 6px 8px; cursor: pointer; font: italic 700 15px var(--cond); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: linear-gradient(180deg, #e3141f, var(--red-dk)); color: #fff; }
.seg button.none:not(.on) { opacity: .35; }
.check { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; cursor: pointer; }
select option { background: #16181c; }

/* ---------- course map: the in-race minimap ---------- */
.mapHead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mapBox { position: relative; background: var(--map-bg); border: 3px solid #111; outline: 1px solid #5c6b61; }
.mapHud, .mapHint { display: none; }
#map { width: 100%; aspect-ratio: 1 / 1; display: block; cursor: pointer; }
.player { display: grid; grid-template-columns: auto 64px 1fr auto; align-items: center; gap: 8px; margin-top: 10px; }
.player input[type=range] { width: 100%; accent-color: var(--yellow); }
.clock { font: italic 800 20px var(--cond); font-variant-numeric: tabular-nums; min-width: 82px; text-align: right; }
.legend { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.legend li { display: flex; justify-content: space-between; gap: 8px; }
.legend .gapnow { font: italic 700 15px var(--cond); color: var(--muted); font-variant-numeric: tabular-nums; }

.foot { max-width: 1480px; margin: 0 auto; color: var(--muted); font-size: 12px; padding: 4px 20px 24px; display: flex; gap: 10px; flex-wrap: wrap; }
.foot a { color: var(--yellow); }
.scrim { display: none; }
.mapToggle { display: none; }

/* ---------- driver profile ---------- */
.nameBtn { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: inherit; cursor: pointer; text-align: left; }
.nameBtn:hover { color: var(--yellow); text-decoration: underline; text-underline-offset: 3px; }
.profScrim { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6); }
.prof {
  position: fixed; z-index: 60; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow-y: auto;
  background: #15171b; border: 1px solid var(--line); border-top: 4px solid var(--red); padding: 14px 16px 16px; box-shadow: 0 20px 60px rgba(0,0,0,.7);
}
.profScrim[hidden], .prof[hidden] { display: none; }
.profTop { display: flex; align-items: flex-start; justify-content: space-between; }
.profClose { background: none; border: 0; color: var(--muted); font-size: 30px; line-height: 1; cursor: pointer; padding: 0 4px; }
.profClose:hover { color: #fff; }
.profClose:focus:not(:focus-visible) { outline: none; }
.profCar { width: 100%; aspect-ratio: 192 / 108; background-color: #0d0e10; background-size: 400% 300%; background-repeat: no-repeat; border: 1px solid var(--line); cursor: grab; touch-action: pan-y; }
.profCar.none { display: grid; place-items: center; color: var(--muted); font: italic 700 16px var(--cond); letter-spacing: .08em; text-transform: uppercase; cursor: default; }
.profId { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 12px; margin-top: 12px; }
.profId h3 { margin: 0; font: italic 800 30px/1 var(--cond); letter-spacing: .04em; }
.profTags { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.profTags a, .profTags span { font: italic 700 12px var(--cond); letter-spacing: .08em; text-transform: uppercase; padding: 2px 7px; text-decoration: none; }
.profTags .steam { background: var(--blue); color: #fff; }
.profTags .discord { background: #2b2f6b; color: #d6dafe; text-transform: none; letter-spacing: .02em; }
.profTags .id { background: #24272c; color: var(--muted); text-transform: none; }
.profBio { margin: 10px 0 0; color: #d3d7de; white-space: pre-wrap; }
.profBio:empty { display: none; }
.profStats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.profStats div { background: #1d2024; border: 1px solid var(--line); padding: 8px 10px; min-width: 0; }
.profStats dt { font: italic 700 12px var(--cond); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.profStats dd { margin: 2px 0 0; font: italic 800 18px/1.15 var(--cond); letter-spacing: .03em; overflow-wrap: anywhere; }
.profTimes { width: 100%; }
.profTimes td { padding: 7px 8px; }
.profTimes tr { cursor: pointer; }
.profTimes .pc { font: italic 800 17px var(--cond); text-transform: uppercase; letter-spacing: .04em; white-space: normal; }
.profTimes .pp { font: italic 800 19px var(--cond); color: var(--muted); width: 44px; }
.profTimes .pt { font: italic 800 19px var(--cond); text-align: right; font-variant-numeric: tabular-nums; }
.profTimes .pg { font: italic 700 14px var(--cond); color: #ff7b7b; text-align: right; width: 70px; }
.profTimes tr.p1 .pp { color: var(--gold); }

@media (max-width: 1100px) {
  .grid { grid-template-columns: 210px minmax(0, 1fr); }
  .side { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

/* ---------- phones: banner, [Change course] [Options], ranking; courses slide in from the left; map floats ---------- */
@media (max-width: 720px) {
  .bannerIn { padding: 8px 12px; gap: 10px; }
  .brand .jp { font-size: 22px; -webkit-text-stroke-width: 1px; text-shadow: 2px 2px 0 #000; }
  .brand .en { font-size: 12px; letter-spacing: .08em; }
  .status, .wide { display: none; }
  .narrow { display: inline; }
  .mapToggle {
    display: flex; align-items: center; gap: 6px; margin-left: auto; flex: none; cursor: pointer;
    font: italic 800 15px var(--cond); letter-spacing: .08em; text-transform: uppercase; color: #fff;
    background: rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.5); padding: 4px 8px;
  }
  .bar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px 12px 0; }
  .barBtn {
    display: flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 8px; cursor: pointer;
    background: #0e0f12; border: 2px solid var(--yellow); color: var(--yellow);
    font: italic 800 17px var(--cond); letter-spacing: .08em; text-transform: uppercase;
  }
  .barBtn .tri { font-size: 11px; font-style: normal; }
  #optBar[aria-expanded=true] { background: var(--yellow); color: #111; }
  .grid { grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 0 12px 16px; margin-top: 10px; }
  .side { display: contents; }
  .filters { order: 1; display: none; }
  body.opts .filters { display: block; }
  .board { order: 2; padding: 10px 8px; }
  .c-date, .c-gap, .c-car, .c-map { display: none; }
  .who .pic, .who .ph { display: none; }
  td { padding: 10px 8px; }
  td.c-time { font-size: 21px; }
  /* the course list: a drawer from the left */
  .courses {
    position: fixed; z-index: 40; top: 0; left: 0; bottom: 0; width: min(80vw, 300px); overflow-y: auto;
    border-top: 0; border-right: 3px solid var(--red); padding: 16px 12px;
    transform: translateX(-105%); transition: transform .2s ease-out; background: #15171b;
  }
  body.drawer .courses { transform: none; box-shadow: 10px 0 30px rgba(0,0,0,.6); }
  .scrim { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.55); }
  body.drawer .scrim { display: block; }
  /* the map: a small minimap over the ranking, bottom right */
  .mapPanel { display: none; position: fixed; right: 12px; bottom: 12px; z-index: 20; width: min(46vw, 210px); padding: 0; border: 0; background: none; box-shadow: 0 8px 24px rgba(0,0,0,.6); }
  body.mapon .mapPanel { display: block; }
  .mapHead, .player, .legend { display: none; }
  .mapHud { display: flex; align-items: center; gap: 6px; position: absolute; left: 4px; top: 4px; background: rgba(0,0,0,.78); padding: 2px 6px 2px 2px; pointer-events: none; }
  .mapHud button { pointer-events: auto; width: 26px; height: 24px; padding: 0; border: 0; background: var(--yellow); color: #111; font-size: 12px; cursor: pointer; }
  .mapHud span { font: italic 800 14px var(--cond); color: #fff; font-variant-numeric: tabular-nums; }
  .mapHint:not([hidden]) { display: block; position: absolute; right: 0; bottom: calc(100% + 10px); width: 220px; padding: 8px 10px;
    background: var(--yellow); color: #111; font: 600 13px/1.35 Barlow, sans-serif; box-shadow: 0 6px 16px rgba(0,0,0,.5); }
  .mapHint::after { content: ''; position: absolute; right: 24px; top: 100%; border: 8px solid transparent; border-top-color: var(--yellow); }
  .foot { padding: 4px 12px 20px; }
  .prof { top: auto; bottom: 0; left: 0; transform: none; width: 100%; max-height: 88vh; border-left: 0; border-right: 0; }
  .profStats dd { font-size: 16px; }
  .profTimes .pg { display: none; }
  body.mapon .foot { padding-bottom: 250px; }
}
