:root {
  color-scheme: dark;
  --black: #050708;
  --panel: #0b0f10;
  --cream: #f3ecdf;
  --muted: #969d98;
  --line: rgba(243, 236, 223, 0.16);
  --acid: #d9ff48;
  --amber: #f0a640;
  --red: #f02432;
  --green: #8dba84;
  --hold-angle: 0deg;
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: var(--black);
  color: var(--cream);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--black);
}

button {
  font: inherit;
}

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

[hidden] {
  display: none !important;
}

.grain {
  position: fixed;
  z-index: 100;
  inset: 0;
  opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.92' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
  pointer-events: none;
}

.kicker {
  margin: 0 0 1rem;
  color: var(--acid);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

kbd {
  display: inline-grid;
  min-width: 1.55rem;
  min-height: 1.45rem;
  border: 1px solid rgba(243, 236, 223, 0.34);
  border-bottom-width: 3px;
  border-radius: 3px;
  padding: 0.15rem 0.35rem;
  color: var(--cream);
  background: #15191a;
  font: inherit;
  place-items: center;
}

.start-screen {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  min-height: 100svh;
  padding: clamp(1.5rem, 6vw, 6rem);
  background:
    linear-gradient(90deg, #030505 0 40%, rgba(3, 5, 5, 0.68) 62%, rgba(3, 5, 5, 0.15)),
    radial-gradient(circle at 70% 45%, rgba(240, 36, 50, 0.18), transparent 30%),
    #050708;
  align-items: center;
}

.start-trent {
  position: absolute;
  z-index: -1;
  top: 0;
  right: 0;
  bottom: 0;
  width: 68%;
  background:
    linear-gradient(90deg, #030505 0, transparent 60%),
    linear-gradient(0deg, #030505 0, transparent 35%),
    url("assets/trent-rearview.png") center / cover no-repeat;
  filter: contrast(1.08) saturate(0.86);
}

.start-copy {
  width: min(100%, 780px);
}

.start-copy h1 {
  margin: 0;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(5rem, 12vw, 11rem);
  font-weight: 900;
  letter-spacing: -0.055em;
  line-height: 0.76;
  text-transform: uppercase;
}

.start-copy h1 span {
  color: var(--red);
}

.start-copy > p:not(.kicker) {
  max-width: 42rem;
  margin: clamp(2rem, 5vh, 3.5rem) 0 1.25rem;
  color: #d0cbc1;
  font-size: clamp(0.95rem, 1.4vw, 1.12rem);
  line-height: 1.6;
}

.control-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1.25rem;
  margin: 1.2rem 0 1.6rem;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.62rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.control-strip span {
  display: flex;
  gap: 0.3rem;
  align-items: center;
}

.primary-button {
  display: flex;
  width: min(100%, 360px);
  min-height: 58px;
  border: 0;
  padding: 0 1.2rem;
  align-items: center;
  justify-content: space-between;
  color: #080a0a;
  background: var(--acid);
  box-shadow: 6px 6px 0 #fff;
  cursor: pointer;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease;
}

.primary-button:hover {
  box-shadow: 2px 2px 0 #fff;
  transform: translate(4px, 4px);
}

.game {
  display: grid;
  width: 100%;
  min-height: 100svh;
  grid-template-rows: 72px minmax(0, 1fr);
  background: #060808;
}

.hud {
  position: relative;
  z-index: 20;
  display: flex;
  min-width: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(5, 7, 8, 0.98);
}

.brand {
  display: grid;
  width: 125px;
  flex: 0 0 125px;
  padding: 0.8rem 1rem;
  align-content: center;
  border-right: 1px solid var(--line);
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  line-height: 0.78;
  text-transform: uppercase;
}

.brand span {
  font-size: 0.85rem;
  letter-spacing: 0.18em;
}

.brand strong {
  color: var(--red);
  font-size: 1.5rem;
}

.hud-stat {
  display: grid;
  min-width: 112px;
  padding: 0.8rem 1.1rem;
  align-content: center;
  border-right: 1px solid var(--line);
}

.hud-stat span,
.pressure-label span {
  color: var(--muted);
  font-size: 0.53rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hud-stat strong {
  margin-top: 0.18rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9rem;
}

.hud-health strong {
  color: var(--green);
  letter-spacing: 0.16em;
}

.pressure-wrap {
  display: grid;
  min-width: 175px;
  flex: 1;
  padding: 0.8rem 1.2rem;
  align-content: center;
}

.pressure-label {
  display: flex;
  margin-bottom: 0.35rem;
  justify-content: space-between;
}

.pressure-label strong {
  color: var(--amber);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
}

.pressure-track {
  height: 7px;
  overflow: hidden;
  background: rgba(243, 236, 223, 0.12);
}

.pressure-track i {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--amber), var(--red));
  box-shadow: 0 0 15px var(--red);
  transition: width 80ms linear;
}

.sound-button {
  display: flex;
  gap: 0.55rem;
  min-width: 105px;
  border: 0;
  border-left: 1px solid var(--line);
  padding: 0 1rem;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 0.56rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sound-button[aria-pressed="true"] > span:first-child {
  color: var(--acid);
  animation: sound-pulse 600ms ease-in-out infinite alternate;
}

.game-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: #081012;
  isolation: isolate;
  touch-action: none;
}

#roadCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.route-card {
  position: absolute;
  z-index: 8;
  top: 1.2rem;
  left: 1.2rem;
  display: grid;
  min-width: 205px;
  border: 1px solid rgba(217, 255, 72, 0.35);
  border-left: 4px solid var(--acid);
  padding: 0.7rem 0.9rem;
  background: rgba(4, 8, 8, 0.84);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(8px);
}

.route-card.is-urgent {
  border-color: var(--red);
  border-left-color: var(--red);
  animation: route-jolt 500ms ease-in-out infinite alternate;
}

.route-card span,
.route-card small {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.56rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.route-card strong {
  margin: 0.2rem 0;
  font-size: 0.88rem;
  text-transform: uppercase;
}

.mirror-shell {
  position: absolute;
  z-index: 8;
  top: 1rem;
  left: 50%;
  width: min(36vw, 510px);
  transform: translateX(-50%);
  transform-origin: top center;
}

.mirror {
  position: relative;
  overflow: hidden;
  aspect-ratio: 3.25 / 1;
  border: 6px solid #030404;
  border-radius: 4rem 4rem 1.2rem 1.2rem / 1.2rem;
  background: #121515;
  box-shadow:
    0 0 0 1px #454743,
    0 12px 30px rgba(0, 0, 0, 0.6);
}

.mirror img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition:
    filter 450ms ease,
    opacity 300ms ease,
    transform 500ms ease;
}

.mirror i {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.16), transparent 20%),
    linear-gradient(180deg, transparent 45%, rgba(0, 0, 0, 0.42));
  pointer-events: none;
}

.passenger-label {
  width: max-content;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-top: 0;
  padding: 0.35rem 0.75rem;
  color: var(--amber);
  background: rgba(5, 7, 8, 0.88);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.55rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.bark {
  position: absolute;
  z-index: 12;
  top: min(25vh, 230px);
  left: 50%;
  display: grid;
  width: min(82vw, 680px);
  padding: 0.8rem 1rem 0.9rem;
  color: #fff;
  background: rgba(5, 7, 8, 0.9);
  box-shadow:
    -5px 0 0 var(--red),
    0 18px 40px rgba(0, 0, 0, 0.45);
  text-align: center;
  transform: translateX(-50%);
  animation: bark-in 170ms ease-out both;
  backdrop-filter: blur(7px);
}

.bark span {
  color: var(--amber);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.52rem;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.bark strong {
  margin-top: 0.25rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.25rem, 2.3vw, 2.1rem);
  font-style: italic;
  line-height: 1.05;
}

.phone-sos {
  position: absolute;
  z-index: 12;
  top: 1.2rem;
  right: 1.2rem;
  display: grid;
  border-left: 4px solid var(--red);
  padding: 0.65rem 0.9rem;
  background: rgba(5, 7, 8, 0.92);
  animation: phone-shake 240ms linear infinite;
}

.phone-sos span {
  color: var(--red);
  font-size: 0.55rem;
  font-weight: 950;
  letter-spacing: 0.12em;
}

.phone-sos strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
}

.event-flash {
  position: absolute;
  z-index: 16;
  top: 43%;
  left: 50%;
  color: var(--acid);
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(2.5rem, 7vw, 6rem);
  letter-spacing: -0.02em;
  line-height: 0.9;
  pointer-events: none;
  text-align: center;
  text-shadow: 0 4px 0 #000;
  text-transform: uppercase;
  transform: translate(-50%, -50%);
}

.event-flash.pop {
  animation: event-pop 700ms ease-out both;
}

.kill-control {
  position: absolute;
  z-index: 20;
  right: 1.25rem;
  bottom: 2.5rem;
  display: grid;
  width: 180px;
  place-items: center;
}

.kill-control > p,
.kill-control > small {
  margin: 0.35rem 0;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.52rem;
  letter-spacing: 0.07em;
  text-align: center;
  text-transform: uppercase;
}

.kill-control > small kbd {
  min-width: 1.2rem;
  min-height: 1rem;
  border-bottom-width: 2px;
  padding: 0;
}

.kill-button {
  --button-scale: 1;
  position: relative;
  display: grid;
  width: 145px;
  aspect-ratio: 1;
  border: 8px solid #2e0207;
  border-radius: 50%;
  padding: 0;
  color: white;
  background:
    radial-gradient(circle at 50% 30%, #ff6570 0 4%, transparent 5%),
    radial-gradient(circle at 50% 44%, #f52c3a, #ba0916 63%, #650008 65%);
  box-shadow:
    0 10px 0 #480007,
    0 17px 30px rgba(0, 0, 0, 0.68),
    inset 0 4px 8px rgba(255, 255, 255, 0.25);
  cursor: pointer;
  place-items: center;
  transform: scale(var(--button-scale));
  transition:
    filter 150ms ease,
    transform 180ms ease;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.kill-button:hover {
  filter: brightness(1.15);
}

.kill-button.is-holding {
  box-shadow:
    0 4px 0 #480007,
    0 8px 18px rgba(0, 0, 0, 0.75),
    inset 0 5px 13px rgba(55, 0, 4, 0.55);
  transform: translateY(6px) scale(calc(var(--button-scale) * 0.98));
}

.kill-button.is-tempting {
  animation: kill-pulse 650ms ease-in-out infinite alternate;
}

.kill-button > span {
  position: relative;
  z-index: 2;
  display: grid;
  width: 82%;
  pointer-events: none;
  text-align: center;
  text-transform: uppercase;
}

.kill-button small {
  font-size: 0.52rem;
  font-weight: 950;
  letter-spacing: 0.1em;
}

.kill-button strong {
  margin-top: 0.2rem;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 1.65rem;
  line-height: 0.85;
}

.hold-progress {
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  background: conic-gradient(var(--acid) var(--hold-angle), rgba(255, 255, 255, 0.13) 0);
  -webkit-mask: radial-gradient(transparent 66%, #000 68%);
  mask: radial-gradient(transparent 66%, #000 68%);
}

.desktop-controls {
  position: absolute;
  z-index: 9;
  bottom: 1.2rem;
  left: 1.2rem;
  display: flex;
  gap: 0.7rem;
}

.desktop-controls span {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  color: #8b938f;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.5rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.desktop-controls kbd {
  min-width: 1.35rem;
  min-height: 1.2rem;
  border-bottom-width: 2px;
  padding: 0;
}

.touch-controls {
  display: none;
}

.countdown {
  position: absolute;
  z-index: 30;
  inset: 0;
  display: grid;
  color: var(--acid);
  background: rgba(3, 5, 5, 0.35);
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: min(30vw, 14rem);
  text-shadow: 0 8px 0 #000;
  place-items: center;
}

.game.is-killed .mirror img {
  filter: brightness(0.18) saturate(0.2);
  transform: translateY(44%) rotate(5deg);
}

.game.is-killed .passenger-label {
  color: var(--red);
}

.game.is-critical .game-stage::after {
  position: absolute;
  z-index: 6;
  inset: 0;
  content: "";
  border: clamp(12px, 3vw, 35px) solid rgba(240, 36, 50, 0.2);
  box-shadow: inset 0 0 80px rgba(240, 36, 50, 0.28);
  pointer-events: none;
  animation: danger-pulse 450ms ease-in-out infinite alternate;
}

.outcome {
  position: fixed;
  z-index: 70;
  inset: 0;
  display: grid;
  overflow-y: auto;
  padding: 1.25rem;
  background: rgba(3, 5, 5, 0.86);
  backdrop-filter: blur(13px);
  place-items: center;
}

.outcome-card {
  width: min(100%, 670px);
  border-top: 7px solid var(--acid);
  padding: clamp(1.5rem, 4vw, 3rem);
  background: #0e1213;
  box-shadow: 0 35px 100px #000;
  animation: outcome-in 280ms ease-out both;
}

.outcome-card.is-bad {
  border-color: var(--red);
}

.outcome-card h2 {
  margin: 0;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(3.5rem, 10vw, 7rem);
  letter-spacing: -0.04em;
  line-height: 0.8;
  text-transform: uppercase;
}

.outcome-card.is-bad h2 {
  color: var(--red);
}

.outcome-card > p:not(.kicker) {
  margin: 1.3rem 0 1.7rem;
  color: #c8c3ba;
  line-height: 1.55;
}

.results {
  display: grid;
  margin-bottom: 1.5rem;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  grid-template-columns: repeat(3, 1fr);
}

.result {
  display: grid;
  min-height: 75px;
  padding: 0.8rem;
  align-content: center;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.result span {
  color: var(--muted);
  font-size: 0.52rem;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.result strong {
  margin-top: 0.3rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.result strong.good {
  color: var(--acid);
}

.result strong.bad {
  color: var(--red);
}

.outcome .primary-button {
  width: 100%;
}

.noscript {
  position: fixed;
  z-index: 200;
  inset: 1rem;
  display: grid;
  background: var(--red);
  place-items: center;
}

@keyframes sound-pulse {
  to {
    opacity: 0.35;
  }
}

@keyframes bark-in {
  from {
    opacity: 0;
    transform: translate(-50%, 10px) scale(0.97);
  }
}

@keyframes phone-shake {
  50% {
    transform: translateX(2px);
  }
}

@keyframes event-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.4);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes kill-pulse {
  to {
    filter: brightness(1.25);
    transform: scale(calc(var(--button-scale) * 1.05));
  }
}

@keyframes route-jolt {
  to {
    transform: translateX(3px);
  }
}

@keyframes danger-pulse {
  to {
    opacity: 0.42;
  }
}

@keyframes outcome-in {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }
}

@media (max-width: 900px) {
  .game {
    grid-template-rows: 58px minmax(0, 1fr);
  }

  .brand {
    width: 86px;
    flex-basis: 86px;
    padding: 0.55rem 0.7rem;
  }

  .brand span {
    font-size: 0.62rem;
  }

  .brand strong {
    font-size: 1.12rem;
  }

  .hud-stat {
    min-width: 75px;
    padding: 0.55rem 0.65rem;
  }

  .hud-stat:nth-of-type(2),
  .hud-health,
  .sound-button span:last-child {
    display: none;
  }

  .pressure-wrap {
    min-width: 115px;
    padding: 0.55rem 0.7rem;
  }

  .sound-button {
    min-width: 48px;
    padding: 0;
  }

  .mirror-shell {
    top: 0.7rem;
    width: min(52vw, 390px);
  }

  .route-card {
    top: 0.7rem;
    left: 0.7rem;
    min-width: 155px;
    padding: 0.55rem 0.65rem;
  }

  .phone-sos {
    top: 0.7rem;
    right: 0.7rem;
  }

  .desktop-controls {
    display: none;
  }

  .touch-controls {
    position: absolute;
    z-index: 20;
    right: 0.7rem;
    bottom: 0.7rem;
    left: 0.7rem;
    display: grid;
    gap: 0.45rem;
    grid-template-columns: 1fr 0.85fr 0.85fr 1fr;
  }

  .touch-controls button {
    min-height: 56px;
    border: 1px solid rgba(243, 236, 223, 0.3);
    border-bottom-width: 4px;
    color: var(--cream);
    background: rgba(7, 11, 12, 0.82);
    font-size: 0.65rem;
    font-weight: 950;
    touch-action: none;
  }

  .touch-controls button:first-child,
  .touch-controls button:last-child {
    font-size: 1.4rem;
  }

  .touch-controls button.is-down {
    border-bottom-width: 1px;
    transform: translateY(3px);
  }

  .kill-control {
    right: 0.8rem;
    bottom: 5.8rem;
    width: 125px;
  }

  .kill-button {
    width: 104px;
    border-width: 6px;
  }

  .kill-button strong {
    font-size: 1.15rem;
  }

  .kill-control > p,
  .kill-control > small {
    display: none;
  }

  .bark {
    top: 24%;
    width: min(88vw, 620px);
  }
}

@media (max-width: 560px) {
  .start-screen {
    padding: 1.2rem;
    align-items: end;
  }

  .start-trent {
    width: 100%;
    opacity: 0.56;
  }

  .start-screen::after {
    position: absolute;
    z-index: -1;
    inset: 0;
    content: "";
    background: linear-gradient(0deg, #030505 15%, transparent 78%);
  }

  .start-copy h1 {
    font-size: clamp(4.5rem, 21vw, 7rem);
  }

  .start-copy > p:not(.kicker) {
    margin-top: 1.5rem;
  }

  .control-strip span:nth-child(2) {
    display: none;
  }

  .hud-stat:first-of-type {
    display: none;
  }

  .mirror-shell {
    top: 4.5rem;
    width: 72vw;
  }

  .route-card {
    max-width: 51vw;
  }

  .route-card strong {
    font-size: 0.7rem;
  }

  .phone-sos {
    top: 4.5rem;
  }

  .bark {
    top: 28%;
  }

  .bark strong {
    font-size: 1.2rem;
  }

  .event-flash {
    top: 48%;
  }

  .results {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
