:root {
  --tour-ink: #e9f2f3;
  --tour-muted: #a9bac3;
  --tour-accent: #aaf475;
  --tour-dark: #10191e;
  --tour-edge: #ffffff26;
}
html, body { background: #111b21; overflow: hidden; }
body, button, input, select { font-family: Inter, "Segoe UI", Arial, sans-serif; }
.apex { color: var(--tour-ink); font-size: clamp(12px, 1.52vmin, 17px); inset: 0; }
.apex *, .apex *::before, .apex *::after { box-sizing: border-box; }
.apex button, .apex a { -webkit-tap-highlight-color: transparent; }
.apex button:focus-visible, .apex a:focus-visible { outline: 2px solid var(--tour-accent); outline-offset: 3px; }
.apex p { margin: 0; }
.apex button:disabled { opacity: .46; cursor: default; }
.apex .tour-top {
  position: absolute;
  inset: max(14px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) auto max(22px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 2;
  pointer-events: none;
}
.tour-brand { font-size: .88em; font-weight: 800; letter-spacing: .19em; white-space: nowrap; }
.tour-brand small { color: var(--tour-accent); font-size: .88em; margin-left: 4px; }
.tour-section { text-align: center; font-weight: 750; white-space: nowrap; }
.tour-stats { display: flex; align-items: center; gap: 14px; white-space: nowrap; font-size: .92em; }
.tour-stats span { color: var(--tour-muted); }
.tour-stats b, .tour-credit { color: var(--tour-accent); font-size: .92em; }
#tour-menu, #tour-event, #tour-garage, #tour-licenses {
  background: linear-gradient(90deg, rgba(8,14,19,.95), rgba(8,14,19,.77) 42%, rgba(8,14,19,.14) 78%),
    linear-gradient(180deg, #0b151dc9, transparent 28%, transparent 72%, #0a1119cf);
}
#tour-menu {
  background: linear-gradient(90deg, #081119f0 0%, #09141dbf 36%, #0a141d15 70%),
    linear-gradient(180deg, #09131bbf, transparent 25%, transparent 70%, #0a141dbf),
    url("assets/ui/cover.webp") 66% center / cover no-repeat #101b24;
}
.tour-home, .tour-page {
  position: absolute;
  inset: max(56px, calc(env(safe-area-inset-top) + 42px)) 0 max(12px, env(safe-area-inset-bottom));
  padding: 14px 5.4vw 18px;
  overflow: auto;
  scrollbar-width: thin;
  pointer-events: auto;
}
.tour-home { display: grid; align-content: center; justify-items: start; }
.tour-hero { width: min(38em, 58vw); }
.tour-hero h1 { margin: 0; }
.tour-logo { display: block; width: 100%; height: auto; filter: drop-shadow(0 8px 20px #050c19a8); }
.tour-icon { width: 1.42em; height: 1.42em; object-fit: contain; flex: none; vertical-align: middle; }
.tour-modes { display: grid; gap: 8px; width: min(39em, 58vw); grid-template-columns: 1fr 1fr; margin: 24px 0 18px; }
.tour-mode, .tour-license, .tour-car, .tour-chip, .tour-plain, .tour-link, .tour-primary {
  border: 1px solid var(--tour-edge);
  background: #18262de8;
  color: var(--tour-ink);
  min-height: 44px;
  cursor: pointer;
  font-weight: 700;
  transition: background .16s, border-color .16s, color .16s;
  border-radius: 5px;
}
.tour-mode:hover, .tour-license:hover:not(:disabled), .tour-car:hover, .tour-chip:hover,
.tour-plain:hover, .tour-link:hover { border-color: #aaf47580; background: #2c4037; }
.tour-mode {
  min-height: 69px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  text-align: left;
  padding: 10px;
}
.tour-mode .tour-mode-art { width: 44px; height: 44px; }
.tour-mode .tour-mode-arrow { width: 15px; height: 15px; }
.tour-mode strong, .tour-license strong, .tour-car strong { display: block; font-size: 1.05em; }
.tour-mode small, .tour-license small, .tour-car small {
  display: block;
  margin-top: 4px;
  font-weight: 500;
  font-size: .86em;
  color: var(--tour-muted);
  line-height: 1.25;
}
.tour-links, .tour-actions, .tour-choices { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tour-plain, .tour-link, .tour-primary, .tour-chip {
  padding: 9px 13px;
  font-size: .97em;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: .5em;
  text-decoration: none;
}
.tour-link { background: #1b282fc4; pointer-events: auto; }
.tour-plain { background: #17242baf; }
.tour-primary { background: var(--tour-accent); color: #14231a; border-color: var(--tour-accent); padding-inline: 19px; }
.tour-primary:hover:not(:disabled) { background: #cdffa8; }
.tour-primary [data-art="car"], .tour-primary [data-art="retry"] { filter: brightness(.2); }
.tour-chip.selected, .tour-car.selected { color: var(--tour-accent); border-color: var(--tour-accent); background: #254031; }
.tour-page { display: flex; align-items: safe center; }
.tour-shade {
  width: min(40em, 100%);
  background: #10191ef0;
  border: 1px solid var(--tour-edge);
  border-left: 3px solid #aaf475b0;
  box-shadow: 0 22px 65px #02080a4f;
  border-radius: 3px 7px 7px 3px;
  padding: clamp(15px, 2.8vw, 29px);
  margin-block: auto;
}
.tour-shade h1, .tour-shade h2 { margin: 0 0 .34em; font-style: italic; font-weight: 850; line-height: 1; letter-spacing: -.035em; }
.tour-shade h1 { font-size: clamp(2.2em, 4.7vmin, 3.5em); }
.tour-shade h2 { font-size: 2.2em; }
.tour-shade p { color: var(--tour-muted); line-height: 1.48; }
.tour-shade .tour-sub { color: var(--tour-accent); font-size: .89em; font-weight: 750; margin-bottom: 7px; }
.tour-options { display: grid; gap: 7px; margin: 17px 0; }
.tour-options > label { color: var(--tour-muted); font-weight: 650; }
.tour-hint { color: var(--tour-muted); font-size: .92em; line-height: 1.4; margin: 5px 0 8px; }
.tour-hint kbd { background: #2d3b46; border: 1px solid #64758370; border-radius: 4px; padding: 1px 4px; color: #fff; }
.tour-summary { display: flex; justify-content: space-between; gap: 8px; padding: 10px 0; border-top: 1px solid var(--tour-edge); color: var(--tour-muted); }
.tour-summary b { color: var(--tour-ink); font-variant-numeric: tabular-nums; }
.tour-actions { margin-top: 12px; }
.tour-license-group { display: grid; gap: 5px; margin-top: 12px; }
.tour-license-group h2 { font-style: normal; font-size: 1em; color: var(--tour-muted); margin: 3px 0 2px; }
.tour-license {
  display: grid;
  grid-template-columns: 2.2em minmax(0,1fr) auto;
  align-items: center;
  gap: 8px;
  text-align: left;
  min-height: 53px;
  padding: 7px 10px;
}
.tour-license-no { color: var(--tour-accent); }
.tour-medal { display: flex; align-items: center; gap: .3em; color: var(--tour-muted); font-size: .83em; }
.tour-medal img { width: 1.5em; height: 1.5em; }
.tour-medal.gold { color: #ffd879; }
.tour-medal.silver { color: #ccdfea; }
.tour-medal.bronze { color: #f0ab72; }
.tour-cars { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 18px 0; }
.tour-car { display: flex; align-items: center; gap: 8px; min-height: 56px; text-align: left; padding: 8px 10px; }
.tour-car .tour-icon { width: 1.8em; height: 1.8em; }
.tour-dialog {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 12px;
  background: #0b1319bd;
  pointer-events: auto;
}
.tour-dialog .tour-shade { width: min(37em, 100%); max-height: calc(100dvh - 24px); overflow: auto; }
.tour-dialog label { display: flex; justify-content: space-between; gap: 12px; align-items: center; min-height: 38px; }
.tour-setting-label, .tour-result-title { display: flex; gap: .5em; align-items: center; }
.tour-dialog select {
  appearance: none;
  background: url("assets/ui/down.webp") right 6px center / 16px 16px no-repeat #1c2c36;
  color: var(--tour-ink);
  border: 1px solid var(--tour-edge);
  padding: 6px 28px 6px 8px;
}
.tour-dialog input { max-width: 45%; accent-color: #aaf475; }
.tour-shade .tour-pb { color: var(--tour-accent); margin: 0 0 8px; }
#tour-pause, #tour-result { z-index: 23; }
#tour-settings { z-index: 25; }
#sdk-guard { position: fixed; inset: 0; background: #0a12192b; pointer-events: none; z-index: 100; }
#sdk-guard[hidden] { display: none; }
#tour-shift {
  display: flex; position: absolute; right: calc(var(--touch-edge, 14px) + var(--pedal-size, 64px) + 10px); bottom: calc(var(--touch-floor, 18px) + var(--pedal-size, 64px) + 8px); z-index: 15;
  pointer-events: auto; touch-action: none; color: var(--tour-ink); background: #142027dd;
}
#tour-shift.selected { background: var(--tour-accent); color: #13261a; }
#tour-shift.selected .tour-icon { filter: brightness(.23); }
#tour-shift[hidden], body:has(.apex.on .tour-dialog) #tour-shift,
body:not(:has(#hud.on)) #tour-shift, body:not(:has(#touch.on)) #tour-shift { display: none; }
#loading.apex { z-index: 40; background: #101a21; }
.tour-loading { height: 100%; display: grid; place-content: center; width: 100%; padding: 6vw; }
.tour-loading .tour-hero { margin: 25px 0 4px; width: min(525px, 85vw); }
.tour-load-track { height: 4px; width: 100%; background: #2a4049; overflow: hidden; margin: 14px 0 10px; }
.tour-load-track i { display: block; width: 0; height: 100%; background: var(--tour-accent); transition: width .15s; }
#ldt { color: var(--tour-muted); }
#hud .en, #hud .ps { color: #f1f6f8; }
#hud .ob, #hud .tm { color: #aaf475; }
#hud.on #mm { background: #101b23c9; border-color: #c6e5e44d; }
#hud .br2 .ni, #hud .br2 .hp { opacity: .7; }
#hud .keys { opacity: .82; }
.hud-label-art, .hud-control-art { width: 1.15em; height: 1.15em; vertical-align: -.19em; object-fit: contain; }
.hud-control-art { width: 62%; height: 62%; pointer-events: none; }
#hud .tm:not(:empty)::before, #hud .ob.wrong::before {
  content: "";
  display: inline-block;
  width: .85em;
  height: .85em;
  margin-right: .25em;
  background: url("assets/ui/timer.webp") center / contain no-repeat;
}
#hud .ob.wrong::before { background-image: url("assets/ui/warning.webp"); }
#hud .hbtn {
  display: grid;
  place-items: center;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  width: clamp(40px, 3.2em, 52px);
  height: clamp(40px, 3.2em, 52px);
  padding: 0;
}
#hud .hbtn .hud-control-art { width: 58%; height: 58%; }
#hud .keys .hud-label-art { width: .95em; height: .95em; }
.tour-hidden-meter, body:not([data-apex-mode="drag"]) #hud .drag-key { display: none; }
body[data-apex-mode] #touch [data-k="n"], body[data-apex-mode="drag"] #touch [data-k="h"] { display: none; }
body:has(#touch.on) {
  --touch-side: clamp(11px, 3vw, 24px);
  --touch-edge: max(var(--touch-side), env(safe-area-inset-right));
  --touch-left: max(var(--touch-side), env(safe-area-inset-left));
  --touch-floor: max(13px, calc(env(safe-area-inset-bottom) + 6px));
  --pedal-size: clamp(56px, 13vmin, 84px);
}
#touch .tb {
  width: var(--pedal-size);
  height: var(--pedal-size);
  bottom: var(--touch-floor);
  border-color: #e0eff397;
  background: #101c28bc;
  color: #f4fbff;
  padding: 0;
  gap: 1px;
  flex-direction: column;
  touch-action: none;
  user-select: none;
}
#touch .tb.p { background: #234936d9; border-color: #b6fa77a6; }
#touch .tb:has(span) .hud-control-art { width: 44%; height: 44%; }
#touch .tb span { font: 700 clamp(8px, 1.9vmin, 12px)/1 Arial, sans-serif; letter-spacing: .05em; pointer-events: none; }
#touch [data-k="l"] { left: var(--touch-left); }
#touch [data-k="r"] { left: calc(var(--touch-left) + var(--pedal-size) + 8px); }
#touch [data-k="g"] { right: var(--touch-edge); }
#touch [data-k="b"] { right: calc(var(--touch-edge) + var(--pedal-size) + 8px); }
#touch [data-k="h"] {
  right: var(--touch-edge);
  bottom: calc(var(--touch-floor) + var(--pedal-size) + 8px);
  width: calc(var(--pedal-size) * .9);
  height: calc(var(--pedal-size) * .9);
}
#touch [data-k="n"] {
  right: var(--touch-edge);
  bottom: calc(var(--touch-floor) + var(--pedal-size) * 2 + 16px);
}
body:has(#touch.on) #hud #mm {
  left: auto;
  bottom: auto;
  right: var(--touch-edge);
  top: max(59px, calc(env(safe-area-inset-top) + 52px));
  width: clamp(62px, 17vmin, 104px);
  height: clamp(62px, 17vmin, 104px);
}
body:has(#touch.on) #hud .br2 {
  bottom: auto;
  top: max(68px, calc(env(safe-area-inset-top) + 61px));
  right: auto;
  left: var(--touch-left);
  width: min(28vw, 110px);
  padding: 6px 7px;
  background: #101b28ba;
  border: 1px solid #e0eff34d;
  border-radius: 7px;
  text-align: left;
}
body:has(#touch.on) #hud .bl { color: #edf7fe; }
body:has(#touch.on) #hud .spd { font-size: clamp(20px, 5vmin, 36px); }
body:has(#touch.on) #hud .tl { max-width: 39vw; top: max(10px, env(safe-area-inset-top)); left: var(--touch-left); }
body:has(#touch.on) #hud .tc { inset: max(10px, env(safe-area-inset-top)) 36% auto; }
body:has(#touch.on) #hud .ps { font-size: clamp(16px, 5vmin, 32px); }
body:has(#touch.on) #hud .tm { font-size: clamp(13px, 3.8vmin, 24px); }
@media (max-width: 690px) {
  .apex .tour-top { right: 13px; left: 13px; }
  .tour-home, .tour-page { padding-inline: 14px; }
  .tour-hero { width: min(36em, 100%); }
  .tour-modes { width: min(36em, 100%); margin: 15px 0 14px; }
  .tour-mode { grid-template-columns: 33px minmax(0, 1fr) auto; gap: 6px; padding: 8px; }
  .tour-mode .tour-mode-art { width: 32px; height: 32px; }
  .tour-mode .tour-mode-arrow { width: 11px; height: 11px; }
  .tour-stats { gap: 8px; }
}
@media (orientation: portrait) {
  #tour-event, #tour-garage, #tour-licenses {
    background: linear-gradient(0deg, #0b151df5, #0b151dc9 50%, #0b151d2e 87%, #0b151de0);
  }
  #tour-menu {
    background: linear-gradient(0deg, #08121bf7 4%, #091621 36%, #09162100 76%, #0a141d91 100%),
      url("assets/ui/cover.webp") 75% top / auto 72% no-repeat #08121b;
  }
  .tour-home { align-content: end; padding-bottom: max(24px, env(safe-area-inset-bottom)); }
  .tour-hero { width: min(36em, 100%); }
  .tour-page { align-items: safe end; }
  .tour-page .tour-shade { margin-block: auto 8px; }
}
@media (max-height: 440px) and (orientation: landscape) {
  .tour-home { grid-template-columns: .9fr 1.1fr; gap: 7px 24px; }
  .tour-hero { grid-row: 1 / span 2; align-self: center; width: 100%; }
  .tour-modes { width: 100%; margin: 0; }
  .tour-mode { min-height: 52px; }
  .tour-links { justify-content: end; }
  .tour-shade { margin-block: 0; }
}
