/* One screen, no scrolling: the map takes the room the bars and panels leave. */
.app {
  height: 100vh;
  height: 100dvh;
  max-width: 1400px;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.title { flex: 1; margin: 0; font-size: clamp(1.4rem, 6vw, 2.3rem); text-align: center; }
.top-actions { display: flex; gap: 8px; }
.icon-btn.small { width: 46px; height: 46px; font-size: 1.15rem; }

/* Player chips */
.players { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  background: rgba(255, 248, 236, 0.92);
  box-shadow: 0 4px 0 var(--cream-dark);
  font-weight: 600;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.chip.active { transform: translateY(-2px); box-shadow: 0 0 0 3px var(--c), 0 6px 0 var(--cream-dark); }
.chip.retired { opacity: 0.7; }
.chip .car { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--c); color: #fff; font-size: 0.9rem; }
.chip .who { white-space: nowrap; color: var(--c-dark, var(--ink)); } /* names are at most 12 letters: always shown in full */
.chip .cash { font-variant-numeric: tabular-nums; color: var(--ink); }

/* Layout: the map, and under it (upright) or beside it (on its side) the panels */
.layout { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.stage {
  flex: 1;
  min-height: 140px;
  position: relative;
  border-radius: 26px;
  overflow: hidden;
  box-shadow: inset 0 0 0 4px #fff, 0 6px 0 var(--cream-dark), 0 22px 34px -16px rgba(90, 50, 150, 0.5);
  background: var(--field, #e9f7d9);
}
/* touch-action only on the map itself: the page still scrolls when you swipe anywhere else */
#map { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#map:active { cursor: grabbing; }
.map-buttons { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 8px; }
.map-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 14px;
  background: rgba(255, 248, 236, 0.95);
  box-shadow: 0 4px 0 var(--cream-dark);
  font-size: 1.2rem;
  cursor: pointer;
}
.map-btn.on { background: var(--purple); box-shadow: 0 4px 0 var(--purple-dark); }
.map-btn:focus-visible, .option:focus-visible, .kind button:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; }
.toasts { position: absolute; left: 12px; right: 64px; top: 12px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; pointer-events: none; }
.toast {
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 248, 236, 0.96);
  box-shadow: 0 3px 0 var(--cream-dark);
  font-weight: 600;
  animation: toast 2.6s ease forwards;
}
.toast.plus { color: #2c8a0e; }
.toast.minus { color: #c4232a; }

.side { flex: none; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }

/* Current player card */
.me { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.me-head { display: flex; align-items: center; gap: 10px; }
.me-head .car { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--c); font-size: 1.2rem; }
.me-name { font-weight: 700; font-size: 1.25rem; color: var(--c-dark); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-cash { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.me-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.fact { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 12px; background: var(--cream-2); font-weight: 600; font-size: 0.92rem; min-width: 0; }
.fact span:last-child { min-width: 0; line-height: 1.2; overflow-wrap: anywhere; } /* wraps instead of being cut off */
.fact.wide { grid-column: 1 / -1; }

/* Spinner wheel */
.wheel-panel { padding: 12px 16px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.wheel-label { margin: 0; font-weight: 600; text-align: center; min-height: 1.4em; }
.wheel-wrap { position: relative; width: 190px; height: 190px; }
.wheel {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: 0 6px 0 var(--cream-dark), 0 14px 22px -10px rgba(90, 50, 150, 0.5);
  cursor: pointer;
  transition: transform var(--spin, 2.8s) cubic-bezier(0.12, 0.6, 0.12, 1);
}
.wheel-pointer {
  position: absolute;
  left: 50%;
  top: -10px;
  z-index: 2;
  width: 0;
  height: 0;
  margin-left: -13px;
  border-left: 13px solid transparent;
  border-right: 13px solid transparent;
  border-top: 26px solid var(--ink);
  filter: drop-shadow(0 2px 0 #fff);
}
.wheel-hub {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 30%, #fff, var(--cream));
  box-shadow: 0 3px 0 var(--cream-dark);
  font-size: 1.6rem;
  font-weight: 700;
  pointer-events: none;
}
.wheel-hub.pop { animation: pop 0.4s ease; }
.spin-row { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.spin-btn { width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fast-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; font-size: 1.05rem; }
.fast-btn .art { width: 1.3em; height: 1.3em; }
.fast-btn.on { background: linear-gradient(180deg, color-mix(in srgb, var(--purple) 75%, #fff), var(--purple)); color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.15); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4), 0 6px 0 var(--purple-dark); }

/* Log */
.log { display: none; flex-direction: column; min-height: 0; padding: 10px 14px; }
.log .label { margin: 0 0 6px; }
.log ol { flex: 1; min-height: 0; margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.log li { font-size: 0.92rem; line-height: 1.35; color: var(--muted); }
.log li b { color: var(--c); }

/* Card modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(110, 63, 196, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.card {
  width: min(430px, 100%);
  padding: 18px 18px 20px;
  text-align: center;
  animation: flip 0.45s ease;
}
.card-who { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; background: var(--c); color: #fff; font-weight: 600; font-size: 0.9rem; }
.card-icon { font-size: 3.6rem; line-height: 1.1; margin: 8px 0 2px; }
.card-title { margin: 0; font-size: 1.5rem; font-weight: 700; }
.card-text { margin: 6px 0 14px; color: var(--muted); font-weight: 500; line-height: 1.4; }
.card-options { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.option {
  flex: 1 1 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 10px;
  border: 0;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 5px 0 var(--cream-dark);
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.option:hover { transform: translateY(-2px); }
.option:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--cream-dark); }
.option .o-icon { font-size: 2rem; }
.option .o-label { font-weight: 700; font-size: 1.05rem; }
.option .o-sub { font-size: 0.85rem; color: var(--muted); font-weight: 500; line-height: 1.3; }
.option.picked { box-shadow: 0 0 0 4px var(--c), 0 5px 0 var(--cream-dark); }
.option.plain { flex-basis: 100%; padding: 10px; }
.card.ai .option { cursor: default; }
.option:disabled { opacity: 1; }
.option:disabled:hover { transform: none; }
.card:focus { outline: none; }
.card-options .btn { flex: 1 1 100%; }

/* Start screen */
.start, .final {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  overflow-y: auto;
  /* one column that may shrink: the cards never get wider than the screen */
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  padding: 24px 16px;
  background: var(--theme-sky, #bfe2ff) var(--theme-bg, url("../../assets/candy-bg.svg")) center bottom / cover no-repeat;
}
.start-card, .final-card { position: relative; z-index: 1; width: min(420px, 100%); display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.start-card h1 { margin: 0; font-size: clamp(3rem, 15vw, 4.6rem); }
/* The hero above the title: the candy cars on a bit of road (built in game.js). One drives in on the near
   lane, stops with a bounce and a puff of dust, and drives on; the parked ones bob a little. */
.start-head { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.zl-hero { width: min(290px, 76vw); aspect-ratio: 320 / 132; line-height: 0; }
.zl-hero svg { display: block; width: 100%; height: 100%; overflow: hidden; }
.zl-hero g { transform-box: fill-box; }
.zl-drive { transform-origin: 50% 100%; animation: zl-drive 4s infinite; }
.zl-drive .zl-wheel > g { transform-origin: center; animation: zl-roll 4s linear infinite; }
.zl-park { transform-origin: 50% 100%; animation: zl-bob 2.4s ease-in-out infinite; }
.zl-park2 { animation-delay: -1.2s; }
.zl-puff { opacity: 0; transform-origin: 100% 50%; animation: zl-puff 4s ease-out infinite; }
@keyframes zl-drive {
  0% { transform: translateX(-230%); animation-timing-function: cubic-bezier(0.25, 0.6, 0.35, 1); }
  30% { transform: translateX(0); animation-timing-function: ease-out; }
  35% { transform: scale(1.07, 0.9); }
  42% { transform: translateY(-9%) scale(0.97, 1.04); }
  49% { transform: translateY(0) scale(1.02, 0.98); }
  55%, 80% { transform: none; animation-timing-function: ease-in; }
  100% { transform: translateX(240%); }
}
@keyframes zl-roll { 0% { transform: rotate(0deg); } 30%, 80% { transform: rotate(900deg); } 100% { transform: rotate(1500deg); } }
@keyframes zl-bob { 50% { transform: translateY(-3%) scaleY(1.02); } }
@keyframes zl-puff { 0%, 30% { opacity: 0; transform: scale(0.4); } 34% { opacity: 0.9; transform: scale(0.8); } 52%, 100% { opacity: 0; transform: translateX(-14%) scale(1.5); } }
.start-best { margin: 0; padding: 6px 18px; border-radius: 999px; font-size: 1.15rem; font-weight: 700; }
.start-best .art { vertical-align: -0.15em; }
.start-form { width: 100%; padding: 12px 12px 10px; display: flex; flex-direction: column; gap: 8px; }
.start-form .label { margin: 0; display: flex; flex-direction: column; gap: 1px; }
.label-hint { font-size: 0.85rem; font-weight: 500; }
/* four seats in a row: the car (tap to switch Mens / Computer / Uit) above the name */
.slots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.slot { min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 4px; border-radius: 16px; background: var(--cream-2); box-shadow: inset 0 2px 4px rgba(120, 80, 40, 0.18); }
.seat-kind { width: 100%; min-height: 44px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 2px 0; border: 0; border-radius: 12px; background: none; font: inherit; color: var(--ink); cursor: pointer; }
.seat-kind:focus-visible { outline: 3px solid var(--purple); outline-offset: 1px; }
.seat-kind .car { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--c); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15), 0 3px 0 rgba(0, 0, 0, 0.12); transition: transform 0.12s ease; }
.seat-kind:active .car { transform: scale(0.92); }
.seat-kind .car .art { width: 30px; height: 30px; }
.slot.off .seat-kind .car { background: #fff; box-shadow: inset 0 0 0 3px var(--c); color: var(--c); font-size: 1.7rem; line-height: 1; }
.seat-tag { font-size: 0.85rem; font-weight: 700; color: var(--muted); }
.slot input { width: 100%; min-width: 0; min-height: 40px; padding: 0 4px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, 0.7); font: inherit; font-size: 0.92rem; font-weight: 600; text-align: center; text-overflow: ellipsis; color: var(--ink); outline: none; }
.slot input:focus { background: #fff; box-shadow: 0 0 0 3px var(--c); }
.slot input::placeholder { color: var(--muted); }
.slot.off input { visibility: hidden; }
.start-hint { margin: 0; color: var(--red); font-weight: 600; font-size: 0.92rem; }
.start-hint:empty { display: none; }
.start-actions { width: min(280px, 100%); display: flex; flex-direction: column; align-items: center; gap: 14px; }
.start-actions > button.btn { width: 100%; text-align: center; }
.start-actions a { text-decoration: none; }
/* "Verder spelen" with whose turn it is under it */
.resume-btn { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.resume-btn small { font-size: 0.9rem; font-weight: 600; opacity: 0.95; }
/* the stickers earned in this game, with the final tally */
.new-stickers { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px 10px; margin: 0; padding: 6px 12px; border-radius: 16px; background: #fff7cc; box-shadow: inset 0 0 0 3px var(--lemon), 0 4px 0 var(--cream-dark); color: var(--ink); font-weight: 700; line-height: 1.2; animation: rise 0.5s ease; }
.new-stickers[hidden] { display: none; }
.new-stickers > span { display: inline-flex; align-items: center; gap: 6px; }
.new-stickers .art { width: 34px; height: 34px; }
/* a long title breaks between words only (candyText in game.js keeps the letters of a word together) */
.candy-title .word { white-space: nowrap; }
/* Help on the start screen: every line starts with its own little picture */
.help { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--muted); font-size: 0.98rem; line-height: 1.45; text-align: left; }
.help summary { list-style: none; min-height: 44px; display: inline-flex; align-items: center; gap: 6px; padding: 8px 18px; border-radius: 999px; cursor: pointer; color: var(--ink); font-weight: 600; }
.help summary::-webkit-details-marker { display: none; }
.help ul { margin: 0; padding: 12px 16px; width: 100%; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.help li { display: flex; align-items: flex-start; gap: 10px; }
.help li > i[data-icon] { flex: none; line-height: 0; }
.help strong { color: var(--ink); }

/* Final tally */
/* the tally grows line by line, so it starts at the top instead of jumping around the middle */
.final { align-items: start; }
.final-card { width: min(560px, 100%); padding-top: 4vh; }
.final-card h2 { margin: 0; font-size: clamp(2rem, 9vw, 3.6rem); line-height: 1.1; }
.final-skip { padding: 10px 26px; font-size: 1.05rem; }
.final-list { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.result {
  padding: 12px 14px;
  border-radius: 22px;
  background: linear-gradient(180deg, #fff8ec, var(--cream));
  box-shadow: inset 0 0 0 3px #fff, 0 5px 0 var(--cream-dark);
  text-align: left;
  opacity: 0;
  animation: rise 0.5s ease forwards;
}
.result.winner { box-shadow: inset 0 0 0 3px #ffd21e, 0 5px 0 #d4a017, 0 0 26px rgba(255, 210, 30, 0.6); }
.result-head { display: flex; align-items: center; gap: 10px; }
.result-head .place { display: inline-block; font-size: 1.6rem; }
.result-head .who { flex: 1; font-weight: 700; font-size: 1.2rem; color: var(--c-dark); }
.result-head .total { font-weight: 700; font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.result-lines { margin: 8px 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; font-size: 0.9rem; color: var(--muted); }
.result-lines li { display: contents; }
.result-lines span:last-child { text-align: right; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.result-lines .neg { color: #c4232a !important; }
.result-lines li.new span { animation: line-in 0.35s ease; }
.result-lines li.bonus span { font-weight: 700; color: var(--ink); }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }

@keyframes toast { 0% { opacity: 0; transform: translateY(-6px); } 10% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; } }
@keyframes pop { 0% { transform: scale(0.6); } 60% { transform: scale(1.2); } 100% { transform: scale(1); } }
@keyframes flip { 0% { transform: perspective(700px) rotateY(80deg) scale(0.9); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes line-in { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes toast-fade { 0% { opacity: 0; } 10% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }

/* Upright: under the map the current player and the wheel as a compact bar (wheel left, "Draai!" right). */
@media (orientation: portrait) {
  .wheel-panel {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: 'wheel label' 'wheel buttons';
    align-items: center;
    gap: 6px 12px;
    padding: 10px 12px;
  }
  .wheel-wrap { grid-area: wheel; width: 92px; height: 92px; }
  .wheel-pointer { top: -6px; margin-left: -9px; border-left-width: 9px; border-right-width: 9px; border-top-width: 18px; }
  .wheel-hub { width: 36px; height: 36px; margin: -18px 0 0 -18px; font-size: 1.15rem; }
  .wheel-label { grid-area: label; text-align: left; font-size: 0.98rem; line-height: 1.25; }
  .spin-row { grid-area: buttons; flex-direction: row; gap: 8px; }
  .spin-btn { flex: 1; min-width: 0; padding: 11px 14px; font-size: 1.08rem; }
  .fast-btn { flex: none; padding: 10px 14px; }
  .me { padding: 10px 12px; gap: 8px; }
  .me-head .car { width: 34px; height: 34px; }
  .me-cash { font-size: 1.3rem; }
}
@media (orientation: portrait) and (max-width: 699px) {
  .chip { gap: 6px; padding: 4px 10px 4px 4px; font-size: 0.92rem; }
}
/* short phones: the chips already show everyone's money, so the player card makes room for the map */
@media (orientation: portrait) and (max-height: 700px) {
  .me { display: none; }
  .wheel-wrap { width: 76px; height: 76px; }
}
/* tablets upright: the player card, the wheel and the log side by side under the map */
@media (orientation: portrait) and (min-width: 700px) {
  .side { grid-template-columns: minmax(0, 1fr) 250px minmax(0, 1fr); grid-template-areas: 'me wheel log'; align-items: stretch; }
  .me { grid-area: me; }
  .me-facts { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .fact { padding: 4px 8px; }
  .log { grid-area: log; display: flex; contain: size; } /* as high as its neighbours, it scrolls inside */
  .wheel-panel { grid-area: wheel; display: flex; flex-direction: column; padding: 12px 14px 14px; }
  .wheel-wrap { width: 160px; height: 160px; }
  .wheel-pointer { top: -10px; margin-left: -13px; border-left-width: 13px; border-right-width: 13px; border-top-width: 26px; }
  .wheel-hub { width: 52px; height: 52px; margin: -26px 0 0 -26px; font-size: 1.5rem; }
  .wheel-label { text-align: center; }
  .spin-row { flex-direction: column; }
  .fast-btn .fast-label { display: none; }
  .fast-btn { align-self: center; width: 60px; padding: 10px 0; }
}
@media (orientation: portrait) and (min-width: 700px) and (min-height: 1200px) {
  .wheel-wrap { width: 190px; height: 190px; }
  .side { grid-template-columns: minmax(0, 1fr) 280px minmax(0, 1fr); }
}
@media (max-width: 440px) {
  .players { gap: 6px; }
  .chip { gap: 5px; padding: 3px 9px 3px 3px; font-size: 0.86rem; }
  .chip .car { width: 26px; height: 26px; }
  .fact { font-size: 0.86rem; padding: 6px; gap: 5px; }
  .fast-btn { width: 50px; padding: 10px 0; }
  .fast-btn .fast-label { display: none; }
}

/* On its side: the map in the middle at the full height; back on the left; on the right the round buttons,
   the players, the current player, the wheel with "Draai!" and the log. */
@media (orientation: landscape) {
  .app {
    --side: 320px;
    max-width: none;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) var(--side);
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas: 'back map actions' '. map players' '. map side';
    gap: 10px 14px;
  }
  .topbar, .layout { display: contents; }
  .topbar .back-link { grid-area: back; }
  .title { display: none; }
  .top-actions { grid-area: actions; justify-content: flex-end; }
  .players { grid-area: players; flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 6px; }
  .chip { padding: 4px 12px 4px 4px; }
  .chip .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .chip.active { transform: none; }
  .stage { grid-area: map; min-height: 0; }
  .side { grid-area: side; display: flex; flex-direction: column; min-height: 0; }
  .me { padding: 10px 12px; gap: 8px; }
  .log { display: flex; flex: 1 1 0; }
  .wheel-panel { flex: none; padding: 10px 14px 14px; gap: 8px; }
  .wheel-wrap { width: 150px; height: 150px; }
}
@media (orientation: landscape) and (min-height: 900px) {
  .wheel-wrap { width: 190px; height: 190px; }
}
/* phones on their side: everyone's money in a narrow column left, only the wheel and "Draai!" on the right */
@media (orientation: landscape) and (max-height: 500px) {
  .app {
    --side: 250px;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: 'back map actions' 'players map side';
    gap: 8px 10px;
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  .topbar .icon-btn, .topbar .back-link, .icon-btn.small { width: 44px; height: 44px; font-size: 1.1rem; }
  .top-actions { gap: 6px; }
  .players { align-self: start; width: 112px; }
  .chip { flex-direction: column; gap: 2px; padding: 4px 6px 6px; border-radius: 18px; font-size: 0.86rem; }
  .chip .car { width: 26px; height: 26px; }
  .chip .who { display: none; }
  .me, .log { display: none; }
  .side { justify-content: flex-end; }
  .wheel-panel { padding: 8px 10px 10px; gap: 6px; }
  .wheel-label { font-size: 0.92rem; line-height: 1.2; }
  .wheel-wrap { width: 110px; height: 110px; }
  .wheel-pointer { top: -6px; margin-left: -9px; border-left-width: 9px; border-right-width: 9px; border-top-width: 18px; }
  .wheel-hub { width: 38px; height: 38px; margin: -19px 0 0 -19px; font-size: 1.15rem; }
  .spin-row { flex-direction: row; gap: 6px; }
  .spin-btn { flex: 1; min-width: 0; padding: 10px 8px; font-size: 1.05rem; }
  .fast-btn { flex: none; width: 50px; padding: 10px 0; }
  .fast-btn .fast-label { display: none; }
}

/* The start screen in landscape: the seats left, the big button right. */
@media (orientation: landscape) and (max-height: 820px) {
  .start-card {
    width: min(820px, 100%);
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    grid-template-areas: 'logo actions' 'best actions' 'form actions';
    gap: 10px 28px;
    align-items: center;
    justify-items: center;
  }
  .start-head { grid-area: logo; }
  .zl-hero { width: clamp(150px, 30vh, 260px); }
  .start-card h1 { font-size: clamp(2.2rem, 9vh, 4rem); }
  .start-best { grid-area: best; }
  .start-form { grid-area: form; }
  .start-actions { grid-area: actions; width: 100%; gap: 12px; }
  .start-actions #start-btn:not(.btn--cream), .start-actions #resume { padding-top: 20px; padding-bottom: 20px; font-size: 1.45rem; }
  .start-card .help, .start-card .start-utils { grid-column: 1 / -1; }
}
@media (orientation: landscape) and (max-height: 500px) {
  /* low screens: the hero beside the title, so Spelen! keeps its place */
  .start-head { flex-direction: row; gap: 12px; }
  .zl-hero { width: clamp(120px, 34vh, 160px); }
  .start { padding: 6px 16px; }
  .start-card { gap: 6px 24px; }
  .start-form { padding: 8px 10px; gap: 6px; }
  .label-hint { display: none; }
  .start-actions #start-btn:not(.btn--cream), .start-actions #resume { padding-top: 14px; padding-bottom: 14px; }
}
/* The final tally on a low landscape screen: the title and the buttons left, the scores right (they scroll
   by themselves), so "Nog een keer!" and "Menu" are always on screen. */
@media (orientation: landscape) and (max-height: 600px) {
  .final { overflow: hidden; align-items: center; padding: max(10px, env(safe-area-inset-top)) 16px max(10px, env(safe-area-inset-bottom)); }
  .final-card {
    width: min(920px, 100%);
    height: calc(100dvh - max(10px, env(safe-area-inset-top)) - max(10px, env(safe-area-inset-bottom)));
    padding-top: 0;
    display: grid;
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
    grid-template-rows: 1fr auto auto auto 1fr;
    grid-template-areas: '. list' 'title list' 'skip list' 'stickers list' 'actions list';
    align-items: center;
    gap: 10px 22px;
  }
  .final-card h2 { grid-area: title; font-size: clamp(1.6rem, 4.6vw, 2.8rem); }
  .final-skip { grid-area: skip; justify-self: center; }
  #final-stickers { grid-area: stickers; font-size: 0.92rem; }
  #final-stickers .art { width: 28px; height: 28px; }
  #final-actions { grid-area: actions; width: 100%; flex-direction: row; align-self: start; gap: 10px; }
  #final-actions .btn { flex: 1 1 0; min-width: 0; padding-left: 10px; padding-right: 10px; font-size: 1.05rem; white-space: nowrap; }
  .final-list { grid-area: list; align-self: stretch; min-height: 0; overflow-y: auto; padding: 4px 4px 10px; }
}

/* the smallest phones upright */
@media (orientation: portrait) and (max-height: 760px) {
  .zl-hero { width: min(210px, 60vw); }
}
@media (orientation: portrait) and (max-height: 640px) {
  .start { padding: 12px 12px; }
  .start-card { gap: 10px; }
  .start-card h1 { font-size: clamp(2.4rem, 13vw, 4.6rem); }
  .seat-kind .car { width: 40px; height: 40px; }
  .zl-hero { display: none; }
}
/* tablets: the start screen has room to spare, so the hero is big */
@media (min-width: 700px) and (min-height: 1000px) {
  .zl-hero { width: 520px; }
  .start-card { width: min(520px, 100%); }
}

@media (prefers-reduced-motion: reduce) {
  .zl-drive, .zl-drive .zl-wheel > g, .zl-park, .zl-puff { animation: none; }
  .card, .wheel-hub.pop, .result-lines li.new span, .new-stickers { animation: none; }
  .result { animation-name: fade; animation-duration: 0.3s; }
  .toast { animation-name: toast-fade; }
  .chip, .option { transition: none; }
}

/* drawn icons */
.chip .car .art { width: 20px; height: 20px; }
.me-head .car .art { width: 26px; height: 26px; }
.card-icon .art { vertical-align: 0; }
.fact .art { width: 1.25em; height: 1.25em; }
.map-btn .art { width: 1.3em; height: 1.3em; vertical-align: 0; }
.result-head .place .art { vertical-align: -0.2em; }
.place-num { display: inline-grid; place-items: center; width: 1.2em; height: 1.2em; border-radius: 50%; background: var(--cream-2, #f3e6d3); font-size: 0.8em; }



/* ---------- Desktop: a big screen ----------
   The map in the middle at the full height. Left: back, the round buttons and everyone's money (the scores);
   right, at the full height: the current player, a big wheel with a big "Draai!" (with a mouse, html.mouse, its
   key under it) and the log. A big tablet on its side gets the same layout. Everything grows with --ui
   (assets/style.css). Phones and smaller tablets never match this query. */
@media (min-width: 1100px) and (min-height: 650px) {
  .app {
    --left: calc(244px * var(--ui)); /* the shared pill of four 52px buttons, zoomed by --ui (assets/style.css) */
    --side: clamp(340px, 24vw, 560px);
    --wheel: clamp(260px, min(36vh, var(--side) - 64px), 440px);
    grid-template-columns: var(--left) minmax(0, 1fr) var(--side);
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas: 'back map side' 'actions map side' 'players map side';
    gap: calc(12px * var(--ui)) calc(16px * var(--ui));
    padding: calc(12px * var(--ui)) calc(16px * var(--ui));
    font-size: calc(16px * var(--ui));
  }
  #app .topbar .top-actions { grid-area: actions; justify-self: start; align-self: start; flex-wrap: nowrap; }
  .stage { border-radius: calc(26px * var(--ui)); }

  /* everyone's money: a card per player, the name above the amount */
  .players { justify-content: flex-start; gap: calc(10px * var(--ui)); }
  .chip {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: 'car who' 'car cash';
    column-gap: calc(10px * var(--ui));
    padding: calc(8px * var(--ui)) calc(12px * var(--ui)) calc(8px * var(--ui)) calc(8px * var(--ui));
    border-radius: calc(22px * var(--ui));
    line-height: 1.15;
  }
  .chip .car { grid-area: car; width: calc(42px * var(--ui)); height: calc(42px * var(--ui)); }
  .chip .car .art { width: calc(26px * var(--ui)); height: calc(26px * var(--ui)); }
  .chip .who { grid-area: who; font-size: max(18px, calc(17px * var(--ui))); overflow: visible; }
  .chip .cash { grid-area: cash; font-size: max(22px, calc(20px * var(--ui))); font-weight: 700; }
  .chip.active { transform: translateX(4px); }

  /* the current player, the wheel and the log share the right column; the log takes what is left */
  .side { gap: calc(12px * var(--ui)); }
  .me { padding: calc(12px * var(--ui)) calc(14px * var(--ui)); gap: calc(8px * var(--ui)); }
  .me-head .car { width: calc(42px * var(--ui)); height: calc(42px * var(--ui)); }
  .me-head .car .art { width: calc(27px * var(--ui)); height: calc(27px * var(--ui)); }
  .me-name { font-size: max(20px, calc(19px * var(--ui))); }
  .me-cash { font-size: max(24px, calc(23px * var(--ui))); }
  .me-facts { gap: calc(6px * var(--ui)); }
  .fact { font-size: max(18px, calc(15px * var(--ui))); padding: calc(5px * var(--ui)) calc(9px * var(--ui)); border-radius: calc(12px * var(--ui)); }
  .wheel-panel { padding: calc(12px * var(--ui)) calc(16px * var(--ui)) calc(16px * var(--ui)); gap: calc(10px * var(--ui)); }
  .wheel-label { font-size: max(19px, calc(18px * var(--ui))); line-height: 1.25; }
  .wheel-wrap { width: var(--wheel); height: var(--wheel); }
  /* a finger flings the big wheel round (game.js); the page has nothing to scroll here */
  .wheel { touch-action: none; }
  .wheel-pointer { top: calc(var(--wheel) * -0.06); margin-left: calc(var(--wheel) * -0.07); border-left-width: calc(var(--wheel) * 0.07); border-right-width: calc(var(--wheel) * 0.07); border-top-width: calc(var(--wheel) * 0.14); }
  .wheel-hub { width: calc(var(--wheel) * 0.3); height: calc(var(--wheel) * 0.3); margin: calc(var(--wheel) * -0.15) 0 0 calc(var(--wheel) * -0.15); font-size: calc(var(--wheel) * 0.13); }
  .spin-row { flex-direction: row; gap: calc(10px * var(--ui)); }
  .spin-btn { flex: 1; min-width: 0; min-height: max(64px, calc(62px * var(--ui))); font-size: calc(1.5rem * var(--ui)); border-radius: calc(22px * var(--ui)); }
  .fast-btn { flex: none; min-height: max(64px, calc(62px * var(--ui))); padding: 0 calc(16px * var(--ui)); font-size: max(18px, calc(1.05rem * var(--ui))); }
  .fast-btn .fast-label { display: none; }
  html.mouse .wheel-panel .keys-line { display: block; }
  .wheel-panel:has(.spin-btn:disabled) .keys-line { visibility: hidden; } /* only while it is your turn */
  .log { padding: calc(12px * var(--ui)) calc(16px * var(--ui)); }
  .log .label { font-size: max(18px, calc(16px * var(--ui))); }
  .log li { font-size: max(18px, calc(15px * var(--ui))); }
  .map-buttons { right: calc(14px * var(--ui)); bottom: calc(14px * var(--ui)); gap: calc(10px * var(--ui)); }
  .map-btn { width: max(52px, calc(50px * var(--ui))); height: max(52px, calc(50px * var(--ui))); border-radius: calc(16px * var(--ui)); font-size: calc(1.35rem * var(--ui)); }
  .toast { font-size: max(18px, calc(17px * var(--ui))); padding: calc(7px * var(--ui)) calc(16px * var(--ui)); }

  /* the card: wider, with the choices side by side */
  .card { width: min(calc(660px * var(--ui)), 100%); padding: calc(24px * var(--ui)) calc(26px * var(--ui)) calc(26px * var(--ui)); border-radius: calc(30px * var(--ui)); }
  .card-who { font-size: max(18px, calc(16px * var(--ui))); padding: calc(5px * var(--ui)) calc(14px * var(--ui)); }
  .card-icon { font-size: calc(4.6rem * var(--ui)); }
  .card-title { font-size: calc(2rem * var(--ui)); }
  .card-text { font-size: max(19px, calc(18px * var(--ui))); margin: calc(8px * var(--ui)) 0 calc(18px * var(--ui)); }
  .card-options { flex-wrap: nowrap; gap: calc(14px * var(--ui)); }
  .option { flex: 1 1 0; min-width: 0; min-height: max(72px, calc(70px * var(--ui))); padding: calc(14px * var(--ui)) calc(12px * var(--ui)); border-radius: calc(20px * var(--ui)); justify-content: flex-start; }
  .option .o-icon { font-size: calc(2.6rem * var(--ui)); }
  .option .o-label { font-size: max(20px, calc(19px * var(--ui))); }
  .option .o-sub { font-size: max(18px, calc(15px * var(--ui))); }
  .option.plain { flex: 0 1 calc(320px * var(--ui)); margin: 0 auto; }
  .card-options:has(.option:nth-child(4)) { flex-wrap: wrap; }
  .card-options:has(.option:nth-child(4)) .option { flex: 1 1 40%; }

  /* the start screen in two columns: the seats left; the cars, the title and the big button right */
  .start { padding: calc(24px * var(--ui)) 32px; }
  .start-card {
    width: min(calc(1040px * var(--ui)), 100%);
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
    grid-template-areas: 'best head' 'form actions';
    gap: calc(16px * var(--ui)) calc(48px * var(--ui));
    justify-items: center;
  }
  .start-head { grid-area: head; align-self: end; gap: calc(6px * var(--ui)); }
  .zl-hero { width: clamp(260px, calc(420px * var(--ui)), 100%); }
  .start-card h1 { font-size: calc(4.6rem * var(--ui)); }
  .start-best { grid-area: best; align-self: end; font-size: max(20px, calc(1.2rem * var(--ui))); padding: calc(8px * var(--ui)) calc(22px * var(--ui)); }
  .start-form { grid-area: form; align-self: start; padding: calc(16px * var(--ui)); gap: calc(10px * var(--ui)); }
  .start-form .label { font-size: max(19px, calc(1.1rem * var(--ui))); }
  .label-hint { font-size: max(18px, calc(0.95rem * var(--ui))); }
  .slots { gap: calc(10px * var(--ui)); }
  .slot { padding: calc(10px * var(--ui)) calc(6px * var(--ui)); border-radius: calc(18px * var(--ui)); gap: calc(6px * var(--ui)); }
  .seat-kind .car { width: calc(64px * var(--ui)); height: calc(64px * var(--ui)); }
  .seat-kind .car .art { width: calc(42px * var(--ui)); height: calc(42px * var(--ui)); }
  .slot.off .seat-kind .car { font-size: calc(2.3rem * var(--ui)); }
  .seat-tag { font-size: max(18px, calc(0.95rem * var(--ui))); }
  .slot input { min-height: max(52px, calc(50px * var(--ui))); font-size: max(18px, calc(1rem * var(--ui))); border-radius: calc(12px * var(--ui)); }
  .start-hint { font-size: max(18px, calc(1rem * var(--ui))); }
  .start-card .start-actions { grid-area: actions; align-self: start; width: min(calc(400px * var(--ui)), 100%); gap: calc(16px * var(--ui)); }
  .start-actions #start-btn:not(.btn--cream), .start-actions #resume { padding-top: calc(24px * var(--ui)); padding-bottom: calc(24px * var(--ui)); font-size: calc(1.8rem * var(--ui)); border-radius: calc(26px * var(--ui)); }
  .start-actions .btn { min-height: max(56px, calc(58px * var(--ui))); font-size: calc(1.25rem * var(--ui)); }
  .resume-btn small { font-size: max(18px, calc(1rem * var(--ui))); }
  .start-card .help, .start-card .start-utils { grid-column: 1 / -1; margin-top: calc(10px * var(--ui)); }

  /* the final tally: the players side by side, two in a row */
  .final { padding: calc(24px * var(--ui)) 32px; }
  .final-card { width: min(calc(1040px * var(--ui)), 100%); padding-top: 2vh; gap: calc(18px * var(--ui)); }
  .final-card h2 { font-size: calc(3.8rem * var(--ui)); }
  .final-skip { font-size: max(18px, calc(1.1rem * var(--ui))); min-height: 56px; }
  .final-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: calc(16px * var(--ui)); }
  .final-list > .result:only-child { grid-column: 1 / -1; }
  .result { padding: calc(14px * var(--ui)) calc(18px * var(--ui)); border-radius: calc(24px * var(--ui)); }
  .result-head .place { font-size: calc(1.9rem * var(--ui)); }
  .result-head .who { font-size: max(22px, calc(1.35rem * var(--ui))); }
  .result-head .total { font-size: max(24px, calc(1.6rem * var(--ui))); }
  .result-lines { font-size: max(18px, calc(1rem * var(--ui))); gap: calc(4px * var(--ui)) calc(14px * var(--ui)); }
  .new-stickers { font-size: max(18px, calc(1.05rem * var(--ui))); }
  #final-actions { width: min(calc(560px * var(--ui)), 100%); flex-direction: row; gap: calc(14px * var(--ui)); }
  #final-actions .btn { flex: 1 1 0; min-height: max(60px, calc(60px * var(--ui))); font-size: calc(1.35rem * var(--ui)); }
}
/* low desktop windows: the current player's card drops its name row (the left column shows it) */
@media (min-width: 1100px) and (min-height: 650px) and (max-height: 799px) {
  .me-head { display: none; }
}
/* the key caps only where there is a keyboard and a mouse */
.keys-line { display: none; margin: 0; color: var(--muted); font-weight: 600; font-size: max(18px, calc(0.95rem * var(--ui))); text-align: center; }
.keys-line kbd { font: inherit; padding: 1px 9px; border-radius: 8px; background: #fff; box-shadow: 0 2px 0 var(--cream-dark); color: var(--ink); }
/* hover: the round map buttons, the wheel and the card's choices answer a mouse (the start screen's buttons lift
   by themselves, assets/style.css) */
@media (hover: hover) and (pointer: fine) {
  .map-btn { transition: transform 0.12s ease, filter 0.12s ease; }
  .map-btn:hover { transform: translateY(-2px); filter: brightness(1.05); }
  .wheel.ready { cursor: grab; }
  .wheel.ready:hover { filter: brightness(1.04); }
  .wheel.grabbed { cursor: grabbing; }
  .option:not(:disabled):hover { box-shadow: 0 7px 0 var(--cream-dark), 0 12px 18px -10px rgba(90, 50, 150, 0.45); filter: brightness(1.02); }
}
