:root {
  color-scheme: dark;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  font-synthesis: none;
  color: #faf6f1;
  background: #13161e;
  --ink: #211c22;
  --highlight: #ffbf8c;
  --card-paper: #f7f2e9;
  --card-ink: #351d42;
  --card-header: #462358;
  --card-border: #e2cede;
  --tile-selected: #ffadd2;
  --tile-cleared: #dcbaff;
  --road-y: 65%;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
button { font: inherit; -webkit-tap-highlight-color: transparent; }

body[data-intro] { overflow: hidden; }
body[data-intro="loading"] .challenge,
body[data-intro="teaser"] .card-front .challenge-footer { visibility: hidden; }
body[data-intro="teaser"] .balance { display: none; }
body[data-intro="teaser"] .prompt { display: flex; flex-direction: column-reverse; }
body[data-intro="teaser"] .challenge-prompt { margin: 5px 0 0; }
body:is([data-intro="teaser"], [data-intro="entering"]) .challenge { animation: reveal-game .28s ease-out backwards; }
body[data-intro="entering"] :is(.balance, .card-front .challenge-footer) { animation: reveal-game .82s ease-out .1s backwards; }
body[data-intro="entering"] .prompt { animation: reveal-game .45s ease-out backwards; }
@keyframes reveal-game { from { opacity: 0; } to { opacity: 1; } }
.intro {
  position: fixed;
  z-index: 5;
  inset: 0;
  overflow: hidden;
  background: #292043;
  transition: opacity .95s ease-in-out;
}
.intro[data-state="leaving"] { opacity: 0; pointer-events: none; }
.intro-backdrop, .intro-light { position: absolute; inset: 0; width: 100%; height: 100%; }
.intro-backdrop { object-fit: cover; object-position: 45% 48%; transform: scale(1.05); }
.intro-actors {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: max(100vw, calc(100svh * 16 / 9));
  max-width: none;
  height: auto;
  transform: translateX(-46.5%);
  transform-origin: center bottom;
}
.intro[data-state] .intro-backdrop { animation: intro-pan 1.8s ease-out both; }
.intro[data-state] .intro-actors { animation: intro-slide 1.8s ease-out both; }
.intro-light { background: linear-gradient(0deg, #20152a88, transparent 36%), linear-gradient(90deg, #24172b4f, transparent 51%); }
@keyframes intro-pan { to { transform: translateX(-1.3%) scale(1.07); } }
@keyframes intro-slide { to { transform: translateX(-43.5%) scale(1.04); } }
.intro-loader {
  position: absolute;
  bottom: clamp(24px, 4vh, 48px);
  left: clamp(22px, 4vw, 56px);
  width: 44px;
  height: 44px;
  border: 3px solid #fff7e565;
  border-top-color: #fff7e5;
  border-right-color: #fff7e5;
  border-radius: 50%;
  animation: intro-spin .9s linear infinite;
}
@keyframes intro-spin { to { rotate: 1turn; } }
.confetti { position: fixed; z-index: 12; inset: 0; overflow: hidden; pointer-events: none; }
.confetti span {
  position: absolute;
  width: var(--size);
  height: calc(var(--size) * 1.35);
  border-radius: 2px;
  box-shadow: inset 0 1px #fff8, 0 1px 3px #24142a38;
  animation: confetti-burst linear both;
}
.confetti span:nth-child(3n) { height: var(--size); border-radius: 50%; }
@keyframes confetti-burst {
  from { opacity: 0; transform: translate(-50%, -50%) scale(.4); animation-timing-function: cubic-bezier(.2,.72,.33,1); }
  9% { opacity: 1; }
  34% { transform: translate(calc(var(--drift) * .72), var(--lift)) rotate(calc(var(--spin) * .35)); animation-timing-function: ease-in; }
  78% { opacity: 1; }
  to { opacity: 0; transform: translate(var(--drift), var(--fall)) rotate(var(--spin)); }
}

.game {
  position: relative;
  z-index: 1;
  isolation: isolate;
  display: grid;
  grid-template-rows: minmax(24px, 1fr) auto minmax(78px, var(--map-height)) minmax(var(--studio-link-height), .43fr);
  justify-items: center;
  block-size: 100dvh;
  min-block-size: min-content;
  overflow: clip;
  background: radial-gradient(ellipse at 50% 78%, #4a414c, #14161d 74%);
  --map-height: clamp(146px, 25dvh, 236px);
  --studio-link-height: max(44px, calc(40px + env(safe-area-inset-bottom)));
}
.game::after {
  content: "";
  position: absolute;
  z-index: 3;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, #13161e9c, #13161e25 41%, transparent 64%, #0d141c3b),
    linear-gradient(90deg, #11101824, transparent 32% 68%, #11101824);
}

.studio-link {
  position: relative;
  z-index: 4;
  grid-row: 4;
  align-self: end;
  display: grid;
  place-items: center;
  block-size: var(--studio-link-height);
  padding: 0 12px env(safe-area-inset-bottom);
  border-radius: 6px;
  translate: 0 calc(-1 * clamp(6px, 2.2dvh, 18px));
  animation: reveal-game .36s ease-out;
}
.studio-link img { width: clamp(96px, 10vw, 116px); height: auto; filter: drop-shadow(0 1px 4px #17121ccf); }
.studio-link:focus-visible { outline: 2px solid #fff4e7; outline-offset: -3px; }
@media (hover: hover) { .studio-link:hover img { filter: drop-shadow(0 1px 7px #17121c); } }

.challenge {
  z-index: 6;
  grid-row: 2;
  width: min(418px, calc(100% - 32px), max(244px, calc(72svh - 126px)));
  align-self: end;
  perspective: 1100px;
  container-type: inline-size;
  --control-height: 48px;
}
.challenge-card {
  position: relative;
  transform-style: preserve-3d;
  transition: transform .56s cubic-bezier(.25,.75,.3,1);
}
.challenge-card[data-side="back"] { transform: rotateY(180deg); }
.card-face {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--card-border);
  border-radius: 11px;
  overflow: hidden;
  background: var(--card-paper);
  color: var(--card-ink);
  box-shadow: 0 24px 78px #090a117c, 0 3px 13px #07070d70;
  backface-visibility: hidden;
}
.card-back {
  position: absolute;
  inset: 0;
  transform: rotateY(180deg);
}
.challenge-header {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  block-size: 82px;
  padding: 11px 15px;
  border-radius: 6px 6px 3px 3px;
  background: linear-gradient(124deg, var(--card-header), #73305d 60%, #964655);
  color: #faf6ed;
}
.prompt { min-width: 0; }
.challenge-prompt { margin: 0 0 3px; color: #fae4f0; font-size: .78rem; font-weight: 600; }
.challenge h1, .challenge h2 {
  margin: 0;
  font-size: clamp(1.16rem, 4.7vw, 1.72rem);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -.027em;
}
.challenge h1:focus, .challenge h2:focus { outline: none; }
.payout-amount {
  margin: 4px 0 0;
  color: #ffe0b7;
  font-size: clamp(.76rem, 5.4cqi, 1.38rem);
  font-weight: 750;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.payout-amount[data-finish] {
  color: #ffdf8d;
  font-size: clamp(.86rem, 6.65cqi, 1.8rem);
  font-weight: 850;
  text-shadow: 0 2px 15px #ffb35157;
}
.balance {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 58px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.balance span { color: #fae4f0; font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.balance output { color: #ffe0b7; font-size: clamp(.95rem, 3.5vw, 1.2rem); font-weight: 800; line-height: 1; }

.challenge-footer {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 3px 3px;
  --action-font-size: clamp(.69rem, min(2.8vw, 4.2cqi), .84rem);
}
.card-front .challenge-footer { flex-wrap: wrap-reverse; }
.card-tools { display: flex; flex: none; align-items: center; gap: 2px; }
.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  block-size: var(--control-height);
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--card-header);
  cursor: pointer;
}
.icon-button:focus-visible { outline: 2px solid var(--card-header); outline-offset: -2px; }
@media (hover: hover) { .icon-button:hover { background: #8b48741c; } }
.sound-icon { position: relative; width: 17px; height: 16px; }
.sound-icon::before, .sound-icon::after { content: ""; position: absolute; }
.sound-icon::before { inset: 0; background: currentColor; clip-path: polygon(0 34%, 21% 34%, 57% 8%, 57% 92%, 21% 66%, 0 66%); }
.sound-icon::after { inset: 2px 1px 2px auto; width: 6px; border-right: 2px solid currentColor; border-radius: 50%; }
.sound-toggle[aria-pressed="false"] .sound-icon::after { inset: 7px 0 auto; width: 100%; height: 2px; border: 0; border-radius: 0; background: currentColor; box-shadow: 0 -1px var(--card-paper); rotate: -45deg; }
.info-icon { display: grid; place-items: center; width: 18px; height: 18px; border: 2px solid currentColor; border-radius: 50%; font: 800 .73rem/1 Georgia, serif; }

.info-copy { flex: 1; min-height: 0; overflow: auto; padding: 2px 15px 8px; font-size: clamp(.83rem, 2.7vw, .93rem); line-height: 1.42; }
.info-copy ol { margin: 0; padding: 0; list-style: none; counter-reset: rule; }
.info-copy li { display: grid; grid-template-columns: 1rem minmax(0, 1fr); column-gap: 7px; padding-block: 8px; counter-increment: rule; }
.info-copy li + li { border-top: 1px solid #e8dce4; }
.info-copy li::before { content: counter(rule) "."; color: #91496f; font-weight: 600; }
.info-copy p { margin: 8px 0 0; color: #68536a; font-size: .79rem; line-height: 1.4; }
.info-details { margin: 5px 0 0; padding-block: 5px; border-block: 1px solid var(--card-border); }
.info-details div { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding-block: 3px; }
.info-details dd { margin: 0; font-weight: 600; text-align: right; white-space: nowrap; }
.gamepad-settings { padding: 6px 0 8px; border-bottom: 1px solid var(--card-border); }
.gamepad-settings label { display: flex; align-items: center; gap: 7px; min-height: 28px; font-weight: 650; cursor: pointer; }
.gamepad-settings input { width: 15px; height: 15px; margin: 0; accent-color: var(--card-header); color-scheme: light; }
.gamepad-settings p { margin: 0; }

.tiles {
  contain: paint;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template: repeat(4, minmax(0, 1fr)) / repeat(4, minmax(0, 1fr));
  gap: 2px;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid #f5dee9;
  border-radius: 3px;
  background: #f5dee9;
}
.tiles::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: transparent;
  transition: background .22s;
}
.tiles[data-state="police"] .tile:not([data-police]) { filter: brightness(.55); }
.tiles[data-state="cashed"]::after { background: #41274e55; }
.tiles[data-state="wrong"]::after { background: #b82048bb; }
.tile {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background-color: #4d304f;
  background-image: linear-gradient(#b15e9b0d, #b15e9b0d), var(--puzzle-art);
  background-repeat: no-repeat;
  background-size: 100% 100%, 400% 400%;
  background-position: center, calc(var(--column) * 100% / 3) calc(var(--row) * 100% / 3);
  cursor: pointer;
}
.tile:focus-visible { z-index: 1; outline: 2px solid white; outline-offset: -4px; }
body[data-gamepad-active] .tile:focus {
  z-index: 1;
  outline: 3px solid #fff1b4;
  outline-offset: -5px;
}
.gamepad-hint { display: none; }
body[data-gamepad-active] :is(.button, .tile:focus) .gamepad-hint {
  display: grid;
  place-items: center;
  flex: none;
  inline-size: 1.1rem;
  block-size: 1.1rem;
  border-radius: 50%;
  background: var(--card-ink);
  color: #fff4e7;
  font: 750 .65rem/1 system-ui, sans-serif;
}
.gamepad-hint > span { translate: 0 -.5px; }
body[data-gamepad-active] .button:has(> .gamepad-hint) {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.tile .gamepad-hint { position: absolute; top: 8px; left: 8px; z-index: 1; }
.tile::before, .tile::after { content: ""; position: absolute; pointer-events: none; }
@media (hover: hover) { .tile[aria-pressed="false"]:hover::before { inset: 0; background: #ffd4e540; } }
.tile[aria-pressed="true"]::before { inset: 0; background: #3215359c; box-shadow: inset 0 0 0 3px var(--tile-selected); }
.tile-tick {
  display: none;
  position: absolute;
  top: 7px;
  right: 7px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--tile-selected);
  box-shadow: 0 2px 5px #0d071380;
  pointer-events: none;
}
.tile[aria-pressed="true"] .tile-tick { display: grid; place-items: center; }
.tile-tick::before { content: ""; width: 5px; height: 9px; border: solid var(--ink); border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.tiles[data-state="revealing"] .tile[aria-pressed="false"],
.tiles[data-state="driving"] .tile[aria-pressed="false"],
.tiles[data-state="checkpoint"] .tile[aria-pressed="false"] { filter: brightness(.72); }
.tiles[data-state="revealing"] .tile:not([data-reveal]) .tile-tick { opacity: .29; }
.tile[data-reveal="scanning"] .tile-tick { opacity: 0; }
.tile[data-reveal="scanning"]::before { background: #ffd19547; box-shadow: inset 0 0 0 4px #ffe3af, inset 0 0 20px #ffe5b288; animation: tile-scan .46s ease-out both; }
.tile[data-reveal="clear"]::before { background: #43235e70; box-shadow: inset 0 0 0 3px var(--tile-cleared); }
.tile[data-reveal="clear"] .tile-tick { background: var(--tile-cleared); }
@keyframes tile-scan { from { background: #3215359c; } 40% { background: #ffd19561; } }
.tile[data-police] { z-index: 1; background-image: url("assets/police-grid.webp"); background-size: cover; background-position: center; }
.tile[data-police] .tile-tick { display: none; }
.tile[data-police]::before { background: #dc315527; box-shadow: inset 0 0 0 3px #ff97ac; animation: patrol-lights .62s ease-in-out 2 alternate; }
.tile[data-police]::after { content: "POLICE"; inset: auto 0 3px; padding: 3px 1px; background: #151320d9; color: white; font-size: clamp(.48rem, 2vw, .64rem); font-weight: 800; }
@keyframes patrol-lights {
  from { background: #eb254f6b; box-shadow: inset 0 0 0 3px #ff9bab, inset 0 0 19px #fa275c; }
  50% { background: transparent; }
  to { background: #4331d865; box-shadow: inset 0 0 0 3px #b8aaff, inset 0 0 19px #6047ef; }
}

.buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); flex: 1; gap: 5px; min-width: 0; }
.card-front .buttons { flex-basis: min(100%, 225px); }
.buttons:has(#cash-out:not([hidden])) { grid-template-columns: minmax(max-content, 1fr) minmax(0, 1fr); }
.buttons > :is(.bet-control, .round-bank, .secondary) { grid-area: 1 / 1; }
.buttons > .primary { grid-area: 1 / 2; }
.button {
  flex: 1;
  min-width: 0;
  block-size: var(--control-height);
  padding: 4px 9px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: var(--action-font-size);
  font-weight: 600;
  line-height: 1.15;
  cursor: pointer;
  transition: background-color .15s, color .15s;
}
#cash-out { padding-inline: 4px; white-space: nowrap; }
.bet-control {
  display: flex;
  align-items: stretch;
  block-size: var(--control-height);
  border: 1px solid #e6aac7;
  border-radius: 6px;
  overflow: hidden;
  background: #fff8f3;
  color: var(--card-ink);
}
.bet-step { flex: 0 0 clamp(18px, 20%, 30px); padding: 0; border: 0; color: #6c3058; background: #f8e4eb; font-size: 1rem; font-weight: 600; cursor: pointer; }
.bet-step:disabled { color: #8d7889; background: transparent; cursor: default; }
.bet-step:focus-visible, .bet-field:focus-within { outline: 2px solid var(--card-header); outline-offset: -2px; }
.bet-field { flex: 1; min-width: 0; display: flex; justify-content: center; align-items: center; gap: .23em; font-size: var(--action-font-size); font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; }
.bet-field input { appearance: textfield; inline-size: calc(var(--bet-digits, 2) * 1ch); min-width: 0; padding: 0; border: 0; outline: none; background: transparent; color: inherit; font: inherit; font-variant-numeric: inherit; text-align: center; }
.bet-field input::-webkit-inner-spin-button, .bet-field input::-webkit-outer-spin-button { appearance: none; margin: 0; }
.bet-field input:disabled { opacity: 1; }
.round-bank { display: grid; place-content: center; gap: 3px; min-width: 0; block-size: var(--control-height); border: 1px solid var(--card-border); border-radius: 6px; background: #f6ecf5; text-align: center; white-space: nowrap; }
.round-bank span { font-size: .63rem; line-height: 1; color: #785773; }
.round-bank strong { font-size: var(--action-font-size); font-weight: 600; line-height: 1.15; }
.button:focus-visible { outline: 2px solid var(--card-header); outline-offset: 2px; }
.primary { color: var(--card-ink); background: #ffbf91; border-color: #edab85; }
.primary:disabled { color: #685268; background: #ede1e7; border-color: var(--card-border); cursor: default; }
.secondary { color: #572449; background: #f5c9dd; border-color: #e6aac7; }
@media (hover: hover) {
  .primary:not(:disabled):hover { background: #ffcfaa; }
  .secondary:hover { background: #efb6d1; }
  .bet-step:not(:disabled):hover { background: #f5c9dd; }
}

.map {
  position: relative;
  grid-row: 3;
  width: min(1160px, calc(100% - 28px));
  align-self: stretch;
  margin-top: 3px;
  --lane-y: max(54px, 34%);
  --route-start: 6%;
  --route-end: 94%;
  --scene-width: max(110vw, 970px);
  --vehicle-width: clamp(64px, 9.5vw, 108px);
  --patrol-width: var(--vehicle-width);
  --patrol-edge: 0px;
}
.map-art {
  pointer-events: none;
  position: absolute;
  top: var(--lane-y);
  left: 50%;
  width: var(--scene-width);
  max-width: none;
  height: auto;
  transform: translate(-50%, calc(-1 * var(--road-y)));
  user-select: none;
}
.map-background { z-index: -1; mask-image: linear-gradient(180deg, transparent, #000 19% 96%, transparent); }
.map-foreground {
  z-index: 2;
  /* Keep the palm fronds in front of the wheels and soften them across the lane. */
  mask-image: linear-gradient(
    to bottom,
    #0001 calc(var(--road-y) + var(--vehicle-width) * .035),
    #0007 calc(var(--road-y) + var(--vehicle-width) * .17),
    #000 calc(var(--road-y) + var(--vehicle-width) * .3)
  );
  clip-path: polygon(
    0% 60.69%, 0.56% 60.28%, 0.83% 61.53%, 0.46% 62.78%, 2.13% 63.75%,
    2.87% 64.31%, 3.24% 65.42%, 4.63% 66.53%, 4.91% 68.19%, 5.74% 69.44%,
    14.81% 69.44%, 16.11% 67.92%, 17.5% 66.81%, 18.52% 66.53%, 18.98% 65.28%,
    19.35% 65.83%, 19.81% 65%, 20.37% 66.11%, 21.39% 66.81%, 22.69% 66.81%,
    23.61% 67.92%, 24.63% 69.58%, 28.43% 69.58%, 29.26% 67.64%, 30.74% 66.94%,
    31.67% 65.83%, 30.46% 64.58%, 29.72% 64.03%, 30.74% 63.89%, 31.85% 64.58%,
    32.41% 63.89%, 31.67% 62.36%, 32.5% 62.92%, 32.41% 61.39%, 33.24% 62.36%,
    33.7% 61.81%, 34.26% 62.64%, 35.09% 61.39%, 36.02% 61.81%, 36.3% 62.92%,
    37.5% 62.92%, 38.15% 63.89%, 37.31% 64.58%, 38.8% 64.58%, 38.89% 65.69%,
    37.78% 66.81%, 39.07% 67.5%, 40.28% 68.89%, 40.65% 69.58%, 51.57% 69.44%,
    52.5% 68.19%, 53.7% 67.36%, 54.44% 66.53%, 55.28% 66.53%, 56.02% 67.08%,
    56.11% 65.56%, 56.85% 64.86%, 57.41% 65.14%, 58.15% 64.31%, 58.89% 65.28%,
    59.35% 65.42%, 59.72% 65.69%, 59.72% 66.53%, 60.74% 67.08%, 61.76% 67.36%,
    62.59% 69.17%, 62.96% 69.72%, 73.15% 69.58%, 74.26% 68.06%, 75.28% 67.22%,
    76.2% 66.11%, 77.04% 66.25%, 77.69% 65.14%, 77.41% 64.03%, 78.24% 64.44%,
    78.7% 63.33%, 79.72% 63.61%, 80.09% 64.44%, 80.93% 64.31%, 81.85% 65.14%,
    82.04% 65.97%, 83.52% 66.11%, 84.26% 67.08%, 85.09% 68.61%, 85.37% 69.72%,
    93.89% 69.72%, 95.19% 68.33%, 95.83% 67.5%, 96.76% 66.81%, 97.41% 65.69%,
    98.24% 65.83%, 98.24% 64.72%, 99.07% 64.72%, 99.44% 62.78%, 100% 62.64%,
    100% 100%, 0% 100%
  );
}
.track {
  position: absolute;
  inset-inline: var(--route-start) calc(100% - var(--route-end));
  top: var(--lane-y);
  height: 4px;
  translate: 0 -50%;
  background: repeating-linear-gradient(90deg, #fff6df 0 7px, transparent 7px 15px);
  filter: drop-shadow(0 2px 2px #140e13);
}
.track-done { width: 0; height: 100%; background: linear-gradient(90deg, #ffac94, #ffdc9f); }
.route { position: absolute; inset: 0; padding: 0; margin: 0; list-style: none; }
.waypoint {
  position: absolute;
  top: var(--lane-y);
  margin: -5px 0 0 -5px;
  display: grid;
  place-items: center;
  width: 10px;
  height: 10px;
  border: 1.5px solid #fff6df;
  border-radius: 50%;
  background: #39333a;
  box-shadow: 0 1px 2px #140e13;
}
.waypoint.is-passed { background: var(--highlight); border-color: var(--highlight); }
.waypoint.is-current { box-shadow: 0 0 0 5px #ffd6a74d; }
.waypoint-tag {
  position: absolute;
  z-index: 4;
  bottom: calc(100% + 14px);
  min-width: 36px;
  padding: 5px 9px;
  border: 1px solid #e8d8ce66;
  border-radius: 5px;
  background: #261d2bf5;
  color: #fff4e7;
  box-shadow: 0 2px 6px #140e1373;
  text-align: center;
  white-space: nowrap;
  font-size: clamp(.88rem, 1.65vw, 1.12rem);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.waypoint-tag::after { content: ""; position: absolute; top: 100%; left: 50%; width: 1px; height: 12px; background: #fff0ddbd; }
.waypoint.is-current .waypoint-tag { color: #301c24; border-color: #ffd4a8; background: var(--highlight); }
.car {
  position: absolute;
  z-index: 1;
  top: var(--lane-y);
  left: var(--route-start);
  width: var(--vehicle-width);
  height: auto;
  translate: -50% -50%;
  filter: drop-shadow(0 4px 2px #170e15a8);
  user-select: none;
  pointer-events: none;
}

.patrol {
  position: absolute;
  z-index: 1;
  top: calc(var(--lane-y) - 3px);
  left: min(calc(var(--patrol-position) + (var(--vehicle-width) + var(--patrol-width)) / 2 + 10px), calc(100% + var(--patrol-edge) - var(--patrol-width) / 2));
  width: var(--patrol-width);
  translate: -50% -50%;
  rotate: -6deg;
  pointer-events: none;
  animation: patrol-arrive .44s cubic-bezier(.22,.65,.33,1) both;
}
.patrol img { position: relative; display: block; width: 100%; height: auto; filter: drop-shadow(0 4px 2px #170e15a8); }
.patrol::before {
  content: "";
  position: absolute;
  inset: -56% -23%;
  background: radial-gradient(ellipse at 33% 52%, #fa345c84, transparent 65%), radial-gradient(ellipse at 70% 57%, #3985ff96, transparent 63%);
  animation: patrol-spill .64s ease-in-out infinite alternate;
}
.patrol-beacon { position: absolute; top: 15%; left: 44.5%; width: 0; height: 0; }
.patrol-beacon::before, .patrol-beacon::after {
  content: "";
  position: absolute;
  width: clamp(3px, .68vw, 7px);
  height: clamp(3px, .68vw, 7px);
  border-radius: 50%;
  translate: -50% -50%;
  animation: patrol-beacon .64s ease-in-out infinite alternate;
}
.patrol-beacon::before { background: #ffb6bb; box-shadow: 0 0 7px 3px #ff273b; }
.patrol-beacon::after { top: 4px; background: #c6e9ff; box-shadow: 0 0 7px 3px #236aff; animation-direction: alternate-reverse; }
@keyframes patrol-arrive { from { opacity: 0; transform: translateX(36px); } to { opacity: 1; transform: translateX(0); } }
@keyframes patrol-spill { from { opacity: .4; } to { opacity: .88; } }
@keyframes patrol-beacon { from { opacity: .27; } to { opacity: 1; } }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 500px) {
  .intro-actors { width: max(100vw, calc(81svh * 16 / 9)); transform: translateX(-49%); }
  .intro[data-state] .intro-actors { animation-name: intro-slide-phone; }
  .game { grid-template-rows: minmax(22px, 1fr) auto minmax(74px, var(--map-height)) minmax(var(--studio-link-height), .48fr); }
  .game::after { background: linear-gradient(180deg, #13161e73, #13161e28 38%, transparent 64%, #0d141c3b); }
  .challenge-header { padding-inline: 12px; }
  .map {
    width: calc(100% - 24px);
    --scene-width: max(1120px, 188svh);
    --vehicle-width: clamp(44px, 14.7vw, 64px);
    --patrol-width: min(calc(var(--vehicle-width) * .92), calc(18vw - 13px));
    --patrol-edge: 9px;
  }
  .map-background { mask-image: linear-gradient(180deg, transparent, #000 10% 96%, transparent); }
  .waypoint-tag { padding: 4px 4px; font-size: clamp(.65rem, 3.1vw, .86rem); }
}
@keyframes intro-slide-phone { to { transform: translateX(-47%) scale(1.025); } }

@media (max-width: 360px) {
  .challenge-header { block-size: 76px; padding: 8px 10px; }
  .challenge h1 { font-size: 1.08rem; }
  .icon-button { width: 32px; }
  .button { padding-inline: 5px; }
  .waypoint-tag { min-width: 32px; padding-inline: 2px; }
}

@media (max-width: 300px) {
  .buttons:has(#cash-out:not([hidden])) .button { padding-inline: 3px; }
  .waypoint-tag { padding-inline: 1px; font-size: .625rem; }
}

@container (min-width: 361px) {
  #cash-out { padding-inline: 7px; }
}

@container (max-width: 340px) {
  .card-front .challenge-footer { row-gap: 2px; }
  .card-front .icon-button { block-size: 36px; }
}

@container (max-width: 230px) {
  .challenge-header:has(.payout-amount:not([hidden])) { gap: 5px; padding-inline: 8px; }
  .challenge-header:has(.payout-amount:not([hidden])) h1 { font-size: .92rem; }
  .challenge-header:has(.payout-amount:not([hidden])) .balance output { font-size: .72rem; }
}

@media (max-height: 645px) {
  .challenge { max-width: max(244px, calc(100dvh - 331px)); }
}

@media (max-height: 500px) and (orientation: landscape) {
  .game { grid-template-rows: minmax(10px, 1fr) auto minmax(70px, 83px) minmax(var(--studio-link-height), .2fr); }
  .challenge { width: min(270px, 42vw, max(190px, calc(100svh - 188px))); --control-height: 44px; }
  .challenge-header { block-size: 70px; padding-block: 5px; }
  .challenge h1, .challenge h2 { font-size: 1.1rem; }
  .challenge-footer { --action-font-size: .69rem; }
  .button { padding: 2px 5px; }
}

@media (max-height: 600px) and (min-width: 480px) and (orientation: landscape) {
  .challenge {
    --landscape-grid: clamp(144px, min(60dvh, calc(100dvh - 139px), calc(100vw - 292px)), 340px);
    width: min(calc(100% - 32px), calc(var(--landscape-grid) + 286px));
    max-width: none;
  }
  .card-front {
    display: grid;
    grid-template-columns: var(--landscape-grid) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
  }
  .card-front .tiles { grid-area: 1 / 1 / span 2; }
  .card-front .challenge-header { grid-area: 1 / 2; }
  .card-front .challenge-footer { grid-area: 2 / 2; align-self: end; row-gap: 2px; }
  .card-front .icon-button { block-size: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
  .patrol::before, .patrol-beacon::before, .patrol-beacon::after { animation: none; }
}
