:root {
  --accent: #ffb300;
  --accent-2: #ff5722;
  --bg: #0e1320;
  --panel: rgba(16, 22, 38, 0.82);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  /* Branded bezel: a warm-dark tone (echoing the gold UI) so any device
     safe-area strip the scene can't fill reads as an intentional frame rather
     than a dead black bar. Solid so it looks the same on whichever edge the
     strip lands. */
  background: #241c0c;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  color: #fff;
  overscroll-behavior: none;
}

/* Stage is sized/rotated by JS (layoutStage) so the game always presents in
   landscape. Its transform makes it the containing block for the fixed-
   positioned canvas, HUD and overlays inside it. */
#stage {
  position: fixed;
  top: 0;
  left: 0;
  transform-origin: center center;
  overflow: hidden;
  background: #0e1320;
}

/* Absolute (not fixed) so they're positioned against the rotated #stage —
   Safari positions `fixed` elements against the viewport even inside a
   transformed ancestor, which caused the canvas to be cut off / leave a gap. */
#game,
#game canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hidden {
  display: none !important;
}

/* ===== Overlays ===== */
/* Menu cinematic cross-fade: a snapshot of the previous biome, stretched over
   the canvas (z below the menu cards) and faded out to dissolve into the next
   biome. No dip to black. */
#menu-xfade {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 40;
  opacity: 0;
  pointer-events: none;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, #1b2540, #070a12 80%);
  padding: 10px;
  text-align: center;
}

/* The main menu and its sub-screens float over the LIVE 3D world (a slow camera
   orbit renders behind), so darken it just enough for legibility instead of
   hiding it. */
#menu,
#howto,
#settings,
#install-help,
#track-panel {
  background: radial-gradient(circle at 50% 42%, rgba(7, 10, 18, 0.12), rgba(6, 9, 16, 0.7) 95%);
}

.menu-card {
  background: var(--panel);
  border: 2px solid rgba(255, 179, 0, 0.4);
  border-radius: 18px;
  padding: 16px 22px;
  max-width: min(560px, 100%);
  max-height: 97%;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  /* Frosted glass so the live 3D scene reads through behind the menu. */
  backdrop-filter: blur(7px) saturate(1.15);
  -webkit-backdrop-filter: blur(7px) saturate(1.15);
}

/* The start screen is laid out as two columns — branding + track map on one side,
   the action buttons on the other — because the stage always presents LANDSCAPE
   (wide, but short): stacking everything vertically clipped the bottom. The
   columns wrap to a single stack if the card is ever too narrow. */
.menu-card.menu-main {
  display: flex;
  flex-flow: row wrap;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: min(720px, 100%);
  max-width: min(720px, 100%); /* override the narrower base .menu-card cap */
  gap: 8px 24px;
  padding: 14px 22px;
  border-color: rgba(255, 179, 0, 0.55);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05) inset,
    0 0 40px rgba(255, 179, 0, 0.12);
}
.menu-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1 1 250px;
  min-width: 230px;
  max-width: 340px;
}
.menu-col-actions {
  gap: 1px;
}
/* Keep the main-menu map compact so the brand column doesn't tower. */
.menu-col-brand .map-frame {
  margin: 8px auto 0;
  max-width: 320px;
}

/* Track panel: a full-width header (title + subtitle on the left, mode toggle on
   the right) over a two-column body (map | controls), so the tall control stack
   and map fit the short landscape stage without feeling cramped. */
.menu-card.track-main {
  display: flex;
  flex-direction: column;
  /* Narrower so the centred card clears the Dynamic Island / rounded corners. */
  width: min(700px, 100%);
  max-width: min(700px, 100%);
  text-align: left;
  padding: 10px 20px;
  gap: 6px;
}
.track-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding-bottom: 7px;
}
.track-title {
  display: flex;
  align-items: center;
  gap: 11px;
}
.track-ico {
  font-size: 26px;
  line-height: 1;
}
.track-title-text h1 {
  margin: 0;
  font-size: clamp(20px, 3.2vw, 26px);
}
.track-sub {
  margin: 1px 0 0;
  font-size: 11px;
  font-weight: normal;
  letter-spacing: 0.3px;
  color: rgba(255, 255, 255, 0.55);
  text-transform: none;
}
.track-header #track-mode {
  margin: 0;
  flex: 0 0 auto;
}
.track-body {
  display: flex;
  flex-flow: row wrap;
  align-items: stretch;
  gap: 12px 24px;
}
.track-col-map {
  flex: 1 1 240px;
  min-width: 210px;
  max-width: 290px;
  display: flex;
}
/* Map box holds the preview plus the reroll button beneath it. */
.track-col-map .map-frame {
  margin: 0;
  width: 100%;
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
/* Time-of-day picker: one compact row of four chips under Environment. */
.tod-pick {
  margin-top: 2px;
}
.tod-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}
.tod-grid .biome-chip {
  width: 100%;
  text-align: center;
  padding: 5px 4px;
  font-size: 10px;
  letter-spacing: 0;
}
.map-reroll {
  width: 100%;
  margin: 0;
  font-size: 13px;
  padding: 7px 14px;
}
.track-col-ctrl {
  flex: 1 1 340px;
  min-width: 290px;
  display: flex;
  flex-direction: column;
}
.track-col-ctrl #track-knobs {
  margin: 0 0 6px;
  width: 100%;
}
/* Slider rows: label on the left, slider in the middle, live value on the right. */
.track-main .track-row {
  grid-template-columns: 64px 1fr 30px;
  gap: 10px;
  margin-bottom: 6px;
}
.track-main .setting-label {
  font-size: 13px;
}
.track-val {
  font-size: 13px;
  font-weight: bold;
  color: #fff;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
/* Slimmer slider track + thumb in the track panel so four rows pack tighter. */
.track-main .slider {
  height: 6px;
}
.track-main .slider::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
}
.track-main .slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
}
.env-label {
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  margin: 2px 0 4px;
}
.track-main .biome-pick {
  justify-content: flex-start;
  margin: 0 0 2px;
  gap: 6px;
}
.track-main .biome-chip {
  padding: 5px 10px;
  font-size: 11px;
}
/* Play + Back share one row to save vertical space. Play is the wider primary. */
.track-actions {
  display: flex;
  gap: 10px;
  margin-top: auto;
  padding-top: 6px;
}
.track-main #track-apply {
  flex: 2 1 0;
  margin: 0;
  font-size: 15px;
  padding: 9px 18px;
}
.track-main #track-back {
  flex: 1 1 0;
  margin: 0;
  font-size: 15px;
  padding: 9px 14px;
}

/* Compact the primary buttons so each column fits the short landscape height. */
.menu-col-actions > button {
  font-size: 16px;
  padding: 9px 28px;
  margin-top: 6px;
  width: 100%;
}
.menu-main h1 {
  font-size: clamp(22px, 4vw, 32px);
  margin: 0;
}
.menu-main .tagline {
  margin: 0 0 2px;
}
.menu-main .menu-options {
  margin-top: 9px;
}
.menu-main .menu-options button.small {
  padding: 7px 15px;
}
.menu-main .hint {
  margin-top: 8px;
  font-size: 10px;
}

/* Track generator panel */
#track-knobs {
  margin: 14px 0 6px;
}
.track-row {
  display: grid;
  grid-template-columns: 60px 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  text-align: left;
}
.biome-pick {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  margin: 12px 0 6px;
}

/* Track map preview (track menu + main menu). A sunken framed panel holding the
   2D outline canvas, styled to feel like a little tactical map of the circuit. */
.map-frame {
  position: relative;
  margin: 12px auto;
  padding: 8px;
  border-radius: 14px;
  background: radial-gradient(120% 120% at 50% 0%, rgba(70, 110, 80, 0.5), rgba(20, 30, 28, 0.7));
  border: 2px solid rgba(255, 179, 0, 0.35);
  box-shadow: inset 0 2px 14px rgba(0, 0, 0, 0.5);
  width: 100%;
  box-sizing: border-box;
}
.track-map {
  display: block;
  width: 100%;
  height: auto;
}
/* On the main menu the map doubles as a button into the track editor. */
.map-frame-btn {
  cursor: pointer;
  display: block;
  -webkit-tap-highlight-color: transparent;
}
.map-frame-btn:active {
  transform: scale(0.99);
}
.map-label {
  position: absolute;
  left: 10px;
  bottom: 8px;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}
.biome-chip {
  font-size: 12px;
  letter-spacing: 0.5px;
  font-weight: bold;
  padding: 7px 12px;
  margin: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.5);
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: none;
}
.biome-chip:active {
  transform: none;
  box-shadow: none;
}
.biome-chip.on {
  background: linear-gradient(180deg, #ffd24d, var(--accent));
  color: #1a1206;
  border-color: transparent;
}
#track-mode {
  margin: 0 auto;
}

/* Multiplayer join (lobby code) */
.mp-join {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}
.mp-join .hint {
  margin: 0;
}
.mp-join .hint strong {
  color: var(--accent);
  letter-spacing: 1px;
}
.mp-join-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
#mp-code {
  font-family: inherit;
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-align: center;
  width: 170px;
  padding: 8px 10px;
  color: #fff;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  outline: none;
}
#mp-code::placeholder {
  color: rgba(255, 255, 255, 0.4);
  text-transform: none;
  letter-spacing: 0.5px;
  font-weight: normal;
}
#mp-code:focus {
  border-color: var(--accent);
}
.mp-join-row button.small {
  margin-top: 0;
}

/* Add-to-Home-Screen instructions */
.install-gate-note {
  margin: 10px auto 4px;
  max-width: 340px;
  font-size: 13.5px;
  color: var(--accent);
  font-weight: bold;
}
.install-steps {
  text-align: left;
  margin: 14px auto;
  padding-left: 22px;
  max-width: 320px;
  line-height: 1.55;
  font-size: 14px;
}
.install-steps li {
  margin-bottom: 9px;
}
.install-steps strong {
  color: var(--accent);
}
.share-ico {
  display: inline-flex;
  vertical-align: middle;
  width: 22px;
  height: 22px;
  padding: 2px;
  margin: 0 2px;
  border-radius: 5px;
  background: rgba(120, 190, 255, 0.18);
  color: #7fd0ff;
}
.share-ico svg {
  width: 100%;
  height: 100%;
}

/* Solo / Multiplayer segmented toggle — two pills in one track; the selected
   side is filled so it's obvious which mode is active. */
.seg-toggle {
  display: inline-flex;
  margin-top: 10px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.18);
}
.seg-btn {
  font-size: 13px;
  letter-spacing: 0.5px;
  font-weight: bold;
  padding: 7px 16px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  box-shadow: none;
  margin: 0;
  transition: background 0.15s, color 0.15s;
}
.seg-btn:active {
  transform: none;
  box-shadow: none;
}
.seg-btn.is-active {
  background: linear-gradient(180deg, #ffd24d, var(--accent));
  color: #1a1206;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.menu-main h1 {
  /* Stacked drop-shadows give the title a chunky 2.5D extrude. */
  text-shadow: 0 2px 0 var(--accent-2), 0 4px 0 #b93310, 0 6px 0 rgba(120, 30, 8, 0.6),
    0 10px 18px rgba(0, 0, 0, 0.55);
}

/* Row of small option buttons (Laps · How to Play · Settings). */
.menu-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}
.menu-options button.small {
  margin-top: 0;
}

h1 {
  font-size: clamp(26px, 4.5vw, 40px);
  letter-spacing: 2px;
  color: var(--accent);
  text-shadow: 0 3px 0 var(--accent-2);
}

.tagline {
  margin: 2px 0 12px;
  opacity: 0.8;
  letter-spacing: 4px;
  text-transform: uppercase;
  font-size: 12px;
}

.how-to-title {
  color: var(--accent);
  font-size: 14px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.how-to {
  list-style: none;
  text-align: left;
  margin: 0;
  padding: 0;
  line-height: 1.45;
  font-size: 13.5px;
}

.how-to li {
  margin-bottom: 3px;
}

.how-to strong {
  color: var(--accent);
}

button {
  font-family: inherit;
  font-size: 20px;
  font-weight: bold;
  letter-spacing: 2px;
  color: #1a1206;
  background: linear-gradient(180deg, #ffd24d, var(--accent));
  border: none;
  border-radius: 999px;
  padding: 14px 40px;
  cursor: pointer;
  box-shadow: 0 6px 0 #b97c00, 0 10px 20px rgba(0, 0, 0, 0.4);
  transition: transform 0.05s;
}

button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #b97c00, 0 6px 12px rgba(0, 0, 0, 0.4);
}

.hint {
  margin-top: 10px;
  font-size: 11px;
  opacity: 0.6;
  max-width: 220px;
}

#start-btn {
  margin-top: 6px;
}

kbd {
  background: #222;
  border-radius: 4px;
  padding: 1px 6px;
  border: 1px solid #444;
  font-size: 11px;
}

#rotate {
  z-index: 100; /* above the menu/HUD so it always takes priority */
}

.rotate-icon {
  font-size: 64px;
  margin-bottom: 12px;
  animation: spin 2s ease-in-out infinite;
}

@keyframes spin {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(90deg); }
}

#results-list {
  text-align: left;
  display: inline-block;
  margin: 6px auto 14px;
  line-height: 1.5;
  font-size: 16px;
}

#results-list .you {
  color: var(--accent);
  font-weight: bold;
}

#lobby-players {
  list-style: none;
  padding: 0;
  margin: 10px auto 14px;
  display: inline-block;
  text-align: left;
  line-height: 1.8;
  font-size: 16px;
}
#lobby-players .you {
  color: var(--accent);
  font-weight: bold;
}
#lobby-code {
  letter-spacing: 2px;
  color: var(--accent);
}

/* ===== HUD ===== */
#hud {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
}

#info {
  position: absolute;
  top: max(8px, var(--safe-top, 0px));
  right: max(12px, var(--safe-right, 0px));
  text-align: right;
  background: var(--panel);
  padding: 5px 12px;
  border-radius: 12px;
  line-height: 1.12;
}

#lap {
  font-size: 16px;
  font-weight: bold;
  color: var(--accent);
}

#place {
  font-size: 13px;
}

#speed {
  font-size: 12px;
  opacity: 0.85;
}

#timer {
  font-size: 12px;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

/* Throttle slider (left). The whole strip is the touch target, so the finger
   doesn't have to land precisely on the track. Inset generously so it clears
   the Dynamic Island / status bar whichever edge they land on. */
#throttle {
  position: absolute;
  left: max(46px, calc(var(--safe-left, 0px) + 18px));
  top: 12%;
  bottom: 12%;
  width: 96px;
  display: flex;
  align-items: center;
  pointer-events: auto;
}

#throttle-track {
  position: relative;
  width: 70px;
  height: min(70%, 320px);
  margin: auto;
  border-radius: 40px;
  background: linear-gradient(
    180deg,
    rgba(76, 175, 80, 0.35),
    rgba(255, 255, 255, 0.05) 50%,
    rgba(244, 67, 54, 0.35)
  );
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.4);
}

#throttle-thumb {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  margin: -29px 0 0 -29px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, var(--accent));
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  transition: background 0.1s;
}

.throttle-label {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: bold;
  white-space: nowrap;
  opacity: 0.85;
  pointer-events: none;
}

.throttle-up { top: -22px; color: #7CFC9A; }
.throttle-down { bottom: -22px; color: #ff8a7a; }

/* Bottom-right action buttons, arranged as a thumb-reachable cluster/fan. */
#action-buttons {
  position: absolute;
  right: max(8px, calc(var(--safe-right, 0px) + 4px));
  bottom: max(8px, calc(var(--safe-bottom, 0px) + 4px));
  width: 224px;
  height: 224px;
  pointer-events: none;
}

.action-btn {
  position: absolute;
  pointer-events: auto;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  font-size: 27px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(16, 22, 38, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  padding: 0;
}

#btn-shoot {
  right: 104px;
  bottom: 30px;
  background: rgba(255, 87, 34, 0.5);
  border-color: rgba(255, 138, 101, 0.7);
  transition: transform 0.08s ease, box-shadow 0.1s ease;
}

/* Recharging / locked out after a hit. */
#btn-shoot.disabled {
  opacity: 0.4;
}

/* Held: charging a stronger shot. */
#btn-shoot.charging {
  transform: scale(1.12);
  box-shadow: 0 0 18px rgba(255, 138, 101, 0.95);
}

#btn-jump {
  right: 8px;
  bottom: 8px;
  width: 86px;
  height: 86px;
  font-size: 34px;
  background: rgba(33, 150, 243, 0.45);
  border-color: rgba(144, 202, 249, 0.7);
}

#btn-shield {
  right: 76px;
  bottom: 150px;
  background: rgba(33, 120, 180, 0.45);
  border-color: rgba(129, 212, 250, 0.8);
}

#btn-shield.active {
  background: rgba(79, 195, 247, 0.85);
  box-shadow: 0 0 16px rgba(79, 195, 247, 0.9);
}

#btn-boost {
  right: 150px;
  bottom: 108px;
  overflow: hidden;
  background: rgba(40, 60, 30, 0.5);
  border-color: rgba(197, 225, 165, 0.8);
}

/* Fill rising from the bottom shows the recharging boost meter. */
#boost-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 100%;
  background: linear-gradient(0deg, #7cb342, #aed581);
  transition: height 0.1s linear;
  z-index: 0;
}

.btn-emoji {
  position: relative;
  z-index: 1;
}

#btn-boost.disabled #boost-fill {
  background: linear-gradient(0deg, #5a6a4a, #7a8a6a);
}

.action-btn.flash {
  transform: scale(0.9);
  background: var(--accent);
  color: #1a1206;
  transition: transform 0.08s;
}

/* Steering indicator */
#steer {
  position: absolute;
  bottom: max(12px, var(--safe-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

#steer-bar {
  position: relative;
  width: 180px;
  height: 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.3);
  display: none; /* hidden by default; toggled from the pause menu */
}

#steer-bar::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -3px;
  width: 2px;
  height: 16px;
  background: rgba(255, 255, 255, 0.4);
}

#steer-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, var(--accent));
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  transition: transform 0.05s linear;
}

#calibrate {
  pointer-events: auto;
  font-size: 11px;
  letter-spacing: 0.5px;
  padding: 5px 12px;
  border-radius: 999px;
  color: #fff;
  background: rgba(16, 22, 38, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: none;
}

#calibrate:active {
  transform: none;
  background: rgba(255, 179, 0, 0.4);
}

/* Pause button: right side, under the lap/speed box, clear of the top bar */
#btn-pause {
  position: absolute;
  top: calc(max(8px, var(--safe-top, 0px)) + 76px);
  right: max(12px, var(--safe-right, 0px));
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 18px;
  color: #fff;
  background: rgba(16, 22, 38, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: none;
  pointer-events: auto;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#btn-pause:active {
  transform: scale(0.92);
}

/* Secondary (outline) button used on the pause card */
button.secondary {
  margin-top: 10px;
  color: #fff;
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.5);
  box-shadow: none;
}

button.secondary:active {
  transform: translateY(2px);
  box-shadow: none;
}

/* Rear-view mirror frame. The image is drawn by WebGL into the inner area
   (inset by this border in main.js), so the frame is a clean opaque rectangle
   that crops it — square corners, no rounding, so nothing spills out. */
#mirror-frame {
  position: absolute;
  border: 3px solid #2a2f3a;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

#mirror-frame span {
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.6);
  text-shadow: 0 1px 2px #000;
}

/* Small secondary button (e.g. graphics toggle on the menu) */
button.small {
  font-size: 13px;
  letter-spacing: 1px;
  padding: 8px 18px;
  margin-top: 8px;
}

/* ===== Settings screen ===== */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 18px 0 8px;
  text-align: left;
}

.setting-row {
  display: grid;
  grid-template-columns: 88px 76px 1fr;
  align-items: center;
  gap: 14px;
}

/* The Graphics row has no slider; let its toggle span the slider column too. */
#quality-toggle {
  grid-column: 2 / 4;
  justify-self: start;
  margin-top: 0; /* the seg-toggle's default top margin is for the menu, not here */
}

.setting-label {
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 1px;
  color: var(--accent);
  text-transform: uppercase;
}

/* Keep the small toggle buttons a fixed width so On/Off don't jump around. */
.setting-row .toggle {
  margin-top: 0;
  min-width: 70px;
  text-align: center;
}

/* A toggle that's "off" reads dim/red so the state is obvious at a glance. */
.secondary.small.toggle.off {
  border-color: rgba(255, 120, 120, 0.7);
  color: #ff9a9a;
  opacity: 0.85;
}

/* Volume sliders */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  outline: none;
  cursor: pointer;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffd24d, var(--accent));
  border: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffd24d, var(--accent));
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.slider:disabled {
  opacity: 0.4;
}

/* White hit flash overlay */
#flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 40;
}

#flash.on {
  animation: hitflash 0.32s ease-out;
}

@keyframes hitflash {
  0% { opacity: 0.55; }
  100% { opacity: 0; }
}

/* Lap toast */
#toast {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  font-size: clamp(30px, 7vw, 60px);
  font-weight: bold;
  color: var(--accent);
  text-shadow: 0 4px 0 var(--accent-2), 0 6px 20px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
}

#toast.show {
  animation: toast 1.4s ease-out;
}

@keyframes toast {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  70% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}

/* Minimap — bottom-left, just right of the throttle. Kept small and mostly
   transparent (track outline + dots) so it doesn't cover the driving view. */
#minimap {
  position: absolute;
  bottom: max(16px, calc(var(--safe-bottom, 0px) + 12px));
  left: max(150px, calc(var(--safe-left, 0px) + 122px));
  width: 132px;
  height: 132px;
  border-radius: 12px;
  background: rgba(10, 16, 32, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.18);
  pointer-events: none;
}
