/* fredoka-latin-400-normal */
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url(./fredoka-latin-400-normal.woff2) format('woff2'), url(./fredoka-latin-400-normal.woff) format('woff');
}/* fredoka-latin-500-normal */
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url(./fredoka-latin-500-normal.woff2) format('woff2'), url(./fredoka-latin-500-normal.woff) format('woff');
}/* fredoka-latin-600-normal */
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-display: swap;
  font-weight: 600;
  src: url(./fredoka-latin-600-normal.woff2) format('woff2'), url(./fredoka-latin-600-normal.woff) format('woff');
}/* fredoka-latin-700-normal */
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-display: swap;
  font-weight: 700;
  src: url(./fredoka-latin-700-normal.woff2) format('woff2'), url(./fredoka-latin-700-normal.woff) format('woff');
}:root {
  --ink: #2b3240;
  --ink-soft: #5d6474;
  --muted: #7d8291;
  --card: #fffaf2;
  --card-2: #f6eddf;
  --edge: #e6d8c3;
  --edge-dark: #d4c2a7;
  --primary: #c94c35;
  --primary-dark: #973322;
  --teal: #2fb5a9;
  --mustard: #edb33b;
  --lavender: #9c8ae0;
  --focus: #2f9fe0;
  --danger: #d9534f;
  --radius: 20px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --font:
    'Fredoka', ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', Roboto,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #3e4859;
  color: var(--ink);
  font-family: var(--font);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#stage {
  position: absolute;
  inset: 0;
}

#stage canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
}

#stage canvas:focus-visible {
  outline: 3px solid #7fd6ff;
  outline-offset: -6px;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

button,
select,
input {
  font-family: inherit;
}

button {
  touch-action: manipulation;
}

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

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow:
    0 2px 0 var(--edge),
    0 10px 28px rgba(35, 25, 15, 0.18);
}

/* ------------------------------------------------------------------ buttons */

.btn {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 18px;
  border: 0;
  border-radius: 16px;
  background: #fffdf8;
  color: var(--ink);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow:
    0 4px 0 var(--edge-dark),
    0 6px 14px rgba(60, 40, 20, 0.1);
  transform: translateY(0);
  transition:
    transform 0.07s ease-out,
    box-shadow 0.07s ease-out,
    opacity 0.15s;
}

.btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow:
    0 1px 0 var(--edge-dark),
    0 3px 8px rgba(60, 40, 20, 0.1);
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow:
    inset 0 2px 0 #e0705a,
    0 4px 0 var(--primary-dark),
    0 8px 18px rgba(150, 50, 30, 0.3);
}

.btn-primary:active:not(:disabled) {
  box-shadow:
    0 1px 0 var(--primary-dark),
    0 3px 8px rgba(198, 86, 68, 0.25);
}

.btn-selected {
  background: #e7f6f3;
  color: #1d7d74;
  box-shadow: 0 4px 0 #bfe4de;
}

.btn-big {
  min-height: 62px;
  font-size: 21px;
  padding: 0 26px;
  border-radius: 20px;
}

.btn-big small {
  font-size: 14px;
  font-weight: 500;
  opacity: 0.85;
  margin-left: 2px;
}

.btn-small {
  min-height: 40px;
  font-size: 14px;
  padding: 0 12px;
  border-radius: 12px;
}

.btn-danger {
  color: var(--danger);
}

.btn-danger.armed {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 4px 0 #a73a36;
}

.btn-icon {
  display: inline-flex;
}

.btn-icon svg {
  width: 22px;
  height: 22px;
}

.btn-icon-only {
  width: 50px;
  padding: 0;
}

.btn.ready {
  animation: pop-in 0.28s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.icon-btn {
  pointer-events: auto;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 14px;
  background: var(--card-2);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 3px 0 var(--edge-dark);
}

.icon-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--edge-dark);
}

/* ---------------------------------------------------------------------- HUD */

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

.hud[hidden] {
  display: none;
}

.hud-top {
  pointer-events: auto;
  position: absolute;
  top: calc(var(--safe-t) + 10px);
  left: calc(var(--safe-l) + 10px);
  right: calc(var(--safe-r) + 10px);
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
}

.hud-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.hud-level {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-dark);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.hud-name {
  font-size: 19px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 70px;
  height: 46px;
  padding: 0 14px 0 10px;
  border-radius: 14px;
  background: #3e4859;
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  justify-content: center;
}

.chip-icon svg {
  width: 24px;
  height: 24px;
  stroke-width: 2.2;
}

.chip.pulse {
  animation: chip-pulse 0.24s ease-out;
}

.chip[data-combo]:not([data-combo=''])::after {
  content: attr(data-combo);
  position: absolute;
  top: -10px;
  right: -8px;
  background: var(--mustard);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 8px;
  animation: pop-in 0.25s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.toolbar {
  pointer-events: auto;
  position: absolute;
  left: calc(var(--safe-l) + 10px);
  right: calc(var(--safe-r) + 10px);
  bottom: calc(var(--safe-b) + 12px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
}

.tool-gap {
  flex: 1;
}

.tool[hidden] {
  display: none;
}

.tool {
  pointer-events: auto;
  min-width: 72px;
  height: 64px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  border-radius: 16px;
  background: var(--card-2);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--edge-dark);
  transition:
    transform 0.07s,
    box-shadow 0.07s,
    opacity 0.15s;
}

.tool:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--edge-dark);
}

.tool:disabled {
  opacity: 0.4;
  cursor: default;
}

.tool-icon svg {
  width: 26px;
  height: 26px;
}

.tool-hint .tool-icon {
  color: #c98a0e;
}

.tool-restart {
  background: transparent;
  box-shadow: inset 0 0 0 2px var(--edge);
  color: var(--ink-soft);
}

/* Landscape: side rails instead of top/bottom bars */
.landscape .hud-top {
  right: auto;
  bottom: auto;
  top: calc(var(--safe-t) + 12px);
  width: 220px;
  flex-direction: column;
  align-items: stretch;
  padding: 12px;
}

.landscape .hud-top .icon-btn {
  align-self: flex-start;
}

.landscape .hud-title {
  flex: 0 0 auto;
}

.landscape .hud-name {
  white-space: normal;
}

.landscape .toolbar {
  left: auto;
  right: calc(var(--safe-r) + 12px);
  top: 50%;
  bottom: auto;
  transform: translateY(-50%);
  flex-direction: column;
  width: 92px;
  padding: 10px;
}

.landscape .toolbar .tool {
  width: 100%;
}

.landscape .toolbar .tool-gap {
  flex: 0 0 18px;
}

.landscape.short .hud-top {
  width: 128px;
  padding: 8px;
  gap: 8px;
  top: calc(var(--safe-t) + 8px);
}

.landscape.short .hud-name {
  font-size: 15px;
}

.landscape.short .chip {
  height: 40px;
  font-size: 19px;
}

.landscape.short .toolbar {
  width: 80px;
  padding: 6px;
  gap: 6px;
}

.landscape.short .tool {
  height: 54px;
  min-width: 0;
  font-size: 12px;
}

.landscape.short .toolbar .tool-gap {
  flex: 0 0 6px;
}

.narrow .tool {
  min-width: 64px;
}

/* Toy-box HUD: chunky plastic panels with a thick moulded edge */
.hud .card {
  border-radius: 24px;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.9),
    0 5px 0 var(--edge-dark),
    0 14px 30px rgba(35, 25, 15, 0.22);
}

.hud .icon-btn,
.hud .tool {
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.7),
    0 4px 0 var(--edge-dark);
}

.hud .icon-btn:active,
.hud .tool:active:not(:disabled) {
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.7),
    0 1px 0 var(--edge-dark);
}

.chip {
  background: linear-gradient(#4a5568, #3a4354);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.16),
    0 4px 0 #262d3a;
}

.tool-undo {
  background: #e3f4f1;
  color: #17736a;
}

.hud .tool-undo {
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.8),
    0 4px 0 #b7ddd6;
}

.tool-hint {
  background: #fff1cc;
  color: #6e4f0a;
}

.hud .tool-hint {
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.8),
    0 4px 0 #ecd28d;
}

.hud .tool-restart,
.hud .tool-restart:active:not(:disabled) {
  box-shadow: inset 0 0 0 2px var(--edge);
}

/* Large desktop: scale the whole HUD up so it reads at arm's length */
.landscape.big .hud-top {
  width: 280px;
  top: calc(var(--safe-t) + 20px);
  left: calc(var(--safe-l) + 20px);
  padding: 16px;
  gap: 12px;
}

.landscape.big .hud-top .icon-btn {
  width: 56px;
  height: 56px;
  border-radius: 16px;
}

.landscape.big .icon-btn svg {
  width: 26px;
  height: 26px;
}

.landscape.big .hud-level {
  font-size: 16px;
}

.landscape.big .hud-name {
  font-size: 27px;
  line-height: 1.12;
}

.landscape.big .chip {
  height: 60px;
  font-size: 30px;
  border-radius: 18px;
  gap: 10px;
}

.landscape.big .chip-icon svg {
  width: 32px;
  height: 32px;
}

.landscape.big .toolbar {
  right: calc(var(--safe-r) + 20px);
  width: 124px;
  padding: 14px;
  gap: 12px;
}

.landscape.big .tool {
  height: 92px;
  border-radius: 20px;
  font-size: 16px;
  gap: 6px;
}

.landscape.big .tool-icon svg {
  width: 36px;
  height: 36px;
}

.landscape.big .toolbar .tool-gap {
  flex: 0 0 22px;
}

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

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-b) + 104px);
  transform: translate(-50%, 12px);
  max-width: min(92vw, 420px);
  padding: 12px 18px;
  border-radius: 16px;
  background: rgba(43, 50, 64, 0.94);
  color: #fff;
  font-size: 16px;
  font-weight: 500;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s,
    transform 0.2s;
}

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

.landscape .toast {
  bottom: calc(var(--safe-b) + 18px);
}

/* ------------------------------------------------------------------ screens */

.screen-root {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.title-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-t) + 4.5vh) calc(var(--safe-r) + 16px) calc(var(--safe-b) + 4vh)
    calc(var(--safe-l) + 16px);
  pointer-events: none;
}

.title-top {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---- sticker logo (pre-rendered by tools/make-logo.mjs: letters, cream edge, dark rim, shadow) */

.logo {
  margin: 0;
  line-height: 0;
  animation:
    logo-in 0.75s cubic-bezier(0.2, 1.4, 0.4, 1) 0.05s both,
    logo-bob 6s ease-in-out 1s infinite;
}

.logo-img {
  display: block;
  height: auto;
  pointer-events: none;
  -webkit-user-drag: none;
}

.logo-img.stacked {
  width: min(80vw, 380px, calc(32vh * 1.43));
}

.logo-img.wide {
  display: none;
  width: min(62vw, 760px, calc(21vh * 4.01));
}

.landscape .logo-img.stacked {
  display: none;
}

.landscape .logo-img.wide {
  display: block;
}

@keyframes logo-in {
  0% {
    transform: translateY(-46px) scale(0.86) rotate(-3deg);
    opacity: 0;
  }
  55% {
    opacity: 1;
  }
  100% {
    transform: none;
    opacity: 1;
  }
}

@keyframes logo-bob {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-4px) rotate(-0.6deg);
  }
}

.tagline {
  position: relative;
  z-index: 1;
  margin: -16px 0 0;
  padding: 7px 15px 8px;
  border-radius: 999px;
  background: #2b3240;
  color: #fffaf2;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transform: rotate(-2deg);
  box-shadow:
    0 3px 0 #171c27,
    0 10px 18px rgba(10, 14, 30, 0.25);
  animation: tag-in 0.5s 0.55s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.landscape .tagline {
  margin-top: -26px;
  font-size: clamp(14px, 2.2vh, 18px);
}

@keyframes tag-in {
  0% {
    opacity: 0;
    transform: translateY(10px) rotate(-2deg) scale(0.9);
  }
  100% {
    opacity: 1;
    transform: rotate(-2deg);
  }
}

/* ---- actions at the bottom */

.title-actions {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 360px;
  animation: fade-up 0.5s 0.45s ease-out both;
}

.title-actions .btn-big {
  min-height: 64px;
  font-size: 22px;
  border-radius: 999px;
  box-shadow:
    inset 0 2px 0 #e0705a,
    0 5px 0 var(--primary-dark),
    0 12px 26px rgba(120, 40, 25, 0.35);
}

.title-row {
  display: flex;
  gap: 12px;
}

.title-row .btn {
  border-radius: 999px;
  box-shadow:
    0 4px 0 var(--edge-dark),
    0 10px 20px rgba(20, 20, 40, 0.2);
}

.title-row .btn:not(.btn-icon-only) {
  flex: 1;
}

.landscape .title-actions {
  max-width: 520px;
  flex-direction: row;
  align-items: center;
}

.landscape .title-actions .btn-big {
  flex: 1.25;
}

.landscape .title-row {
  flex: 1.6;
}

.landscape.short .title-screen {
  padding-top: calc(var(--safe-t) + 14px);
  padding-bottom: calc(var(--safe-b) + 20px);
}

.landscape.short .tagline {
  font-size: 13px;
  padding: 5px 12px 6px;
  margin-top: -14px;
}

/* roomy desktop: bigger buttons to balance the logo */
@media (min-height: 700px) and (min-width: 900px) {
  .landscape .title-actions {
    max-width: 640px;
  }
  .landscape .title-actions .btn-big {
    min-height: 72px;
    font-size: 24px;
  }
  .landscape .title-row .btn {
    min-height: 56px;
    font-size: 18px;
  }
  .landscape .title-row .btn-icon-only {
    width: 56px;
  }
}

.landscape.short .title-actions .btn-big {
  min-height: 52px;
  font-size: 19px;
}

@keyframes fade-up {
  0% {
    opacity: 0;
    transform: translateY(14px);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .logo,
  .tagline,
  .title-actions {
    animation: none !important;
  }
}

/* panels (levels / garage) */

.panel-screen {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: calc(var(--safe-t) + 12px) calc(var(--safe-r) + 12px) calc(var(--safe-b) + 12px)
    calc(var(--safe-l) + 12px);
  background: rgba(244, 236, 223, 0.5);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  pointer-events: auto;
}

.panel {
  width: 100%;
  max-width: 680px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 14px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.panel-head h2 {
  flex: 1;
  margin: 0;
  font-size: 26px;
  font-weight: 700;
}

.panel-stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #c98a0e;
  font-weight: 700;
  font-size: 17px;
}

.panel-stat svg {
  width: 22px;
  height: 22px;
}

.panel-sub {
  margin: 8px 4px 12px;
  color: var(--muted);
  font-size: 15px;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  overflow-y: auto;
  padding: 4px 4px 8px;
  -webkit-overflow-scrolling: touch;
}

.landscape .level-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.level-tile {
  position: relative;
  aspect-ratio: 1 / 0.9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px;
  border: 0;
  border-radius: 16px;
  background: #fffdf8;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 4px 0 var(--edge-dark);
}

.level-tile:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--edge-dark);
}

.tile-num {
  font-size: 26px;
  font-weight: 700;
}

.tile-name {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-align: center;
  line-height: 1.15;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.level-tile.done {
  background: #eaf6f2;
  box-shadow: 0 4px 0 #bfe0d6;
}

.level-tile.clean {
  background: #fff4d6;
  box-shadow: 0 4px 0 #ecd28d;
}

.level-tile.locked {
  background: var(--card-2);
  color: #b5ab9c;
  box-shadow: none;
  cursor: default;
}

.tile-lock svg,
.tile-check svg {
  width: 18px;
  height: 18px;
}

.tile-lock {
  position: absolute;
  top: 6px;
  right: 6px;
}

.tile-check {
  position: absolute;
  top: 6px;
  right: 6px;
  color: #1d9a8d;
}

.level-tile.clean .tile-check {
  color: #d39a12;
}

.garage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  overflow-y: auto;
  padding: 4px;
}

.landscape .garage-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.garage-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: #fffdf8;
  box-shadow: 0 3px 0 var(--edge);
}

.garage-card.selected {
  box-shadow:
    0 0 0 3px var(--teal),
    0 3px 0 var(--edge);
}

.garage-card h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.garage-preview {
  position: relative;
  overflow: hidden;
  aspect-ratio: 22 / 13;
  border-radius: 14px;
  background: radial-gradient(120% 90% at 50% 35%, #5d6a80 0%, #48536a 70%, #3f495d 100%);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.12);
}

.garage-card.locked .garage-preview img {
  filter: saturate(0.55);
  opacity: 0.8;
}

.garage-car {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.garage-lock {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

.lock-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.lock-line svg {
  width: 16px;
  height: 16px;
}

.progress {
  height: 8px;
  border-radius: 8px;
  background: var(--card-2);
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--teal);
  border-radius: 8px;
}

/* -------------------------------------------------------------------- modals */

.modal-root {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(40, 32, 22, 0.28);
  pointer-events: auto;
  animation: fade-in 0.18s ease-out;
}

.modal-backdrop.kind-results,
.modal-backdrop.kind-finale {
  background: rgba(40, 32, 22, 0.12);
}

.modal {
  width: 100%;
  max-width: 400px;
  max-height: calc(100% - 8px);
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: modal-in 0.26s cubic-bezier(0.2, 1.3, 0.4, 1);
}

.modal h2 {
  margin: 0;
  font-size: 28px;
}

.eyebrow {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary-dark);
}

.results-title {
  font-size: 40px !important;
  color: var(--ink);
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

.modal-actions .row {
  display: flex;
  gap: 10px;
}

.modal-actions .row .btn {
  flex: 1;
}

.muted {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.muted svg {
  width: 18px;
  height: 18px;
  vertical-align: -3px;
  color: #d39a12;
}

.small {
  font-size: 13px;
}

.badge-clean {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 14px;
  background: #fff1c7;
  color: #8a5d00;
  font-weight: 700;
  font-size: 18px;
  animation: pop-in 0.35s 0.15s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}

.badge-clean svg {
  width: 24px;
  height: 24px;
  color: #e3a516;
}

.time-line,
.unlock-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 17px;
  font-weight: 500;
}

.time-line svg,
.unlock-line svg {
  width: 20px;
  height: 20px;
  color: var(--ink-soft);
}

.unlock-line {
  color: #1d7d74;
}

.new-best {
  color: #1d9a8d;
  font-weight: 700;
}

.finale-icon {
  color: var(--mustard);
}

.finale-icon svg {
  width: 48px;
  height: 48px;
}

.landscape.short .modal {
  padding: 14px;
  gap: 6px;
}

.landscape.short .results-title {
  font-size: 32px !important;
}

/* settings */

.settings {
  gap: 4px;
}

.settings .panel-head {
  margin-bottom: 6px;
}

.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 4px 2px;
  border-bottom: 1px solid var(--card-2);
  font-size: 17px;
  font-weight: 500;
}

.set-row input[type='range'] {
  width: 48%;
  accent-color: var(--primary);
  height: 28px;
}

.set-row select {
  font-size: 16px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 2px solid var(--edge);
  background: #fffdf8;
  color: var(--ink);
  max-width: 55%;
}

.set-reset {
  border-bottom: 0;
  justify-content: flex-end;
}

.switch {
  position: relative;
  width: 56px;
  height: 32px;
  border: 0;
  border-radius: 20px;
  background: #d9cfbf;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 0.15s;
}

.switch .knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s;
}

.switch[aria-checked='true'] {
  background: var(--teal);
}

.switch[aria-checked='true'] .knob {
  transform: translateX(24px);
}

/* ad blocker overlay */

.ad-blocker {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(40, 32, 22, 0.45);
  pointer-events: auto;
  z-index: 20;
}

.ad-blocker[hidden] {
  display: none;
}

.ad-blocker-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  border-radius: 18px;
  background: var(--card);
  font-weight: 600;
}

.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid var(--edge);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}

/* --------------------------------------------------------------- animations */

@keyframes chip-pulse {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.14);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes pop-in {
  0% {
    transform: scale(0.6);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes modal-in {
  0% {
    transform: translateY(18px) scale(0.96);
    opacity: 0;
  }
  100% {
    transform: none;
    opacity: 1;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes letter-in {
  0% {
    transform: translateY(-30px) scale(0.6);
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.reduced-motion *,
.reduced-motion *::before,
.reduced-motion *::after {
  animation-duration: 0.001ms !important;
  animation-delay: 0ms !important;
  transition-duration: 0.001ms !important;
}

@media (hover: hover) {
  .btn:hover:not(:disabled),
  .tool:hover:not(:disabled),
  .icon-btn:hover,
  .level-tile:hover:not(:disabled) {
    filter: brightness(1.03);
  }
}

/* ------------------------------------------------------------ bus stop HUD */

.hud-top {
  flex-wrap: wrap;
}

.stop-panel {
  flex: 1 0 100%;
  display: flex;
  align-items: stretch;
  gap: 8px;
  min-width: 0;
  padding-top: 2px;
}

.stop-panel[hidden] {
  display: none;
}

.stop-side {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding: 5px 8px 6px;
  border-radius: 16px;
  background: var(--card-2);
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.04);
}

.stop-side-q {
  flex: 1 1 auto;
}

.stop-side-l {
  flex: 0 0 auto;
}

.stop-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.stop-queue-wrap {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  min-width: 0;
  height: 40px;
}

.stop-queue {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 1px;
  min-width: 0;
  overflow: hidden;
}

/* fade the tail of a long queue */
.stop-queue.long {
  mask-image: linear-gradient(90deg, #000 80%, transparent);
  -webkit-mask-image: linear-gradient(90deg, #000 80%, transparent);
}

.stop-more {
  flex: 0 0 auto;
  align-self: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.peg {
  flex: 0 0 auto;
  display: inline-block;
  width: 22px;
  height: 28px;
  transform-origin: 50% 100%;
}

.peg svg {
  display: block;
  width: 100%;
  height: 100%;
}

.peg.front {
  width: 31px;
  height: 39px;
  margin-right: 3px;
  animation: peg-wave 1.6s ease-in-out infinite;
}

.peg.shift {
  animation: peg-shift 0.28s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.peg.front.shift {
  animation:
    peg-shift 0.28s cubic-bezier(0.2, 1.4, 0.4, 1),
    peg-wave 1.6s ease-in-out 0.3s infinite;
}

.peg.leaving {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 31px;
  height: 39px;
  z-index: 2;
  animation: peg-board 0.5s cubic-bezier(0.3, 0.7, 0.5, 1) both;
}

.stop-lot {
  display: flex;
  gap: 4px;
  height: 40px;
  align-items: center;
}

.lot-slot {
  position: relative;
  flex: 0 0 auto;
  width: 27px;
  height: 37px;
  border-radius: 8px;
  border: 2px dashed #cbbba0;
  background: rgba(255, 255, 255, 0.5);
  transition:
    border-color 0.2s,
    background-color 0.2s;
}

.stop-lot.warn .lot-slot {
  border-color: #e8a33a;
}

.stop-lot.full .lot-slot {
  border-color: var(--primary);
  background: rgba(240, 117, 96, 0.12);
}

.lot-car {
  position: absolute;
  inset: 1px;
  display: block;
}

.lot-car svg {
  display: block;
  width: 100%;
  height: 100%;
}

.lot-car.arrive {
  animation: lot-arrive 0.36s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}

.lot-car.leaving {
  z-index: 2;
  animation: lot-leave 0.45s ease-in both;
}

.stop-panel.shake {
  animation: shake 0.42s ease-out;
}

.tool.flash {
  animation: flash-ring 1.4s ease-out;
}

/* landscape: the stop stacks under the title inside the left rail */
.landscape .hud-top {
  flex-wrap: nowrap;
}

.landscape .stop-panel {
  flex: 0 0 auto;
  flex-direction: column;
  gap: 6px;
}

.landscape .stop-side-l {
  align-self: stretch;
}

.landscape .stop-queue-wrap {
  height: 42px;
}

.landscape.short .stop-panel {
  gap: 4px;
}

.landscape.short .stop-side {
  padding: 3px 6px 4px;
}

.landscape.short .stop-label {
  display: none;
}

.landscape.short .peg {
  width: 15px;
  height: 19px;
}

.landscape.short .peg.front {
  width: 24px;
  height: 30px;
}

.landscape.short .stop-queue-wrap,
.landscape.short .stop-lot {
  height: 31px;
}

.landscape.short .lot-slot {
  width: 20px;
  height: 28px;
}

.landscape.big .stop-label {
  font-size: 12px;
}

.landscape.big .peg {
  width: 26px;
  height: 33px;
}

.landscape.big .peg.front {
  width: 38px;
  height: 48px;
}

.landscape.big .stop-queue-wrap,
.landscape.big .stop-lot {
  height: 50px;
}

.landscape.big .lot-slot {
  width: 34px;
  height: 46px;
}

.narrow .peg {
  width: 18px;
  height: 23px;
}

.narrow .lot-slot {
  width: 23px;
  height: 33px;
}

@keyframes peg-wave {
  0%,
  100% {
    transform: rotate(0) translateY(0);
  }
  50% {
    transform: rotate(-4deg) translateY(-2px);
  }
}

@keyframes peg-shift {
  from {
    transform: translateX(22px);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes peg-board {
  0% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  45% {
    transform: translateY(-16px) scale(1.12);
    opacity: 1;
  }
  100% {
    transform: translateY(-26px) scale(0.4);
    opacity: 0;
  }
}

@keyframes lot-arrive {
  from {
    transform: translateY(14px) scale(0.6);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

@keyframes lot-leave {
  from {
    transform: none;
    opacity: 1;
  }
  to {
    transform: translateY(-22px);
    opacity: 0;
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  45% {
    transform: translateX(5px);
  }
  70% {
    transform: translateX(-3px);
  }
}

@keyframes flash-ring {
  0% {
    box-shadow:
      0 0 0 0 rgba(47, 181, 169, 0.7),
      0 4px 0 var(--edge-dark);
  }
  100% {
    box-shadow:
      0 0 0 14px rgba(47, 181, 169, 0),
      0 4px 0 var(--edge-dark);
  }
}

.reduced-motion .peg.front,
.reduced-motion .peg.shift {
  animation: none;
}

/* ------------------------------------------------------- tutorial / stuck */

.modal.tutorial,
.modal.stuck {
  text-align: center;
}

.tut-art svg {
  display: block;
  width: 100%;
  max-width: 320px;
  margin: 0 auto 4px;
}

.tut-list {
  text-align: left;
  margin: 4px 0 6px;
  padding-left: 22px;
  display: grid;
  gap: 8px;
  font-size: 15.5px;
  line-height: 1.35;
}

.tut-list li::marker {
  font-weight: 700;
  color: var(--primary);
}

.stuck-icon svg {
  width: 44px;
  height: 44px;
  color: var(--primary);
}

.tile-pips {
  display: flex;
  gap: 2px;
  margin-top: 1px;
}

.tile-pips i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0.85;
}

/* the waiting lot now lives in the 3D scene (bays on the bus-stop deck) */
.stop-side-l {
  display: none !important;
}

/* ------------------------------------------------------------ tutorial coach */

.coach {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.coach[hidden],
.coach-pointer[hidden] {
  display: none;
}

.coach-pointer {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
}

.coach-ring {
  position: absolute;
  left: -30px;
  top: -30px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 4px solid #ffd24d;
  box-shadow: 0 0 0 3px rgba(43, 50, 64, 0.35);
  animation: coach-pulse 1.1s ease-out infinite;
}

.coach-arrow {
  position: absolute;
  left: -19px;
  top: -86px;
  width: 38px;
  height: 46px;
  color: #ffd24d;
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.3));
  animation: coach-bob 0.8s ease-in-out infinite alternate;
}

.coach-arrow svg {
  width: 100%;
  height: 100%;
}

.coach-bubble {
  pointer-events: auto;
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-b) + 112px);
  transform: translateX(-50%);
  width: min(440px, calc(100% - 28px));
  height: 104px;
  overflow: hidden;
  padding: 10px 12px 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 20px;
  box-shadow:
    0 4px 0 var(--edge-dark),
    0 12px 30px rgba(35, 25, 15, 0.28);
}

.coach-bubble.shake {
  animation: shake-x 0.42s ease-out;
}

.coach-text {
  flex: 1;
  margin: 0;
  font-size: 15px;
  line-height: 1.32;
}

.coach-text b {
  font-weight: 600;
}

.coach-skip {
  flex: 0 0 auto;
  min-height: 34px;
  font-size: 13px;
}

.coach-dot {
  display: inline-block;
  width: 15px;
  height: 15px;
  margin: 0 2px -2px;
  border-radius: 50%;
  border: 2px solid rgba(43, 50, 64, 0.55);
}

.landscape .coach-bubble {
  bottom: calc(var(--safe-b) + 14px);
}

@keyframes coach-pulse {
  0% {
    transform: scale(0.8);
    opacity: 1;
  }
  100% {
    transform: scale(1.35);
    opacity: 0;
  }
}

@keyframes coach-bob {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(10px);
  }
}

@keyframes shake-x {
  0%,
  100% {
    transform: translateX(-50%);
  }
  25% {
    transform: translateX(calc(-50% - 7px));
  }
  60% {
    transform: translateX(calc(-50% + 5px));
  }
}

/* small phones (320–359 px wide): keep the title row and tagline inside the screen */
@media (max-width: 359px) {
  .title-row {
    gap: 8px;
  }
  .title-row .btn:not(.btn-icon-only) {
    min-width: 0;
    padding: 0 10px;
    font-size: 15px;
    gap: 6px;
  }
  .title-row .btn-icon-only {
    flex: 0 0 48px;
    width: 48px;
  }
  .tagline {
    font-size: 12.5px;
    padding: 6px 12px 7px;
  }
}
