/*!
 * Not Again, Biscuit!
 * Copyright (c) 2026 ANGEL TECH CORPORATION INDUSTRIES L.L.C. All rights reserved.
 * Proprietary software. See LICENSE.
 */

/* Layout: full-bleed 3D road; the HUD sits at the edges like roadside signs;
   menus are street signs, and the game-over screen is a photocopied LOST DOG flyer.
   One deliberate look (US road signage over a live scene), so no light/dark switch. */
:root {
  --sign-green: #0e6b48;
  --sign-green-deep: #0a4f35;
  --sign-white: #f7f7f2;
  --warn-yellow: #ffd23f;
  --guide-blue: #1d4f9c;
  --stop-red: #d7262f;
  --ink: #15171a;
  --asphalt: rgba(24, 27, 31, 0.78);
  --paper: #fbfbf7;
  --tape: rgba(222, 205, 160, 0.82);
  --shade: rgba(10, 12, 14, 0.55);
  --font-sign: 'Bungee', 'Arial Black', Impact, system-ui, sans-serif;
  --font-ui: 'Barlow Semi Condensed', 'Arial Narrow', 'Helvetica Neue', Arial, sans-serif;
  --font-hand: 'Permanent Marker', 'Marker Felt', 'Comic Sans MS', cursive;
  --gutter: 16px;
  color-scheme: dark;
}

[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: #1a1d21;
  color: var(--sign-white);
  font-family: var(--font-ui);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app { position: fixed; inset: 0; overflow: hidden; touch-action: none; background: #1a1d21; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 3px solid var(--warn-yellow); outline-offset: 3px; }

.ico { display: inline-block; width: 1em; height: 1em; background: currentColor; vertical-align: -0.12em;
  -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; }
.hud-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: flex-start; gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) var(--gutter) 0;
}
.marker {
  background: var(--sign-green); border: 2px solid var(--sign-white); border-radius: 6px;
  box-shadow: 0 0 0 2px var(--sign-green), 0 4px 10px rgba(0,0,0,.35);
  padding: 4px 10px 5px; min-width: 84px; text-align: center; line-height: 1;
}
.marker-label { display: block; font: 700 11px/1 var(--font-ui); letter-spacing: .14em; opacity: .85; }
.marker-value { display: block; font: 22px/1.1 var(--font-sign); font-variant-numeric: tabular-nums; margin-top: 3px; }

.hud-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pursuit { width: min(100%, 300px); }
.pursuit-track {
  position: relative; height: 12px; border-radius: 6px; background: var(--asphalt);
  border: 2px solid rgba(247,247,242,.85); overflow: visible;
}
.pursuit-track::after { content: ""; position: absolute; left: 6px; right: 6px; top: 50%; border-top: 2px dashed rgba(255,210,63,.6); }
.p-dog, .p-chaser {
  position: absolute; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%;
  border: 2px solid var(--sign-white); box-shadow: 0 2px 6px rgba(0,0,0,.4); z-index: 1;
}
.p-dog { left: calc(100% - 4px); background: #c98b45; }
.p-chaser { left: 10%; background: var(--stop-red); transition: background-color .3s; }
.pursuit-label {
  margin-top: 5px; text-align: center; font: 800 13px/1 var(--font-ui); letter-spacing: .08em;
  text-shadow: 0 1px 3px rgba(0,0,0,.8);
}
.pursuit.is-near .pursuit-label { color: var(--warn-yellow); }
.pursuit.is-danger .pursuit-label { color: #ff6b6b; }
.pursuit.is-surge .pursuit-label { color: #ff6b6b; }
.pursuit.is-surge .p-chaser { animation: surge-pulse .3s ease-in-out infinite alternate; }
@keyframes surge-pulse {
  from { transform: scale(1); box-shadow: 0 0 0 0 rgba(215,38,47,0); }
  to { transform: scale(1.3); box-shadow: 0 0 0 7px rgba(215,38,47,.45); }
}

.scoreline { display: flex; align-items: baseline; gap: 6px; font: 18px/1 var(--font-sign); text-shadow: 0 2px 4px rgba(0,0,0,.6); font-variant-numeric: tabular-nums; }
.scoreline .unit { font: 700 11px/1 var(--font-ui); letter-spacing: .12em; opacity: .8; }
.treats { display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; color: var(--sign-white); }
.treats .ico { color: #fff6df; }
.shield { color: var(--stop-red); font-size: 18px; }

.hud-buttons { display: flex; gap: 8px; pointer-events: auto; }
.sq-btn {
  width: 40px; height: 40px; border-radius: 6px; border: 2px solid var(--sign-white);
  background: var(--asphalt); display: grid; place-items: center; padding: 0; font-size: 20px;
}
.sq-btn:active { transform: scale(.94); }

.zone-chip {
  position: absolute; left: 50%; transform: translateX(-50%);
  top: calc(env(safe-area-inset-top, 0px) + 96px);
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
  background: var(--guide-blue); border: 2px solid var(--sign-white); border-radius: 6px;
  padding: 5px 10px; font: 700 14px/1 var(--font-ui); letter-spacing: .04em;
  box-shadow: 0 3px 10px rgba(0,0,0,.35);
}
.zone-chip .ico { font-size: 16px; }

/* Crossroads cards: green street-name blades */
.cross {
  position: absolute; left: 0; right: 0; top: calc(env(safe-area-inset-top, 0px) + 132px);
  padding: 0 var(--gutter); display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.cross-head {
  display: flex; gap: 12px; align-items: center; background: var(--warn-yellow); color: var(--ink);
  border: 2px solid var(--ink); border-radius: 4px; padding: 4px 10px; font: 13px/1 var(--font-sign);
}
.cross-head #cross-dist { font-variant-numeric: tabular-nums; }
.cross-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: min(100%, 560px); }
.card {
  min-width: 0; background: var(--asphalt); border: 2px solid rgba(247,247,242,.35); border-radius: 8px;
  padding: 6px; display: flex; flex-direction: column; gap: 5px; transition: transform .15s, border-color .15s, background-color .15s;
}
.card.is-picked { border-color: var(--warn-yellow); background: rgba(14,107,72,.92); transform: translateY(-4px) scale(1.03); }
.blade {
  display: flex; align-items: center; gap: 4px; background: var(--sign-green); border: 2px solid var(--sign-white);
  border-radius: 4px; padding: 4px 5px; font: 12px/1.05 var(--font-sign); min-width: 0;
}
.blade .ico { flex: none; font-size: 14px; }
.blade b { font-weight: 400; overflow-wrap: anywhere; }
.c-abil { display: flex; align-items: center; gap: 4px; background: var(--guide-blue); border-radius: 4px; padding: 3px 5px; font: 700 12px/1.1 var(--font-ui); }
.c-abil .ico { flex: none; }
.c-tip { font: 600 11.5px/1.2 var(--font-ui); opacity: .92; }
.c-danger { display: flex; align-items: center; gap: 3px; font: 700 10.5px/1 var(--font-ui); letter-spacing: .08em; color: var(--warn-yellow); }
.c-danger .ico { font-size: 12px; }
.c-danger .off { opacity: .25; }
.card-you { display: none; font: 800 10px/1 var(--font-ui); letter-spacing: .14em; color: var(--warn-yellow); text-align: center; }
.card.is-picked .card-you { display: block; }
.cross-hint { font: 700 13px/1 var(--font-ui); letter-spacing: .06em; text-shadow: 0 1px 4px rgba(0,0,0,.9); }

/* Toasts and big callouts */
.toast {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(.9); opacity: 0;
  font: 20px/1.1 var(--font-sign); text-align: center; color: var(--sign-white); max-width: calc(100% - 2 * var(--gutter));
  text-shadow: 0 0 2px #000, 0 3px 0 rgba(0,0,0,.55); transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.toast.warn { color: var(--warn-yellow); }
.toast.bad { color: #ff6b6b; }
.toast.good { color: #9ff0b8; }
.toast.shout { font: 22px/1.1 var(--font-hand); color: #fff; }
.big {
  position: absolute; left: 50%; top: 34%; transform: translate(-50%, -50%) scale(.6); opacity: 0;
  font: clamp(44px, 14vw, 96px)/1 var(--font-sign); color: var(--warn-yellow);
  text-shadow: 0 0 3px #000, 0 6px 0 rgba(0,0,0,.5); transition: opacity .25s, transform .25s; white-space: nowrap;
}
.big.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.tap-hint {
  position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 92px); transform: translateX(-50%);
  font: 26px/1 var(--font-sign); color: var(--warn-yellow); text-shadow: 0 0 3px #000, 0 4px 0 rgba(0,0,0,.5);
  animation: tap-pulse .45s ease-in-out infinite alternate; white-space: nowrap;
}
@keyframes tap-pulse { from { transform: translateX(-50%) scale(1); } to { transform: translateX(-50%) scale(1.12); } }

.speed {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.speed-paws { display: flex; gap: 6px; }
.speed-paws .ico { font-size: 24px; color: rgba(247,247,242,.28); filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); transition: color .12s; }
.speed-paws .ico.on { color: var(--sign-white); }
.speed-paws .ico.hot { color: var(--warn-yellow); }
.speed-tier { font: 15px/1 var(--font-sign); letter-spacing: .04em; text-shadow: 0 2px 3px rgba(0,0,0,.7); }

#vignette {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, rgba(215,38,47,0) 55%, rgba(215,38,47,.55) 100%);
  transition: opacity .2s;
}

/* ---------- Screens ---------- */
.screen {
  position: absolute; inset: 0; overflow-y: auto; touch-action: pan-y;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: calc(env(safe-area-inset-top, 0px) + 20px) var(--gutter) calc(env(safe-area-inset-bottom, 0px) + 20px);
}
.screen-title { background: linear-gradient(to bottom, rgba(10,14,18,.15) 0%, rgba(10,14,18,.1) 35%, rgba(10,14,18,.78) 100%); }
.screen-pause { background: var(--shade); }
.screen-over { background: rgba(14,16,18,.72); justify-content: flex-start; }

.logo { position: relative; width: min(86vw, 360px); height: 168px; flex: none; }
.logo-pole { position: absolute; left: 50%; top: 0; bottom: -24px; width: 12px; margin-left: -6px; background: linear-gradient(90deg, #8c939a, #d7dbdf 45%, #7d848b); border-radius: 3px; }
.blade {
  /* shared with cards above; the logo blades override size */
}
.logo .blade {
  position: absolute; left: 50%; justify-content: center; padding: 10px 18px 8px; border-width: 4px; border-radius: 8px;
  box-shadow: 0 0 0 3px var(--sign-green), 0 10px 22px rgba(0,0,0,.45); font-size: clamp(38px, 12vw, 56px); line-height: 1; white-space: nowrap;
}
.blade-a { top: 8px; transform: translateX(-50%) rotate(-3deg); }
.logo .blade-a { font-size: clamp(24px, 7.6vw, 36px); padding: 9px 16px 7px; background: var(--stop-red); box-shadow: 0 0 0 3px var(--stop-red), 0 10px 22px rgba(0,0,0,.45); }
.blade-b { top: 88px; transform: translateX(-46%) rotate(4deg); background: var(--sign-green-deep); }

.tagline { margin: 0; max-width: 34ch; text-align: center; font: 600 18px/1.3 var(--font-ui); text-shadow: 0 1px 4px rgba(0,0,0,.85); text-wrap: balance; }
.go-btn {
  background: var(--warn-yellow); color: var(--ink); border: 3px solid var(--ink); border-radius: 6px;
  box-shadow: 0 0 0 3px var(--warn-yellow), 0 8px 18px rgba(0,0,0,.45);
  font: 24px/1 var(--font-sign); padding: 14px 26px 12px; min-width: 220px;
}
.go-btn:active { transform: translateY(2px); }
.plain-btn { background: transparent; border: 2px solid rgba(247,247,242,.7); border-radius: 6px; padding: 10px 18px; font: 700 16px/1 var(--font-ui); letter-spacing: .04em; min-width: 200px; }
.howto { list-style: none; margin: 0; padding: 12px 14px; display: grid; gap: 7px; background: var(--asphalt); border-radius: 8px; border: 1px solid rgba(247,247,242,.2); width: min(100%, 380px); }
.howto li { display: flex; align-items: center; gap: 10px; font: 600 15px/1.25 var(--font-ui); }
.howto .key { flex: none; min-width: 92px; text-align: center; background: var(--sign-white); color: var(--ink); border-radius: 4px; padding: 3px 6px; font: 800 12px/1.1 var(--font-ui); letter-spacing: .06em; }
.howto .howto-keys { font: 500 13px/1.3 var(--font-ui); opacity: .8; display: block; }
.settings-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; }
.settings-label { font: 700 14px/1 var(--font-ui); letter-spacing: .04em; text-shadow: 0 1px 3px rgba(0,0,0,.8); }
.seg { display: inline-flex; border: 2px solid var(--sign-white); border-radius: 6px; overflow: hidden; background: var(--asphalt); }
.seg button { background: transparent; border: 0; padding: 8px 12px; font: 700 14px/1 var(--font-ui); }
.seg button + button { border-left: 1px solid rgba(247,247,242,.35); }
.seg button[aria-checked="true"] { background: var(--sign-white); color: var(--ink); }
.best-line { margin: 0; font: 700 15px/1 var(--font-ui); letter-spacing: .06em; color: var(--warn-yellow); text-shadow: 0 1px 3px rgba(0,0,0,.8); min-height: 1em; }
.legal { margin: 4px 0 0; font: 500 11.5px/1.35 var(--font-ui); opacity: .72; text-align: center; max-width: 46ch; }
.legal a { color: inherit; text-decoration: underline; text-underline-offset: 2px; padding: 4px 2px; display: inline-block; }
.legal a:focus-visible { outline: 2px solid var(--warn-yellow); outline-offset: 2px; }

/* Second chance: a yellow sign taped over the flyer */
.revive-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px; width: 100%; margin: 0 0 14px;
  background: var(--warn-yellow); color: var(--ink); border: 3px solid var(--ink); border-radius: 6px;
  box-shadow: 0 0 0 3px var(--warn-yellow), 0 6px 14px rgba(0,0,0,.25); padding: 10px 12px 9px;
  animation: revive-nudge 1.2s ease-in-out infinite;
}
.revive-main { font: 22px/1 var(--font-sign); }
.revive-main::before { content: "\25B6"; font-size: .7em; margin-right: 8px; vertical-align: .12em; }
.revive-sub { font: 700 13px/1.2 var(--font-ui); letter-spacing: .02em; }
@keyframes revive-nudge { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.03); } }

.pause-sign {
  font: clamp(40px, 12vw, 64px)/1 var(--font-sign); color: var(--sign-white); background: var(--stop-red);
  border: 4px solid var(--sign-white); box-shadow: 0 0 0 3px var(--stop-red); padding: 16px 22px 12px;
  clip-path: polygon(29% 0, 71% 0, 100% 29%, 100% 71%, 71% 100%, 29% 100%, 0 71%, 0 29%);
}
.pause-actions { display: flex; flex-direction: column; align-items: center; gap: 10px; }

/* ---------- Game over flyer ---------- */
.flyer {
  position: relative; width: min(100%, 380px); margin: 10px 0 24px; background: var(--paper); color: var(--ink);
  padding: 22px 18px 0; box-shadow: 0 18px 40px rgba(0,0,0,.5); transform: rotate(-1.2deg); flex: none;
}
.tape { position: absolute; top: -10px; width: 86px; height: 26px; background: var(--tape); }
.tape-l { left: -16px; transform: rotate(-32deg); }
.tape-r { right: -16px; transform: rotate(30deg); }
.flyer-title { margin: 0; text-align: center; font: clamp(40px, 13vw, 58px)/0.95 var(--font-hand); letter-spacing: .02em; color: var(--ink); text-wrap: balance; }
.flyer-title.is-found { color: var(--sign-green); }
.flyer-photo { margin: 12px auto 10px; border: 3px solid var(--ink); background: #ddd; aspect-ratio: 4 / 3; max-width: 100%; overflow: hidden; }
.flyer-photo img { width: 100%; height: 100%; object-fit: cover; display: block; filter: grayscale(1) contrast(1.35) brightness(1.05); }
.flyer-name { margin: 0; text-align: center; font: 22px/1.1 var(--font-hand); }
.flyer-name b { font-weight: 400; color: var(--stop-red); }
.flyer-line { margin: 6px 0 10px; text-align: center; font: 700 16px/1.3 var(--font-ui); }
.flyer-stats { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); }
.flyer-stats div { padding: 8px 4px; text-align: center; min-width: 0; }
.flyer-stats div + div { border-left: 2px dashed rgba(21,23,26,.45); }
.flyer-stats dt { font: 800 11px/1 var(--font-ui); letter-spacing: .14em; text-transform: uppercase; opacity: .7; }
.flyer-stats dd { margin: 4px 0 0; font: 20px/1.1 var(--font-sign); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.flyer-route { margin: 10px 0 2px; font: 600 14px/1.35 var(--font-ui); text-align: center; overflow-wrap: anywhere; }
.flyer-best { margin: 0 0 12px; font: 800 13px/1.2 var(--font-ui); letter-spacing: .08em; text-align: center; color: var(--stop-red); }
.tabs { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; margin: 0 -18px; border-top: 2px dashed rgba(21,23,26,.55); }
.tab {
  background: var(--paper); color: var(--ink); border: 0; border-right: 2px dashed rgba(21,23,26,.45);
  min-height: 92px; padding: 8px 4px; font: 15px/1 var(--font-sign);
  display: flex; align-items: center; justify-content: center; text-align: center;
}
/* Sideways text sits on an inner span: Safari ignores writing-mode on buttons, and no
   rotation is used, so if a browser can't turn the text it stays upright instead of flipping. */
.tab-label { display: inline-block; -webkit-writing-mode: vertical-rl; writing-mode: vertical-rl; }
.tabs > :last-child { border-right: 0; }
.tab-go { background: var(--warn-yellow); font-size: 18px; }
.tab-deco { font: 13px/1 var(--font-hand); opacity: .55; }

.boot-error { position: absolute; inset: auto var(--gutter) 40% var(--gutter); background: var(--stop-red); padding: 14px; border-radius: 8px; font: 700 16px/1.35 var(--font-ui); text-align: center; }

@media (max-width: 420px) {
  .marker { min-width: 70px; padding: 4px 8px 5px; }
  .marker-value { font-size: 19px; }
  .sq-btn { width: 36px; height: 36px; font-size: 18px; }
  .c-tip { font-size: 10.5px; }
  .blade { font-size: 10.5px; }
  .c-abil { font-size: 11px; }
}
@media (max-height: 640px) {
  .logo { height: 140px; transform: scale(.85); }
  .howto { gap: 4px; padding: 8px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .tap-hint, .pursuit.is-surge .p-chaser, .revive-btn { animation: none; }
  .toast, .big, .card { transition: none; }
}
