:root {
  --bg: #f4e4ca;
  --bg-soft: #fff3df;
  --ink: #171311;
  --muted: #675a4c;
  --line: rgba(23, 19, 17, 0.14);
  --line-strong: rgba(23, 19, 17, 0.24);
  --panel: rgba(250, 241, 227, 0.84);
  --shadow: 0 18px 0 rgba(24, 18, 14, 0.1), 0 28px 58px rgba(24, 18, 14, 0.2);
  --accent: #d15a34;
  --accent-deep: #a63e1d;
  --accent-soft: #ffd6bf;
  --teal: #235c59;
  --teal-soft: #d4e7df;
  --warn: #efb132;
  --warn-soft: #ffe8b6;
  --danger: #c54a38;
  --danger-soft: #ffd8d0;
  --ok: #389757;
  --ok-soft: #d6f0db;
  --arcade-cream: #fff1bc;
  --arcade-black: #090807;
  --arcade-gold: #ffc83d;
  --arcade-road: #32343b;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Outfit", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 10%, rgba(255, 255, 255, 0.62), transparent 22%),
    linear-gradient(180deg, #9ed8ff 0%, #87cdfa 45%, #b7e5ff 100%);
}

body.app-closed {
  overflow: hidden;
}

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  background-image:
    linear-gradient(rgba(17, 32, 45, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 32, 45, 0.018) 1px, transparent 1px);
  background-size: 18px 18px;
}

.page-shell {
  position: relative;
  width: 100%;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

body.app-closed .page-shell {
  width: 100%;
  margin: 0;
  padding: 0;
}

.app-shell {
  display: grid;
  gap: 0;
}

body.app-closed .app-shell {
  display: none;
}

body.app-open .entry-menu {
  min-height: 0;
  max-height: 0;
  margin: 0;
  padding-top: 0;
  padding-bottom: 0;
  border: 0;
  box-shadow: none;
  overflow: hidden;
}

.entry-menu {
  position: relative;
  min-height: 100vh;
  width: 100%;
  display: block;
  overflow: hidden;
  padding: 0;
  margin-bottom: 0;
  border-radius: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  isolation: isolate;
}

.home-frame {
  display: block;
  width: 100%;
  height: 100vh;
  border: 0;
  background: transparent;
}

#scene {
  position: relative;
  width: 100%;
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
  background: linear-gradient(135deg, #149fce 0%, #1f63dc 58%, #2126ea 100%);
  cursor: none;
}

.scene-sky {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  z-index: 0;
}

.cloud {
  position: absolute;
  z-index: 1;
  pointer-events: none;
  user-select: none;
  will-change: transform;
}

.cloud img {
  display: block;
}

#c1 { left: 4%; top: 32%; z-index: 2; }
#c1 img { width: 220px; }
#c2 { left: 6%; top: 52%; z-index: 2; }
#c2 img { width: 170px; }
#c3 { left: 4%; top: 68%; z-index: 2; }
#c3 img { width: 150px; }
#c4 { left: 68%; top: 22%; z-index: 2; }
#c4 img { width: 200px; }
#c5 { left: 76%; top: 44%; z-index: 2; }
#c5 img { width: 160px; }
#c6 { left: 72%; top: 62%; z-index: 2; }
#c6 img { width: 180px; }
#c7 { left: 83%; top: 74%; z-index: 2; }
#c7 img { width: 140px; }
#c8 { left: 20%; top: 12%; z-index: 1; }
#c8 img { width: 120px; opacity: 0.7; }

#title-wrap {
  position: absolute;
  top: 2.4%;
  left: 50%;
  z-index: 5;
  width: min(36vw, 520px);
  height: min(18vw, 220px);
  transform: translateX(-50%);
  text-align: center;
  overflow: hidden;
  will-change: transform;
}

#title-wrap img {
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  width: 182%;
  max-width: none;
  height: auto;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 4px 0 rgba(0, 0, 60, 0.18));
}

#subtitle {
  position: absolute;
  top: 18.4%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  color: #23384d;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
  font-family: "Arial Black", sans-serif;
  will-change: transform;
}

#island-wrap {
  position: absolute;
  left: 50%;
  top: 52.5%;
  transform: translate(-50%, -50%);
  z-index: 3;
  animation: floatIsland 4.5s ease-in-out infinite;
  will-change: margin-left, margin-top;
}

#island-wrap img {
  width: min(40vw, 760px);
  display: block;
  filter: drop-shadow(0 40px 70px rgba(0, 0, 60, 0.4));
}

#buttons {
  position: absolute;
  bottom: 4.4%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  gap: 20px;
  align-items: center;
  will-change: transform;
}

.scene-button {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    filter 0.15s ease;
}

.scene-button img {
  display: block;
  height: 74px;
  width: auto;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 80, 0.35));
}

.scene-button:hover,
.scene-button:focus-visible {
  transform: translateY(-5px) scale(1.05);
  filter: drop-shadow(0 14px 28px rgba(0, 0, 80, 0.45)) brightness(1.08);
  outline: none;
}

#cursor {
  position: fixed;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  transition:
    width 0.2s ease,
    height 0.2s ease,
    background 0.2s ease;
  mix-blend-mode: difference;
}

#cursor.hovering {
  width: 38px;
  height: 38px;
  background: rgba(255, 255, 255, 0.1);
}

@keyframes floatIsland {
  0%, 100% { transform: translate(-50%, -50%) translateY(0); }
  50% { transform: translate(-50%, -50%) translateY(-14px); }
}

@keyframes driftLeft {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-9px); }
}

@keyframes driftRight {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(9px); }
}

#c1, #c2, #c3 { animation: driftLeft 8s ease-in-out infinite; }
#c4, #c5, #c6, #c7 { animation: driftRight 10s ease-in-out infinite; }
#c8 { animation: driftLeft 13s ease-in-out infinite; }

body.app-open #cursor {
  opacity: 0;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 420px);
  gap: 22px;
  align-items: stretch;
  margin-bottom: 18px;
  position: relative;
}

.hero,
.product-switch {
  display: none !important;
}

.hero-copy,
.route-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-copy {
  position: relative;
  min-height: 360px;
  padding: 32px 34px;
  overflow: hidden;
}

.route-card {
  padding: 22px 24px;
  background: linear-gradient(180deg, rgba(26, 20, 16, 0.94), rgba(49, 34, 26, 0.96));
}

.eyebrow,
.section-label,
.card-label,
.viewport-kicker {
  margin: 0 0 10px;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

h1,
h2,
h3,
.route-card strong {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
}

h1 {
  max-width: 9ch;
  font-family: "Press Start 2P", cursive;
  font-size: clamp(2rem, 4.4vw, 4.1rem);
  line-height: 1.04;
  color: var(--arcade-cream);
  text-shadow:
    0 0 0 var(--arcade-black),
    3px 0 0 var(--arcade-black),
    -3px 0 0 var(--arcade-black),
    0 3px 0 var(--arcade-black),
    0 -3px 0 var(--arcade-black),
    0 7px 0 rgba(9, 8, 7, 0.55);
}

h2 {
  font-size: clamp(1.7rem, 2.8vw, 2.5rem);
  line-height: 1;
}

h3 {
  font-size: clamp(1.15rem, 2vw, 1.45rem);
}

.hero-text,
.route-card p,
.decision-feedback,
.controls-help p,
.viewport-overlay p,
.note-card p {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.hero-actions {
  display: none;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 14px 20px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

button:hover {
  transform: translateY(-1px);
}

.primary-button {
  background: var(--accent);
  color: #fff7f2;
  box-shadow: 0 14px 26px rgba(221, 95, 51, 0.28);
}

.primary-button:hover {
  background: var(--accent-deep);
}

.ghost-button,
.mode-button,
.decision-button,
.product-tab {
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  border: 1px solid var(--line);
}

.product-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 18px;
  padding: 8px;
  border-radius: 999px;
  border: 2px solid rgba(17, 13, 11, 0.14);
  background: rgba(255, 247, 232, 0.92);
  box-shadow: var(--shadow);
  position: sticky;
  top: 10px;
  z-index: 20;
}

.product-tab.active {
  background: #18242f;
  color: #fff8e8;
  border-color: transparent;
  box-shadow: inset 0 0 0 3px #1f80ff;
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.72fr) minmax(320px, 390px);
  grid-template-areas: "experience map";
  gap: 22px;
  align-items: start;
}

.theory-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.panel {
  padding: 24px;
}

.section-splash {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 4px;
  padding: 0 6px;
}

.practice-splash,
.theory-splash,
.embedded-contextual-panel,
.theory-side-panel {
  display: none !important;
}

.section-splash p {
  margin: 8px 0 0;
  max-width: 52rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.section-splash h2 {
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(2rem, 4vw, 3.3rem);
  line-height: 0.95;
  letter-spacing: -0.05em;
}

.section-back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.experience-panel {
  grid-area: experience;
  display: grid;
  gap: 18px;
}

.map-panel {
  grid-area: map;
  display: grid;
  gap: 16px;
}

.control-panel {
  grid-area: side;
}

.alerts-panel {
  grid-area: support;
}

.is-hidden {
  display: none !important;
}

.viewer-status-row {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.64);
}

.theory-main-panel,
.theory-side-panel {
  display: grid;
  gap: 18px;
}

.theory-intro,
.theory-question-card,
.theory-source-card,
.theory-feedback,
.theory-config-card,
.theory-stats-grid article,
.theory-outline-item {
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.66);
}

.theory-intro,
.theory-question-card,
.theory-source-card,
.theory-config-card {
  padding: 18px;
}

.theory-config-card {
  display: grid;
  gap: 14px;
}

.theory-field,
.theory-toggle,
.theory-source-toggles label {
  display: grid;
  gap: 6px;
}

.theory-field span,
.theory-toggle span,
.theory-source-toggles span {
  color: var(--ink);
  font-weight: 700;
}

.theory-field input[type="number"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
}

.theory-field small {
  color: var(--muted);
}

.theory-toggle,
.theory-source-toggles label {
  grid-template-columns: auto 1fr;
  align-items: center;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.58);
}

.theory-source-toggles {
  display: grid;
  gap: 8px;
}

.theory-source-toggles input,
.theory-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

.theory-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
}

.theory-question-card {
  display: grid;
  gap: 18px;
}

.theory-question-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.theory-topic-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(13, 107, 115, 0.1);
  color: var(--teal);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

.theory-options {
  display: grid;
  gap: 12px;
}

.theory-visual-card {
  border-radius: 24px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(248, 242, 233, 0.88));
  overflow: hidden;
}

.theory-visual-card[hidden] {
  display: none;
}

.theory-visual-card svg {
  display: block;
  width: 100%;
  height: auto;
}

.theory-option {
  display: grid;
  gap: 6px;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  text-align: left;
}

.theory-option small {
  color: var(--muted);
  font-size: 0.9rem;
}

.theory-option.correct {
  background: var(--ok-soft);
  border-color: rgba(44, 141, 95, 0.25);
}

.theory-option.wrong {
  background: var(--danger-soft);
  border-color: rgba(199, 68, 55, 0.24);
}

.theory-feedback {
  display: grid;
  gap: 8px;
  padding: 16px 18px;
}

.theory-feedback[hidden] {
  display: none;
}

.theory-feedback p,
.theory-source-card p,
.theory-intro p,
.theory-outline-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.theory-source-link a {
  color: var(--teal);
  font-weight: 700;
  text-decoration: none;
}

.theory-source-link a:hover {
  text-decoration: underline;
}

.theory-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.theory-stats-grid article {
  padding: 16px;
}

.theory-stats-grid span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.theory-stats-grid strong {
  font-size: 1.2rem;
}

.theory-outline {
  display: grid;
  gap: 12px;
}

.theory-outline-item {
  padding: 14px 16px;
}

.theory-outline-item.active {
  border-color: rgba(221, 95, 51, 0.24);
  background: rgba(255, 243, 236, 0.86);
}

.viewer-status-row p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.viewer-badge {
  width: fit-content;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(17, 32, 45, 0.08);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.viewer-badge.live {
  background: var(--ok-soft);
  color: var(--ok);
}

.viewer-badge.error {
  background: var(--warn-soft);
  color: #8c5a08;
}

.panel-heading {
  display: grid;
  gap: 6px;
}

.drawer-card {
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
  overflow: hidden;
}

.drawer-card summary {
  list-style: none;
  padding: 16px 18px;
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
}

.circuit-picker summary {
  display: grid;
  gap: 4px;
}

.circuit-picker summary span {
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.circuit-picker summary strong {
  font-size: 1rem;
  max-width: calc(100% - 24px);
}

.drawer-card summary::-webkit-details-marker {
  display: none;
}

.drawer-card summary::after {
  content: "+";
  float: right;
  color: var(--muted);
  transition: transform 160ms ease;
}

.drawer-card[open] summary::after {
  transform: rotate(45deg);
}

.drawer-card > :not(summary) {
  padding: 0 18px 18px;
}

.tool-drawer .calibration-card {
  padding: 18px;
}

.circuit-options {
  display: grid;
  gap: 10px;
}

.map-panel .circuit-picker {
  margin-bottom: 18px;
}

.circuit-option {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
  cursor: pointer;
}

.circuit-option.active {
  border-color: rgba(13, 107, 115, 0.2);
  background: rgba(204, 236, 235, 0.68);
  cursor: default;
}

.circuit-option strong {
  font-size: 1rem;
}

.circuit-option span {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.map-panel {
  align-content: start;
}

.map-panel .panel-heading {
  gap: 10px;
}

.map-panel .panel-heading h2 {
  font-size: clamp(2.15rem, 4vw, 3.35rem);
  line-height: 0.96;
  letter-spacing: -0.06em;
}

.circuit-picker {
  border-radius: 20px;
  border: 1px solid rgba(23, 19, 17, 0.12);
  background: rgba(255, 252, 245, 0.88);
  box-shadow: 0 14px 32px rgba(24, 18, 14, 0.08);
  overflow: visible;
}

.circuit-picker summary {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 16px 18px 16px 56px;
}

.circuit-picker summary::before {
  content: "≡";
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(35, 92, 89, 0.08);
  color: var(--teal);
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1;
}

.circuit-picker summary::after {
  content: "▾";
  float: none;
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 1rem;
}

.circuit-picker[open] summary::after {
  transform: translateY(-50%) rotate(180deg);
}

.circuit-picker summary span {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.circuit-picker summary strong {
  max-width: none;
  padding-right: 22px;
  font-size: 1rem;
  line-height: 1.35;
}

.circuit-picker > :not(summary) {
  padding: 0 10px 10px;
}

.circuit-options {
  gap: 8px;
  max-height: 330px;
  overflow: auto;
  padding-top: 2px;
}

.circuit-option {
  padding: 14px 14px 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
  transition:
    border-color 140ms ease,
    background 140ms ease,
    transform 140ms ease;
}

.circuit-option:not(.active):hover {
  background: rgba(230, 243, 242, 0.82);
  border-color: rgba(35, 92, 89, 0.2);
  transform: translateY(-1px);
}

.circuit-option strong {
  font-size: 0.98rem;
  line-height: 1.25;
}

.circuit-option span {
  font-size: 0.86rem;
}

.mode-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.theory-main-panel .panel-heading h2 {
  max-width: 14ch;
}

.mode-button.active {
  background: var(--ink);
  color: #fefaf5;
  border-color: transparent;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.status-grid article,
.progress-card,
.decision-panel,
.controls-help,
.note-card,
.calibration-card {
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
}

.status-grid article {
  padding: 16px;
}

.status-grid span,
.progress-copy span,
.car-hud span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.status-grid strong,
.progress-copy strong,
.car-hud strong {
  font-size: 1.2rem;
}

.progress-card,
.controls-help,
.note-card,
.calibration-card {
  padding: 18px;
}

.calibration-card {
  display: grid;
  gap: 12px;
}

.route-calibration-card {
  margin-top: 16px;
}

.route-calibration-card summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
}

.route-calibration-card summary::-webkit-details-marker {
  display: none;
}

.calibration-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.calibration-heading span,
.route-calibration-card summary span {
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.calibration-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.calibration-button {
  justify-self: start;
}

.calibration-card pre {
  margin: 0;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(17, 32, 45, 0.05);
  color: var(--ink);
  font: 0.82rem/1.45 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.progress-bar {
  margin-top: 14px;
  height: 12px;
  border-radius: 999px;
  background: rgba(17, 32, 45, 0.08);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #f19361);
  transition: width 240ms ease;
}

.decision-panel {
  padding: 18px;
}

.decision-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0 12px;
}

.decision-button.correct {
  background: var(--ok-soft);
  border-color: rgba(44, 141, 95, 0.25);
}

.decision-button.wrong {
  background: var(--danger-soft);
  border-color: rgba(199, 68, 55, 0.24);
}

.viewport {
  position: relative;
  min-height: 780px;
  overflow: hidden;
  border-radius: 30px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 50% 10%, rgba(255, 221, 178, 0.95), transparent 34%),
    linear-gradient(180deg, #a8d3dd 0%, #dceff0 28%, #fbf4e8 29%, #efe4d1 100%);
}

.street-view-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.viewport.street-view-live {
  background: #dbe4e8;
}

.viewport.street-view-live .street-view-canvas {
  opacity: 1;
  pointer-events: auto;
}

.viewport.street-view-live .road-stage {
  opacity: 0;
  pointer-events: none;
}

.viewport::before,
.viewport::after {
  content: "";
  position: absolute;
  inset: auto;
  border-radius: 999px;
  filter: blur(2px);
}

.viewport::before {
  width: 260px;
  height: 260px;
  top: -110px;
  right: 8%;
  background: rgba(255, 246, 222, 0.74);
}

.viewport::after {
  width: 210px;
  height: 210px;
  bottom: 86px;
  left: -60px;
  background: rgba(30, 120, 95, 0.1);
}

.viewport-overlay {
  position: absolute;
  z-index: 4;
  top: 18px;
  left: 18px;
  max-width: min(320px, calc(100% - 36px));
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 252, 248, 0.72);
  border: 1px solid rgba(17, 32, 45, 0.1);
  backdrop-filter: blur(12px);
}

.signal-stack {
  position: absolute;
  z-index: 4;
  right: 18px;
  top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  width: min(360px, calc(100% - 36px));
}

.route-cue {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: min(420px, calc(100% - 120px));
  max-width: min(520px, calc(100% - 120px));
  padding: 12px 14px;
  border-radius: 22px;
  background: rgba(17, 32, 45, 0.76);
  color: #fff8f0;
  box-shadow: 0 16px 28px rgba(17, 32, 45, 0.22);
  backdrop-filter: blur(14px);
}

.route-cue.near-turn {
  background: rgba(221, 95, 51, 0.9);
}

.route-cue-arrow {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  font-size: 1.5rem;
  font-weight: 800;
}

.route-cue-arrow.turn-left {
  transform: rotate(-90deg);
}

.route-cue-arrow.turn-right {
  transform: rotate(90deg);
}

.route-cue-copy {
  display: grid;
  gap: 2px;
}

.route-cue-copy strong {
  font-size: 1rem;
}

.route-cue-copy span {
  font-size: 0.9rem;
  line-height: 1.35;
  color: rgba(255, 248, 240, 0.82);
}

.turn-badge {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: 126px;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(122, 226, 157, 0.94);
  color: #163221;
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 14px 24px rgba(31, 78, 52, 0.18);
  opacity: 0;
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.turn-badge.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

.signal-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 180px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.8rem;
  line-height: 1.2;
  box-shadow: 0 10px 18px rgba(17, 32, 45, 0.08);
  backdrop-filter: blur(12px);
}

.signal-pill strong {
  display: inline;
  margin: 0;
}

.signal-pill.stop {
  background: rgba(255, 216, 212, 0.86);
  border-color: rgba(199, 68, 55, 0.22);
}

.signal-pill.school {
  background: rgba(255, 232, 191, 0.88);
  border-color: rgba(240, 163, 38, 0.28);
}

.signal-pill.traffic-light,
.signal-pill.priority {
  background: rgba(204, 236, 235, 0.86);
  border-color: rgba(13, 107, 115, 0.2);
}

.signal-pill.note {
  background: rgba(255, 255, 255, 0.78);
  border-color: var(--line);
}

.signal-pill span {
  display: none;
}

.road-stage {
  position: absolute;
  z-index: 1;
  inset: auto 0 0;
  height: 72%;
  transition: opacity 220ms ease;
}

.road-horizon {
  position: absolute;
  inset: 14% 0 auto;
  height: 46%;
  clip-path: polygon(35% 0%, 65% 0%, 100% 100%, 0% 100%);
  background:
    linear-gradient(180deg, #5d5f64 0%, #3f4348 100%);
}

.road-lane {
  position: absolute;
  bottom: 6%;
  width: 8px;
  height: 48%;
  background:
    repeating-linear-gradient(
      180deg,
      rgba(255, 249, 224, 0.94) 0 28px,
      transparent 28px 56px
    );
}

.road-lane-left {
  left: 46%;
  transform: skewX(-12deg);
}

.road-lane-right {
  right: 46%;
  transform: skewX(12deg);
}

.car-hud {
  z-index: 4;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 252, 248, 0.76);
  border: 1px solid rgba(17, 32, 45, 0.1);
  backdrop-filter: blur(12px);
}

.viewport-bottom-bar {
  position: absolute;
  z-index: 4;
  left: 18px;
  right: 18px;
  bottom: 18px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.micro-tip {
  max-width: min(360px, 60%);
  padding: 10px 14px;
  border-radius: 16px;
  background: rgba(17, 32, 45, 0.74);
  color: #fff8f0;
  font-size: 0.9rem;
  line-height: 1.35;
  box-shadow: 0 12px 24px rgba(17, 32, 45, 0.18);
}

.viewport-mini {
  margin: 8px 0 0;
  font-size: 0.9rem;
  line-height: 1.45;
}

.viewer-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.embedded-contextual-panel {
  display: grid;
  gap: 16px;
  margin-top: 4px;
  padding-top: 2px;
}

.drive-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.drive-button {
  padding: 12px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(17, 32, 45, 0.08);
}

.drive-button-primary {
  background: rgba(13, 107, 115, 0.92);
  color: #f4fffe;
  border-color: transparent;
}

#routeMapCanvas {
  width: 100%;
  min-height: 430px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(248, 242, 233, 0.85));
  overflow: hidden;
}

.map-context-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: start;
  padding: 18px 20px;
  border-radius: 24px;
  border: 1px solid rgba(240, 163, 38, 0.28);
  background:
    linear-gradient(180deg, rgba(255, 251, 239, 0.98), rgba(255, 247, 226, 0.98));
  box-shadow: 0 16px 28px rgba(240, 163, 38, 0.12);
}

.map-context-card[hidden] {
  display: none;
}

.map-context-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: rgba(240, 163, 38, 0.18);
  color: #9a6408;
  font-size: 1.3rem;
  font-weight: 900;
}

.map-context-copy {
  display: grid;
  gap: 8px;
}

.map-context-copy h3 {
  font-size: 1.08rem;
}

.map-context-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

.legend div {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  display: inline-block;
}

.active-dot {
  background: var(--accent);
}

.pending-dot {
  background: rgba(17, 32, 45, 0.18);
}

.checkpoint-dot {
  background: var(--teal);
}

.contextual-list {
  display: grid;
  gap: 12px;
}

.alert-card {
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
}

.alert-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 8px;
}

.alert-card strong {
  font-size: 1rem;
}

.alert-badge {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.alert-badge.stop {
  background: var(--danger-soft);
  color: var(--danger);
}

.alert-badge.school {
  background: var(--warn-soft);
  color: #8c5a08;
}

.alert-badge.traffic-light,
.alert-badge.priority {
  background: var(--teal-soft);
  color: var(--teal);
}

.alert-badge.note {
  background: rgba(17, 32, 45, 0.08);
  color: var(--ink);
}

.alert-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.contextual-item {
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  overflow: hidden;
}

.contextual-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  cursor: pointer;
  list-style: none;
}

.contextual-item summary::-webkit-details-marker {
  display: none;
}

.contextual-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.contextual-index {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 999px;
  background: rgba(17, 32, 45, 0.08);
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 800;
}

.contextual-item.opening .contextual-index,
.contextual-item[open] .contextual-index {
  background: rgba(221, 95, 51, 0.16);
  color: var(--accent-deep);
}

.contextual-heading {
  display: grid;
  gap: 3px;
}

.contextual-heading strong {
  font-size: 1rem;
}

.contextual-heading span {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.contextual-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(13, 107, 115, 0.1);
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
}

.contextual-body {
  display: grid;
  gap: 12px;
  padding: 0 18px 18px;
}

.contextual-body p,
.contextual-body blockquote {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.contextual-body blockquote {
  padding: 12px 14px;
  border-left: 4px solid rgba(221, 95, 51, 0.42);
  border-radius: 0 14px 14px 0;
  background: rgba(255, 244, 236, 0.85);
  color: var(--ink);
}

.contextual-source {
  display: grid;
  gap: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.contextual-source span {
  color: var(--muted);
  font-size: 0.92rem;
}

.route-path {
  fill: none;
  stroke: rgba(17, 32, 45, 0.18);
  stroke-width: 14;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.route-segment {
  fill: none;
  stroke: rgba(17, 32, 45, 0.14);
  stroke-width: 14;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 180ms ease, opacity 180ms ease;
}

.route-segment.active {
  stroke: var(--accent);
}

.route-segment.done {
  stroke: rgba(221, 95, 51, 0.42);
}

.route-checkpoint {
  fill: var(--teal);
  stroke: #fffaf4;
  stroke-width: 4;
}

.route-label {
  font-size: 14px;
  fill: var(--ink);
  font-family: "Outfit", sans-serif;
}

.hero-copy {
  background:
    linear-gradient(rgba(14, 12, 11, 0.26), rgba(14, 12, 11, 0.18)),
    linear-gradient(90deg, rgba(49, 52, 59, 0.94) 0 16%, transparent 16% 17%, rgba(49, 52, 59, 0.94) 17% 33%, transparent 33% 34%, rgba(49, 52, 59, 0.94) 34% 50%, transparent 50% 51%, rgba(49, 52, 59, 0.94) 51% 67%, transparent 67% 68%, rgba(49, 52, 59, 0.94) 68% 84%, transparent 84% 85%, rgba(49, 52, 59, 0.94) 85% 100%),
    radial-gradient(circle at 50% 68%, rgba(89, 226, 81, 0.22), transparent 12%),
    linear-gradient(180deg, #c8a684 0%, #b48966 100%);
}

.hero-copy::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(90deg, transparent 0 146px, rgba(20, 15, 13, 0.35) 146px 150px),
    repeating-linear-gradient(180deg, transparent 0 146px, rgba(20, 15, 13, 0.35) 146px 150px),
    repeating-linear-gradient(90deg, transparent 0 150px, rgba(255, 245, 219, 0.9) 150px 158px, transparent 158px 300px),
    repeating-linear-gradient(180deg, transparent 0 150px, rgba(255, 245, 219, 0.9) 150px 158px, transparent 158px 300px);
  opacity: 0.44;
  pointer-events: none;
}

.hero-copy > * {
  position: relative;
  z-index: 1;
}

.hero-copy .eyebrow,
.hero-copy .hero-text {
  color: #fff8e8;
  text-shadow: 0 2px 0 rgba(9, 8, 7, 0.38);
}

.hero-text {
  max-width: 42rem;
  font-size: 1.06rem;
}

.route-card .card-label,
.route-card strong,
.route-card p {
  color: #fff3d5;
}

.route-card strong {
  display: block;
  margin-bottom: 12px;
  font-size: 1.4rem;
  line-height: 1.15;
}

.hero-hud {
  display: grid;
  grid-template-columns: 112px 1fr auto;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.hero-mini-map {
  position: relative;
  width: 112px;
  height: 112px;
  border-radius: 16px;
  border: 3px solid var(--arcade-cream);
  box-shadow: 0 0 0 4px rgba(9, 8, 7, 0.4);
  background:
    repeating-linear-gradient(90deg, rgba(94, 98, 105, 0.96) 0 24px, transparent 24px 28px),
    repeating-linear-gradient(180deg, rgba(94, 98, 105, 0.96) 0 24px, transparent 24px 28px),
    #d8d0c3;
}

.hero-mini-map span {
  position: absolute;
  background: #73b462;
}

.hero-mini-map span:nth-child(1) { left: 10px; top: 10px; width: 46px; height: 18px; }
.hero-mini-map span:nth-child(2) { right: 10px; top: 10px; width: 26px; height: 18px; }
.hero-mini-map span:nth-child(3) { left: 12px; bottom: 14px; width: 32px; height: 14px; }

.hero-mini-map i {
  position: absolute;
  left: 48px;
  top: 42px;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 18px solid #51e247;
  filter: drop-shadow(0 2px 0 rgba(9, 8, 7, 0.6));
}

.hero-score {
  display: grid;
  gap: 8px;
}

.hero-score span,
.hero-score strong,
.hero-stars {
  font-family: "Press Start 2P", cursive;
}

.hero-score span {
  font-size: 0.54rem;
  color: #fff1c5;
}

.hero-score strong {
  font-size: 1rem;
  color: #fff1c5;
}

.hero-stars {
  display: flex;
  gap: 4px;
  font-size: 1.85rem;
  line-height: 1;
  color: var(--arcade-gold);
  text-shadow: 0 3px 0 rgba(9, 8, 7, 0.55);
}

.hero-actions,
.viewer-footer,
.route-calibration-card {
  display: none !important;
}

.map-panel {
  position: sticky;
  top: 84px;
}

.map-panel .circuit-picker {
  margin-bottom: 10px;
}

#routeMapCanvas {
  min-height: 360px;
  border: 2px solid rgba(20, 14, 10, 0.16);
  box-shadow: inset 0 0 0 4px rgba(255, 248, 232, 0.78);
}

.viewport {
  min-height: 820px;
  border: 2px solid rgba(20, 14, 10, 0.2);
  box-shadow: 0 24px 54px rgba(20, 14, 10, 0.24);
}

.viewer-status-row,
.drawer-card,
.theory-intro,
.theory-question-card,
.theory-config-card,
.theory-stats-grid article,
.theory-outline-item,
.circuit-option,
.contextual-item {
  background: rgba(255, 248, 232, 0.8);
}

.map-panel .panel-heading h2,
.experience-panel .panel-heading h2,
.embedded-contextual-panel .panel-heading h2,
.theory-main-panel .panel-heading h2,
.theory-side-panel .panel-heading h2 {
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(1.55rem, 2.2vw, 2.2rem);
  line-height: 1;
  letter-spacing: -0.04em;
}

.experience-panel,
.map-panel,
.theory-main-panel,
.theory-side-panel {
  background: rgba(253, 247, 237, 0.94);
  box-shadow: 0 18px 44px rgba(45, 32, 21, 0.11);
}

.viewport {
  min-height: 760px;
  border: 1px solid rgba(20, 14, 10, 0.14);
  box-shadow: 0 20px 40px rgba(20, 14, 10, 0.16);
}

@media (max-width: 1120px) {
  .entry-menu {
    min-height: 100vh;
  }

  #title-wrap {
    width: min(48vw, 500px);
    height: min(22vw, 190px);
    top: 2.8%;
  }

  #subtitle {
    top: 17.6%;
  }

  #title-wrap img {
    width: 188%;
  }

  #island-wrap {
    top: 53%;
  }

  #island-wrap img {
    width: min(52vw, 640px);
  }

  #buttons {
    bottom: 4.2%;
    gap: 14px;
  }

  .scene-button img {
    height: 66px;
  }

  .dashboard {
    grid-template-columns: 1fr;
    grid-template-areas:
      "experience"
      "map";
  }

  .theory-dashboard {
    grid-template-columns: 1fr;
  }

  .hero {
    grid-template-columns: 1fr;
  }

  .section-splash {
    flex-direction: column;
    align-items: flex-start;
  }

  .viewer-footer {
    flex-direction: column;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: 100%;
    padding: 0;
  }

  #scene {
    min-height: 100svh;
  }

  #title-wrap {
    width: min(82vw, 360px);
    height: 120px;
    top: 5.2%;
  }

  #subtitle {
    top: 17.2%;
    width: min(88vw, 540px);
    font-size: 11px;
    line-height: 1.35;
    text-align: center;
    white-space: normal;
  }

  #island-wrap {
    top: 50.5%;
  }

  #island-wrap img {
    width: min(76vw, 470px);
  }

  #buttons {
    bottom: 4.2%;
    width: 100%;
    flex-direction: column;
    gap: 14px;
  }

  .scene-button img {
    height: auto;
    width: min(76vw, 310px);
  }

  #cursor {
    display: none;
  }

  .hero-copy,
  .route-card,
  .panel {
    padding: 20px;
    border-radius: 24px;
  }

  .status-grid,
  .decision-actions,
  .mode-switch,
  .theory-stats-grid {
    grid-template-columns: 1fr;
  }

  .viewport {
    min-height: 560px;
  }
  .signal-stack {
    left: 18px;
    right: 18px;
    width: auto;
    justify-content: flex-start;
  }

  .route-cue {
    top: auto;
    bottom: 88px;
    min-width: 0;
    max-width: calc(100% - 36px);
  }

  .turn-badge {
    bottom: 154px;
  }

  .viewport-bottom-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .micro-tip {
    max-width: none;
  }

  .viewer-footer,
  .drive-controls {
    flex-direction: column;
    align-items: stretch;
  }
}
