@font-face {
  font-family: 'Grandstander';
  src: url('../fonts/grandstander-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Figtree';
  src: url('../fonts/figtree-latin.woff2') format('woff2');
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Chivo Mono';
  src: url('../fonts/chivo-mono-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --indigo: #14243d;
  --deep: #0b1728;
  --cream: #f4e9d4;
  --tomato: #e2513a;
  --marigold: #f2a63b;
  --teal: #2f8f8a;
  --mint: #9fd3bd;
  --pink: #e3a2a4;
  --hud-top-h: 84px;
  --hint-top: 96px;
  --hint-h: 24px;
  --tilt-top: 0.45deg;
  --tilt-bottom: -0.5deg;
  --shadow-ink: 5px 6px 0 rgba(7, 15, 28, 0.75);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--deep);
  color: var(--cream);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  font-family: 'Figtree', system-ui, sans-serif;
}

body { touch-action: manipulation; }

button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 3px solid var(--marigold); outline-offset: 3px; }

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--deep);
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- the printed field ---------- */

#sky {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: var(--deep);
}

#sky-img {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 52% 48%;
  display: block;
  transition: filter 0.6s ease;
}

#twinkles { position: absolute; inset: 0; pointer-events: none; }

.twinkle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--cream);
  clip-path: polygon(50% 0%, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0% 50%, 40% 40%);
  opacity: 0;
  animation: blink var(--dur, 7s) steps(1, end) var(--delay, 0s) infinite;
  transform: scale(var(--s, 1));
  transform-origin: center;
}

.twinkle.round {
  border-radius: 50%;
  clip-path: none;
  width: 4px;
  height: 4px;
}

@keyframes blink {
  0%, 70%, 100% { opacity: 0; }
  74%, 88% { opacity: 0.92; }
  90% { opacity: 0.35; }
}

#stage {
  position: absolute;
  inset: 0;
  z-index: 2;
  transition: filter 0.7s ease;
}
#stage canvas { display: block; }
#app.failed #sky-img { filter: saturate(0.32) brightness(0.92); }
#app.failed #stage { filter: saturate(0.28) brightness(0.94); }

#grain {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
  background-image: url('../assets/grain.png');
  background-repeat: repeat;
  opacity: 0.5;
  mix-blend-mode: soft-light;
}

/* ---------- the two console strips ---------- */

.strip {
  position: absolute;
  left: max(10px, 2vw);
  right: max(10px, 2vw);
  z-index: 20;
  background: var(--deep);
  border: 3px solid var(--cream);
  border-radius: 20px;
  box-shadow: 0 6px 0 rgba(226, 81, 58, 0.95), 0 11px 0 rgba(7, 15, 28, 0.55);
  display: flex;
  align-items: center;
}

.strip::before {
  content: '';
  position: absolute;
  inset: 5px;
  border: 1.5px solid rgba(244, 233, 212, 0.3);
  border-radius: 13px;
  pointer-events: none;
}

#hud-top {
  top: calc(var(--safe-top) + 9px);
  min-height: 62px;
  padding: 6px 11px;
  gap: clamp(6px, 1.2vw, 16px);
  transform: rotate(var(--tilt-top));
}

#logo {
  height: clamp(44px, 10vh, 96px);
  width: auto;
  display: block;
  filter: drop-shadow(2px 3px 0 rgba(7, 15, 28, 0.35));
  flex: none;
}

.plate {
  position: relative;
  flex: none;
  background: var(--cream);
  border: 3px solid var(--indigo);
  border-radius: 12px;
  box-shadow: 3px 4px 0 var(--tomato), 5px 7px 0 rgba(7, 15, 28, 0.4);
  color: var(--indigo);
  padding: 2px clamp(7px, 1.3vw, 15px) 4px;
  text-align: center;
  transform: rotate(1.3deg);
  line-height: 0.86;
}

.plate span {
  display: block;
  font-family: 'Figtree', sans-serif;
  font-weight: 800;
  font-size: clamp(7px, 1.15vw, 11px);
  letter-spacing: 0.16em;
  margin-bottom: 1px;
}

.plate strong {
  display: block;
  font-family: 'Grandstander', sans-serif;
  font-weight: 800;
  font-size: clamp(20px, 3.8vw, 44px);
  letter-spacing: -0.02em;
  line-height: 0.9;
}

#cab-badge {
  height: clamp(38px, 7.4vh, 70px);
  width: auto;
  display: block;
  flex: none;
  transform: rotate(-2deg);
}

#fuel-wrap {
  position: relative;
  margin-left: auto;
  height: clamp(46px, 8.5vh, 96px);
  aspect-ratio: 1024 / 468;
  flex: none;
}

#fuel-gauge {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

#fuel-pips { position: absolute; inset: 0; pointer-events: none; }

.pip-spent {
  position: absolute;
  background: url('../assets/elements/feedback_decals_05_spent_fuel_pip_socket_a_dark_empty_droplet_shape.webp') center / contain no-repeat;
  opacity: 0;
  transform: scale(0.55);
  transition: opacity 0.18s ease, transform 0.22s cubic-bezier(.2, 1.6, 0.4, 1);
  pointer-events: none;
}

.pip-spent[data-pip="0"] { left: 39.2%; top: 11.9%; width: 12.3%; height: 40%; }
.pip-spent[data-pip="1"] { left: 55.6%; top: 12.1%; width: 12.9%; height: 39.5%; }
.pip-spent[data-pip="2"] { left: 73.7%; top: 12.1%; width: 12.4%; top: 15.0%; height: 35.8%; }

.pip-spent.on { opacity: 1; transform: scale(1); }

#fuel-wrap.spend #fuel-gauge { animation: gaugeKnock 0.32s ease; }
@keyframes gaugeKnob { 0% { transform: scale(1); } 40% { transform: scale(1.05) rotate(-0.6deg); } 100% { transform: scale(1); } }
@keyframes gaugeKnock {
  0% { transform: scale(1); }
  35% { transform: scale(1.035) rotate(-0.4deg); }
  100% { transform: scale(1); }
}
#fuel-wrap.refuel #fuel-gauge { animation: gaugeKnock 0.5s ease; }

#hint {
  position: absolute;
  top: var(--hint-top);
  left: 0;
  right: 0;
  z-index: 19;
  display: flex;
  justify-content: center;
  pointer-events: none;
  padding: 0 10px;
}

#hint-text {
  max-width: min(92vw, 640px);
  background: rgba(20, 36, 61, 0.82);
  border: 2px solid rgba(244, 233, 212, 0.6);
  border-radius: 999px;
  color: var(--cream);
  font-family: 'Figtree', sans-serif;
  font-weight: 600;
  font-size: clamp(10px, 1.35vw, 15px);
  letter-spacing: 0.01em;
  line-height: 1.1;
  padding: 3px clamp(9px, 1.4vw, 16px) 4px;
  text-align: center;
  box-shadow: 2px 3px 0 rgba(7, 15, 28, 0.4);
  transition: opacity 0.24s ease;
}

#hud-bottom {
  bottom: calc(var(--safe-bottom) + 10px);
  min-height: 54px;
  padding: 5px 9px;
  justify-content: space-between;
  gap: 8px;
  transform: rotate(var(--tilt-bottom));
}

.tabs-left, .tabs-right { display: flex; align-items: center; gap: clamp(5px, 1vw, 10px); }

.tab {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 46px;
  min-height: 42px;
  padding: 3px 9px;
  background: var(--cream);
  border: 3px solid var(--indigo);
  border-radius: 12px;
  box-shadow: 0 4px 0 var(--tomato), 0 6px 0 rgba(7, 15, 28, 0.35);
  color: var(--indigo);
  cursor: pointer;
  transform: rotate(0.4deg);
  transition: transform 0.08s ease, box-shadow 0.08s ease, opacity 0.2s ease, filter 0.2s ease;
}

.tab:active { transform: translateY(3px) rotate(0.4deg); box-shadow: 0 1px 0 var(--tomato); }
.tab:disabled { cursor: default; opacity: 0.42; filter: grayscale(0.7); }
.tab:disabled:active { transform: rotate(0.4deg); box-shadow: 0 4px 0 var(--tomato); }

.tab.icon-tab {
  font-family: 'Grandstander', sans-serif;
  font-weight: 800;
  font-size: clamp(17px, 2.5vw, 24px);
  padding: 0;
  width: clamp(44px, 6.2vw, 56px);
  height: clamp(42px, 6vw, 52px);
}

.pause-mark { display: flex; gap: 4px; }
.pause-mark i {
  display: block;
  width: 5px;
  height: 17px;
  border-radius: 2px;
  background: var(--indigo);
}

.tab.wide {
  font-family: 'Figtree', sans-serif;
  font-weight: 800;
  font-size: clamp(10px, 1.3vw, 15px);
  letter-spacing: 0.09em;
  padding-right: clamp(8px, 1.4vw, 14px);
}

.tab.wide img {
  height: clamp(26px, 4.2vw, 36px);
  width: auto;
  display: block;
  border-radius: 7px;
}

/* ---------- toast ---------- */

#toast {
  position: absolute;
  z-index: 30;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 84px);
  transform: translate(-50%, 8px);
  background: var(--cream);
  color: var(--indigo);
  border: 3px solid var(--indigo);
  border-radius: 10px;
  box-shadow: 3px 4px 0 var(--tomato);
  font-family: 'Figtree', sans-serif;
  font-weight: 700;
  font-size: clamp(11px, 1.4vw, 15px);
  padding: 6px 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 86vw;
  text-align: center;
}

#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- overlays and paper cards ---------- */

#modal-layer { z-index: 46; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: max(12px, 2.4vw);
  background: rgba(7, 15, 28, 0.66);
}
[hidden] { display: none !important; }

.paper-card {
  position: relative;
  width: min(94vw, 600px);
  /* the ribbon overlaps the top edge and must not be clipped */
  max-height: 88dvh;
  overflow: visible;
  background: var(--cream);
  color: var(--indigo);
  border: 4px solid var(--indigo);
  border-radius: 20px;
  box-shadow: 9px 10px 0 rgba(7, 15, 28, 0.8), 0 0 0 3px var(--cream);
  padding: 26px clamp(14px, 3vw, 30px) 20px;
}

.ribbon {
  position: relative;
  width: min(86%, 430px);
  margin: -44px auto 16px;
  background: var(--tomato);
  border: 3px solid var(--indigo);
  border-radius: 12px;
  box-shadow: 4px 5px 0 var(--deep);
  transform: rotate(-1.2deg);
  padding: 5px 14px 7px;
  text-align: center;
}

.ribbon h2 {
  margin: 0;
  font-family: 'Grandstander', sans-serif;
  font-weight: 800;
  font-size: clamp(20px, 4.4vw, 34px);
  letter-spacing: 0.01em;
  color: var(--cream);
  text-shadow: 2px 3px 0 var(--indigo);
  line-height: 1;
}

#modal-body { font-family: 'Figtree', sans-serif; max-height: calc(88dvh - 128px); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 2px 2px 4px; }
#modal-card.has-footer #modal-body { max-height: calc(88dvh - 192px); }

.card-copy {
  font-family: 'Figtree', sans-serif;
  font-size: clamp(13px, 1.7vw, 16px);
  line-height: 1.42;
  margin: 0 0 14px;
  text-align: center;
  font-weight: 500;
}

.card-copy strong { font-weight: 800; }
.scope-note { text-align: center; font-family: 'Chivo Mono', monospace; font-weight: 600; font-size: clamp(9px, 1.1vw, 11px); color: #6c6b60; margin: -9px 0 11px; letter-spacing: 0.02em; }

.menu-grid { display: grid; gap: 10px; margin: 6px 0 4px; }

.modal-footer { background: var(--cream); padding: 10px 0 2px; }
.modal-footer .paper-btn { width: 100%; }
.menu-grid.two { grid-template-columns: 1fr 1fr; }

.paper-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  background: var(--cream);
  color: var(--indigo);
  border: 3px solid var(--indigo);
  border-radius: 12px;
  box-shadow: 0 4px 0 var(--tomato);
  font-family: 'Figtree', sans-serif;
  font-weight: 800;
  font-size: clamp(12px, 1.5vw, 16px);
  letter-spacing: 0.05em;
  padding: 8px 14px;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.paper-btn:hover { transform: translateY(-1px); }
.paper-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--tomato); }
.paper-btn.primary { background: var(--tomato); color: var(--cream); box-shadow: 0 4px 0 var(--deep); text-shadow: 1px 2px 0 rgba(7, 15, 28, 0.4); }
.paper-btn.teal { background: var(--teal); color: var(--cream); box-shadow: 0 4px 0 var(--deep); }

.sound-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 3px solid var(--indigo);
  border-radius: 12px;
  background: rgba(244, 233, 212, 0.6);
  padding: 8px 12px;
  font-weight: 700;
  font-size: clamp(12px, 1.5vw, 16px);
}
.switch {
  position: relative;
  width: 54px;
  height: 30px;
  border: 3px solid var(--indigo);
  border-radius: 999px;
  background: #cfc7b4;
  cursor: pointer;
  flex: none;
  transition: background 0.15s ease;
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--cream);
  border: 2px solid var(--indigo);
  transition: left 0.16s cubic-bezier(.2, 1.4, .4, 1);
}
.switch[aria-checked="true"] { background: var(--teal); }
.switch[aria-checked="true"]::after { left: 26px; }

.help-list { display: grid; gap: 9px; margin: 8px 0 16px; }
.help-row {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 11px;
  align-items: center;
  font-size: clamp(12px, 1.5vw, 15px);
  font-weight: 600;
  line-height: 1.3;
}
.help-icon {
  width: 44px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 2px solid var(--indigo);
  border-radius: 9px;
  background: var(--indigo);
  color: var(--cream);
  font-family: 'Chivo Mono', monospace;
  font-weight: 700;
  font-size: 15px;
  overflow: hidden;
}
.help-icon img { width: 32px; height: 32px; object-fit: contain; }
.help-icon.route { background: var(--indigo); }
.help-icon.route img { width: 38px; height: 38px; object-fit: contain; }
.help-icon.oneway { font-family: 'Figtree', sans-serif; font-size: 22px; }
.help-icon.once { background: var(--indigo); }
.help-icon.toll { background: var(--marigold); color: var(--indigo); font-size: 13px; }

/* level select */
.level-summary {
  text-align: center;
  font-family: 'Chivo Mono', monospace;
  font-weight: 600;
  font-size: clamp(11px, 1.4vw, 14px);
  letter-spacing: 0.04em;
  margin: 0 0 12px;
}
.level-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(6px, 1.2vw, 10px);
  margin-bottom: 16px;
}
.level-tile {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: var(--cream);
  color: var(--indigo);
  border: 3px solid var(--indigo);
  border-radius: 11px;
  box-shadow: 3px 3px 0 var(--tomato);
  font-family: 'Grandstander', sans-serif;
  font-weight: 800;
  font-size: clamp(15px, 2.2vw, 22px);
  cursor: pointer;
  padding: 2px;
  line-height: 1;
  transition: transform 0.1s ease;
}
.tab:not(:disabled):hover, .level-tile:not(:disabled):hover { filter: brightness(1.03); }
.level-tile:not(:disabled):active { transform: translateY(3px); }
.level-tile.current { background: var(--marigold); border-color: var(--indigo); box-shadow: 0 0 0 2px var(--indigo) inset, 3px 3px 0 var(--tomato); }
.level-tile.locked {
  background: #d6d1c3;
  border-color: #8d9088;
  color: #8d9088;
  box-shadow: none;
  cursor: not-allowed;
}
.level-tile .tile-stars {
  font-family: 'Figtree', sans-serif;
  font-size: clamp(7px, 1vw, 10px);
  letter-spacing: 1px;
  color: var(--tomato);
  min-height: 1em;
}
.level-tile.locked .tile-stars { color: #8d9088; }
.level-tile .lock {
  width: 15px;
  height: 16px;
  border: 2.5px solid #8d9088;
  border-radius: 3px;
  position: relative;
  margin-top: 1px;
}
.level-tile .lock::before {
  content: '';
  position: absolute;
  left: 2px;
  top: -8px;
  width: 7px;
  height: 8px;
  border: 2.5px solid #8d9088;
  border-bottom: none;
  border-radius: 5px 5px 0 0;
}

/* ---------- result card ---------- */

#result-layer.show { animation: overlayIn 0.25s ease both; }
#result-layer.show #result-card { animation: cardIn 0.55s cubic-bezier(.18, 1.35, .4, 1) both; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes cardIn {
  0% { opacity: 0; transform: translateY(34px) scale(0.82); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}


.result-stage {
  position: relative;
  width: min(92vw, 570px, calc((100dvh - 108px) * 1.448));
  display: flex;
  flex-direction: column;
  align-items: center;
}

#result-card {
  position: relative;
  width: 100%;
  aspect-ratio: 1024 / 707;
  filter: drop-shadow(8px 10px 0 rgba(7, 15, 28, 0.78));
}

.result-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  transition: filter 0.35s ease;
}

#result-card.fail .result-bg { filter: saturate(0.16) brightness(1.01); }

#result-card h2 {
  position: absolute;
  left: 11%;
  right: 11%;
  top: 8.2%;
  height: 18%;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: 'Grandstander', sans-serif;
  font-weight: 800;
  font-size: clamp(18px, 4.4vw, 36px);
  letter-spacing: 0.01em;
  line-height: 0.95;
  color: var(--cream);
  text-shadow: 2px 3px 0 var(--indigo);
}

#result-body {
  position: absolute;
  left: 13%;
  right: 13%;
  top: 33%;
  height: 23%;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  font-family: 'Figtree', sans-serif;
  font-weight: 600;
  font-size: clamp(11px, 1.9vw, 17px);
  line-height: 1.25;
  color: var(--indigo);
}

#result-body .big {
  font-family: 'Grandstander', sans-serif;
  font-weight: 800;
  font-size: clamp(16px, 2.8vw, 25px);
  line-height: 1;
}

#result-body .stars {
  font-family: 'Figtree', sans-serif;
  font-size: clamp(17px, 3vw, 26px);
  letter-spacing: 3px;
  color: var(--tomato);
  line-height: 1;
}

#result-body .muted { font-weight: 500; font-size: 0.92em; }
.mono { font-family: 'Chivo Mono', monospace; font-weight: 600; letter-spacing: 0.02em; }

#result-btn {
  position: absolute;
  left: 29%;
  top: 73.4%;
  width: 42%;
  height: 15.8%;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--cream);
  font-family: 'Figtree', sans-serif;
  font-weight: 800;
  font-size: clamp(12px, 1.9vw, 19px);
  letter-spacing: 0.08em;
  cursor: pointer;
  text-shadow: 1px 2px 0 rgba(7, 15, 28, 0.45);
  transition: transform 0.1s ease;
}
#result-btn:active { transform: translateY(2px) scale(0.99); }
#result-btn:hover { transform: scale(1.02); }

.result-decal {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.4s cubic-bezier(.2, 1.5, .4, 1);
}

#result-starburst {
  width: 26%;
  right: 0;
  top: -9%;
  transform: rotate(14deg) scale(0.6);
  z-index: 3;
  filter: drop-shadow(4px 5px 0 rgba(7, 15, 28, 0.55));
}

#result-confetti {
  width: 22%;
  left: 0;
  bottom: -4%;
  transform: rotate(-9deg) scale(0.7);
  z-index: 1;
  filter: drop-shadow(4px 5px 0 rgba(7, 15, 28, 0.4));
}

#result-retry {
  width: 15%;
  right: 1%;
  bottom: 1%;
  transform: rotate(-10deg) scale(0.8);
  z-index: 3;
}

.result-stage.fail #result-retry { opacity: 1; transform: rotate(-10deg) scale(1); }

#result-puff {
  width: 24%;
  right: 0;
  top: -7%;
  transform: rotate(8deg) scale(0.7);
  z-index: 3;
  filter: drop-shadow(4px 5px 0 rgba(7, 15, 28, 0.5));
}

.result-stage.victory #result-starburst,
.result-stage.victory #result-confetti { opacity: 1; transform: rotate(0deg) scale(1); }
.result-stage.fail #result-puff { opacity: 1; transform: rotate(0deg) scale(1); }

.result-stage.victory #result-starburst { transform: rotate(14deg) scale(1); }

#modal-card .ribbon { margin-top: -42px; }

.text-link {
  margin-top: 22px;
  background: none;
  border: none;
  color: var(--cream);
  font-family: 'Figtree', sans-serif;
  font-weight: 700;
  font-size: clamp(12px, 1.5vw, 15px);
  letter-spacing: 0.04em;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
  padding: 6px 10px;
  text-shadow: 2px 2px 0 rgba(7, 15, 28, 0.8);
}

/* ---------- responsive ---------- */

@media (max-width: 700px) {
  .level-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  #cab-badge { display: block; height: clamp(30px, 5vh, 44px); }
}

@media (max-width: 359px) {
  .level-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  :root { --tilt-top: 0.3deg; --tilt-bottom: -0.35deg; }
  #hud-top { min-height: 56px; padding: 5px 8px; gap: 6px; border-width: 2.5px; border-radius: 16px; }
  #logo { height: clamp(38px, 6.6vh, 52px); }
  .plate { padding: 1px 6px 3px; border-width: 2.5px; border-radius: 9px; box-shadow: 2px 3px 0 var(--tomato); }
  .plate strong { font-size: clamp(19px, 5.8vw, 26px); }
  .plate span { font-size: 8px; letter-spacing: 0.12em; }
  #fuel-wrap { height: clamp(40px, 6.4vh, 52px); }
  #hud-bottom { min-height: 50px; padding: 4px 6px; }
  .tab { min-height: 40px; border-width: 2.5px; border-radius: 10px; }
  .tab.icon-tab { width: 42px; height: 40px; }
  .tab.wide { min-width: 84px; padding: 2px 7px; gap: 4px; font-size: 10px; }
  .tab.wide img { height: 24px; }
  #toast { bottom: calc(var(--safe-bottom) + 74px); }
  .paper-card { padding: 24px 12px 16px; }
  .ribbon { margin-top: -40px; }
  .result-stage { width: min(94vw, 500px); }
}

@media (max-height: 560px) and (orientation: landscape) {
  .level-grid { grid-template-columns: repeat(9, minmax(0, 1fr)); }
}

@media (max-width: 380px) {
  #logo { height: 36px; }
  #cab-badge { height: 28px; }
  .tab.wide span { display: none; }
  .tab.wide { min-width: 46px; }
  .tab.wide img { height: 27px; }
  #fuel-wrap { height: 38px; }
}

@media (max-height: 560px) and (orientation: landscape) {
  #hud-top { min-height: 48px; }
  #logo { height: 40px; }
  #fuel-wrap { height: 42px; }
  #hud-bottom { min-height: 46px; }
  .tab { min-height: 36px; }
  .tab.icon-tab { height: 36px; width: 40px; }
  #hint-text { font-size: 10px; padding: 2px 10px 3px; }
  #toast { bottom: calc(var(--safe-bottom) + 62px); }
}

@media (prefers-reduced-motion: reduce) {
  .twinkle { animation: none; opacity: 0.4; }
  .tab, .paper-btn, .level-tile { transition: none; }
}
