:root {
  color-scheme: dark;
  --bg: #06111f;
  --panel: rgba(10, 31, 51, 0.92);
  --panel-strong: #0c263e;
  --line: rgba(137, 217, 255, 0.18);
  --text: #effaff;
  --muted: #9fb8c8;
  --cyan: #39e4ff;
  --cyan-soft: #baf7ff;
  --lime: #a7f55b;
  --amber: #ffd462;
  --danger: #ff6985;
  font-family: Inter, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

/* 視覚的に隠すが、スクリーンリーダーには読み上げさせる */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 0%, rgba(0, 172, 238, 0.18), transparent 32rem),
    radial-gradient(circle at 90% 40%, rgba(40, 255, 187, 0.1), transparent 28rem),
    linear-gradient(155deg, #07192c 0%, #030b14 70%);
}

button {
  color: inherit;
  font: inherit;
}

a {
  color: inherit;
}

button:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 18px clamp(12px, 3vw, 42px) 28px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.eyebrow,
.kicker {
  margin: 0 0 5px;
  color: var(--cyan);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

h1,
h2,
p {
  margin-top: 0;
}

.site-header h1 {
  margin: 0;
  font-size: clamp(1.55rem, 4vw, 2.7rem);
  letter-spacing: 0.06em;
  line-height: 1;
}

.site-header h1 span {
  color: var(--lime);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(13, 43, 68, 0.92), rgba(5, 21, 36, 0.96));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34), inset 0 1px rgba(255, 255, 255, 0.04);
}

.select-screen {
  padding: clamp(16px, 2.2vw, 26px);
}

.landing-screen {
  position: relative;
  display: grid;
  min-height: min(680px, calc(100vh - 118px));
  place-items: center;
  padding: clamp(34px, 7vw, 96px);
  overflow: hidden;
  isolation: isolate;
}

.landing-screen::before,
.landing-screen::after {
  position: absolute;
  z-index: -1;
  width: min(52vw, 720px);
  aspect-ratio: 1;
  border-radius: 50%;
  content: "";
  filter: blur(80px);
  opacity: 0.2;
}

.landing-screen::before {
  top: -42%;
  left: -12%;
  background: var(--cyan);
}

.landing-screen::after {
  right: -14%;
  bottom: -56%;
  background: var(--lime);
}

.landing-content {
  display: grid;
  width: min(960px, 100%);
  place-items: center;
  text-align: center;
}

.landing-content .kicker {
  margin-bottom: 12px;
  font-size: clamp(0.72rem, 1.3vw, 0.95rem);
}

.landing-content h2 {
  max-width: 12em;
  margin: 0;
  font-size: clamp(2.4rem, 7vw, 6.2rem);
  line-height: 1.04;
  letter-spacing: 0.02em;
}

.landing-description {
  max-width: 780px;
  margin: clamp(18px, 3vw, 30px) 0 0;
  color: #c2dce8;
  font-size: clamp(0.92rem, 1.6vw, 1.16rem);
  font-weight: 700;
  line-height: 1.85;
}

.landing-start-button {
  min-width: min(360px, 100%);
  margin-top: clamp(24px, 4vw, 42px);
  font-size: 1.08rem;
}

.landing-start-button small {
  font-size: 0.68rem;
}

.select-copy {
  display: grid;
  grid-template-columns: minmax(320px, 1.15fr) minmax(300px, 0.85fr);
  gap: clamp(22px, 4vw, 54px);
  align-items: center;
  margin-bottom: 20px;
}

.select-copy h2 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 4vw, 3.5rem);
  line-height: 1.08;
}

.select-intro > p:first-child {
  margin-bottom: 2px;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.75;
}

.best-score {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin: 10px 0 0;
  padding: 6px 14px;
  border: 1px solid rgba(255, 212, 98, 0.4);
  border-radius: 999px;
  color: var(--amber);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  background: rgba(255, 212, 98, 0.07);
}

.best-score strong {
  font-size: 0.92rem;
}

.level-picker {
  margin-bottom: 16px;
  padding: 16px 18px 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(5, 22, 37, 0.72), rgba(3, 14, 25, 0.8));
}

.level-picker-heading {
  margin-bottom: 12px;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.level-card {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 12px;
  min-width: 0;
  min-height: 116px;
  padding: 14px 15px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  background: rgba(4, 17, 29, 0.72);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.level-card::after {
  position: absolute;
  right: -36px;
  bottom: -52px;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  content: "";
  background: var(--level-color);
  filter: blur(48px);
  opacity: 0.13;
  pointer-events: none;
}

.level-card:hover {
  transform: translateY(-2px);
  border-color: rgba(57, 228, 255, 0.5);
}

.level-card[aria-checked="true"] {
  border-color: var(--cyan);
  background: linear-gradient(150deg, rgba(20, 70, 95, 0.92), rgba(5, 22, 37, 0.94));
  box-shadow: 0 0 0 2px rgba(57, 228, 255, 0.16), 0 12px 28px rgba(0, 0, 0, 0.22);
}

.level-card[aria-checked="true"]::before {
  position: absolute;
  top: 9px;
  right: 9px;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  color: #042132;
  content: "✓";
  font-size: 0.72rem;
  font-weight: 900;
  background: var(--cyan);
}

.level-index {
  grid-row: 1 / 4;
  align-self: start;
  color: var(--level-color);
  font-size: 1.8rem;
  font-weight: 950;
  letter-spacing: -0.08em;
  line-height: 1;
}

.level-route {
  margin: 0;
  padding-right: 22px;
  font-size: clamp(0.88rem, 1.25vw, 1.08rem);
  line-height: 1.3;
}

.level-distance {
  color: var(--cyan-soft);
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.level-features {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-self: end;
}

.level-features span {
  padding: 4px 7px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 999px;
  color: #b8cfda;
  font-size: 0.58rem;
  font-weight: 800;
  background: rgba(0, 0, 0, 0.14);
}

.level-features .level-difficulty {
  border-color: color-mix(in srgb, var(--level-color), transparent 58%);
  color: var(--level-color);
}

.level-key-help {
  margin: 9px 1px 0;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-align: right;
}

.garage-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(390px, 0.88fr);
  gap: 16px;
  align-items: stretch;
}

.garage-layout > * {
  min-width: 0;
}

.machine-picker,
.selection-footer {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(5, 22, 37, 0.7), rgba(3, 14, 25, 0.78));
}

.machine-picker {
  padding: 18px;
}

.picker-heading,
.garage-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.picker-heading {
  margin-bottom: 14px;
}

.picker-heading span,
.garage-label span {
  color: var(--cyan);
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.picker-heading h3 {
  margin: 2px 0 0;
  font-size: 1.15rem;
}

.picker-heading b,
.garage-label b {
  padding: 6px 10px;
  border: 1px solid rgba(57, 228, 255, 0.25);
  border-radius: 999px;
  color: var(--cyan-soft);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  background: rgba(57, 228, 255, 0.06);
}

.vehicle-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 0;
}

.vehicle-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(180px, 0.76fr) minmax(220px, 1fr);
  grid-template-rows: auto auto 1fr;
  gap: 10px 24px;
  min-width: 132px;
  min-height: 154px;
  padding: 18px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  background: rgba(4, 17, 29, 0.7);
  transition: 180ms ease;
}

.vehicle-card::after {
  position: absolute;
  inset: auto -20px -40px auto;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  content: "";
  background: var(--vehicle-color);
  filter: blur(46px);
  opacity: 0.12;
}

.vehicle-card:hover {
  transform: translateY(-3px);
  border-color: rgba(57, 228, 255, 0.5);
}

.vehicle-card[aria-checked="true"] {
  border-color: var(--cyan);
  background: linear-gradient(155deg, rgba(20, 70, 95, 0.92), rgba(5, 22, 37, 0.92));
  box-shadow: 0 0 0 2px rgba(57, 228, 255, 0.18), 0 16px 35px rgba(0, 0, 0, 0.25);
}

.vehicle-card[aria-checked="true"]::before {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  color: #042132;
  content: "✓";
  font-weight: 900;
  background: var(--cyan);
}

.vehicle-number {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.vehicle-meta {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.vehicle-meta b {
  color: var(--lime);
  font-size: 0.56rem;
  letter-spacing: 0.04em;
}

.vehicle-card h3 {
  grid-column: 1;
  grid-row: 2;
  align-self: end;
  margin: 0 0 4px;
  font-size: 1.22rem;
  line-height: 1.25;
}

.vehicle-card .vehicle-kind {
  grid-column: 1;
  grid-row: 3;
  min-height: 30px;
  margin: 0;
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 700;
  line-height: 1.35;
}

.mini-stats {
  grid-column: 2;
  grid-row: 2 / 4;
  display: grid;
  gap: 7px;
  align-self: center;
}

.mini-stat {
  display: grid;
  grid-template-columns: 76px minmax(90px, 1fr);
  gap: 9px;
  align-items: center;
  color: #b8cfda;
  font-size: 0.7rem;
  font-weight: 800;
}

.mini-stat i {
  height: 4px;
  overflow: hidden;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
}

.mini-stat i::after {
  display: block;
  width: var(--value);
  height: 100%;
  content: "";
  border-radius: inherit;
  background: var(--cyan);
}

.selection-footer {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(190px, 1fr) auto;
  gap: 12px;
  align-items: stretch;
  margin: 0;
  padding: 18px;
}

.garage-label {
  min-height: 28px;
}

.selected-preview {
  position: relative;
  display: grid;
  place-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 78%, rgba(57, 228, 255, 0.14), transparent 62%),
    rgba(0, 0, 0, 0.18);
}

.selected-preview.is-loading-3d::after {
  content: "3Dモデル読み込み中…";
  grid-area: 1 / 1;
  align-self: end;
  justify-self: center;
  margin-bottom: 14px;
  padding: 6px 12px;
  border: 1px solid rgba(126, 222, 255, 0.28);
  border-radius: 999px;
  background: rgba(3, 18, 27, 0.72);
  color: #bdefff;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  pointer-events: none;
}

.selected-preview.is-model-failed::after {
  content: "3Dモデルを読み込めません";
  grid-area: 1 / 1;
  align-self: center;
  justify-self: center;
  padding: 8px 14px;
  border: 1px solid rgba(255, 212, 98, 0.32);
  border-radius: 999px;
  background: rgba(3, 18, 27, 0.78);
  color: var(--amber);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.06em;
  pointer-events: none;
}

.vehicle-preview-model,
.vehicle-preview-turntable {
  grid-area: 1 / 1;
  display: block;
  width: min(420px, 100%);
  height: 200px;
  pointer-events: none;
  opacity: 0;
  background: transparent;
  transition: opacity 180ms ease;
}

.vehicle-preview-model {
  --poster-color: transparent;
}

.vehicle-preview-turntable {
  object-fit: contain;
}

.vehicle-preview-model.is-active,
.vehicle-preview-turntable.is-active {
  opacity: 1;
}

.selected-summary {
  display: none;
  align-content: center;
  gap: 8px;
  min-height: 74px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.12);
}

.selected-summary strong {
  color: var(--cyan-soft);
  font-size: 1.15rem;
}

.summary-route {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px 10px;
  align-items: center;
  padding-bottom: 9px;
  border-bottom: 1px solid color-mix(in srgb, var(--level-color), transparent 68%);
}

.summary-route span,
.summary-route em {
  color: var(--level-color);
  font-size: 0.62rem;
  font-style: normal;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.summary-route b {
  color: var(--text);
  font-size: 0.82rem;
}

.summary-head {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.summary-note {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.6;
}

.stat-rows {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 18px;
}

.stat-row {
  display: grid;
  grid-template-columns: 84px minmax(90px, 1fr);
  gap: 8px;
  align-items: center;
  color: #b8cfda;
  font-size: 0.68rem;
  font-weight: 800;
}

.stat-row i {
  height: 7px;
  overflow: hidden;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
}

.stat-row i::after {
  display: block;
  width: var(--value);
  height: 100%;
  content: "";
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--lime));
}

.spec-source {
  margin: 0;
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 700;
  text-align: right;
}

.tech-pill {
  display: inline-flex;
  align-items: center;
  align-self: start;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 999px;
  color: #062033;
  font-size: 0.68rem;
  font-weight: 900;
  white-space: nowrap;
  background: var(--cyan);
}

.model-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 9px;
  border: 1px solid rgba(167, 245, 91, 0.32);
  border-radius: 999px;
  color: var(--lime);
  font-size: 0.62rem;
  font-weight: 900;
  white-space: nowrap;
  background: rgba(167, 245, 91, 0.07);
}

.primary-button,
.ghost-button {
  border-radius: 999px;
  font-weight: 900;
  cursor: pointer;
  transition: 180ms ease;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 58px;
  padding: 14px 28px;
  border: 0;
  color: #041d2c;
  background: linear-gradient(100deg, var(--cyan), var(--lime));
  box-shadow: 0 10px 30px rgba(57, 228, 255, 0.18);
}

.primary-button small {
  padding: 3px 7px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 5px;
  font-size: 0.62rem;
}

.primary-button:hover,
.ghost-button:hover {
  transform: translateY(-2px);
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.04);
}

.hud {
  display: grid;
  grid-template-columns: 0.85fr 0.9fr 1.9fr 0.85fr 0.85fr;
  gap: 8px;
  margin-bottom: 8px;
}

.hud-block {
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(5, 22, 37, 0.9);
}

.hud-block > span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.hud-block strong {
  font-size: clamp(0.92rem, 2.2vw, 1.35rem);
}

.fuel-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.fuel-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.fuel-track i {
  display: block;
  width: 80%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--lime));
  transition: width 120ms linear, background 180ms ease;
}

.fuel-track i.low {
  background: linear-gradient(90deg, #ff536d, var(--amber));
}

.route-progress {
  position: relative;
  margin: 2px 6px 24px;
}

.route-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.route-track i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--lime));
  transition: width 200ms linear;
}

.route-dots {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.route-dot {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
}

.route-dot i {
  display: block;
  width: 11px;
  height: 11px;
  border: 2px solid var(--cyan-soft);
  border-radius: 50%;
  background: var(--panel-strong);
}

.route-dot b {
  position: absolute;
  top: 13px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 800;
  white-space: nowrap;
}

.route-dot:first-child b { transform: translateX(-20%); }
.route-dot:last-child b { transform: translateX(-80%); }

.canvas-wrap {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(126, 222, 255, 0.22);
  border-radius: 20px;
  background: #081823;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.38);
}

.integrated-drive {
  position: relative;
  display: block;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  background: #050b13;
}

.integrated-drive #driveCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.drive-loading {
  position: absolute;
  z-index: 40;
  top: 50%;
  left: 50%;
  display: grid;
  width: min(390px, calc(100vw - 40px));
  gap: 7px;
  padding: 20px 24px;
  border: 1px solid rgba(95, 231, 255, 0.4);
  border-radius: 22px;
  color: #f2fbff;
  text-align: center;
  background: rgba(3, 15, 27, 0.9);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.45);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.drive-loading[hidden] {
  display: none;
}

.drive-loading span {
  color: #52e7ff;
  font-size: 0.72rem;
  font-weight: 1000;
  letter-spacing: 0.18em;
}

.drive-loading strong {
  font-size: clamp(0.95rem, 3vw, 1.2rem);
}

.drive-loading i {
  display: block;
  width: 100%;
  height: 5px;
  margin-top: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.drive-loading i::after {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #36e4ff, #a7ff5b);
  animation: drive-loading-slide 1.05s ease-in-out infinite alternate;
  content: "";
}

@keyframes drive-loading-slide {
  from { transform: translateX(0); }
  to { transform: translateX(138%); }
}

.mobile-drive-controls {
  display: none;
}

.mobile-control-button {
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

body.real-drive-main,
body.real-drive-main * {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.drive-fx-layer {
  position: absolute;
  z-index: 2;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.drive-fx-layer > span {
  position: absolute;
  inset: 0;
  display: block;
  opacity: 0;
}

.drive-speed-lines {
  inset: -18% !important;
  background:
    repeating-conic-gradient(
      from 188deg at 50% 68%,
      transparent 0deg 7deg,
      rgba(123, 246, 255, 0.2) 7.4deg 7.8deg,
      transparent 8.2deg 16deg
    );
  mask-image: radial-gradient(circle at 50% 68%, transparent 0 24%, #000 54%, #000 100%);
  -webkit-mask-image: radial-gradient(circle at 50% 68%, transparent 0 24%, #000 54%, #000 100%);
  transform: scale(1.04);
}

.drive-fx-layer.is-rushing .drive-speed-lines {
  opacity: 0.28;
  animation: drive-speed-rush 420ms linear infinite;
}

.drive-fx-flash,
.drive-low-fuel-edge {
  border-radius: 18px;
}

.drive-fx-layer.fx-h2 .drive-fx-flash {
  animation: drive-fx-h2 420ms ease-out both;
  background: radial-gradient(circle at 50% 60%, rgba(97, 238, 255, 0.2), transparent 46%);
}

.drive-fx-layer.fx-item .drive-fx-flash {
  animation: drive-fx-item 520ms ease-out both;
  box-shadow: inset 0 0 46px rgba(167, 255, 91, 0.24);
}

.drive-fx-layer.fx-tank .drive-fx-flash {
  animation: drive-fx-tank 600ms ease-out both;
  background: linear-gradient(0deg, rgba(53, 226, 255, 0.18), transparent 54%);
}

.drive-fx-layer.fx-turbo .drive-fx-flash {
  animation: drive-fx-turbo 520ms ease-out both;
  box-shadow: inset 0 0 54px rgba(83, 255, 190, 0.28);
}

.drive-fx-layer.fx-impact .drive-fx-flash {
  animation: drive-fx-impact 260ms ease-out both;
  box-shadow: inset 0 0 72px rgba(255, 91, 68, 0.3);
  background: radial-gradient(circle at 50% 70%, rgba(255, 119, 66, 0.14), transparent 50%);
}

.drive-fx-layer.fx-region .drive-fx-flash {
  animation: drive-fx-region 900ms ease-out both;
  background: linear-gradient(90deg, transparent, rgba(85, 233, 255, 0.12), rgba(167, 255, 91, 0.14), transparent);
}

.drive-fx-layer.fx-goal .drive-fx-flash {
  animation: drive-fx-goal 1200ms ease-out both;
  box-shadow: inset 0 0 90px rgba(255, 210, 98, 0.32);
}

.drive-fx-layer.is-low-fuel .drive-low-fuel-edge {
  opacity: 1;
  box-shadow: inset 0 0 28px rgba(255, 102, 78, 0.2);
  animation: drive-low-fuel 1.8s ease-in-out infinite;
}

.drive-fx-layer.is-critical-fuel .drive-low-fuel-edge {
  box-shadow: inset 0 0 42px rgba(255, 72, 64, 0.3);
  animation-duration: 1.15s;
}

@keyframes drive-speed-rush {
  from { transform: scale(1.03) rotate(0deg); }
  to { transform: scale(1.08) rotate(0.8deg); }
}

@keyframes drive-fx-h2 {
  0% { opacity: 0; transform: scale(0.88); }
  24% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.08); }
}

@keyframes drive-fx-item {
  0% { opacity: 0; transform: scale(0.96); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.03); }
}

@keyframes drive-fx-tank {
  0% { opacity: 0; transform: translateY(18px); }
  28% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-10px); }
}

@keyframes drive-fx-turbo {
  0% { opacity: 0; transform: scale(0.94); }
  22% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.06); }
}

@keyframes drive-fx-impact {
  0% { opacity: 0; }
  25% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes drive-fx-region {
  0% { opacity: 0; transform: translateX(-22%); }
  34% { opacity: 1; }
  100% { opacity: 0; transform: translateX(22%); }
}

@keyframes drive-fx-goal {
  0% { opacity: 0; transform: scale(0.94); }
  28% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.08); }
}

@keyframes drive-low-fuel {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.9; }
}

.drive-region-banner {
  position: absolute;
  z-index: 7;
  top: 198px;
  right: 18px;
  left: auto;
  display: grid;
  width: min(360px, calc(100vw - 240px));
  min-width: 280px;
  padding: 12px 30px 14px;
  overflow: hidden;
  border: 1px solid rgba(116, 238, 255, 0.5);
  border-radius: 18px;
  color: #f4fdff;
  text-align: left;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(14px) scale(0.97);
  background:
    linear-gradient(90deg, rgba(54, 228, 255, 0.16), transparent 28%, transparent 72%, rgba(167, 245, 91, 0.14)),
    linear-gradient(145deg, rgba(3, 20, 35, 0.92), rgba(5, 35, 48, 0.78));
  box-shadow:
    0 18px 54px rgba(0, 0, 0, 0.34),
    inset 0 1px rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
}

.drive-region-banner::before,
.drive-region-banner::after {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 7px;
  content: "";
  background: linear-gradient(180deg, var(--cyan), var(--lime));
  box-shadow: 0 0 22px rgba(57, 228, 255, 0.48);
}

.drive-region-banner::before { left: 0; }
.drive-region-banner::after { right: 0; transform: scaleY(-1); }

.drive-region-banner.visible {
  visibility: visible;
  animation: drive-region-reveal 2.05s cubic-bezier(0.2, 0.75, 0.25, 1) both;
}

.drive-region-kicker {
  color: var(--cyan);
  font-size: 0.6rem;
  font-weight: 1000;
  letter-spacing: 0.28em;
}

.drive-region-banner strong {
  margin-top: 1px;
  font-size: clamp(1.55rem, 3.4vw, 2.75rem);
  font-weight: 1000;
  line-height: 1.05;
  letter-spacing: 0.08em;
  text-shadow: 0 4px 22px rgba(57, 228, 255, 0.34);
}

.drive-region-banner small {
  margin-top: 5px;
  overflow: hidden;
  color: #c7eff5;
  font-size: clamp(0.64rem, 1.2vw, 0.78rem);
  font-weight: 850;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes drive-region-reveal {
  0% {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
  14%, 76% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-10px) scale(0.99);
  }
}

.integrated-drive-topbar,
.integrated-route-panel,
.integrated-item-panel,
.integrated-fuel-panel,
.integrated-drive-message,
.integrated-telemetry {
  position: absolute;
  z-index: 5;
  border: 1px solid rgba(126, 222, 255, 0.22);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(7, 25, 43, 0.82), rgba(3, 11, 20, 0.72));
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28), inset 0 1px rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(14px);
}

.integrated-drive-topbar {
  top: 16px;
  left: 92px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 74px;
  padding: 12px 16px;
}

.integrated-drive-topbar h2 {
  margin: 0;
  font-size: clamp(1.25rem, 2.6vw, 2.35rem);
  letter-spacing: 0.06em;
}

.integrated-drive-status {
  margin: 0;
  padding: 7px 12px;
  border: 1px solid rgba(54, 228, 255, 0.24);
  border-radius: 999px;
  color: #c9f7ff;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
  background: rgba(54, 228, 255, 0.07);
}

.integrated-route-panel {
  top: 108px;
  left: 50%;
  width: min(680px, calc(100vw - 220px));
  padding: 13px 18px 30px;
  transform: translateX(-50%);
}

.integrated-route-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.integrated-route-head span {
  color: var(--cyan);
  font-size: 0.66rem;
  font-weight: 1000;
  letter-spacing: 0.16em;
}

.integrated-route-head strong {
  color: #fdf3d8;
  font-size: clamp(0.82rem, 1.65vw, 1.08rem);
  font-weight: 1000;
  text-align: right;
}

.integrated-route-track {
  position: relative;
  height: 12px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
}

.integrated-route-track i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--lime), var(--amber));
  box-shadow: 0 0 18px rgba(57, 228, 255, 0.35);
  transition: width 160ms linear;
}

.integrated-route-dots {
  position: absolute;
  right: 18px;
  bottom: 11px;
  left: 18px;
  height: 24px;
  pointer-events: none;
}

.integrated-route-dot {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
}

.integrated-route-dot i {
  display: block;
  width: 10px;
  height: 10px;
  border: 2px solid #e8fbff;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px rgba(57, 228, 255, 0.5);
}

.integrated-route-dot b {
  position: absolute;
  top: 12px;
  left: 50%;
  color: #d7f6ff;
  font-size: 0.58rem;
  font-weight: 900;
  white-space: nowrap;
  transform: translateX(-50%);
}

.integrated-route-dot:first-child b { transform: translateX(-18%); }
.integrated-route-dot:last-child b { transform: translateX(-82%); }

.integrated-item-panel {
  top: 118px;
  left: 18px;
  display: grid;
  gap: 4px;
  width: min(174px, calc(100vw - 36px));
  min-height: 116px;
  place-items: center;
  padding: 16px;
  text-align: center;
}

.integrated-item-panel span,
.integrated-item-panel small {
  color: #aeeefa;
  font-size: 0.58rem;
  font-weight: 1000;
  letter-spacing: 0.12em;
}

.integrated-item-panel strong {
  display: grid;
  width: 78px;
  height: 78px;
  place-items: center;
  border: 4px solid rgba(255, 255, 255, 0.78);
  border-radius: 50%;
  color: #fff;
  font-size: 0.76rem;
  font-weight: 1000;
  line-height: 1.18;
  background: radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.18), rgba(57, 228, 255, 0.18) 42%, rgba(2, 20, 34, 0.88));
  box-shadow: inset 0 0 20px rgba(57, 228, 255, 0.22), 0 8px 24px rgba(0, 0, 0, 0.26);
}

.integrated-item-panel.powered {
  border-color: rgba(167, 245, 91, 0.58);
  box-shadow: 0 0 36px rgba(167, 245, 91, 0.28), inset 0 1px rgba(255, 255, 255, 0.06);
}

.integrated-fuel-panel {
  z-index: 8;
  left: 18px;
  bottom: 18px;
  width: min(326px, calc(100vw - 36px));
  padding: 14px 16px;
}

.integrated-fuel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.integrated-fuel-head span {
  color: var(--cyan);
  font-size: 0.62rem;
  font-weight: 1000;
  letter-spacing: 0.15em;
}

.integrated-fuel-head strong {
  color: #e8fbff;
  font-size: 1.05rem;
  font-weight: 1000;
  white-space: nowrap;
}

.integrated-fuel-track {
  height: 18px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.integrated-fuel-track i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #29d8ff, #69f3ff, #a7f55b);
  box-shadow: 0 0 20px rgba(57, 228, 255, 0.36);
  transform: scaleX(1);
  transform-origin: left center;
  transition: transform 120ms linear, background 180ms ease;
}

.integrated-fuel-panel small {
  display: block;
  margin-top: 8px;
  color: #bdebf6;
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1.35;
}

.integrated-fuel-panel.is-low {
  border-color: rgba(255, 207, 77, 0.55);
}

.integrated-fuel-panel.is-low .integrated-fuel-track i {
  background: linear-gradient(90deg, #ffcf4d, #fff06c);
  box-shadow: 0 0 22px rgba(255, 207, 77, 0.44);
}

.integrated-fuel-panel.is-danger {
  border-color: rgba(255, 92, 122, 0.72);
  box-shadow: 0 0 34px rgba(255, 92, 122, 0.22), inset 0 1px rgba(255, 255, 255, 0.04);
}

.integrated-fuel-panel.is-danger .integrated-fuel-track i {
  background: linear-gradient(90deg, #ff5c7a, #ff9f4d);
  box-shadow: 0 0 24px rgba(255, 92, 122, 0.5);
}

@media (min-width: 821px) and (max-width: 1280px) {
  .integrated-fuel-panel {
    bottom: 132px;
  }
}

.integrated-drive-message {
  top: 226px;
  left: 50%;
  margin: 0;
  min-width: min(420px, calc(100vw - 48px));
  padding: 12px 22px;
  color: #fdf3d8;
  font-size: clamp(0.95rem, 2.2vw, 1.25rem);
  font-style: italic;
  font-weight: 1000;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.integrated-drive-message.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.integrated-telemetry {
  right: 16px;
  bottom: 16px;
  display: grid;
  grid-template-columns: repeat(6, minmax(88px, 1fr));
  gap: 10px;
  min-width: min(900px, calc(100vw - 32px));
  padding: 14px;
}

.integrated-telemetry div {
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.22);
}

.integrated-telemetry span {
  display: block;
  color: var(--cyan);
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.integrated-telemetry strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  font-size: clamp(1rem, 2.2vw, 1.8rem);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.real-drive-exit {
  position: fixed;
  z-index: 20;
  top: 18px;
  left: 18px;
  background: rgba(4, 17, 29, 0.72);
  backdrop-filter: blur(14px);
}

body.real-drive-main {
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

body.real-drive-main .integrated-drive,
body.real-drive-main .integrated-drive * {
  touch-action: none;
}

body.real-drive-main .app-shell {
  width: 100%;
  max-width: none;
  padding: 0;
}

body.real-drive-main .site-header,
body.real-drive-main .prototype-note,
body.real-drive-main .game-screen > :not(.integrated-drive):not(.real-drive-exit) {
  display: none !important;
}

body.real-drive-main .integrated-drive-topbar {
  display: none;
}

body.real-drive-main .integrated-route-panel {
  top: 16px;
}

body.real-drive-main .game-screen {
  min-height: 100vh;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
}

.vehicle-race-model {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 0.5%;
  display: block;
  width: 34%;
  height: 34%;
  pointer-events: none;
  opacity: 0;
  --poster-color: transparent;
  background: transparent;
  transform: translateX(calc(-50% + var(--vehicle-x, 0px))) translateY(var(--vehicle-y, 0px)) rotate(var(--vehicle-tilt, 0deg));
  transform-origin: 50% 82%;
  transition: opacity 180ms ease;
}

.vehicle-race-model.is-active.is-loaded {
  opacity: 1;
}

#gameCanvas:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: -4px;
}

.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fdf3d8;
  font-size: clamp(4rem, 16vw, 10rem);
  font-style: italic;
  font-weight: 1000;
  -webkit-text-stroke: 4px #33261a;
  text-shadow: 0 8px 0 rgba(51, 38, 26, 0.55);
  pointer-events: none;
}

.countdown.pop {
  animation: countdown-pop 580ms ease both;
}

.integrated-countdown {
  z-index: 30;
}

@keyframes countdown-pop {
  0% { transform: scale(1.7); opacity: 0; }
  28% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.72); opacity: 0; }
}

.race-message,
.combo-badge {
  position: absolute;
  left: 50%;
  z-index: 2;
  transform: translateX(-50%);
  pointer-events: none;
}

.combo-badge {
  top: 56px;
  padding: 6px 18px;
  border: 2px solid rgba(167, 245, 91, 0.75);
  border-radius: 999px;
  color: var(--lime);
  font-size: clamp(0.85rem, 2.4vw, 1.2rem);
  font-style: italic;
  font-weight: 1000;
  letter-spacing: 0.06em;
  background: rgba(4, 24, 12, 0.72);
  text-shadow: 0 0 14px rgba(167, 245, 91, 0.5);
  opacity: 0;
  transition: opacity 180ms ease;
}

.combo-badge.visible { opacity: 1; }

.combo-badge.pop {
  animation: combo-pop 320ms ease;
}

@keyframes combo-pop {
  0% { transform: translateX(-50%) scale(1.45); }
  100% { transform: translateX(-50%) scale(1); }
}

.item-panel,
.day-panel {
  position: absolute;
  z-index: 3;
  pointer-events: none;
}

.item-panel {
  top: 16px;
  left: 16px;
  display: grid;
  min-width: 164px;
  min-height: 74px;
  place-content: center;
  padding: 10px 18px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 22px;
  text-align: center;
  background: linear-gradient(145deg, rgba(11, 41, 66, 0.94), rgba(8, 113, 135, 0.84));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28), inset 0 0 24px rgba(57, 228, 255, 0.12);
}

.item-panel span,
.day-panel span {
  color: #aeeefa;
  font-size: 0.58rem;
  font-weight: 1000;
  letter-spacing: 0.14em;
}

.item-panel strong {
  overflow: hidden;
  color: white;
  font-size: clamp(0.78rem, 2vw, 1.08rem);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-panel.powered {
  border-color: var(--lime);
  box-shadow: 0 0 28px rgba(167, 245, 91, 0.34), inset 0 0 24px rgba(167, 245, 91, 0.12);
}

.day-panel {
  right: 16px;
  bottom: 16px;
  min-width: 118px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 13px;
  text-align: center;
  background: rgba(3, 19, 32, 0.82);
}

.day-panel strong {
  display: block;
  margin-top: 2px;
  color: #fff2ad;
  font-size: 1.05rem;
}

.race-message {
  top: 76px;
  min-width: 240px;
  padding: 9px 22px;
  border: 4px solid #33261a;
  border-radius: 999px;
  color: #33261a;
  text-align: center;
  font-size: 0.88rem;
  font-style: italic;
  font-weight: 1000;
  background: #fdf3d8;
  box-shadow: 0 4px 0 rgba(51, 38, 26, 0.4);
  transform: translateX(-50%) rotate(-1deg);
  opacity: 0;
  transition: opacity 160ms ease;
}

.race-message.visible { opacity: 1; }

.orientation-note {
  display: none;
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  margin-top: 10px;
}

.control-cluster {
  display: flex;
  gap: 9px;
}

.pedal-controls { justify-content: flex-end; }

.control-button {
  min-width: 72px;
  min-height: 54px;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  color: white;
  font-size: 0.78rem;
  font-weight: 1000;
  cursor: pointer;
  user-select: none;
  touch-action: none;
  background: rgba(13, 44, 68, 0.92);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08);
}

.control-button.active,
.control-button:active {
  transform: translateY(2px);
  background: #176080;
}

.control-button.accelerate {
  color: #06231f;
  background: var(--lime);
}

.control-button.brake { color: #ffdbe2; border-color: rgba(255, 105, 133, 0.45); }
.control-button.item { color: var(--cyan-soft); border-color: rgba(57, 228, 255, 0.48); }

.control-help {
  display: grid;
  gap: 2px;
  min-width: 150px;
  text-align: center;
}

.control-help strong { color: var(--cyan-soft); }
.control-help span { color: var(--muted); font-size: 0.66rem; }

.prototype-note {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 13px;
  color: #7f9aaa;
  font-size: 0.68rem;
  text-align: center;
}

.prototype-note strong { color: #b9ced8; }

dialog {
  max-width: min(560px, calc(100vw - 28px));
  border: 1px solid rgba(109, 221, 255, 0.32);
  border-radius: 24px;
  color: var(--text);
  background: linear-gradient(155deg, #102f49, #061624);
  box-shadow: 0 35px 100px rgba(0, 0, 0, 0.65);
}

dialog::backdrop {
  background: rgba(1, 8, 14, 0.78);
  backdrop-filter: blur(6px);
}

.info-dialog {
  padding: 30px;
  line-height: 1.75;
}

.info-dialog ol {
  padding-left: 1.4rem;
  color: #c3d7e1;
}

.dialog-close {
  position: absolute;
  top: 13px;
  right: 13px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.08);
}

.result-dialog {
  width: min(760px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  padding: clamp(20px, 4vw, 38px);
  text-align: center;
}

.result-position {
  margin: 0;
  color: var(--lime);
  font-size: clamp(3.7rem, 15vw, 8rem);
  font-style: italic;
  font-weight: 1000;
  letter-spacing: -0.08em;
  line-height: 0.9;
  text-shadow: 0 8px 35px rgba(167, 245, 91, 0.22);
}

.result-position.clear {
  font-size: clamp(2.8rem, 10vw, 5.3rem);
  letter-spacing: -0.04em;
}

.result-position.failed {
  color: #ff6f72;
  font-size: clamp(2.8rem, 10vw, 5.3rem);
  letter-spacing: -0.04em;
  text-shadow: 0 8px 35px rgba(255, 78, 86, 0.25);
}

.result-dialog h2 {
  margin: 8px 0 20px;
  font-size: clamp(1.35rem, 4.4vw, 2.45rem);
  line-height: 1.18;
}

.result-best {
  margin: -14px 0 18px;
  color: var(--amber);
  font-size: clamp(0.9rem, 2.6vw, 1.2rem);
  font-weight: 1000;
  letter-spacing: 0.08em;
  text-shadow: 0 0 18px rgba(255, 212, 98, 0.45);
  animation: record-blink 900ms ease infinite alternate;
}

@keyframes record-blink {
  from { opacity: 1; }
  to { opacity: 0.55; }
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 10px;
}

.result-stats div {
  min-width: 0;
  padding: 14px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.15);
}

.result-stats span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.result-stats strong {
  display: block;
  overflow: visible;
  font-size: clamp(0.82rem, 2.2vw, 1.08rem);
  line-height: 1.22;
  overflow-wrap: anywhere;
  white-space: normal;
}

.result-comment {
  min-height: 3em;
  margin: 22px 0;
  color: #c0d5df;
  line-height: 1.8;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.result-actions > button {
  min-width: 150px;
  min-height: 52px;
}

.next-stage-button {
  border-color: rgba(167, 245, 91, 0.5);
  color: var(--lime);
  background: rgba(167, 245, 91, 0.09);
}

@media (max-width: 1060px) {
  .level-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .garage-layout { grid-template-columns: 1fr; }
  .vehicle-grid { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
  .vehicle-card { display: grid; grid-template-columns: 1fr; grid-template-rows: auto; min-height: 178px; }
  .vehicle-meta,
  .vehicle-card h3,
  .vehicle-card .vehicle-kind,
  .mini-stats { grid-column: auto; grid-row: auto; }
  .selection-footer {
    grid-template-columns: minmax(280px, 0.85fr) minmax(0, 1.15fr);
    grid-template-rows: auto auto auto;
  }
  .garage-label { grid-column: 1 / -1; }
  .selected-preview { grid-row: 2 / 4; }
  .selection-footer .primary-button { width: 100%; }
}

@media (max-width: 820px) {
  .app-shell { padding-inline: 10px; }
  .select-copy { grid-template-columns: 1fr; gap: 10px; }
  .level-grid { grid-template-columns: 1fr; }
  .level-card { min-height: 96px; }
  .selection-footer { grid-template-columns: 1fr; grid-template-rows: auto auto auto auto; }
  .garage-label { grid-column: auto; }
  .selected-preview { grid-row: auto; }
  .vehicle-preview-model { width: 100%; max-width: 420px; }
  .vehicle-grid { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
  .hud { grid-template-columns: repeat(4, 1fr); }
  .hud-wide { grid-column: span 4; order: 5; }
  .route-dot b { display: none; }
  .route-progress { margin-bottom: 12px; }
  .controls { grid-template-columns: 1fr 1fr; }
  .control-help { display: none; }
  .control-button { min-width: 58px; }
  .prototype-note { flex-direction: column; gap: 2px; }
  .integrated-drive-topbar { left: 12px; min-height: 60px; padding: 10px 12px; }
  .drive-region-banner {
    top: 188px;
    right: 12px;
    width: min(300px, calc(100vw - 176px));
    min-width: 0;
    padding: 10px 24px 12px;
    border-radius: 15px;
  }
  .integrated-drive-status { display: none; }
  .integrated-route-panel { top: 82px; width: calc(100vw - 24px); }
  .integrated-item-panel { top: 176px; width: 136px; min-height: 92px; padding: 10px; }
  .integrated-item-panel strong { width: 58px; height: 58px; font-size: 0.62rem; }
  .integrated-fuel-panel {
    left: 10px;
    bottom: 148px;
    width: min(310px, calc(100vw - 20px));
    padding: 10px 12px;
  }
  .integrated-fuel-head strong { font-size: 0.92rem; }
  .integrated-fuel-track { height: 14px; }
  .integrated-drive-message { top: 178px; min-width: calc(100vw - 180px); }
  .integrated-telemetry {
    grid-template-columns: repeat(3, minmax(82px, 1fr));
    right: 10px;
    bottom: 10px;
    min-width: calc(100vw - 20px);
    padding: 10px;
  }
}

/* The 3D game is fullscreen, so its touch controls must live inside the
   integrated scene rather than in the desktop control strip below it. */
@media (max-width: 820px),
       (hover: none) and (pointer: coarse),
       (orientation: landscape) and (max-height: 500px) {
  .mobile-drive-controls {
    position: absolute;
    z-index: 12;
    inset: 0;
    display: block;
    pointer-events: none;
  }

  body.real-drive-main .integrated-route-panel {
    top: 70px;
  }

  .mobile-control-button {
    position: absolute;
    display: grid;
    place-items: center;
    margin: 0;
    padding: 0;
    border: 2px solid rgba(231, 252, 255, 0.78);
    color: #f2fdff;
    font-family: inherit;
    font-weight: 1000;
    line-height: 1;
    background: linear-gradient(155deg, rgba(15, 55, 78, 0.93), rgba(4, 22, 36, 0.9));
    box-shadow:
      0 10px 28px rgba(0, 0, 0, 0.34),
      inset 0 1px rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    transform: translateY(0) scale(1);
    transition: transform 70ms ease, filter 70ms ease, background 70ms ease;
  }

  .mobile-control-button.active,
  .mobile-control-button:active {
    filter: brightness(1.18);
    transform: translateY(2px) scale(0.96);
  }

  .mobile-accelerator {
    bottom: calc(14px + env(safe-area-inset-bottom));
    left: calc(14px + env(safe-area-inset-left));
    width: 92px;
    height: 92px;
    border-color: rgba(202, 255, 113, 0.92);
    border-radius: 50%;
    color: #08281d;
    background: radial-gradient(circle at 35% 28%, #e9ff9c, #9cf052 58%, #51b93c);
    box-shadow:
      0 11px 32px rgba(38, 170, 79, 0.34),
      inset 0 3px rgba(255, 255, 255, 0.44),
      inset 0 -5px rgba(26, 98, 47, 0.22);
  }

  .mobile-accelerator span,
  .mobile-item-button span {
    align-self: end;
    font-size: 0.58rem;
    letter-spacing: 0.12em;
  }

  .mobile-accelerator strong {
    align-self: start;
    margin-top: 3px;
    font-size: 1.55rem;
    letter-spacing: 0.02em;
  }

  .mobile-steering-controls {
    position: absolute;
    right: calc(12px + env(safe-area-inset-right));
    bottom: calc(18px + env(safe-area-inset-bottom));
    display: flex;
    gap: 9px;
    padding: 10px;
    pointer-events: auto;
    touch-action: none;
  }

  .mobile-steering-controls .mobile-steer-button {
    position: relative;
    width: 70px;
    height: 70px;
    border-radius: 22px;
    font-size: 1.65rem;
  }

  .mobile-item-button {
    right: calc(10px + env(safe-area-inset-right));
    bottom: calc(116px + env(safe-area-inset-bottom));
    left: auto;
    width: 112px;
    height: 63px;
    border-color: rgba(95, 232, 255, 0.8);
    border-radius: 18px;
    color: #dffbff;
    transform: translateY(0) scale(1);
  }

  .mobile-item-button.active,
  .mobile-item-button:active {
    transform: translateY(2px) scale(0.96);
  }

  .mobile-item-button strong {
    align-self: start;
    margin-top: 3px;
    color: var(--lime);
    font-size: 0.72rem;
  }

  /* Dedicated bottom corners are reserved for touch controls. Keep the two
     essential meters immediately above them and collapse duplicate telemetry. */
  .integrated-item-panel {
    display: none;
  }

  .integrated-fuel-panel {
    left: calc(10px + env(safe-area-inset-left));
    bottom: calc(116px + env(safe-area-inset-bottom));
    width: min(220px, calc(100vw - 164px));
    padding: 9px 11px;
  }

  .integrated-fuel-head {
    margin-bottom: 7px;
  }

  .integrated-fuel-head span {
    font-size: 0.53rem;
  }

  .integrated-fuel-head strong {
    font-size: 0.84rem;
  }

  .integrated-fuel-track {
    height: 12px;
  }

  .integrated-fuel-panel small {
    margin-top: 5px;
    overflow: hidden;
    font-size: 0.56rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .integrated-telemetry {
    top: 170px;
    right: auto;
    bottom: auto;
    left: calc(10px + env(safe-area-inset-left));
    display: block;
    width: auto;
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  .integrated-telemetry div {
    display: none;
  }

  .integrated-telemetry div:nth-child(2) {
    display: block;
    min-width: 112px;
    padding: 9px 11px;
    border: 1px solid rgba(126, 222, 255, 0.3);
    background: linear-gradient(145deg, rgba(7, 25, 43, 0.86), rgba(3, 11, 20, 0.78));
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(10px);
  }

  .integrated-telemetry div:nth-child(2) strong {
    font-size: 1rem;
  }
}

@media (max-width: 420px),
       (hover: none) and (pointer: coarse) and (max-height: 460px),
       (orientation: landscape) and (max-height: 460px) {
  .mobile-accelerator {
    width: 82px;
    height: 82px;
  }

  .mobile-steering-controls .mobile-steer-button {
    width: 62px;
    height: 62px;
  }

  .integrated-fuel-panel,
  .mobile-item-button {
    bottom: calc(104px + env(safe-area-inset-bottom));
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    width: 100%;
    max-width: none;
    padding: 6px 8px;
  }

  .site-header {
    min-height: 38px;
    margin-bottom: 6px;
  }

  .site-header .eyebrow {
    display: none;
  }

  .site-header h1 {
    font-size: clamp(1.08rem, 3.2vw, 1.45rem);
    white-space: nowrap;
  }

  .header-actions {
    gap: 5px;
  }

  .header-actions .ghost-button {
    min-height: 32px;
    padding: 6px 11px;
    font-size: 0.68rem;
  }

  .select-screen {
    display: grid;
    grid-template-rows: 96px minmax(0, 1fr);
    gap: 7px;
    height: calc(100dvh - 50px);
    min-height: 0;
    padding: 7px;
    overflow: hidden;
    border-radius: 17px;
  }

  .landing-screen {
    height: calc(100dvh - 50px);
    min-height: 0;
    padding: 14px 28px;
    border-radius: 17px;
  }

  .landing-content .kicker {
    margin-bottom: 6px;
    font-size: 0.64rem;
  }

  .landing-content h2 {
    font-size: clamp(1.9rem, 6.2vw, 3.2rem);
  }

  .landing-description {
    max-width: 720px;
    margin-top: 12px;
    font-size: clamp(0.72rem, 2vw, 0.9rem);
    line-height: 1.55;
  }

  .landing-start-button {
    min-width: 250px;
    min-height: 48px;
    margin-top: 16px;
    padding: 10px 22px;
    font-size: 0.92rem;
  }

  .select-copy {
    display: none;
  }

  .level-picker {
    display: grid;
    grid-template-rows: 20px minmax(0, 1fr);
    gap: 5px;
    min-height: 0;
    margin: 0;
    padding: 6px 8px;
    border-radius: 13px;
  }

  .level-picker-heading {
    min-height: 0;
    margin: 0;
  }

  .level-picker-heading span,
  .level-picker-heading b,
  .level-key-help {
    display: none;
  }

  .level-picker-heading h3 {
    margin: 0;
    font-size: 0.76rem;
    line-height: 20px;
  }

  .level-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    min-height: 0;
  }

  .level-card {
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    gap: 2px 7px;
    min-height: 0;
    height: 58px;
    padding: 7px 8px;
    border-radius: 11px;
  }

  .level-card[aria-checked="true"]::before {
    top: 4px;
    right: 4px;
    width: 17px;
    height: 17px;
    font-size: 0.58rem;
  }

  .level-index {
    grid-row: 1 / 3;
    font-size: 1.2rem;
  }

  .level-route {
    padding-right: 14px;
    overflow: hidden;
    font-size: 0.65rem;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .level-features {
    display: flex;
    grid-column: 2;
    align-self: end;
    white-space: nowrap;
  }

  .level-features .level-difficulty {
    padding: 1px 4px;
    font-size: 0.46rem;
  }

  .garage-layout {
    display: grid;
    grid-template-columns: minmax(260px, 0.92fr) minmax(260px, 1.08fr);
    gap: 7px;
    min-height: 0;
  }

  .machine-picker,
  .selection-footer {
    min-height: 0;
    padding: 7px;
    border-radius: 13px;
  }

  .machine-picker {
    display: grid;
    grid-template-rows: 24px minmax(0, 1fr);
    gap: 5px;
  }

  .machine-picker .picker-heading {
    min-height: 0;
    margin: 0;
  }

  .machine-picker .picker-heading span,
  .machine-picker .picker-heading b {
    display: none;
  }

  .machine-picker .picker-heading h3 {
    margin: 0;
    font-size: 0.76rem;
    line-height: 24px;
  }

  .vehicle-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    min-height: 0;
  }

  .vehicle-card {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto minmax(0, 1fr);
    gap: 4px;
    min-width: 0;
    min-height: 0;
    height: 100%;
    padding: 9px;
    border-radius: 11px;
  }

  .vehicle-card[aria-checked="true"]::before {
    top: 5px;
    right: 5px;
    width: 18px;
    height: 18px;
    font-size: 0.6rem;
  }

  .vehicle-meta {
    grid-column: 1;
    font-size: 0.52rem;
  }

  .vehicle-meta b {
    display: none;
  }

  .vehicle-card h3 {
    grid-column: 1;
    grid-row: 2;
    align-self: end;
    margin: 0;
    font-size: 0.9rem;
  }

  .vehicle-card .vehicle-kind {
    grid-column: 1;
    grid-row: 3;
    min-height: 0;
    margin: 0;
    font-size: 0.54rem;
  }

  .mini-stats {
    grid-column: 1;
    grid-row: 4;
    display: grid;
    gap: 2px;
    align-self: stretch;
    margin-top: 2px;
  }

  .mini-stat {
    grid-template-columns: 58px minmax(34px, 1fr);
    gap: 5px;
    min-height: 13px;
    font-size: 0.56rem;
    line-height: 1;
  }

  .mini-stat i {
    height: 3px;
  }


  .selection-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 50px;
    gap: 7px;
  }

  .garage-label,
  .selected-summary {
    display: none;
  }

  .selected-preview {
    grid-column: 1;
    grid-row: 1;
    min-height: 0;
    padding: 3px;
    border-radius: 11px;
  }

  .vehicle-preview-model {
    width: 100%;
    height: 100%;
    min-height: 120px;
  }

  .selection-footer .primary-button {
    grid-column: 1;
    grid-row: 2;
    align-self: stretch;
    flex-direction: row;
    gap: 10px;
    min-width: 0;
    min-height: 0;
    padding: 9px;
    border-radius: 13px;
    font-size: 0.76rem;
    line-height: 1.35;
    text-align: center;
  }

  .prototype-note {
    display: none;
  }

  .integrated-drive-topbar {
    top: 8px;
    left: 84px;
    right: 8px;
    min-height: 54px;
    padding: 8px 12px;
  }

  .integrated-drive-topbar .eyebrow,
  .integrated-drive-status {
    display: none;
  }

  .integrated-drive-topbar h2 {
    font-size: clamp(1.05rem, 3vw, 1.45rem);
  }

  .integrated-route-panel {
    top: 8px;
    right: 8px;
    left: auto;
    width: min(620px, calc(100vw - 180px));
    padding: 9px 14px 17px;
    transform: none;
  }

  body.real-drive-main .integrated-route-panel {
    top: 8px;
  }

  .integrated-route-head {
    margin-bottom: 7px;
  }

  .integrated-route-dots {
    display: none;
  }

  .integrated-drive-message {
    top: 130px;
    min-width: min(380px, calc(100vw - 280px));
    padding: 8px 14px;
    font-size: 0.82rem;
  }

  .integrated-telemetry {
    top: 146px;
  }
}

@media (max-width: 540px) {
  .site-header {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
  }
  .site-header .eyebrow { display: none; }
  .site-header h1 {
    font-size: clamp(1.45rem, 7.4vw, 1.8rem);
    line-height: 1.05;
    white-space: nowrap;
  }
  .header-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
  .header-actions .ghost-button {
    min-width: 0;
    padding: 9px 7px;
    font-size: 0.7rem;
    white-space: nowrap;
  }
  .select-screen { border-radius: 20px; }
  .level-picker { padding: 12px; border-radius: 18px; }
  .level-card { min-height: 90px; padding: 12px; }
  .level-index { font-size: 1.45rem; }
  .level-key-help { display: none; }
  .machine-picker,
  .selection-footer { padding: 12px; border-radius: 18px; }
  .vehicle-grid { grid-template-columns: 1fr; gap: 8px; }
  .vehicle-card { min-width: 0; min-height: 154px; padding: 13px 10px; }
  .vehicle-card h3 { font-size: 1rem; }
  .vehicle-card .vehicle-kind { font-size: 0.62rem; }
  .selected-summary { grid-template-columns: 1fr; }
  .summary-route { grid-template-columns: auto 1fr; }
  .summary-route em { grid-column: 2; }
  .hud-block { padding: 8px 9px; }
  .hud-block strong { font-size: 0.85rem; }
  .control-button { min-width: 50px; min-height: 50px; padding: 8px; font-size: 0.68rem; }
  .steering-controls, .pedal-controls { gap: 5px; }
  .controls { gap: 7px; }
  .result-stats { grid-template-columns: repeat(2, 1fr); }
  .result-stats div:last-child { grid-column: span 2; }
  .integrated-route-dot b { display: none; }
  .drive-region-banner {
    top: 178px;
    right: 8px;
    width: min(248px, calc(100vw - 152px));
    padding: 9px 18px 10px;
  }
  .drive-region-kicker { font-size: 0.5rem; }
  .drive-region-banner strong { font-size: clamp(1.35rem, 8vw, 2rem); }
  .drive-region-banner small { font-size: 0.6rem; }
  .integrated-route-panel { padding-bottom: 16px; }
  .integrated-route-dots { display: none; }
  .integrated-item-panel { opacity: 0.92; }
  .integrated-drive-message {
    top: 150px;
    right: 8px;
    left: auto;
    min-width: 0;
    max-width: calc(100vw - 160px);
    padding: 8px 12px;
    font-size: 0.78rem;
    transform: translateY(-8px);
  }
  .integrated-drive-message.visible { transform: translateY(0); }
  .integrated-telemetry div { padding: 8px; }
  .integrated-telemetry strong { font-size: 0.86rem; }
}

@media (max-width: 620px) {
  .item-panel { top: 7px; left: 7px; min-width: 96px; min-height: 45px; padding: 5px 8px; border-radius: 13px; }
  .item-panel strong { font-size: 0.68rem; }
  .day-panel { right: 7px; bottom: 7px; min-width: 76px; padding: 5px 7px; }
  .day-panel span { font-size: 0.45rem; }
  .day-panel strong { font-size: 0.72rem; }
}

@media (orientation: portrait) and (max-width: 620px) {
  .orientation-note {
    position: absolute;
    right: 7px;
    top: 58px;
    bottom: auto;
    display: block;
    padding: 4px 7px;
    border-radius: 7px;
    color: #b8d0dc;
    font-size: 0.52rem;
    background: rgba(0, 0, 0, 0.56);
  }
}

/* Mobile race HUD: keep essential meters in a fixed stack and leave the road
   centre clear. Steering follows the captured finger's current hit zone. */
@media (max-width: 820px),
       (hover: none) and (pointer: coarse),
       (orientation: landscape) and (max-height: 500px) {
  body.real-drive-main .integrated-telemetry {
    top: calc(82px + env(safe-area-inset-top));
    right: auto;
    bottom: auto;
    left: calc(10px + env(safe-area-inset-left));
  }

  body.real-drive-main .integrated-fuel-panel {
    top: calc(146px + env(safe-area-inset-top));
    right: auto;
    bottom: auto;
    left: calc(10px + env(safe-area-inset-left));
    width: 220px;
    max-width: calc(100vw - 140px - env(safe-area-inset-left) - env(safe-area-inset-right));
  }

  body.real-drive-main .integrated-drive-message {
    top: calc(82px + env(safe-area-inset-top));
    right: calc(10px + env(safe-area-inset-right));
    left: auto;
    width: min(330px, calc(100vw - 250px - env(safe-area-inset-left) - env(safe-area-inset-right)));
    min-width: 0;
    max-width: none;
    padding: 8px 12px;
    font-size: 0.78rem;
    transform: translateY(-8px);
  }

  body.real-drive-main .integrated-drive-message.visible {
    transform: translateY(0);
  }

  .mobile-steering-controls {
    gap: 9px;
  }
}

@media (orientation: landscape) and (max-height: 460px) {
  .mobile-steering-controls .mobile-steer-button {
    width: 62px;
    height: 62px;
  }

  body.real-drive-main .integrated-fuel-panel {
    top: calc(146px + env(safe-area-inset-top));
    padding-top: 8px;
    padding-bottom: 8px;
  }

  body.real-drive-main .integrated-telemetry,
  body.real-drive-main .integrated-drive-message {
    top: calc(78px + env(safe-area-inset-top));
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .result-dialog {
    box-sizing: border-box;
    width: min(760px, calc(100vw - 20px - env(safe-area-inset-left) - env(safe-area-inset-right)));
    max-height: calc(100dvh - 12px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    padding: 10px 16px;
    overscroll-behavior: contain;
  }

  .result-dialog > .eyebrow,
  .result-best[hidden] {
    display: none;
  }

  .result-position,
  .result-position.clear,
  .result-position.failed {
    font-size: clamp(2.25rem, 12vh, 3.7rem);
    line-height: 0.88;
  }

  .result-dialog h2 {
    margin: 4px 0 8px;
    font-size: clamp(1rem, 4vh, 1.35rem);
  }

  .result-best {
    margin: -3px 0 7px;
    font-size: 0.72rem;
  }

  .result-stats {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
  }

  .result-stats div {
    padding: 7px 6px;
    border-radius: 10px;
  }

  .result-stats span {
    margin-bottom: 3px;
    font-size: 0.48rem;
  }

  .result-stats strong {
    font-size: clamp(0.68rem, 2.5vh, 0.9rem);
  }

  .result-comment {
    min-height: 0;
    margin: 7px 0;
    font-size: 0.7rem;
    line-height: 1.4;
  }

  .result-actions {
    gap: 6px;
  }

  .result-actions > button {
    min-width: 128px;
    min-height: 38px;
    padding: 7px 11px;
    font-size: 0.72rem;
  }
}

/* Compact mobile HUD. Landscape keeps only the essential readouts; portrait
   remains fully playable with controls lifted above browser chrome. */
@media (max-width: 820px),
       (hover: none) and (pointer: coarse),
       (orientation: landscape) and (max-height: 500px) {
  body.real-drive-main .real-drive-exit {
    top: calc(8px + env(safe-area-inset-top));
    left: calc(8px + env(safe-area-inset-left));
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border-radius: 14px;
    font-size: 0;
  }

  body.real-drive-main .real-drive-exit::after {
    content: "←";
    font-size: 1.2rem;
    font-weight: 1000;
  }

  body.real-drive-main .integrated-route-panel {
    top: calc(8px + env(safe-area-inset-top));
    right: calc(8px + env(safe-area-inset-right));
    left: calc(60px + env(safe-area-inset-left));
    width: auto;
    padding: 7px 11px 10px;
    border-radius: 14px;
    transform: none;
  }

  body.real-drive-main .integrated-route-head {
    gap: 8px;
    margin-bottom: 5px;
  }

  body.real-drive-main .integrated-route-head span {
    font-size: 0.54rem;
    letter-spacing: 0.1em;
  }

  body.real-drive-main .integrated-route-head strong {
    overflow: hidden;
    max-width: 68%;
    font-size: 0.66rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.real-drive-main .integrated-route-track {
    height: 7px;
    border-width: 1px;
  }

  body.real-drive-main .integrated-route-dots {
    display: none;
  }

  body.real-drive-main .integrated-telemetry {
    top: calc(62px + env(safe-area-inset-top));
    left: calc(8px + env(safe-area-inset-left));
  }

  body.real-drive-main .integrated-telemetry div:nth-child(2) {
    min-width: 84px;
    padding: 6px 8px;
    border-radius: 12px;
  }

  body.real-drive-main .integrated-telemetry div:nth-child(2) span {
    display: none;
  }

  body.real-drive-main .integrated-telemetry div:nth-child(2) strong {
    margin: 0;
    font-size: 0.84rem;
  }

  body.real-drive-main .integrated-fuel-panel {
    top: calc(104px + env(safe-area-inset-top));
    left: calc(8px + env(safe-area-inset-left));
    width: 164px;
    max-width: calc(100vw - 120px - env(safe-area-inset-left) - env(safe-area-inset-right));
    padding: 6px 8px 7px;
    border-radius: 13px;
  }

  body.real-drive-main .integrated-fuel-head {
    margin-bottom: 4px;
  }

  body.real-drive-main .integrated-fuel-head span {
    font-size: 0.46rem;
    letter-spacing: 0.09em;
  }

  body.real-drive-main .integrated-fuel-head strong {
    font-size: 0.72rem;
  }

  body.real-drive-main .integrated-fuel-track {
    height: 8px;
    border-width: 1px;
  }

  body.real-drive-main .integrated-fuel-panel small {
    display: none;
  }

  body.real-drive-main .integrated-drive-message {
    top: calc(62px + env(safe-area-inset-top));
    right: calc(8px + env(safe-area-inset-right));
    width: min(280px, calc(100vw - 205px - env(safe-area-inset-left) - env(safe-area-inset-right)));
    padding: 6px 9px;
    border-radius: 12px;
    font-size: 0.68rem;
  }

  .mobile-accelerator {
    width: 76px;
    height: 76px;
  }

  .mobile-steering-controls .mobile-steer-button {
    width: 68px;
    height: 68px;
    border-radius: 21px;
    font-size: 1.62rem;
  }

  .mobile-item-button {
    width: 86px;
    height: 50px;
    border-radius: 15px;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .mobile-accelerator {
    bottom: calc(12px + env(safe-area-inset-bottom));
    left: calc(12px + env(safe-area-inset-left));
  }

  .mobile-steering-controls {
    right: calc(2px + env(safe-area-inset-right));
    bottom: calc(4px + env(safe-area-inset-bottom));
    gap: 14px;
  }

  .mobile-item-button {
    right: calc(10px + env(safe-area-inset-right));
    bottom: calc(96px + env(safe-area-inset-bottom));
  }
}

@media (orientation: portrait) and (max-width: 820px) {
  body.real-drive-main .integrated-route-panel {
    top: calc(10px + env(safe-area-inset-top));
    right: calc(10px + env(safe-area-inset-right));
    left: calc(62px + env(safe-area-inset-left));
  }

  body.real-drive-main .integrated-telemetry {
    top: calc(70px + env(safe-area-inset-top));
    left: calc(10px + env(safe-area-inset-left));
  }

  body.real-drive-main .integrated-fuel-panel {
    top: calc(70px + env(safe-area-inset-top));
    left: calc(104px + env(safe-area-inset-left));
    width: min(178px, calc(100vw - 118px - env(safe-area-inset-left) - env(safe-area-inset-right)));
    max-width: none;
  }

  body.real-drive-main .integrated-drive-message {
    top: calc(122px + env(safe-area-inset-top));
    right: calc(10px + env(safe-area-inset-right));
    width: min(270px, calc(100vw - 20px - env(safe-area-inset-left) - env(safe-area-inset-right)));
    max-width: none;
  }

  .mobile-accelerator {
    bottom: calc(36px + env(safe-area-inset-bottom));
    left: calc(18px + env(safe-area-inset-left));
    width: 88px;
    height: 88px;
  }

  .mobile-steering-controls {
    right: calc(8px + env(safe-area-inset-right));
    bottom: calc(22px + env(safe-area-inset-bottom));
    gap: 16px;
  }

  .mobile-steering-controls .mobile-steer-button {
    width: 78px;
    height: 78px;
    border-radius: 24px;
    font-size: 1.75rem;
  }

  .mobile-item-button {
    right: calc(18px + env(safe-area-inset-right));
    bottom: calc(126px + env(safe-area-inset-bottom));
    width: 94px;
    height: 54px;
  }

  .drive-region-banner {
    top: calc(184px + env(safe-area-inset-top));
    right: calc(10px + env(safe-area-inset-right));
    width: min(264px, calc(100vw - 20px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  }

  .result-dialog {
    max-height: calc(100dvh - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }

  .drive-region-banner.visible {
    opacity: 1;
    animation: none !important;
    transform: none;
  }

  .drive-speed-lines { display: none; }
  .drive-fx-layer.is-low-fuel .drive-low-fuel-edge {
    opacity: 0.48;
    animation: none !important;
  }
}

/* Shared race HUD. Desktop and mobile use the same visual hierarchy and
   anchors; touch-only controls remain gated by the coarse-pointer queries. */
body.real-drive-main .real-drive-exit {
  top: calc(8px + env(safe-area-inset-top));
  left: calc(8px + env(safe-area-inset-left));
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 14px;
  font-size: 0;
}

body.real-drive-main .real-drive-exit::after {
  content: "←";
  font-size: 1.2rem;
  font-weight: 1000;
}

body.real-drive-main .integrated-route-panel {
  top: calc(8px + env(safe-area-inset-top));
  right: calc(8px + env(safe-area-inset-right));
  left: calc(60px + env(safe-area-inset-left));
  width: auto;
  padding: 7px 11px 10px;
  border-radius: 14px;
  transform: none;
}

body.real-drive-main .integrated-route-head {
  gap: 8px;
  margin-bottom: 5px;
}

body.real-drive-main .integrated-route-head span {
  font-size: 0.54rem;
  letter-spacing: 0.1em;
}

body.real-drive-main .integrated-route-head strong {
  overflow: hidden;
  max-width: 68%;
  font-size: 0.66rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.real-drive-main .integrated-route-track {
  height: 7px;
  border-width: 1px;
}

body.real-drive-main .integrated-route-dots {
  display: none;
}

body.real-drive-main .integrated-telemetry {
  top: calc(62px + env(safe-area-inset-top));
  right: auto;
  bottom: auto;
  left: calc(8px + env(safe-area-inset-left));
  display: block;
  width: auto;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

body.real-drive-main .integrated-telemetry div {
  display: none;
}

body.real-drive-main .integrated-telemetry div:nth-child(2) {
  display: block;
  min-width: 92px;
  padding: 6px 9px;
  border: 1px solid rgba(126, 222, 255, 0.3);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(7, 25, 43, 0.86), rgba(3, 11, 20, 0.78));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
}

body.real-drive-main .integrated-telemetry div:nth-child(2) span {
  display: none;
}

body.real-drive-main .integrated-telemetry div:nth-child(2) strong {
  margin: 0;
  font-size: 0.84rem;
}

body.real-drive-main .integrated-fuel-panel {
  top: calc(104px + env(safe-area-inset-top));
  right: auto;
  bottom: auto;
  left: calc(8px + env(safe-area-inset-left));
  width: 164px;
  max-width: calc(100vw - 120px - env(safe-area-inset-left) - env(safe-area-inset-right));
  padding: 6px 8px 7px;
  border-radius: 13px;
}

body.real-drive-main .integrated-fuel-head {
  margin-bottom: 4px;
}

body.real-drive-main .integrated-fuel-head span {
  font-size: 0.46rem;
  letter-spacing: 0.09em;
}

body.real-drive-main .integrated-fuel-head strong {
  font-size: 0.72rem;
}

body.real-drive-main .integrated-fuel-track {
  height: 8px;
  border-width: 1px;
}

body.real-drive-main .integrated-fuel-panel small {
  display: none;
}

body.real-drive-main .integrated-item-panel {
  top: auto;
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: auto;
  width: 92px;
  min-height: 70px;
  padding: 7px;
  border-radius: 15px;
}

body.real-drive-main .integrated-item-panel strong {
  width: 43px;
  height: 43px;
  border-width: 2px;
  font-size: 0.58rem;
}

body.real-drive-main .integrated-item-panel small {
  display: none;
}

body.real-drive-main .integrated-drive-message {
  top: calc(62px + env(safe-area-inset-top));
  right: auto;
  left: 50%;
  width: min(260px, calc(100vw - 440px));
  min-width: 0;
  padding: 7px 11px;
  border-radius: 12px;
  font-size: 0.76rem;
}

body.real-drive-main .drive-region-banner {
  top: calc(62px + env(safe-area-inset-top));
  right: calc(8px + env(safe-area-inset-right));
  width: min(300px, calc(100vw - 220px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  min-width: 0;
  padding: 9px 22px 10px;
  border-radius: 15px;
}

body.real-drive-main .drive-region-banner strong {
  font-size: clamp(1.25rem, 2.8vw, 2rem);
}

/* Desktop race HUD: keep the compact mobile-safe anchors, but restore the
   glanceable size expected on a laptop/desktop display. */
@media (min-width: 821px) and (hover: hover) and (pointer: fine) {
  body.real-drive-main .integrated-route-panel {
    top: 12px;
    right: 14px;
    left: 72px;
    padding: 10px 16px 13px;
    border-radius: 17px;
  }

  body.real-drive-main .integrated-route-head {
    margin-bottom: 7px;
  }

  body.real-drive-main .integrated-route-head span {
    font-size: 0.68rem;
    letter-spacing: 0.12em;
  }

  body.real-drive-main .integrated-route-head strong {
    font-size: 0.86rem;
  }

  body.real-drive-main .integrated-route-track {
    height: 10px;
  }

  body.real-drive-main .integrated-telemetry {
    top: 82px;
    left: 14px;
  }

  body.real-drive-main .integrated-telemetry div:nth-child(2) {
    min-width: 138px;
    padding: 10px 14px;
    border-radius: 15px;
  }

  body.real-drive-main .integrated-telemetry div:nth-child(2) strong {
    font-size: 1.22rem;
  }

  body.real-drive-main .integrated-fuel-panel {
    top: 145px;
    left: 14px;
    width: 238px;
    max-width: none;
    padding: 11px 13px 12px;
    border-radius: 16px;
  }

  body.real-drive-main .integrated-fuel-head {
    margin-bottom: 7px;
  }

  body.real-drive-main .integrated-fuel-head span {
    font-size: 0.63rem;
    letter-spacing: 0.11em;
  }

  body.real-drive-main .integrated-fuel-head strong {
    font-size: 1rem;
  }

  body.real-drive-main .integrated-fuel-track {
    height: 13px;
  }

  body.real-drive-main .integrated-item-panel {
    right: 20px;
    bottom: 20px;
    width: 132px;
    min-height: 118px;
    gap: 6px;
    padding: 12px;
    border-radius: 19px;
  }

  body.real-drive-main .integrated-item-panel span,
  body.real-drive-main .integrated-item-panel small {
    display: block;
    font-size: 0.68rem;
  }

  body.real-drive-main .integrated-item-panel strong {
    width: 68px;
    height: 68px;
    border-width: 3px;
    font-size: 0.82rem;
  }

  body.real-drive-main .integrated-drive-message {
    top: 84px;
    width: min(420px, calc(100vw - 520px));
    padding: 9px 15px;
    font-size: 0.9rem;
  }

  body.real-drive-main .drive-region-banner {
    top: 84px;
  }
}

@media (max-width: 820px),
       (hover: none) and (pointer: coarse),
       (orientation: landscape) and (max-height: 500px) {
  body.real-drive-main .integrated-item-panel {
    display: none;
  }
}

@media (orientation: portrait) and (max-width: 820px) {
  body.real-drive-main .integrated-fuel-panel {
    top: calc(70px + env(safe-area-inset-top));
    left: calc(104px + env(safe-area-inset-left));
    width: min(178px, calc(100vw - 118px - env(safe-area-inset-left) - env(safe-area-inset-right)));
    max-width: none;
  }

  body.real-drive-main .drive-region-banner {
    top: calc(128px + env(safe-area-inset-top));
    right: calc(10px + env(safe-area-inset-right));
    width: min(264px, calc(100vw - 20px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  }
}
