.app {
  max-width: 1100px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: 12px 14px max(12px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

/* Top bar: back, place / lap / time, sound + pause. On narrow screens the board gets its own row. */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mini-logo { display: none; margin: 0; font-size: clamp(1.25rem, 6.2vw, 1.9rem); text-align: center; white-space: nowrap; }
.hud { flex: 1; min-width: 0; max-width: 460px; padding: 6px 10px; }
.solo { display: grid; grid-template-columns: 1fr 1fr 1.2fr; }
.stat { min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.stat b { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.stat small { font-size: 0.82rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.stat + .stat { border-left: 2px dashed var(--cream-2); }
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.player { min-width: 0; display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto; align-items: center; column-gap: 6px; line-height: 1.1; padding: 0 4px; }
.player + .player { border-left: 2px dashed var(--cream-2); padding-left: 10px; }
.player .dot { grid-row: span 2; }
.player .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; font-size: 0.95rem; }
.player b { grid-row: span 2; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.player small { font-size: 0.82rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.dot { display: inline-block; flex: none; width: 14px; height: 14px; margin-right: 6px; border-radius: 50%; background: var(--c, var(--pink)); box-shadow: 0 0 0 2px #fff, 0 2px 0 2px rgba(0, 0, 0, 0.1); vertical-align: -1px; }
.player .dot { margin-right: 0; }
#pause-btn svg { display: block; }

/* The race: one canvas that fills the board; game.js splits it in two views for two players. */
.board {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  outline: none;
}
.board:focus-visible .field { box-shadow: 0 0 0 4px #fff, 0 0 0 8px #2d8dff; }
.field {
  position: relative;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 0 0 4px #fff, 0 7px 0 4px var(--cream-dark), 0 22px 30px -14px rgba(60, 30, 110, 0.55);
}
.field canvas { display: block; touch-action: none; }
.controls { position: absolute; inset: 0; pointer-events: none; }

/* a short note over the race (a slow device, a shared track…) */
.race-note { position: absolute; left: 50%; top: 56px; z-index: 2; translate: -50% 0; width: max-content; max-width: calc(100% - 24px); margin: 0; padding: 8px 16px; border-radius: 16px; background: rgba(255, 255, 255, 0.95); box-shadow: 0 3px 0 var(--cream-dark); color: var(--ink); font-weight: 700; font-size: 0.95rem; line-height: 1.3; text-align: center; pointer-events: none; animation: tip-in 0.3s ease; }

/* The power-up slot (tap it) and the turbo button (hold it) */
.slot, .turbo {
  position: absolute;
  width: var(--s, 68px);
  height: var(--s, 68px);
  padding: 0;
  border: 0;
  border-radius: 50%;
  pointer-events: auto;
  touch-action: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  font: inherit;
}
.slot {
  display: grid;
  place-items: center;
  background: rgba(255, 248, 236, 0.75);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.9), inset 0 0 0 6px rgba(91, 58, 155, 0.18), 0 4px 0 rgba(58, 31, 74, 0.25);
}
.slot:disabled { cursor: default; }
.slot.full {
  background: #fff8ec;
  box-shadow: inset 0 0 0 3px #fff, 0 0 0 4px var(--lemon), 0 5px 0 4px #d9a300, 0 0 22px 6px rgba(255, 210, 58, 0.7);
  animation: slot-beat 1s ease-in-out infinite;
}
.slot-icon { display: grid; place-items: center; width: 100%; height: 100%; line-height: 0; }
.slot:active:not(:disabled) { transform: translateY(3px); }
.turbo {
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 40% 30%, #ffb36b, #ff7a1a 70%);
  box-shadow: 0 5px 0 #c4570c, 0 10px 16px -8px rgba(196, 87, 12, 0.7);
  color: #fff;
}
.turbo > svg { position: absolute; inset: -5px; width: calc(100% + 10px); height: calc(100% + 10px); transform: rotate(-90deg); pointer-events: none; }
.turbo-track { fill: none; stroke: rgba(255, 255, 255, 0.45); stroke-width: 5; }
.turbo-fuel { fill: none; stroke: #ffd23a; stroke-width: 5; stroke-linecap: round; stroke-dasharray: var(--fuel, 100) 100; transition: stroke-dasharray 0.1s linear; }
.turbo-icon { line-height: 0; margin-top: -10px; }
.turbo-label { position: absolute; bottom: 9%; font-size: 0.72rem; font-weight: 700; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25); }
.turbo.on { transform: translateY(4px) scale(0.96); box-shadow: 0 1px 0 #c4570c, 0 0 20px 6px rgba(255, 138, 28, 0.7); }
/* together on a tall screen: the controls of the child at the other side are upside down */
.slot.rot, .turbo.rot, .wheel.rot { transform: rotate(180deg); }
.slot.rot:active:not(:disabled) { transform: rotate(180deg) translateY(3px); }
.turbo.rot.on { transform: rotate(180deg) translateY(4px) scale(0.96); }

/* The steering wheel: turn it (or drag across it); the horn sits in the middle */
.wheel {
  position: absolute;
  width: var(--s, 130px);
  height: var(--s, 130px);
  border-radius: 50%;
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
  -webkit-tap-highlight-color: transparent;
}
.wheel > svg { display: block; width: 100%; height: 100%; overflow: visible; }
.wheel.held { cursor: grabbing; }
.wheel.held .wheel-rim { opacity: 0.95; }
.wheel-hub { transform-box: fill-box; transform-origin: center; }
.wheel.honk .wheel-hub { animation: honk 0.32s ease; }

/* Confetti when you win */
.confetti { position: fixed; inset: 0; z-index: 45; overflow: hidden; pointer-events: none; }
.confetti i { position: absolute; top: -20px; width: 9px; height: 15px; border-radius: 2px; animation: fall 2.4s cubic-bezier(0.25, 0.4, 0.6, 1) forwards; }
.confetti i.round { width: 11px; height: 11px; border-radius: 50%; }

/* End card, pause, save and "are you sure?" */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 14px; background: rgba(110, 63, 196, 0.45); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.sheet { width: min(400px, 100%); max-height: calc(100dvh - 28px); overflow-y: auto; padding: 18px 18px 20px; display: flex; flex-direction: column; gap: 10px; text-align: center; animation: pop-in 0.3s ease; }
.over-icon { display: flex; justify-content: center; line-height: 0; }
.over-title { margin: 0; font-size: 1.6rem; font-weight: 700; line-height: 1.2; outline: none; }
.over-title.record { color: var(--pink-dark); animation: bump 0.6s ease 0.2s; }
.over-stars { display: flex; justify-content: center; gap: 6px; line-height: 0; }
.over-stars:empty { display: none; }
.over-stars span { width: 46px; height: 46px; animation: star-in 0.45s cubic-bezier(0.2, 1.5, 0.4, 1) backwards; }
.over-stars span:nth-child(2) { width: 58px; height: 58px; margin-top: -10px; animation-delay: 0.15s; }
.over-stars span:nth-child(3) { animation-delay: 0.3s; }
.over-stars.fx span { animation: none; } /* ArcadeFx pops them in instead */
.over-stars span:not(.on) { filter: grayscale(1); opacity: 0.3; }
.over-text { margin: 0; color: var(--muted); font-weight: 500; line-height: 1.45; }
.over-text p { margin: 0 0 8px; }
.over-text p:last-child { margin: 8px 0 0; }
.over-text b { color: var(--ink); }
.over-text .over-news { margin: 0 0 8px; padding: 6px 10px; border-radius: 14px; background: #ebfadf; color: #2c7a14; font-weight: 700; }
.over-text table { width: 100%; border-collapse: collapse; color: var(--ink); }
.over-text td { padding: 4px 6px; text-align: left; }
.over-text td:last-child { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.over-text tr + tr td { border-top: 2px dashed var(--cream-2); }
.over-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 6px; }
.over-actions .btn { flex: 1 1 120px; padding-left: 12px; padding-right: 12px; font-size: 1.1rem; white-space: nowrap; }
.over-actions .btn:first-child { flex-basis: 100%; }
.pause-actions { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.btn:disabled { filter: grayscale(0.8); opacity: 0.6; cursor: default; }
.save-preview { align-self: center; width: 220px; height: 176px; max-width: 100%; }
.save-name {
  width: 100%;
  min-height: 52px;
  padding: 8px 16px;
  border: 0;
  border-radius: 16px;
  background: #fff;
  box-shadow: inset 0 0 0 3px var(--cream-2), 0 3px 0 var(--cream-dark);
  font: inherit;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
}
.save-name:focus { outline: none; box-shadow: inset 0 0 0 3px var(--purple), 0 3px 0 var(--cream-dark); }
.save-note { margin: 0; padding: 6px 10px; border-radius: 14px; background: #fff3c4; color: #7a5200; font-weight: 600; font-size: 0.95rem; line-height: 1.35; }
.save-note.bad { background: #ffe0e3; color: #a3202c; }

/* Track choice: the built-in tracks as cards, then your own tracks as rows */
.tracks, .editor {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: var(--theme-sky, #bfe2ff) var(--theme-bg, url("../../assets/candy-bg.svg")) center bottom / cover no-repeat;
}
.tracks-head { display: flex; align-items: center; gap: 12px; width: min(760px, 100%); margin: 0 auto; padding: 12px 14px 8px; }
.tracks-title { flex: 1; min-width: 0; margin: 0; padding: 8px 16px; border-radius: 999px; font-size: 1.35rem; text-align: center; white-space: nowrap; }
.tracks-total { margin: 0; padding: 6px 14px; border-radius: 999px; font-size: 1.1rem; font-weight: 700; white-space: nowrap; }
.tracks-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 4px 14px max(24px, env(safe-area-inset-bottom)); }
.tracks-inner { width: min(760px, 100%); margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.tracks-mode { margin: 0; align-self: center; padding: 4px 14px; border-radius: 999px; background: rgba(255, 255, 255, 0.75); font-weight: 700; color: var(--ink); }
.track-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.track-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 8px 8px;
  border: 0;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.track-card:hover { transform: translateY(-3px); }
.track-card:active { transform: scale(0.97); }
.track-preview { display: block; border-radius: 12px; }
.track-info { width: 100%; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; align-items: center; column-gap: 8px; text-align: left; }
.track-num { grid-row: span 2; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--purple); color: #fff; font-weight: 700; font-size: 1.1rem; box-shadow: 0 3px 0 var(--purple-dark); }
.track-name { font-weight: 700; font-size: 1.05rem; line-height: 1.1; }
.track-stars { display: flex; gap: 1px; line-height: 0; }
.track-stars span:not(.on) { filter: grayscale(1); opacity: 0.35; }
.track-card.locked { cursor: default; }
.track-card.locked:hover { transform: none; }
.track-card.locked .track-preview { filter: grayscale(0.85) brightness(1.1); opacity: 0.55; }
.track-lock { position: absolute; left: 50%; top: 38%; translate: -50% -50%; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 12px; border-radius: 16px; background: rgba(255, 255, 255, 0.92); color: #77728a; font-weight: 700; box-shadow: 0 3px 0 var(--cream-dark); white-space: nowrap; }
.track-lock .lock { width: 26px; height: 26px; }
.track-lock small { font-size: 0.78rem; }
.track-card.nope { animation: shake 0.4s ease; }
/* the track you picked gives a little hop before the race starts */
.track-card.chosen { animation: card-pick 0.32s cubic-bezier(0.3, 1.6, 0.5, 1); box-shadow: 0 0 0 4px var(--pink), var(--panel-shadow); }
.tracks.leaving { pointer-events: none; animation: tracks-out 0.34s ease-in forwards; }
@keyframes tracks-out { 0%, 55% { opacity: 1; } 100% { opacity: 0; } }
@keyframes card-pick { 0% { transform: scale(1); } 40% { transform: translateY(-8px) scale(1.06); } 100% { transform: translateY(0) scale(1); } }
.tracks-sub { display: flex; align-items: center; gap: 10px; margin: 10px 0 0; padding: 8px 16px 8px 10px; font-size: 1.3rem; }
.tracks-sub small { margin-left: auto; font-size: 1rem; color: var(--muted); }
.tracks-sub [data-icon] { line-height: 0; }
.mine-note { margin: 0; align-self: center; padding: 6px 14px; border-radius: 999px; background: #ebfadf; color: #2c7a14; font-weight: 700; }
.mine-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.mine-empty { margin: 0; padding: 14px 18px; color: var(--muted); font-weight: 600; text-align: center; grid-column: 1 / -1; }
.mine-row { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "pic info" "pic buttons"; align-items: center; gap: 6px 12px; padding: 8px 10px; text-align: left; }
.mine-play { grid-area: pic; }
.mine-info { grid-area: info; }
.mine-buttons { grid-area: buttons; }
.mine-open { color: #a35b00; font-weight: 700; }
.mini-btn:disabled { opacity: 0.45; cursor: default; }
@media (max-width: 420px) {
  .mine-row { grid-template-areas: "pic info" "buttons buttons"; }
  .mine-actions .mini-btn { flex: 1; }
}
.mine-play { flex: none; padding: 0; border: 0; border-radius: 12px; background: none; cursor: pointer; line-height: 0; }
.mine-info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 5px; }
.mine-name { font-size: 1.15rem; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mine-actions, .mine-confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 700; }
.mine-actions[hidden], .mine-confirm[hidden] { display: none; }
.mini-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 3px 0 var(--cream-dark);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
}
.mini-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--cream-dark); }
.mini-btn[data-act="play"] { background: var(--pink); color: #fff; box-shadow: 0 3px 0 var(--pink-dark); }
.mini-btn--del { color: #c4202d; }
.mine-confirm .mini-btn--del { background: #ef3c3c; color: #fff; box-shadow: 0 3px 0 #a3202c; }
.mine-new { align-self: center; width: min(320px, 100%); }
.mine-new-row .mine-new { align-self: auto; }

/* The Baanbouwer: grid, palette and buttons. Phones upright: everything under each other. */
.editor { gap: 8px; padding: 10px 10px max(10px, env(safe-area-inset-bottom)); overflow-y: auto; }
.ed-head { display: flex; align-items: center; gap: 10px; width: min(1100px, 100%); margin: 0 auto; }
.ed-status { flex: 1; min-width: 0; min-height: 50px; margin: 0; padding: 6px 14px 6px 8px; border-radius: 999px; display: flex; align-items: center; gap: 8px; font-weight: 700; line-height: 1.2; font-size: 1rem; color: var(--ink); transition: box-shadow 0.2s ease; }
.ed-status-icon { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: #fff; line-height: 0; }
.ed-status.ok { color: #2c7a14; box-shadow: inset 0 2px 0 #fff, 0 0 0 4px #5ad43a, var(--panel-shadow); }
.ed-status.ok .ed-status-icon { background: #ebfadf; }
.ed-status.bad .ed-status-icon { background: #fff0dd; }
.ed-status.pop { animation: bump 0.5s ease; }
.ed-status.shake { animation: shake 0.4s ease; }
.ed-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; width: min(1100px, 100%); margin: 0 auto; }
.ed-grid { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; }
#ed-canvas { display: block; border-radius: 14px; touch-action: none; box-shadow: 0 0 0 4px #fff, 0 6px 0 4px var(--cream-dark), 0 18px 26px -14px rgba(60, 30, 110, 0.55); outline: none; }
#ed-canvas:focus-visible { box-shadow: 0 0 0 4px #fff, 0 0 0 8px #2d8dff; }
.ed-wrap { position: relative; line-height: 0; }
.ed-tip { position: absolute; left: 50%; bottom: 10px; translate: -50% 0; width: max-content; max-width: calc(100% - 16px); margin: 0; padding: 6px 14px; border-radius: 16px; background: rgba(255, 255, 255, 0.94); box-shadow: 0 3px 0 var(--cream-dark); font-weight: 700; font-size: 0.92rem; line-height: 1.25; color: var(--ink); text-align: center; pointer-events: none; animation: tip-in 0.3s ease; }
.ed-side { display: flex; flex-direction: column; gap: 8px; }
.ed-tools { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.tool, .ed-act {
  min-width: 44px;
  min-height: 48px;
  padding: 3px 2px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: 0;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 3px 0 var(--cream-dark);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.05;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.08s ease;
}
.tool svg, .ed-act svg { flex: none; width: 28px; height: 28px; }
.tool:active, .ed-act:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--cream-dark); }
.tool.on { background: var(--purple); color: #fff; box-shadow: 0 3px 0 var(--purple-dark), 0 0 0 3px #fff inset; }
.tool--action { background: #fff3c4; }
.tool:disabled { opacity: 0.45; cursor: default; }
.ed-actions { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.ed-act { min-height: 54px; background: var(--cream); font-size: 0.82rem; box-shadow: inset 0 2px 0 #fff, 0 4px 0 var(--cream-dark); }
.ed-act--go { background: linear-gradient(180deg, #ff7cbd, var(--pink)); color: #fff; box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.45), 0 4px 0 var(--pink-dark); }
.ed-act--save { background: linear-gradient(180deg, #7fe05f, var(--green)); color: #fff; box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.45), 0 4px 0 var(--green-dark); }
.ed-act--go span, .ed-act--save span { text-shadow: 0 1px 0 rgba(0, 0, 0, 0.2); }

/* Start screen */
.start {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  overflow-y: auto;
  padding: 24px 16px;
  background: var(--theme-sky, #bfe2ff) var(--theme-bg, url("../../assets/candy-bg.svg")) center bottom / cover no-repeat;
}
.start-card { width: min(380px, 100%); margin: auto; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.start-card h1 { margin: 0; font-size: clamp(2.6rem, 13vw, 3.8rem); line-height: 0.95; }
.start-card h1 .line { display: block; white-space: nowrap; }
.start-cars { position: relative; width: 260px; height: 92px; animation: cars-in 0.6s cubic-bezier(0.2, 1.3, 0.4, 1) backwards; }
/* each car bounces on its springs and puffs a little cloud of exhaust out of the back, one after the other */
.sc-car { position: absolute; width: 32.3%; aspect-ratio: 1; animation: sc-bounce 2.4s ease-in-out infinite; animation-delay: calc(var(--k) * -0.8s); }
.sc-car canvas { position: relative; display: block; width: 100%; height: 100%; }
.sc-puff { position: absolute; inset: 0; transform: rotate(var(--a, 0rad)); }
.sc-puff::before, .sc-puff::after { content: ""; position: absolute; left: 44%; top: 80%; width: 13%; aspect-ratio: 1; border-radius: 50%; background: rgba(240, 240, 248, 0.95); box-shadow: inset -2px -2px 0 rgba(58, 31, 74, 0.1); opacity: 0; animation: sc-puff 2.4s ease-out infinite; animation-delay: inherit; }
.sc-puff::after { left: 36%; width: 10%; animation-name: sc-puff2; }
.sc-puff { animation-delay: inherit; }
@keyframes sc-bounce { 0%, 40%, 100% { transform: translateY(0); } 10% { transform: translateY(-7%); } 20% { transform: translateY(0); } 28% { transform: translateY(-3%); } }
@keyframes sc-puff { 0%, 4% { opacity: 0; transform: scale(0.3); } 10% { opacity: 0.95; transform: translateY(10%) scale(0.8); } 40%, 100% { opacity: 0; transform: translateY(150%) scale(1.8); } }
@keyframes sc-puff2 { 0%, 12% { opacity: 0; transform: scale(0.3); } 18% { opacity: 0.85; transform: translateY(10%) scale(0.8); } 48%, 100% { opacity: 0; transform: translate(-40%, 170%) scale(1.6); } }
.start-best { margin: 0; padding: 6px 18px; border-radius: 999px; font-size: 1.15rem; font-weight: 700; }
.start-form { width: 100%; padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.start-form .label { margin: 0; }
.targets { display: flex; justify-content: center; gap: 8px; }
.targets button {
  flex: 1;
  min-height: 52px;
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 16px;
  font: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.15;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 4px 0 var(--cream-dark);
  cursor: pointer;
}
.targets button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--cream-dark); }
.targets button small { font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.targets button.on { color: #fff; background: var(--purple); box-shadow: 0 4px 0 var(--purple-dark); }
.targets button.on small { color: rgba(255, 255, 255, 0.85); }
/* the two ways of looking, each with a little picture */
.targets--views button { min-height: 0; padding: 8px 6px 7px; gap: 3px; }
.view-pic { display: block; flex: none; width: 72px; height: 50px; border-radius: 10px; box-shadow: 0 0 0 2px #fff, 0 2px 0 3px rgba(58, 31, 74, 0.12); }
.targets--views button.on .view-pic { box-shadow: 0 0 0 3px #fff; }
.targets--views button > span { line-height: 1.1; }
.view-toggle { display: flex; align-items: center; justify-content: center; gap: 12px; padding-top: 9px; padding-bottom: 9px; }
.view-toggle .view-pic { width: 50px; height: 34px; border-radius: 8px; }
.targets button[hidden] { display: none; }
/* three ways to race side by side: a little smaller */
.targets--modes { gap: 6px; }
.targets--modes button { padding: 4px 3px; font-size: 1.02rem; }
.targets--modes button small { font-size: 0.72rem; }
/* Instellingen */
.settings-sheet { gap: 8px; text-align: left; }
.race-settings { display: flex; flex-direction: column; gap: 8px; }
.race-settings .label { margin: 4px 0 0; }
.settings-sheet .over-title { text-align: center; margin-bottom: 4px; }
.settings-sheet .label { margin: 4px 0 0; }
.settings-sheet .over-actions { margin-top: 10px; }
/* a track as a code to share */
.share-code { margin: 0; padding: 12px 14px; border-radius: 16px; background: #fff; box-shadow: inset 0 0 0 3px var(--cream-2); font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 1.15rem; font-weight: 700; line-height: 1.5; letter-spacing: 0.04em; word-spacing: 0.3em; color: var(--ink); overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; }
.code-input { min-height: 84px; resize: none; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 1.05rem; line-height: 1.4; text-align: left; }
.mine-new-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.mine-new-row .mine-new { flex: 1 1 200px; width: auto; max-width: 320px; }
.help-toggle { display: flex; align-items: center; justify-content: center; gap: 12px; padding-top: 9px; padding-bottom: 9px; }
.help-toggle b { white-space: nowrap; }
.help-pic { display: block; flex: none; width: 48px; height: 32px; border-radius: 8px; box-shadow: 0 0 0 2px #fff, 0 2px 0 3px rgba(58, 31, 74, 0.12); }
.start-actions { width: min(320px, 100%); display: flex; flex-direction: column; align-items: stretch; gap: 14px; }
.start-actions #play { width: 100%; font-size: 1.5rem; }
/* the small tiles under Racen!: Baanbouwer, Mijn banen, Instellingen */
.start-tiles { display: flex; justify-content: center; gap: 10px; }
.start-tile {
  flex: 1 1 0;
  min-width: 64px;
  max-width: 104px;
  min-height: 72px;
  padding: 6px 4px 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 4px 0 var(--cream-dark);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--ink);
  cursor: pointer;
}
.start-tile:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--cream-dark); }
.start-tile-icon { line-height: 0; }
.start-tile-icon svg { width: 34px; height: 34px; }
.help { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--muted); font-size: 0.96rem; line-height: 1.5; text-align: left; }
.help summary { list-style: none; cursor: pointer; }
.help summary::-webkit-details-marker { display: none; }
.help ul { margin: 0; padding: 12px 16px 12px 32px; width: 100%; }
.help strong { color: var(--ink); }
kbd { font: inherit; font-size: 0.85em; padding: 0 7px; border-radius: 8px; background: #fff; box-shadow: 0 2px 0 var(--cream-dark); color: var(--ink); }

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

@keyframes shake { 20% { transform: translateX(-6px) rotate(-0.6deg); } 40% { transform: translateX(5px) rotate(0.6deg); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
@keyframes bump { 50% { transform: scale(1.12); } }
@keyframes pop-in { from { transform: scale(0.85); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes star-in { from { transform: scale(0) rotate(-40deg); } }
@keyframes fall { to { transform: translate(var(--x), 110vh) rotate(var(--r)); } }
@keyframes slot-beat { 50% { transform: scale(1.08); } }
@keyframes tip-in { from { transform: translateY(8px); opacity: 0; } }
@keyframes cars-in { from { transform: translateX(-60px); opacity: 0; } }
@keyframes honk { 35% { transform: scale(0.8); } 70% { transform: scale(1.1); } }

@media (max-width: 559px) {
  .app { gap: 8px; padding: 8px 8px max(8px, env(safe-area-inset-bottom)); }
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .mini-logo { display: block; flex: 1; min-width: 0; }
  .hud { order: 3; flex-basis: 100%; max-width: none; padding: 4px 8px; }
  .stat b { font-size: 1.15rem; }
  .field { border-radius: 16px; }
  .track-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .mine-list { grid-template-columns: 1fr; }
}
@media (max-width: 360px) {
  .stat small { font-size: 0.78rem; }
  .tool { font-size: 0.74rem; }
  .tracks-head { gap: 8px; padding: 10px 10px 6px; }
  .tracks-title { padding: 8px 10px; font-size: 1.1rem; }
  .tracks-total { padding: 6px 10px; font-size: 1rem; }
  .track-card { padding: 8px 4px 6px; }
  .mine-row { gap: 8px; padding: 6px 8px; }
  .mini-btn { padding: 0 9px; font-size: 0.88rem; }
  .ed-status { font-size: 0.88rem; }
}
/* the editor beside its palette when the screen is wide */
@media (orientation: landscape) {
  .ed-body { flex-direction: row; align-items: stretch; }
  .ed-side { flex: 0 0 clamp(250px, 32vw, 380px); justify-content: center; }
  .ed-tools { grid-template-columns: repeat(4, 1fr); }
  .ed-actions { grid-template-columns: repeat(6, 1fr); }
  .ed-act { grid-column: span 2; flex-direction: row; gap: 6px; }
  .ed-act--go, .ed-act--save { grid-column: span 3; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .editor { padding-top: 6px; padding-bottom: 6px; gap: 6px; }
  .ed-head .icon-btn { width: 44px; height: 44px; font-size: 1.2rem; }
  .ed-status { min-height: 44px; font-size: 0.9rem; }
  .ed-status-icon { width: 30px; height: 30px; }
  .tool { min-height: 44px; }
  .tool svg, .ed-act svg { width: 24px; height: 24px; }
  .ed-act { min-height: 48px; font-size: 0.82rem; }
  .ed-tools { gap: 4px; }
  .ed-actions { gap: 4px; }
}
/* tablets: the start screen has room to spare, so the cars are big */
@media (min-width: 700px) and (min-height: 1000px) {
  .start-cars { width: 440px; height: 156px; }
}
@media (max-height: 880px) {
  .start { padding-top: 16px; padding-bottom: 16px; }
  .start-card { gap: 10px; }
  .start-cars { width: 200px; height: 71px; }
  .start-card h1 { font-size: clamp(2.4rem, 11.5vw, 3.3rem); }
}
/* short screens: the start screen drops its picture so everything fits */
@media (max-height: 700px) {
  .start { padding: 12px 16px; }
  .view-pic { width: 58px; height: 40px; }
  .start-cars { display: none; }
  .start-card { gap: 11px; }
  .start-actions { gap: 13px; }
}
/* phones on their side: one slim top row, and the start screen in two columns */
@media (max-height: 500px) {
  .app { gap: 6px; padding-top: 6px; padding-bottom: 6px; }
  .topbar .icon-btn, .topbar .back-link { width: 44px; height: 44px; font-size: 1.2rem; }
  .hud { padding: 2px 10px; }
  .stat b, .player b { font-size: 1.05rem; }
  .stat small, .player small { font-size: 0.82rem; }
  .field { border-radius: 14px; }
}
/* wide screens (phones on their side, tablets, computers): the start screen in two columns, the
   choices on the left and Racen! with the tiles on the right, so everything is in sight at once */
@media (orientation: landscape) and (min-width: 600px) {
  .start-card {
    width: min(820px, 100%);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "cars actions" "logo actions" "best actions" "form utils";
    align-items: center;
    justify-items: center;
    gap: 12px 28px;
  }
  .start-cars { grid-area: cars; }
  .start-card h1 { grid-area: logo; }
  .start-best { grid-area: best; }
  .start-form { grid-area: form; align-self: start; }
  .start-actions { grid-area: actions; align-self: end; }
  .help { grid-area: utils; align-self: start; }
  /* the arcade's chip row goes in the right column, under Racen! */
  #start .start-utils { grid-area: utils; align-self: start; }
}
@media (orientation: landscape) and (min-width: 600px) and (max-height: 500px) {
  .start { padding: 10px 16px; }
  .start-card { gap: 8px 24px; grid-template-areas: "logo actions" "best actions" "form utils"; }
  .start-card h1 { font-size: 2.5rem; }
  .start-best { padding: 4px 14px; font-size: 1rem; }
  .start-form { padding: 8px 12px 10px; gap: 5px; }
  .targets button { min-height: 46px; }
  .start-actions { gap: 10px; }
  .start-tile { min-height: 64px; }
}
/* phones on their side: the top bar becomes two side columns (back and the HUD on the left; sound,
   camera and pause on the right), so the race gets the full height */
@media (orientation: landscape) and (max-height: 500px) {
  .app {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 6px 10px;
    max-width: none;
    padding: 6px max(10px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }
  .topbar { display: contents; }
  .topbar .back-link { grid-column: 1; grid-row: 1; justify-self: start; }
  .hud { grid-column: 1; grid-row: 2; align-self: start; width: 100px; max-width: none; padding: 4px 8px; }
  .solo { grid-template-columns: 1fr; }
  .stat { padding: 4px 0; }
  .stat + .stat { border-left: 0; border-top: 2px dashed var(--cream-2); }
  .stat b { font-size: 1.2rem; }
  .stat small, .player small { font-size: 0.82rem; }
  .duo { grid-template-columns: 1fr; gap: 0; }
  .player { grid-template-columns: auto 1fr; grid-template-rows: auto auto auto; padding: 4px 0; }
  .player + .player { border-left: 0; border-top: 2px dashed var(--cream-2); padding-left: 0; }
  .player .dot { grid-row: 1; }
  .player .name { font-size: 0.85rem; }
  .player b { grid-row: auto; grid-column: 1 / -1; font-size: 1.2rem; }
  .player small { grid-column: 1 / -1; }
  .top-actions { grid-column: 3; grid-row: 1 / 3; flex-direction: column; align-self: start; }
  .board { grid-column: 2; grid-row: 1 / 3; }
  .tool span, .tool { font-size: 0.82rem; }
  .ed-act { font-size: 0.82rem; }
}
/* end cards on a phone on its side: picture and stars on the left, the table and buttons on the right */
@media (orientation: landscape) and (max-height: 500px) and (min-width: 560px) {
  #over .sheet {
    width: min(720px, 100%);
    display: grid;
    grid-template-columns: minmax(150px, 0.7fr) minmax(0, 1.3fr);
    grid-template-areas: "icon text" "title text" "stars text" ". actions";
    align-items: center;
    column-gap: 18px;
    row-gap: 6px;
    padding: 14px 16px;
  }
  #over .over-icon { grid-area: icon; }
  #over .over-title { grid-area: title; font-size: 1.3rem; }
  #over .over-stars { grid-area: stars; }
  #over .over-text { grid-area: text; align-self: start; font-size: 0.95rem; line-height: 1.3; }
  #over .over-text td { padding: 2px 6px; }
  #over .over-actions { grid-area: actions; margin: 0; gap: 8px; }
  #over .over-actions .btn, #save .over-actions .btn { padding-top: 8px; padding-bottom: 8px; font-size: 1rem; }
  #over .over-icon svg { width: 56px; height: 56px; }
  #save .sheet { width: min(640px, 100%); display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "title title" "pic label" "pic name" "pic note" "pic actions"; column-gap: 18px; row-gap: 6px; align-items: center; padding: 14px 16px; }
  #save .over-title { grid-area: title; font-size: 1.3rem; }
  #save .save-preview { grid-area: pic; width: 180px; height: 144px; }
  #save .label { grid-area: label; margin: 0; }
  #save .save-name { grid-area: name; }
  #save .save-note { grid-area: note; }
  #save .over-actions { grid-area: actions; margin: 0; }
  #save .save-note[hidden] { display: none; }
  .pause-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  #pause .sheet { width: min(560px, 100%); }
  #pause .pause-actions .btn { padding-top: 9px; padding-bottom: 9px; font-size: 1rem; }
  #pause #resume { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  .sheet, .over-title.record, .over-stars span, .start-cars, .sc-car, .sc-puff::before, .sc-puff::after, .track-card.chosen, .tracks.leaving, .slot.full, .ed-tip, .race-note, .ed-status.pop, .wheel.honk .wheel-hub { animation: none !important; }
  .track-card.nope, .ed-status.shake { animation: none; }
}

/* ---------- Desktop: a big screen ----------
   The race fills the window under one slim bar (back, the big place / lap / time board, the round buttons); the
   minimap top right, a big wheel bottom centre with (with a mouse, html.mouse) its keys beside it, the power-up slot
   and the turbo bottom right (game.js places them). The track list is four big cards in a row with Mijn banen beside
   it; the Baanbouwer has its palette left, the grid in the middle and the big buttons right. A big tablet on its
   side gets the same layout without the key caps. Phones and smaller tablets never match this query. */
.keycap, .wheel-key, .ed-act--desk { display: none; }
@media (min-width: 1100px) and (min-height: 650px) {
  .app { max-width: none; padding: calc(10px * var(--ui)) calc(14px * var(--ui)); gap: calc(10px * var(--ui)); font-size: calc(16px * var(--ui)); }
  .topbar { gap: calc(14px * var(--ui)); }
  .hud { flex: none; max-width: none; margin-right: auto; padding: calc(6px * var(--ui)) calc(18px * var(--ui)); border-radius: calc(24px * var(--ui)); }
  .solo { grid-template-columns: repeat(3, minmax(calc(104px * var(--ui)), auto)); }
  .stat { padding: 0 calc(14px * var(--ui)); }
  .stat b { font-size: max(28px, calc(1.8rem * var(--ui))); }
  .stat small { font-size: max(18px, calc(1rem * var(--ui))); }
  .duo { gap: calc(10px * var(--ui)); }
  .player { column-gap: calc(10px * var(--ui)); padding: 0 calc(8px * var(--ui)); }
  .player + .player { padding-left: calc(16px * var(--ui)); }
  .player .name { font-size: max(18px, calc(1rem * var(--ui))); }
  .player b { font-size: max(28px, calc(1.8rem * var(--ui))); }
  .player small { font-size: max(18px, calc(0.95rem * var(--ui))); }
  .dot { width: calc(16px * var(--ui)); height: calc(16px * var(--ui)); }
  .field { border-radius: calc(26px * var(--ui)); }
  .race-note { top: calc(20px * var(--ui)); font-size: max(18px, calc(1.05rem * var(--ui))); padding: calc(10px * var(--ui)) calc(20px * var(--ui)); }

  /* the slot and the turbo button: --s from game.js; their key on a little cap underneath */
  .turbo-icon svg { width: calc(var(--s) * 0.44); height: calc(var(--s) * 0.44); }
  .turbo-label { font-size: calc(var(--s) * 0.15); }
  .turbo > svg { inset: -7px; width: calc(100% + 14px); height: calc(100% + 14px); }
  .keycap { display: block; position: absolute; left: 50%; bottom: -12px; translate: -50% 0; line-height: 0; pointer-events: none; }
  .rot .keycap { display: none; }
  .wheel-key { display: block; position: absolute; translate: 0 -50%; line-height: 0; pointer-events: none; }
  :is(.keycap, .wheel-key) kbd { display: inline-grid; place-items: center; min-width: calc(34px * var(--ui)); height: calc(34px * var(--ui)); padding: 0 calc(8px * var(--ui)); border-radius: calc(10px * var(--ui)); background: rgba(255, 255, 255, 0.95); box-shadow: inset 0 -3px 0 var(--cream-dark), 0 0 0 2px var(--cream-dark), 0 6px 10px -6px rgba(40, 20, 60, 0.5); font: inherit; font-size: max(18px, calc(1rem * var(--ui))); font-weight: 700; line-height: 1; color: var(--ink); }
  .wheel-key kbd { min-width: calc(46px * var(--ui)); height: calc(46px * var(--ui)); font-size: calc(1.3rem * var(--ui)); }
  :is(.keycap, .wheel-key) kbd .art { width: 1em; height: 1em; vertical-align: 0; }
  /* a touch screen has no keys to show */
  html:not(.mouse) :is(.keycap, .wheel-key) { display: none; }

  /* the cards over the race: wider and bigger */
  .sheet { width: min(calc(480px * var(--ui)), 100%); padding: calc(24px * var(--ui)) calc(26px * var(--ui)) calc(26px * var(--ui)); gap: calc(12px * var(--ui)); border-radius: calc(30px * var(--ui)); font-size: calc(16px * var(--ui)); }
  .over-title { font-size: calc(2rem * var(--ui)); }
  .over-text { font-size: max(18px, calc(1.05rem * var(--ui))); }
  .over-actions { gap: calc(14px * var(--ui)); }
  .over-actions .btn, .pause-actions .btn { min-height: max(60px, calc(58px * var(--ui))); font-size: calc(1.25rem * var(--ui)); }
  .over-stars span { width: calc(60px * var(--ui)); height: calc(60px * var(--ui)); }
  .over-stars span:nth-child(2) { width: calc(76px * var(--ui)); height: calc(76px * var(--ui)); margin-top: calc(-12px * var(--ui)); }
  .over-icon svg { width: calc(84px * var(--ui)); height: calc(84px * var(--ui)); }
  /* the end card in two columns: the picture, the title and the stars left; the results and the buttons right */
  #over .sheet {
    width: min(calc(820px * var(--ui)), 100%);
    display: grid;
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
    grid-template-rows: auto auto auto;
    grid-template-areas: "icon text" "title text" "stars actions";
    align-items: center;
    gap: calc(10px * var(--ui)) calc(28px * var(--ui));
  }
  #over .over-icon { grid-area: icon; }
  #over .over-title { grid-area: title; }
  #over .over-stars { grid-area: stars; }
  #over .over-text { grid-area: text; align-self: end; }
  #over .over-icon { align-self: end; }
  #over .over-stars { align-self: start; }
  #over .over-actions { align-self: start; }
  #over .over-text td { padding: calc(6px * var(--ui)) 8px; }
  #over .over-actions { grid-area: actions; margin: 0; }
  #pause .sheet { width: min(calc(600px * var(--ui)), 100%); }
  .pause-actions { display: grid; grid-template-columns: 1fr 1fr; gap: calc(12px * var(--ui)); }
  #pause #resume { grid-column: 1 / -1; }
  .view-toggle .view-pic, .help-toggle .help-pic { width: calc(56px * var(--ui)); height: calc(38px * var(--ui)); }
  #save .sheet { width: min(calc(700px * var(--ui)), 100%); display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "title title" "pic label" "pic name" "pic note" "pic actions"; column-gap: calc(24px * var(--ui)); align-items: center; }
  #save .over-title { grid-area: title; }
  #save .save-preview { grid-area: pic; width: calc(260px * var(--ui)); height: calc(208px * var(--ui)); }
  #save .label { grid-area: label; margin: 0; font-size: max(18px, calc(1rem * var(--ui))); }
  #save .save-name { grid-area: name; }
  #save .save-note { grid-area: note; }
  #save .save-note[hidden] { display: none; }
  #save .over-actions { grid-area: actions; margin: 0; }
  #share .sheet, #code .sheet { width: min(calc(620px * var(--ui)), 100%); }
  .save-name { min-height: max(60px, calc(58px * var(--ui))); font-size: calc(1.35rem * var(--ui)); }
  .share-code { font-size: calc(1.4rem * var(--ui)); }
  .code-input { min-height: calc(96px * var(--ui)); font-size: calc(1.15rem * var(--ui)); }
  .save-note { font-size: max(18px, calc(1rem * var(--ui))); }

  /* the settings (in the arcade's sheet, which is zoomed as a whole): three columns side by side */
  .arcade-sheet-card:has(.race-settings) { width: min(980px, calc((100vw - 48px) / var(--ui))); }
  .race-settings { display: grid; grid-template-rows: auto auto; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 10px 18px; }
  .race-settings .label { margin: 0; font-size: 1.1rem; }
  .race-settings .targets { flex-direction: column; align-items: stretch; align-self: start; gap: 10px; }
  .race-settings .targets button { min-height: 64px; font-size: 1.15rem; }
  .race-settings .targets button small { font-size: 1.05rem; }
  .race-settings .targets--views button { padding: 10px 8px; }

  /* the track list: four big cards in a row, Mijn banen beside them */
  .tracks-head { width: min(calc(1600px * var(--ui)), 100%); padding: calc(16px * var(--ui)) 24px calc(10px * var(--ui)); gap: calc(14px * var(--ui)); }
  .tracks-head .icon-btn { width: calc(60px * var(--ui)); height: calc(60px * var(--ui)); font-size: calc(1.6rem * var(--ui)); }
  .tracks-title { font-size: calc(1.6rem * var(--ui)); padding: calc(10px * var(--ui)) 18px; }
  .tracks-total { font-size: max(22px, calc(1.35rem * var(--ui))); padding: calc(8px * var(--ui)) 18px; }
  .tracks-scroll { padding: 4px 24px 28px; }
  .tracks-inner {
    width: min(calc(1600px * var(--ui)), 100%);
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(280px, 21vw, calc(440px * var(--ui)));
    grid-template-rows: auto auto auto auto minmax(0, 1fr);
    grid-template-areas: "mode sub" "grid note" "grid list" "grid new" "grid .";
    align-items: start;
    gap: calc(12px * var(--ui)) calc(28px * var(--ui));
  }
  .tracks-mode { grid-area: mode; font-size: max(18px, calc(1.05rem * var(--ui))); padding: calc(6px * var(--ui)) 18px; }
  .track-grid { grid-area: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: calc(14px * var(--ui)); }
  .track-card { padding: 8px 8px 10px; gap: calc(8px * var(--ui)); border-radius: calc(26px * var(--ui)); }
  .track-card .track-preview { width: 100% !important; height: auto !important; aspect-ratio: 5 / 4; border-radius: calc(16px * var(--ui)); }
  .track-num { width: calc(40px * var(--ui)); height: calc(40px * var(--ui)); font-size: max(20px, calc(1.2rem * var(--ui))); }
  .track-name { font-size: max(20px, calc(1.2rem * var(--ui))); }
  .track-stars svg { width: calc(22px * var(--ui)); height: calc(22px * var(--ui)); }
  .track-lock { font-size: max(18px, calc(1rem * var(--ui))); }
  .track-lock small { font-size: max(16px, calc(0.9rem * var(--ui))); }
  .tracks-sub { grid-area: sub; margin: 0; font-size: max(22px, calc(1.35rem * var(--ui))); }
  .tracks-sub small { font-size: max(18px, calc(1rem * var(--ui))); }
  .mine-note { grid-area: note; font-size: max(18px, calc(1rem * var(--ui))); }
  .mine-list { grid-area: list; grid-template-columns: minmax(0, 1fr); gap: calc(12px * var(--ui)); }
  .mine-empty { font-size: max(18px, calc(1rem * var(--ui))); }
  .mine-row { grid-template-areas: "pic info" "buttons buttons"; padding: 10px 12px; }
  .mine-play canvas { width: calc(132px * var(--ui)) !important; height: calc(106px * var(--ui)) !important; }
  .mine-name { font-size: max(20px, calc(1.2rem * var(--ui))); }
  .mine-open { font-size: max(16px, calc(0.9rem * var(--ui))); }
  .mini-btn { min-height: max(48px, calc(46px * var(--ui))); font-size: max(17px, calc(1rem * var(--ui))); }
  .mine-new-row { grid-area: new; flex-direction: column; align-items: stretch; gap: calc(12px * var(--ui)); }
  .mine-new-row .mine-new { flex: none; max-width: none; width: 100%; min-height: max(64px, calc(62px * var(--ui))); font-size: calc(1.3rem * var(--ui)); }

  /* the Baanbouwer: palette | grid | buttons, the grid as big as the height allows */
  .editor { padding: calc(10px * var(--ui)) calc(16px * var(--ui)); gap: calc(10px * var(--ui)); overflow: hidden; }
  .ed-head { width: 100%; gap: calc(14px * var(--ui)); }
  .ed-head .icon-btn { width: calc(60px * var(--ui)); height: calc(60px * var(--ui)); font-size: calc(1.6rem * var(--ui)); }
  .ed-status { min-height: calc(60px * var(--ui)); font-size: max(19px, calc(1.15rem * var(--ui))); padding: 6px 18px 6px 10px; }
  .ed-status-icon { width: calc(44px * var(--ui)); height: calc(44px * var(--ui)); }
  .ed-body {
    width: 100%;
    display: grid;
    grid-template-columns: calc(200px * var(--ui)) minmax(0, 1fr) calc(190px * var(--ui));
    grid-template-rows: minmax(0, 1fr);
    gap: calc(16px * var(--ui));
  }
  .ed-side { display: contents; }
  .ed-tools { grid-column: 1; grid-row: 1; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); align-self: center; height: min(100%, calc(8 * 104px * var(--ui))); gap: calc(8px * var(--ui)); }
  .ed-grid { grid-column: 2; grid-row: 1; }
  .ed-actions { grid-column: 3; grid-row: 1; display: flex; flex-direction: column; justify-content: center; gap: calc(10px * var(--ui)); }
  .tool { min-height: 0; padding: 6px; gap: 4px; border-radius: calc(18px * var(--ui)); font-size: max(18px, calc(1rem * var(--ui))); box-shadow: 0 4px 0 var(--cream-dark); }
  .tool svg { width: calc(40px * var(--ui)); height: calc(40px * var(--ui)); }
  .ed-act, .ed-act--desk { display: flex; flex-direction: row; justify-content: flex-start; gap: calc(10px * var(--ui)); min-height: max(60px, calc(60px * var(--ui))); padding: 6px calc(14px * var(--ui)); border-radius: calc(18px * var(--ui)); font-size: max(18px, calc(1.05rem * var(--ui))); text-align: left; }
  .ed-act svg { width: calc(34px * var(--ui)); height: calc(34px * var(--ui)); }
  .ed-act--go, .ed-act--save { order: -1; min-height: max(72px, calc(70px * var(--ui))); font-size: calc(1.3rem * var(--ui)); }
  .ed-tip { font-size: max(18px, calc(1rem * var(--ui))); padding: calc(8px * var(--ui)) calc(18px * var(--ui)); bottom: calc(14px * var(--ui)); }

  /* the start screen: the choices left; the cars, the title and the big button right */
  .start { padding: calc(24px * var(--ui)) 32px; }
  .start-card {
    width: min(calc(1000px * var(--ui)), 100%);
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "best cars" "form logo" "form actions" "utils utils";
    gap: calc(16px * var(--ui)) calc(48px * var(--ui));
  }
  .start-cars { width: clamp(260px, calc(400px * var(--ui)), 100%); height: auto; aspect-ratio: 260 / 92; align-self: end; }
  .start-card h1 { font-size: calc(4.4rem * var(--ui)); }
  .start-best { align-self: end; font-size: max(20px, calc(1.2rem * var(--ui))); padding: calc(8px * var(--ui)) calc(22px * var(--ui)); }
  .start-form { align-self: start; padding: calc(16px * var(--ui)) calc(18px * var(--ui)) calc(18px * var(--ui)); gap: calc(12px * var(--ui)); }
  .start-form .label { font-size: max(19px, calc(1.1rem * var(--ui))); }
  .targets { gap: calc(10px * var(--ui)); }
  .targets button { min-height: max(76px, calc(76px * var(--ui))); font-size: calc(1.25rem * var(--ui)); border-radius: calc(20px * var(--ui)); }
  .targets button small, .targets--modes button small { font-size: max(16px, calc(0.92rem * var(--ui))); }
  .targets--modes button { font-size: calc(1.2rem * var(--ui)); }
  .start-actions { width: min(calc(400px * var(--ui)), 100%); align-self: start; gap: calc(16px * var(--ui)); }
  .start-actions #play { min-height: calc(80px * var(--ui)); font-size: calc(1.8rem * var(--ui)); border-radius: calc(26px * var(--ui)); }
  .start-tiles { gap: calc(12px * var(--ui)); }
  .start-tile { max-width: none; min-height: calc(110px * var(--ui)); font-size: max(18px, calc(1rem * var(--ui))); border-radius: calc(22px * var(--ui)); }
  .start-tile-icon svg { width: calc(46px * var(--ui)); height: calc(46px * var(--ui)); }
}
@media (hover: hover) and (pointer: fine) {
  .tool, .ed-act, .mini-btn, .mine-play { transition: transform 0.12s ease-out, filter 0.12s ease-out; }
  .tool:hover:not(:disabled), .ed-act:hover, .mini-btn:hover:not(:disabled), .mine-play:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.05); }
  .slot:hover:not(:disabled), .turbo:hover { filter: brightness(1.06); }
}
