/* Hamba: a MAT-SA learning game. Mobile first, landscape for play. */
@font-face {
  font-family: 'Baloo 2';
  font-weight: 600;
  font-display: swap;
  src: url('fonts/baloo-2-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Baloo 2';
  font-weight: 700;
  font-display: swap;
  src: url('fonts/baloo-2-latin-700-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Baloo 2';
  font-weight: 800;
  font-display: swap;
  src: url('fonts/baloo-2-latin-800-normal.woff2') format('woff2');
}

:root {
  --ink: #1f2a44;
  --ink-2: #4a5570;
  --paper: #ffffff;
  --paper-2: #f3f6fb;
  --line: #dfe5ee;
  --sun: #ffd23a;
  --good: #2bd17e;
  --bad: #e2453c;
  --drone: #13a394;
  --plane: #f2672e;
  --train: #d9473b;
  --accent: var(--ink);
  --glass: rgba(16, 24, 44, 0.62);
  --radius: 22px;
  --shadow: 0 10px 30px rgba(20, 30, 60, 0.18), 0 2px 6px rgba(20, 30, 60, 0.12);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --stick: clamp(96px, 30vmin, 156px);
  --mini: clamp(84px, 24vmin, 124px);
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #bfe6ff;
  color: var(--ink);
  font-family: 'Baloo 2', ui-rounded, system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}
#app {
  position: fixed;
  inset: 0;
}
.gl {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  touch-action: manipulation;
}
button:focus-visible {
  outline: 4px solid var(--sun);
  outline-offset: 3px;
}
[hidden] {
  display: none !important;
}

/* ---------- loading ---------- */
.loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(#bfe6ff, #e9f6ff);
  z-index: 50;
  transition: opacity 0.4s;
}
.loading-mark {
  font-weight: 800;
  font-size: 44px;
  letter-spacing: -0.02em;
  animation: bob 1.2s ease-in-out infinite;
}
body.ready .loading {
  opacity: 0;
  pointer-events: none;
}
@keyframes bob {
  50% {
    transform: translateY(-8px);
  }
}

/* ---------- menus ---------- */
.ui {
  position: absolute;
  inset: 0;
  display: none;
  z-index: 10;
}
.ui.on {
  display: block;
}
.ui.overlay {
  background: rgba(16, 24, 44, 0.28);
}
.screen {
  position: absolute;
  inset: 0;
  padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l));
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  touch-action: pan-y;
  animation: rise 0.28s ease-out;
}
.screen.center {
  align-items: center;
  justify-content: center;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

.title-screen {
  justify-content: center;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.82) 0%, rgba(255, 255, 255, 0.55) 38%, rgba(255, 255, 255, 0) 70%);
}
.title-block {
  max-width: 520px;
  padding-left: clamp(0px, 4vw, 48px);
}
.eyebrow {
  margin: 0;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.logo {
  margin: 0;
  font-weight: 800;
  font-size: clamp(64px, 17vmin, 132px);
  line-height: 0.9;
  letter-spacing: -0.04em;
  color: var(--ink);
}
.logo::after {
  content: '!';
  color: var(--plane);
}
.tagline {
  margin: 10px 0 22px;
  font-size: clamp(18px, 4.4vmin, 24px);
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink-2);
}
.total {
  margin: 14px 0 0;
  font-weight: 700;
  color: var(--ink-2);
}
.foot {
  position: absolute;
  bottom: calc(10px + var(--safe-b));
  left: calc(16px + var(--safe-l) + clamp(0px, 4vw, 48px));
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 28px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 22px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.22), var(--shadow);
  transition: transform 0.1s;
}
.cta:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.22), var(--shadow);
}
/* Hold-to-play: a bar fills from left to right while the button is held. */
.title-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.hold {
  position: relative;
  overflow: hidden;
  min-width: 230px;
  justify-content: center;
  -webkit-touch-callout: none;
  touch-action: none;
}
.hold-fill {
  position: absolute;
  inset: 0;
  background: var(--good);
  transform: scaleX(var(--p, 0));
  transform-origin: left center;
}
.hold svg,
.hold-label {
  position: relative;
}
.hold.ready {
  background: var(--good);
  color: var(--ink);
}
.hold.holding {
  transform: translateY(3px);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.22), var(--shadow);
}
.tip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-2);
}
.ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--paper-2);
  font-weight: 700;
  font-size: 17px;
}

.screen-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.screen-head h2 {
  margin: 0;
  font-size: clamp(26px, 6vmin, 38px);
  font-weight: 800;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 12px rgba(255, 255, 255, 0.8);
}
.icon-btn {
  width: 52px;
  height: 52px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.icon-btn.small {
  width: 44px;
  height: 44px;
  border-radius: 14px;
}

/* vehicle picker */
.vehicle-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-content: center;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
}
@media (orientation: landscape), (min-width: 700px) {
  .vehicle-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
.vehicle-card {
  --c: var(--ink);
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 14px;
  align-items: center;
  text-align: left;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
  border-bottom: 6px solid var(--c);
  transition: transform 0.12s;
}
.vehicle-card:active {
  transform: scale(0.98);
}
.v-drone {
  --c: var(--drone);
}
.v-plane {
  --c: var(--plane);
}
.v-train {
  --c: var(--train);
}
.vehicle-art {
  grid-row: span 2;
  width: 76px;
  height: 76px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--c);
}
.vehicle-art svg {
  width: 48px;
  height: 48px;
}
.vehicle-name {
  font-weight: 800;
  font-size: 28px;
  line-height: 1;
}
.vehicle-tag {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-2);
  line-height: 1.25;
}
.vehicle-stars {
  position: absolute;
  top: 12px;
  right: 14px;
  display: flex;
  gap: 4px;
  align-items: center;
  font-weight: 800;
  font-size: 14px;
  color: var(--ink-2);
}
.vehicle-stars svg {
  fill: var(--sun);
  stroke: #d9a400;
}
@media (orientation: landscape), (min-width: 700px) {
  .vehicle-card {
    grid-template-columns: 1fr;
    justify-items: start;
    row-gap: 6px;
    padding: 18px;
  }
  .vehicle-art {
    grid-row: auto;
    width: clamp(64px, 16vmin, 92px);
    height: clamp(64px, 16vmin, 92px);
    margin-bottom: 6px;
  }
}

/* mission list */
.mission-list {
  display: grid;
  gap: 12px;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
}
@media (orientation: landscape) and (min-width: 600px) {
  .mission-list {
    grid-template-columns: 1fr 1fr;
  }
}
.k-drone {
  --accent: var(--drone);
}
.k-plane {
  --accent: var(--plane);
}
.k-train {
  --accent: var(--train);
}
.mission-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  text-align: left;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
  min-height: 84px;
}
.mission-card.free {
  background: var(--paper-2);
}
.mission-card.locked {
  opacity: 0.66;
  cursor: not-allowed;
}
.mission-num {
  width: 50px;
  height: 50px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 24px;
}
.mission-card.locked .mission-num {
  background: #9aa3b5;
}
.mission-title {
  font-weight: 800;
  font-size: 21px;
  line-height: 1.1;
}
.mission-short {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-2);
  line-height: 1.25;
}
.stars {
  display: flex;
  gap: 2px;
}
.star svg {
  fill: #e3e8f0;
  stroke: #c3cad6;
}
.star.on svg {
  fill: var(--sun);
  stroke: #d9a400;
}
.stars.big {
  justify-content: center;
  gap: 8px;
}
.stars.big .star {
  animation: pop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1) backwards;
}
.stars.big .star:nth-child(2) {
  animation-delay: 0.15s;
}
.stars.big .star:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes pop {
  from {
    transform: scale(0);
  }
}

/* modal */
.modal {
  width: min(560px, 100%);
  max-height: calc(100dvh - 24px - var(--safe-t) - var(--safe-b));
  overflow-y: auto;
  padding: 22px 24px;
  border-radius: 28px;
  background: var(--paper);
  box-shadow: var(--shadow);
  border-top: 8px solid var(--accent);
  touch-action: pan-y;
}
.modal h2 {
  margin: 2px 0 4px;
  font-size: clamp(28px, 6vmin, 38px);
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.modal h3 {
  margin: 14px 0 6px;
  font-size: 15px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-2);
}
.lead {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink-2);
  line-height: 1.3;
}
.controls,
.stats {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
}
.controls dt,
.stats dt {
  font-weight: 800;
}
.controls dd,
.stats dd {
  margin: 0;
  font-weight: 600;
  color: var(--ink-2);
}
.stats {
  margin: 12px 0;
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--paper-2);
}
.result {
  text-align: center;
}
.result .stats {
  text-align: left;
}
.best {
  margin: 0;
  font-weight: 800;
  color: var(--good);
}
.learn {
  display: flex;
  gap: 12px;
  text-align: left;
  padding: 14px 16px;
  border-radius: 16px;
  background: #fff7d6;
  border: 2px solid #ffe58a;
}
.learn-icon {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--sun);
}
.learn-title {
  font-weight: 800;
  font-size: 17px;
}
.learn p {
  margin: 2px 0 0;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.35;
  color: var(--ink-2);
}
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
  margin-top: 18px;
}
.result .modal-actions {
  justify-content: center;
}
.toggles {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 0 14px;
  border-radius: 16px;
  background: var(--paper-2);
  font-weight: 700;
  font-size: 16px;
  text-align: left;
}
.toggle-track {
  flex: none;
  width: 52px;
  height: 30px;
  border-radius: 99px;
  background: #c3cad6;
  position: relative;
  transition: background 0.15s;
}
.toggle-dot {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
.toggle.on .toggle-track {
  background: var(--good);
}
.toggle.on .toggle-dot {
  transform: translateX(22px);
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: none;
  z-index: 5;
  color: #fff;
}
.hud.on {
  display: block;
}
.hud button,
.hud .stick,
.hud .lever {
  pointer-events: auto;
}
.hud-top {
  position: absolute;
  top: calc(10px + var(--safe-t));
  left: calc(10px + var(--safe-l));
  right: calc(10px + var(--safe-r));
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.hud .icon-btn {
  background: var(--glass);
  color: #fff;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: none;
}
.goal-card {
  flex: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 16px 9px;
  border-radius: 18px;
  background: var(--glass);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  text-align: center;
}
.goal-title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.75;
}
.goal-text {
  font-size: clamp(15px, 3.6vmin, 19px);
  font-weight: 700;
  line-height: 1.2;
}
.goal-text.flash {
  animation: flash 0.8s ease-out;
}
@keyframes flash {
  0% {
    color: var(--sun);
    transform: scale(1.05);
  }
}
.goal-progress {
  font-size: 14px;
  font-weight: 700;
  color: var(--sun);
  min-height: 1em;
}
.hud-left {
  display: flex;
  gap: 8px;
}
.hud-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.minimap {
  width: var(--mini);
  height: var(--mini);
  border-radius: 50%;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
.compass {
  position: absolute;
  top: calc(96px + var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 4px 6px;
  border-radius: 99px;
  background: var(--glass);
}
.compass.on {
  display: flex;
}
.compass-arrow {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--sun);
  color: var(--ink);
}
.compass-arrow svg {
  stroke-width: 3;
}
.compass-dist {
  font-weight: 800;
  font-size: 15px;
}
.toast {
  position: absolute;
  top: 34%;
  left: 50%;
  transform: translate(-50%, 10px);
  max-width: min(520px, 86vw);
  padding: 12px 22px;
  border-radius: 20px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 800;
  font-size: clamp(17px, 4vmin, 22px);
  text-align: center;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.on {
  opacity: 1;
  transform: translate(-50%, 0);
}
.warn {
  position: absolute;
  left: 50%;
  bottom: calc(clamp(112px, 30vmin, 150px) + var(--safe-b));
  transform: translateX(-50%);
  padding: 6px 16px;
  border-radius: 99px;
  background: var(--bad);
  font-weight: 800;
  font-size: 16px;
  white-space: nowrap;
  display: none;
  animation: blink 0.9s steps(2) infinite;
}
.warn.on {
  display: block;
}
@keyframes blink {
  50% {
    opacity: 0.6;
  }
}

/* sticks */
.stick {
  position: absolute;
  bottom: calc(18px + var(--safe-b));
  width: calc(var(--stick) + 40px);
  height: calc(var(--stick) + 40px);
  display: grid;
  place-items: center;
  touch-action: none;
}
.stick-left {
  left: calc(10px + var(--safe-l));
}
.stick-right {
  right: calc(10px + var(--safe-r));
}
.stick-base {
  position: relative;
  width: var(--stick);
  height: var(--stick);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.28));
  border: 3px solid rgba(255, 255, 255, 0.55);
  display: grid;
  place-items: center;
}
.stick-knob {
  width: 46%;
  height: 46%;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.stick-label {
  position: absolute;
  top: -24px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
.hud[data-kind='train'] .stick {
  display: none;
}
@media (hover: hover) and (pointer: fine) {
  .stick {
    opacity: 0.35;
  }
}

/* panels */
.panel {
  position: absolute;
  left: 50%;
  bottom: calc(14px + var(--safe-b));
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.chip {
  min-width: 82px;
  padding: 6px 12px;
  border-radius: 16px;
  background: var(--glass);
  text-align: center;
}
.chip-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.7;
}
.chip-value {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.attitude {
  width: clamp(76px, 20vmin, 96px);
  height: clamp(76px, 20vmin, 96px);
  border-radius: 50%;
}
.throttle {
  padding: 6px 10px;
  border-radius: 16px;
  background: var(--glass);
  text-align: center;
}
.throttle-bar {
  position: relative;
  width: 18px;
  height: 52px;
  margin: 4px auto;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.2);
  overflow: hidden;
}
.throttle-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(var(--plane), var(--sun));
}
.throttle-txt {
  font-weight: 800;
  font-size: 13px;
}
.speedo {
  width: clamp(170px, 46vmin, 230px);
  height: auto;
  padding: 2px;
  border-radius: 22px 22px 18px 18px;
  background: var(--glass);
}
.limit-sign {
  width: 56px;
  height: 56px;
  margin-bottom: 8px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fff;
  color: var(--ink);
  border: 6px solid var(--bad);
  font-weight: 800;
  font-size: 20px;
}
.train-btns {
  position: absolute;
  left: calc(14px + var(--safe-l));
  bottom: calc(18px + var(--safe-b));
  display: none;
  flex-direction: column;
  gap: 10px;
}
.hud[data-kind='train'] .train-btns {
  display: flex;
}
.pill-btn {
  width: 72px;
  height: 64px;
  border-radius: 20px;
  background: var(--glass);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 28px;
}
.pill-btn.dir.rev {
  background: var(--plane);
}
.pill-btn:active {
  transform: scale(0.95);
}

/* train lever */
.lever {
  position: absolute;
  right: calc(14px + var(--safe-r));
  bottom: calc(14px + var(--safe-b));
  /* Below the minimap and camera button in the top-right corner. */
  top: calc(var(--mini) + 74px + var(--safe-t));
  width: 92px;
  display: none;
  touch-action: none;
}
.hud[data-kind='train'] .lever {
  display: block;
}
.lever-track {
  position: relative;
  height: 100%;
  border-radius: 24px;
  background: var(--glass);
  display: flex;
  flex-direction: column;
  padding: 4px;
}
.lever-notch {
  flex: 1;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  opacity: 0.6;
}
.lever-notch.p {
  color: #9ff0c4;
}
.lever-notch.b {
  color: #ffc0b8;
}
.lever-thumb {
  position: absolute;
  left: 6px;
  right: 6px;
  height: 11%;
  min-height: 30px;
  transform: translateY(-50%);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 18px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: top 0.12s;
}
.lever-thumb[data-zone='p'] {
  background: var(--good);
}
.lever-thumb[data-zone='b'] {
  background: #ff9c8f;
}

/* plane cockpit overlay */
.cockpit-frame {
  position: absolute;
  inset: 0;
  display: none;
}
.hud.cockpit .cockpit-frame {
  display: block;
}
.cockpit-pillar {
  position: absolute;
  top: -10%;
  bottom: 0;
  width: 9vw;
  background: linear-gradient(90deg, #2a3140, #3b4456);
}
.cockpit-pillar.left {
  left: 6vw;
  transform: skewX(14deg);
}
.cockpit-pillar.right {
  right: 6vw;
  transform: skewX(-14deg);
}
.cockpit-dash {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 26%;
  background: linear-gradient(#2f3747, #1c222d);
  border-top-left-radius: 50% 40px;
  border-top-right-radius: 50% 40px;
  box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.35);
}

/* train cab: a wide front window with slim pillars and a low desk */
.hud[data-kind='train'] .cockpit-pillar {
  width: 4vw;
  background: linear-gradient(90deg, #22303a, #33444f);
}
.hud[data-kind='train'] .cockpit-pillar.left {
  left: 0;
  transform: none;
}
.hud[data-kind='train'] .cockpit-pillar.right {
  right: 0;
  transform: none;
}
.hud[data-kind='train'] .cockpit-dash {
  height: 20%;
  background: linear-gradient(#2c3a44, #1a232a);
  border-radius: 0;
  border-top: 6px solid #13a394;
}
.hud[data-kind='train'] .cockpit-frame::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 7%;
  background: linear-gradient(#1a232a, #2c3a44);
}

/* rotate prompt while playing in portrait on phones */
.rotate {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  background: var(--ink);
  color: #fff;
}
.rotate-phone {
  width: 54px;
  height: 90px;
  border: 5px solid #fff;
  border-radius: 12px;
  animation: turn 1.8s ease-in-out infinite;
}
@keyframes turn {
  40%,
  70% {
    transform: rotate(-90deg);
  }
}
.rotate p {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
}
@media (orientation: portrait) and (pointer: coarse) {
  body:has(.hud.on) .rotate {
    display: flex;
  }
}

/* short landscape phones: camera button moves beside the minimap, away from the MOVE stick */
@media (max-height: 420px) {
  :root {
    --mini: clamp(60px, 22vmin, 96px);
  }
  .hud-right {
    flex-direction: row-reverse;
    align-items: flex-start;
  }
  .lever {
    top: calc(var(--mini) + 22px + var(--safe-t));
  }
  .hud .icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 14px;
  }
  .modal.pause .toggles {
    grid-template-columns: 1fr 1fr;
  }
  .compass {
    top: calc(78px + var(--safe-t));
  }
  .goal-card {
    padding: 5px 12px 6px;
  }
  .modal {
    padding: 16px 18px;
  }
  .modal-actions {
    margin-top: 12px;
  }
  .chip {
    min-width: 70px;
    padding: 4px 10px;
  }
  .chip-value {
    font-size: 19px;
  }
  .lead {
    font-size: 16px;
  }
  /* Result card goes side by side so the buttons are visible without scrolling. */
  .modal.result {
    width: min(780px, 100%);
    display: grid;
    grid-template-columns: 1fr 1.25fr;
    column-gap: 18px;
    align-items: start;
  }
  .result > * {
    grid-column: 1;
  }
  .result > .learn {
    grid-column: 2;
    grid-row: 1 / span 4;
    align-self: center;
  }
  .result > .modal-actions {
    grid-column: 1 / -1;
  }
  .result h2 {
    font-size: 26px;
  }
  .stars.big svg {
    width: 34px;
    height: 34px;
  }
  .result .stats {
    margin: 8px 0 0;
  }
}

.nogl {
  max-width: 420px;
  margin: 20vh auto;
  padding: 24px;
  text-align: center;
}
/* very short screens, e.g. iPhone Safari in landscape with its toolbars showing */
@media (max-height: 320px) {
  .screen {
    padding: calc(8px + var(--safe-t)) calc(10px + var(--safe-r)) calc(8px + var(--safe-b)) calc(10px + var(--safe-l));
    gap: 8px;
  }
  .modal {
    padding: 10px 16px 12px;
    border-radius: 20px;
    border-top-width: 6px;
    max-height: calc(100dvh - 12px);
  }
  .modal h2 {
    font-size: 22px;
  }
  .modal h3 {
    margin: 6px 0 2px;
  }
  .lead,
  .controls,
  .stats {
    font-size: 14px;
  }
  .toggle {
    min-height: 40px;
    font-size: 14px;
  }
  .toggles {
    margin-top: 6px;
    gap: 6px;
  }
  .modal-actions {
    margin-top: 8px;
    gap: 8px;
  }
  .ghost {
    min-height: 40px;
    padding: 0 14px;
    font-size: 15px;
  }
  .cta {
    min-height: 44px;
    padding: 0 20px;
    font-size: 18px;
  }
  .goal-title {
    display: none;
  }
  .goal-text {
    font-size: 14px;
  }
  .goal-progress {
    font-size: 12px;
  }
  .compass {
    top: calc(62px + var(--safe-t));
  }
  .lever-notch {
    font-size: 11px;
  }
  .learn p {
    font-size: 13px;
  }
  .logo {
    font-size: 56px;
  }
  .tagline {
    margin: 4px 0 10px;
  }
  .foot,
  .tip {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
