@font-face {
  font-family: "Press Start 2P";
  src: url("assets/PressStart2P-Regular.ttf") format("truetype");
  font-display: block;
  font-style: normal;
  font-weight: 400;
}

.visual-scale-audit-mode .hud,
.visual-scale-audit-mode #virtualJoystick,
.visual-scale-audit-mode #actionButton,
.visual-scale-audit-mode #countdown {
  display: none !important;
}

:root {
  --deep: #071c4d;
  --primary: #155eef;
  --electric: #3b82f6;
  --paper: #f7f4ec;
  --muted: #8191b2;
  --ink: #071225;
  --coffee: #9a4e2d;
  --warning: #f2a65a;
  --pixel-font: "Press Start 2P";
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --joystick-base-size: 104px;
  --joystick-knob-size: 46px;
  --joystick-max-radius: 38px;
  --joystick-touch-area: 130px;
  --joystick-left-offset: 12px;
  --joystick-bottom-offset: 10px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  background:
    radial-gradient(circle at 50% 10%, #123b94 0, #071c4d 45%, #071225 100%);
}

body {
  display: grid;
  place-items: center;
  color: var(--paper);
  font-family: var(--pixel-font);
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
  font-smooth: never;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button {
  color: inherit;
  font: inherit;
}

button,
canvas {
  touch-action: none;
}

button:focus-visible,
canvas:focus-visible {
  outline: 3px solid var(--paper);
  outline-offset: 3px;
}

.game-app {
  position: relative;
  width: min(100vw, calc(100dvh * 16 / 9), 1280px);
  aspect-ratio: 16 / 9;
  max-height: 100dvh;
  overflow: hidden;
  background: var(--ink);
  box-shadow:
    0 0 0 1px rgb(129 145 178 / 24%),
    0 30px 90px rgb(0 0 0 / 50%);
  isolation: isolate;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.screen.is-active {
  display: block;
  animation: screen-in 240ms steps(4, end) both;
}

.screen-art,
.screen-shade {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.screen-art {
  object-fit: cover;
  object-position: center;
  image-rendering: pixelated;
  pointer-events: none;
}

.screen-shade {
  pointer-events: none;
}

.screen-shade-loading {
  background:
    linear-gradient(180deg, rgb(7 18 37 / 38%), rgb(7 18 37 / 25%) 45%, rgb(7 18 37 / 94%)),
    repeating-linear-gradient(0deg, rgb(255 255 255 / 2%) 0 1px, transparent 1px 4px);
}

.screen-shade-title {
  background:
    linear-gradient(180deg, rgb(7 18 37 / 22%), rgb(7 28 77 / 2%) 43%, rgb(7 18 37 / 78%) 78%, #071225 100%),
    linear-gradient(90deg, rgb(7 18 37 / 16%), transparent 45%, rgb(7 18 37 / 10%));
}

.screen-shade-over {
  background:
    linear-gradient(180deg, rgb(7 18 37 / 10%) 0 44%, rgb(7 18 37 / 92%) 68%, #071225 100%),
    repeating-linear-gradient(0deg, rgb(255 255 255 / 2%) 0 1px, transparent 1px 4px);
}

.eyebrow {
  margin: 0;
  color: #b8c8e8;
  font-size: clamp(9px, 2.6vw, 12px);
  font-weight: 800;
  letter-spacing: 0.16em;
  line-height: 1.3;
  text-transform: uppercase;
}

.loading-card {
  position: absolute;
  right: 24px;
  bottom: calc(36px + var(--safe-bottom));
  left: 24px;
  padding: 22px;
  border: 2px solid rgb(247 244 236 / 74%);
  background: rgb(7 18 37 / 88%);
  box-shadow:
    7px 7px 0 rgb(7 18 37 / 82%),
    inset 0 0 0 2px rgb(59 130 246 / 20%);
}

.mini-logo {
  margin: 8px 0 18px;
  color: var(--electric);
  font-size: 28px;
  font-weight: 1000;
  letter-spacing: -0.08em;
  line-height: 1;
}

.mini-logo span {
  color: var(--paper);
}

.loading-track {
  height: 12px;
  padding: 2px;
  border: 2px solid var(--paper);
  background: var(--deep);
}

.loading-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--electric);
  box-shadow: 0 0 10px rgb(59 130 246 / 72%);
  transition: width 160ms steps(5, end);
}

#loadingText {
  margin: 10px 0 0;
  color: #d7e0f1;
  font-size: 11px;
  font-weight: 700;
}

.title-copy {
  position: absolute;
  top: calc(46px + var(--safe-top));
  right: 24px;
  left: 24px;
  text-align: center;
  filter: drop-shadow(4px 6px 0 rgb(7 18 37 / 65%));
}

.game-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 13px 0 10px;
  font-size: clamp(55px, 19vw, 88px);
  font-weight: 1000;
  letter-spacing: -0.105em;
  line-height: 0.92;
  transform: skew(-5deg);
}

.game-logo .logo-burn,
.game-logo .logo-rate {
  display: block;
  line-height: 0.92;
}

.logo-burn {
  position: relative;
  z-index: 1;
  color: var(--paper);
  text-shadow:
    3px 0 var(--deep),
    -3px 0 var(--deep),
    0 3px var(--deep),
    0 -3px var(--deep),
    7px 8px #071225;
}

.logo-rate {
  color: #72a5ff;
  font-size: 0.77em;
  text-shadow:
    3px 0 var(--deep),
    -3px 0 var(--deep),
    0 3px var(--deep),
    0 -3px var(--deep),
    6px 7px #071225;
}

.tagline {
  margin: 22px auto 0;
  color: var(--paper);
  font-size: clamp(11px, 3.2vw, 14px);
  font-weight: 800;
  line-height: 1.45;
  text-shadow: 2px 2px 0 var(--ink);
}

.title-actions {
  position: absolute;
  right: 24px;
  bottom: calc(22px + var(--safe-bottom));
  left: 24px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 11px;
}

.record-chip {
  align-self: center;
  min-width: 146px;
  padding: 7px 13px;
  border: 2px solid rgb(247 244 236 / 56%);
  background: rgb(7 18 37 / 82%);
  text-align: center;
  box-shadow: 4px 4px 0 rgb(7 18 37 / 68%);
}

.record-chip span,
.score-block span,
.hud-pill span,
.final-score span {
  display: block;
  color: #aab9d6;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.record-chip strong {
  display: block;
  margin-top: 2px;
  color: var(--paper);
  font-size: 20px;
  letter-spacing: 0.05em;
}

.primary-button,
.secondary-button,
.text-button,
.icon-button,
.pause-button {
  cursor: pointer;
}

.primary-button {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 3px solid var(--paper);
  background: var(--primary);
  color: var(--paper);
  font-size: 19px;
  font-weight: 1000;
  letter-spacing: 0.06em;
  box-shadow:
    0 6px 0 #082c83,
    0 9px 0 rgb(7 18 37 / 72%);
  text-shadow: 2px 2px 0 #082c83;
  transition:
    transform 90ms steps(2, end),
    box-shadow 90ms steps(2, end),
    filter 120ms linear;
}

.primary-button:hover {
  filter: brightness(1.12);
}

.primary-button:active {
  transform: translateY(5px);
  box-shadow:
    0 1px 0 #082c83,
    0 4px 0 rgb(7 18 37 / 72%);
}

.primary-button.compact {
  min-height: 50px;
  font-size: 14px;
}

.secondary-button {
  min-height: 48px;
  border: 2px solid #9eb2d7;
  background: #0c2f73;
  color: var(--paper);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.06em;
  box-shadow: 0 4px 0 #071225;
}

.text-button {
  min-height: 42px;
  border: 0;
  background: transparent;
  color: #bdc9dd;
  font-size: 11px;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.control-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 1px 0 0;
  color: var(--paper);
  font-size: 10px;
  font-weight: 800;
  text-align: center;
  text-shadow: 2px 2px 0 var(--ink);
}

.control-hint span {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 2px solid var(--paper);
  background: var(--deep);
  font-size: 15px;
}

.preference-row {
  display: flex;
  justify-content: center;
  gap: 9px;
}

.icon-button {
  display: flex;
  min-height: 39px;
  align-items: center;
  gap: 7px;
  padding: 0 13px;
  border: 2px solid rgb(247 244 236 / 55%);
  background: rgb(7 18 37 / 86%);
  color: #dce5f4;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.icon-button[aria-pressed="false"] {
  color: var(--muted);
}

.game-screen {
  background: #123984;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  outline-offset: -4px;
}

.virtual-joystick {
  position: absolute;
  z-index: 14;
  bottom: calc(var(--joystick-bottom-offset) + var(--safe-bottom));
  left: calc(var(--joystick-left-offset) + var(--safe-left));
  display: none;
  width: var(--joystick-touch-area);
  height: var(--joystick-touch-area);
  place-items: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: contain;
}

.joystick-base {
  position: relative;
  display: block;
  width: var(--joystick-base-size);
  height: var(--joystick-base-size);
  overflow: visible;
  border: 4px solid var(--paper);
  border-radius: 50%;
  background: #071225;
  box-shadow:
    4px 4px 0 #020917,
    inset 0 0 0 4px #155eef;
  pointer-events: none;
}

.joystick-base::before,
.joystick-base::after {
  position: absolute;
  top: 50%;
  left: 50%;
  content: "";
  background: #155eef;
  transform: translate(-50%, -50%);
}

.joystick-base::before {
  width: 4px;
  height: 100%;
}

.joystick-base::after {
  width: 100%;
  height: 4px;
}

.joystick-knob {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  display: block;
  width: var(--joystick-knob-size);
  height: var(--joystick-knob-size);
  margin-top: calc(var(--joystick-knob-size) / -2);
  margin-left: calc(var(--joystick-knob-size) / -2);
  border: 3px solid var(--paper);
  border-radius: 50%;
  background: #155eef;
  box-shadow:
    3px 3px 0 #020917,
    inset 0 0 0 3px #72a5ff;
  transform: translate(0, 0);
  transition: none;
  will-change: transform;
}

.virtual-joystick.is-pressed .joystick-base {
  border-color: #b9d2ff;
  background: #0c2f73;
}

.virtual-joystick.is-pressed .joystick-knob {
  background: #3b82f6;
  box-shadow:
    2px 2px 0 #020917,
    inset 0 0 0 3px #b9d2ff;
}

.legacy-dpad {
  display: none !important;
  visibility: hidden;
  pointer-events: none !important;
}

.input-debug[hidden] {
  display: none !important;
}

.input-debug {
  position: absolute;
  z-index: 35;
  top: calc(68px + var(--safe-top));
  left: calc(8px + var(--safe-left));
  width: 230px;
  padding: 8px;
  border: 3px solid var(--paper);
  background: #071225;
  color: #b9d2ff;
  box-shadow: 4px 4px 0 #020917;
  pointer-events: none;
}

.input-debug strong {
  display: block;
  margin-bottom: 6px;
  color: var(--paper);
  font-size: 9px;
}

.input-debug pre {
  margin: 0;
  color: #b9d2ff;
  font: 8px/1.45 var(--pixel-font);
  white-space: pre-wrap;
}

.virtual-dpad {
  position: absolute;
  z-index: 14;
  bottom: calc(18px + var(--safe-bottom));
  left: 18px;
  display: none;
  grid-template-areas:
    ". up ."
    "left center right"
    ". down .";
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(3, 44px);
  gap: 4px;
  filter: drop-shadow(4px 5px 0 rgb(7 18 37 / 48%));
}

.dpad-button,
.dpad-center {
  border: 2px solid rgb(247 244 236 / 78%);
  background: rgb(7 18 37 / 72%);
}

.dpad-button {
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--paper);
  font-size: 17px;
  font-weight: 1000;
  line-height: 1;
  text-shadow: 2px 2px 0 var(--deep);
}

.dpad-button.is-pressed,
.dpad-button:active {
  border-color: #b9d2ff;
  background: rgb(21 94 239 / 88%);
  transform: translate(2px, 2px);
  box-shadow: inset 0 0 0 2px rgb(114 165 255 / 42%);
}

.dpad-up {
  grid-area: up;
}

.dpad-left {
  grid-area: left;
}

.dpad-center {
  grid-area: center;
  opacity: 0.58;
}

.dpad-right {
  grid-area: right;
}

.dpad-down {
  grid-area: down;
}

.mobile-action-button {
  position: absolute;
  z-index: 14;
  right: calc(18px + var(--safe-right));
  bottom: calc(30px + var(--safe-bottom));
  display: none;
  width: 78px;
  height: 78px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  touch-action: none;
}

.mobile-action-button::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 3px solid var(--paper);
  border-radius: 50%;
  background: #071225;
  box-shadow:
    4px 4px 0 #020917,
    inset 0 0 0 3px #155eef;
  transform: scale(1);
}

.mobile-action-button span {
  position: relative;
  z-index: 1;
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  color: var(--paper);
  font: 18px/1 var(--pixel-font);
  pointer-events: none;
}

.mobile-action-button.is-pressed::before,
.mobile-action-button:active::before {
  background: #155eef;
  box-shadow:
    2px 2px 0 #020917,
    inset 0 0 0 3px #72a5ff;
  transform: scale(0.94);
}

.hud {
  position: absolute;
  z-index: 10;
  top: calc(10px + var(--safe-top));
  right: 10px;
  left: 10px;
  pointer-events: none;
  filter: drop-shadow(3px 4px 0 rgb(7 18 37 / 58%));
}

.hud-top {
  display: grid;
  grid-template-columns: minmax(112px, 1fr) 72px 72px 92px 42px;
  gap: 5px;
}

.score-block,
.hud-pill,
.pause-button {
  min-height: 43px;
  border: 2px solid rgb(247 244 236 / 82%);
  background: rgb(7 18 37 / 86%);
}

.score-block,
.hud-pill {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4px 8px;
}

.score-block strong {
  color: var(--paper);
  font-size: 18px;
  line-height: 1;
}

.hud-pill {
  align-items: center;
}

.hud-pill strong {
  color: #d9e4f8;
  font-size: 13px;
  line-height: 1.1;
}

.multiplier-pill strong {
  color: #75a9ff;
  font-size: 17px;
}

.lives-pill strong {
  display: flex;
  gap: 5px;
  margin-top: 2px;
}

.lives-pill i {
  width: 13px;
  height: 9px;
  border: 1px solid var(--paper);
  background: var(--electric);
  box-shadow: 2px 2px 0 #071225;
}

.lives-pill i.is-lost {
  border-color: #60708e;
  background: #263858;
  opacity: 0.48;
}

.pause-button {
  display: grid;
  width: 38px;
  min-height: 43px;
  place-items: center;
  padding: 0;
  color: var(--paper);
  font-size: 18px;
  font-weight: 1000;
  pointer-events: auto;
}

.caffeine-panel {
  margin-top: 5px;
  padding: 7px 8px 8px;
  border: 2px solid rgb(247 244 236 / 72%);
  background: rgb(7 18 37 / 86%);
}

.caffeine-copy {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.caffeine-copy span {
  color: #aab9d6;
}

.caffeine-copy strong {
  overflow: hidden;
  color: var(--paper);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.caffeine-copy b {
  color: #80b0ff;
  font-size: 12px;
}

.caffeine-track {
  position: relative;
  height: 9px;
  overflow: hidden;
  border: 1px solid #9eb2d7;
  background: #102a5c;
}

.caffeine-track span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: linear-gradient(90deg, #155eef, #72a5ff);
  box-shadow: 0 0 12px #3b82f6;
  transition: width 150ms linear;
}

.caffeine-track i {
  position: absolute;
  z-index: 1;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgb(247 244 236 / 65%);
}

.caffeine-track i:nth-of-type(1) {
  left: 20%;
}

.caffeine-track i:nth-of-type(2) {
  left: 40%;
}

.caffeine-track i:nth-of-type(3) {
  left: 60%;
}

.caffeine-track i:nth-of-type(4) {
  left: 80%;
}

.stage-2 .caffeine-track span,
.stage-2 .multiplier-pill strong {
  filter: brightness(1.18);
}

.stage-3 .caffeine-track span,
.stage-4 .caffeine-track span {
  animation: caffeine-pulse 520ms steps(2, end) infinite;
}

.stage-4 .hud {
  filter:
    drop-shadow(3px 4px 0 rgb(7 18 37 / 58%))
    drop-shadow(0 0 8px rgb(59 130 246 / 72%));
}

.countdown {
  position: absolute;
  z-index: 22;
  inset: 0;
  display: none;
  place-items: center;
  background: rgb(7 18 37 / 26%);
  color: var(--paper);
  font-size: clamp(78px, 28vw, 132px);
  font-weight: 1000;
  letter-spacing: -0.08em;
  text-shadow:
    5px 0 var(--primary),
    -5px 0 var(--primary),
    0 5px var(--primary),
    0 -5px var(--primary),
    9px 10px var(--ink);
}

.countdown.is-visible {
  display: grid;
}

.countdown.is-run {
  font-size: clamp(55px, 18vw, 86px);
  letter-spacing: -0.04em;
}

.countdown.is-pop {
  animation: countdown-pop 620ms steps(5, end) both;
}

.game-overlay {
  position: absolute;
  z-index: 30;
  inset: 0;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgb(7 18 37 / 74%);
  backdrop-filter: blur(2px);
}

.game-overlay.is-visible {
  display: grid;
  animation: overlay-in 180ms steps(3, end) both;
}

.overlay-card {
  width: min(100%, 360px);
  padding: 24px 20px 20px;
  border: 3px solid var(--paper);
  background:
    linear-gradient(135deg, rgb(21 94 239 / 22%), transparent 45%),
    var(--ink);
  box-shadow:
    8px 9px 0 #05102a,
    inset 0 0 0 3px #0f357d;
  text-align: center;
}

.overlay-card h2 {
  margin: 8px 0 20px;
  color: var(--paper);
  font-size: clamp(30px, 9vw, 44px);
  font-weight: 1000;
  letter-spacing: -0.07em;
  text-shadow: 4px 4px 0 var(--primary);
}

.tutorial-card ul {
  display: grid;
  gap: 9px;
  margin: 0 0 21px;
  padding: 0;
  list-style: none;
  text-align: left;
}

.tutorial-card li {
  display: grid;
  grid-template-columns: 31px 1fr;
  align-items: center;
  gap: 9px;
  color: #dce5f4;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.3;
}

.tutorial-card li span {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border: 2px solid #9eb2d7;
  background: #0c2f73;
  color: var(--paper);
  font-size: 15px;
}

.overlay-actions {
  display: grid;
  gap: 12px;
}

.collision-banner {
  position: absolute;
  z-index: 21;
  top: 43%;
  left: 50%;
  display: none;
  width: min(84%, 330px);
  padding: 13px 16px;
  border: 3px solid var(--paper);
  background: var(--primary);
  box-shadow: 7px 8px 0 var(--ink);
  text-align: center;
  transform: translate(-50%, -50%) rotate(-2deg);
}

.collision-banner.is-visible {
  display: block;
  animation: collision-in 250ms steps(3, end) both;
}

.collision-banner strong {
  display: block;
  font-size: 24px;
  line-height: 1;
  text-shadow: 3px 3px 0 var(--deep);
}

.collision-banner span {
  display: block;
  margin-top: 5px;
  color: #dce5f4;
  font-size: 10px;
  font-weight: 800;
}

.game-toast {
  position: absolute;
  z-index: 16;
  right: 18px;
  bottom: calc(30px + var(--safe-bottom));
  left: 18px;
  display: none;
  padding: 9px 12px;
  border: 2px solid #b8c8e8;
  background: rgb(7 18 37 / 88%);
  color: var(--paper);
  font-size: 10px;
  font-weight: 900;
  text-align: center;
  box-shadow: 4px 4px 0 rgb(7 18 37 / 72%);
}

.game-toast.is-visible {
  display: block;
  animation: toast-in 220ms steps(3, end) both;
}

.game-over-panel {
  position: absolute;
  right: 20px;
  bottom: calc(18px + var(--safe-bottom));
  left: 20px;
  padding: 18px;
  border: 3px solid var(--paper);
  background:
    linear-gradient(180deg, rgb(21 94 239 / 22%), transparent 38%),
    rgb(7 18 37 / 94%);
  box-shadow:
    8px 9px 0 rgb(7 18 37 / 75%),
    inset 0 0 0 3px #10357c;
  text-align: center;
}

.game-over-panel h2 {
  margin: 1px 0 8px;
  color: var(--paper);
  font-size: clamp(42px, 13vw, 62px);
  font-weight: 1000;
  letter-spacing: -0.08em;
  line-height: 0.95;
  text-shadow:
    4px 0 var(--primary),
    -4px 0 var(--primary),
    0 4px var(--primary),
    0 -4px var(--primary),
    7px 8px var(--ink);
}

.new-record {
  display: none;
  width: max-content;
  margin: 0 auto 8px;
  padding: 5px 9px;
  background: var(--electric);
  color: var(--paper);
  font-size: 10px;
  font-weight: 1000;
  letter-spacing: 0.09em;
  transform: rotate(-2deg);
  box-shadow: 4px 4px 0 var(--ink);
}

.new-record.is-visible {
  display: block;
  animation: record-pulse 700ms steps(2, end) infinite;
}

.defeat-message {
  min-height: 30px;
  margin: 0 auto 10px;
  color: #c8d3e6;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.35;
}

.final-score {
  padding: 8px;
  border-block: 1px solid rgb(129 145 178 / 48%);
}

.final-score strong {
  display: block;
  margin-top: 2px;
  color: var(--paper);
  font-size: 30px;
  line-height: 1;
  letter-spacing: 0.05em;
}

.run-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 10px 0 13px;
}

.run-stats div {
  min-width: 0;
  padding: 2px 5px;
  border-right: 1px solid rgb(129 145 178 / 40%);
}

.run-stats div:last-child {
  border: 0;
}

.run-stats dt {
  overflow: hidden;
  color: #8fa2c4;
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run-stats dd {
  margin: 4px 0 0;
  color: var(--paper);
  font-size: 12px;
  font-weight: 1000;
}

.game-over-actions {
  display: grid;
  gap: 10px;
}

.error-screen {
  place-items: center;
  padding: 24px;
  background:
    repeating-linear-gradient(135deg, rgb(59 130 246 / 9%) 0 8px, transparent 8px 16px),
    var(--ink);
}

.error-screen.is-active {
  display: grid;
}

.error-screen .overlay-card p:not(.eyebrow) {
  margin: 0 0 20px;
  color: #c8d3e6;
  font-size: 12px;
  line-height: 1.5;
}

.is-shaking #gameCanvas,
.is-shaking .hud {
  animation: danger-shake 180ms steps(2, end) infinite;
}

.motion-reduced * {
  animation-duration: 1ms !important;
  animation-iteration-count: 1 !important;
  scroll-behavior: auto !important;
  transition-duration: 1ms !important;
}

.motion-reduced.is-shaking #gameCanvas,
.motion-reduced.is-shaking .hud {
  animation: none;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

/* Balance instrumentation is opt-in and never participates in the normal UI. */
.balance-debug[hidden],
.balance-final-report[hidden] {
  display: none !important;
}

.balance-debug,
.balance-final-report {
  position: absolute;
  z-index: 34;
  border: 3px solid #f6c453;
  background: rgb(7 18 37 / 97%);
  color: #f7f4ec;
  box-shadow: 5px 5px 0 #020917;
  font-family: var(--pixel-font);
}

.balance-debug {
  top: 68px;
  right: 12px;
  width: min(31vw, 330px);
  max-height: calc(100% - 82px);
  padding: 9px;
  overflow: auto;
}

.balance-debug > strong,
.balance-final-report > strong {
  color: #f6c453;
  font-size: 10px;
}

.balance-debug pre,
.balance-final-report pre {
  margin: 7px 0 0;
  font: 400 8px/1.45 var(--pixel-font);
  white-space: pre-wrap;
}

.balance-debug fieldset {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 9px 0 0;
  padding: 7px;
  border: 2px solid #2b6cff;
}

.balance-debug legend,
.balance-debug label {
  font: 400 7px/1.25 var(--pixel-font);
}

.balance-debug label {
  display: grid;
  gap: 3px;
}

.balance-debug input,
.balance-debug select,
.balance-debug button {
  width: 100%;
  min-width: 0;
  height: 24px;
  padding: 3px 5px;
  border: 2px solid #f7f4ec;
  border-radius: 0;
  background: #0c2f73;
  color: #fff;
  font: 400 9px/1 var(--pixel-font);
}

.balance-debug button {
  height: auto;
  min-height: 30px;
  cursor: pointer;
  background: #123f91;
}

.balance-debug button:active {
  transform: translate(2px, 2px);
}

.balance-debug .balance-pattern-select {
  grid-column: 1 / -1;
}

.balance-final-report {
  top: 50%;
  left: 2%;
  width: min(34%, 430px);
  max-height: 84%;
  padding: 12px;
  overflow: auto;
  transform: translateY(-50%);
}

.balance-final-report pre {
  font-size: 8px;
  line-height: 1.6;
}

@media (max-height: 460px) {
  .balance-debug {
    width: min(33vw, 300px);
  }

  .balance-debug pre,
  .balance-final-report pre {
    font-size: 7px;
  }

  .balance-debug fieldset {
    gap: 4px;
    margin-top: 6px;
    padding: 5px;
  }

  .balance-debug input {
    height: 21px;
    font-size: 8px;
  }
}

@keyframes screen-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes overlay-in {
  from {
    opacity: 0;
    transform: scale(1.03);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes countdown-pop {
  0% {
    opacity: 0;
    transform: scale(1.7);
  }
  20% {
    opacity: 1;
    transform: scale(0.92);
  }
  55% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0.75);
  }
}

@keyframes collision-in {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.45) rotate(2deg);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(-2deg);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes caffeine-pulse {
  50% {
    filter: brightness(1.6);
  }
}

@keyframes record-pulse {
  50% {
    filter: brightness(1.35);
    transform: rotate(2deg) scale(1.04);
  }
}

@keyframes danger-shake {
  0% {
    transform: translate(0, 0);
  }
  25% {
    transform: translate(1px, -1px);
  }
  50% {
    transform: translate(-1px, 1px);
  }
  75% {
    transform: translate(1px, 1px);
  }
}

@media (min-width: 700px) and (min-height: 700px) {
  .game-app {
    border: 8px solid #0b2a67;
    border-radius: 0;
  }
}

@media (max-height: 680px) {
  .title-copy {
    top: calc(25px + var(--safe-top));
  }

  .game-logo {
    font-size: clamp(49px, 16vw, 70px);
  }

  .tagline {
    margin-top: 17px;
  }

  .title-actions {
    bottom: calc(12px + var(--safe-bottom));
    gap: 7px;
  }

  .primary-button {
    min-height: 51px;
  }

  .game-over-panel {
    padding: 13px 15px;
  }

  .game-over-panel h2 {
    font-size: 42px;
  }

  .defeat-message {
    margin-bottom: 7px;
  }

  .run-stats {
    margin: 7px 0 9px;
  }
}

/* Landscape gameplay layout */
.screen-art {
  object-position: center 62%;
}

.title-copy {
  top: 7%;
  right: auto;
  left: 7%;
  width: 38%;
  text-align: left;
}

.title-copy .game-logo {
  align-items: flex-start;
  gap: clamp(4px, 0.8vh, 9px);
  margin: 8px 0;
  font-size: clamp(54px, 8vw, 104px);
  line-height: 0.92;
}

.title-copy .tagline {
  margin: 15px 0 0;
  font-size: clamp(10px, 1.25vw, 16px);
}

.title-actions {
  right: 5%;
  bottom: 8%;
  left: auto;
  width: min(34%, 360px);
  gap: 8px;
}

.primary-button {
  min-height: clamp(42px, 7vh, 58px);
  font-size: clamp(14px, 1.7vw, 19px);
}

.record-chip strong {
  font-size: clamp(15px, 2vw, 20px);
}

.hud {
  top: calc(8px + var(--safe-top));
  right: 12px;
  left: 12px;
}

.hud-top {
  width: min(100%, 650px);
}

.caffeine-panel {
  width: min(100%, 650px);
  padding-block: 5px 6px;
}

.caffeine-copy {
  margin-bottom: 3px;
}

.game-overlay {
  padding: 12px;
}

.overlay-card {
  width: min(82%, 520px);
  padding: 16px 20px;
}

.overlay-card h2 {
  margin: 5px 0 12px;
  font-size: clamp(27px, 5vw, 43px);
}

.tutorial-card {
  width: min(88%, 690px);
}

.tutorial-card ul {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 16px;
  margin-bottom: 13px;
}

.tutorial-card li {
  font-size: clamp(9px, 1.25vw, 12px);
}

.game-over-panel {
  top: 7%;
  right: 5%;
  bottom: auto;
  left: auto;
  width: min(44%, 520px);
  padding: clamp(13px, 2.2vw, 22px);
}

.game-over-panel h2 {
  font-size: clamp(38px, 6vw, 68px);
}

.defeat-message {
  min-height: 0;
  margin-bottom: 6px;
}

.run-stats {
  margin-block: 7px 10px;
}

.game-over-actions {
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.collision-banner {
  top: 34%;
  width: min(54%, 470px);
}

.game-toast {
  right: auto;
  bottom: 18px;
  left: 50%;
  width: min(70%, 560px);
  transform: translateX(-50%);
}

.rotate-overlay {
  position: absolute;
  z-index: 100;
  inset: 0;
  display: none;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 24px;
  background:
    repeating-linear-gradient(135deg, rgb(59 130 246 / 8%) 0 8px, transparent 8px 16px),
    #071225;
  text-align: center;
}

.rotate-overlay h2 {
  margin: 0;
  color: var(--paper);
  font-size: clamp(34px, 11vw, 58px);
  letter-spacing: -0.07em;
  line-height: 0.95;
  text-shadow: 4px 4px 0 var(--primary);
}

.rotate-overlay p:last-child {
  margin: 3px 0 0;
  color: #b8c8e8;
  font-size: 12px;
  font-weight: 800;
}

.rotate-phone {
  color: var(--paper);
  font-size: 64px;
  line-height: 1;
  transform: rotate(90deg);
  animation: rotate-phone 1.6s steps(3, end) infinite;
}

@media (orientation: portrait) and (max-width: 700px) {
  .game-app {
    width: 100vw;
    height: 100dvh;
    max-height: none;
    aspect-ratio: auto;
  }

  .rotate-overlay {
    display: grid;
  }
}

@media (hover: none) and (pointer: coarse), (max-width: 900px) and (max-height: 600px) {
  .virtual-joystick,
  .mobile-action-button {
    display: grid;
  }
}

@media (max-height: 470px) {
  :root {
    --joystick-base-size: 92px;
    --joystick-knob-size: 40px;
    --joystick-touch-area: 120px;
    --joystick-left-offset: 0px;
    --joystick-bottom-offset: 0px;
  }

  .eyebrow {
    font-size: 8px;
  }

  .title-copy {
    top: 5%;
  }

  .title-copy .game-logo {
    gap: 3px;
    margin-block: 5px;
    font-size: clamp(44px, 8vw, 78px);
  }

  .title-actions {
    bottom: 5%;
  }

  .preference-row {
    display: none;
  }

  .record-chip {
    padding-block: 4px;
  }

  .mobile-action-button {
    right: 18px;
    bottom: calc(22px + var(--safe-bottom));
    width: 68px;
    height: 68px;
  }

  .mobile-action-button span {
    font-size: 16px;
  }

  .dpad-button {
    font-size: 14px;
  }

  .game-over-panel {
    top: 3%;
    width: min(48%, 500px);
    padding: 10px 14px;
  }

  .game-over-panel h2 {
    margin-bottom: 3px;
    font-size: 35px;
  }

  .final-score {
    padding: 4px;
  }

  .final-score strong {
    font-size: 23px;
  }

  .primary-button.compact,
  .secondary-button {
    min-height: 38px;
  }
}

@keyframes rotate-phone {
  50% {
    transform: rotate(90deg) scale(1.08);
  }
}

/* Clarity upgrade */
.hud-top {
  grid-template-columns: minmax(128px, 1fr) 68px 76px 72px 88px 96px 42px;
  width: min(100%, 790px);
}

.score-block > span,
.hud-pill > span,
.caffeine-copy > span,
.heart-rate-copy > span {
  font-size: 11px;
  line-height: 1;
}

.score-block strong {
  font-size: 20px;
}

.hud-pill strong,
.coffee-pill b {
  font-size: 15px;
}

.coffee-pill strong {
  display: flex;
  align-items: center;
  gap: 4px;
}

.multiplier-pill strong {
  font-size: 17px;
}

.sequence-pill strong {
  color: #f6c453;
}

.vitals-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  width: min(100%, 790px);
  margin-top: 5px;
}

.vital-panel {
  min-width: 0;
  width: auto;
  margin: 0;
  padding: 7px 9px 8px;
  border: 2px solid rgb(247 244 236 / 72%);
  background: rgb(7 18 37 / 88%);
}

.caffeine-copy,
.heart-rate-copy {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  font-weight: 900;
  letter-spacing: 0.05em;
}

.caffeine-copy strong {
  color: var(--paper);
  font-size: 13px;
  text-align: center;
}

.caffeine-copy b {
  color: #80b0ff;
  font-size: 15px;
}

.heart-rate-copy span,
.caffeine-copy span {
  color: #b8c8e8;
}

.heart-rate-copy strong {
  overflow: hidden;
  color: var(--paper);
  font-size: 13px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.heart-rate-copy b {
  color: #f7d27a;
  font-size: 13px;
  white-space: nowrap;
}

.caffeine-track,
.heart-rate-track {
  height: 13px;
}

.heart-rate-track {
  position: relative;
  overflow: hidden;
  border: 1px solid #9eb2d7;
  background:
    linear-gradient(
      90deg,
      #173c79 0 62.5%,
      #66571e 62.5% 83.33%,
      #6f2533 83.33% 100%
    );
}

.heart-rate-track > span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 16.67%;
  border-right: 3px solid var(--paper);
  background: rgb(247 244 236 / 20%);
  box-shadow: 0 0 9px #f7f4ec;
  transition: width 180ms linear;
}

.heart-rate-track[data-zone="critical"] {
  animation: caffeine-pulse 520ms steps(2, end) infinite;
}

.task-context-panel {
  position: absolute;
  z-index: 18;
  top: 125px;
  right: 14px;
  display: none;
  width: min(290px, calc(100% - 28px));
  padding: 14px;
  border: 3px solid #72a5ff;
  background: rgb(7 18 37 / 94%);
  box-shadow: 7px 8px 0 rgb(7 18 37 / 70%);
  color: var(--paper);
  pointer-events: none;
}

.task-context-panel.is-visible {
  display: grid;
  gap: 10px;
  animation: context-in 180ms steps(3, end) both;
}

.task-context-panel[data-condition="insufficient"] {
  border-color: #aab4c5;
}

.task-context-panel[data-condition="heart_high"] {
  border-color: #ff7474;
}

.task-context-panel[data-condition="perfect"] {
  border-color: #f6c453;
}

.task-context-panel > strong {
  color: var(--paper);
  font-size: 18px;
  line-height: 1;
}

.task-context-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.task-context-grid section {
  display: grid;
  align-content: start;
  gap: 5px;
  min-width: 0;
}

.task-context-grid span,
.task-context-panel small {
  color: #9eb2d7;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.07em;
}

.task-context-grid b {
  color: var(--paper);
  font-size: 15px;
  line-height: 1.1;
}

.task-context-grid section:last-child b:last-child {
  color: #f6c453;
  font-size: 18px;
}

.task-context-panel small {
  padding-top: 7px;
  border-top: 1px solid rgb(158 178 215 / 45%);
  color: #dce5f4;
}

.game-feedback {
  position: absolute;
  z-index: 24;
  top: 51%;
  left: 50%;
  display: none;
  width: min(84%, 380px);
  padding: 16px 20px;
  border: 3px solid #72a5ff;
  background: rgb(7 18 37 / 94%);
  box-shadow: 9px 10px 0 rgb(7 18 37 / 72%);
  color: var(--paper);
  text-align: center;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.game-feedback.is-visible {
  display: grid;
  gap: 5px;
  animation: feedback-cycle 2s steps(6, end) both;
}

.game-feedback[data-kind="task"] {
  border-color: #f6c453;
}

.game-feedback[data-kind="loss"] {
  border-color: #ff7474;
}

.game-feedback[data-kind="coffee"] {
  border-color: #72a5ff;
}

.game-feedback > strong {
  color: #f6c453;
  font-size: 36px;
  line-height: 1;
  text-shadow: 3px 3px 0 #123984;
}

.game-feedback[data-kind="loss"] > strong {
  color: #ff8888;
}

.game-feedback[data-kind="coffee"] > strong {
  color: #80b0ff;
}

.game-feedback > span {
  font-weight: 1000;
}

.game-feedback > span:nth-of-type(1) {
  font-size: 18px;
}

.game-feedback > span:nth-of-type(2) {
  color: #dce5f4;
  font-size: 16px;
}

.game-feedback > b {
  color: #f6c453;
  font-size: 18px;
}

.game-feedback.is-compact {
  width: min(78%, 460px);
  padding: 12px 16px;
}

.game-feedback.is-compact > strong:empty,
.game-feedback.is-compact > span:empty,
.game-feedback.is-compact > b:empty {
  display: none;
}

.game-feedback.is-compact > span:nth-of-type(1) {
  font-size: 16px;
}

.score-debug {
  position: absolute;
  z-index: 30;
  top: 125px;
  left: 12px;
  width: 250px;
  padding: 10px;
  border: 2px solid #f6c453;
  background: rgb(7 18 37 / 95%);
  color: #f7f4ec;
  pointer-events: none;
}

.score-debug strong {
  color: #f6c453;
  font-size: 11px;
}

.score-debug pre {
  margin: 6px 0 0;
  font: 400 11px/1.35 var(--pixel-font);
  white-space: pre-wrap;
}

.game-over-panel {
  top: 50%;
  right: 3%;
  bottom: auto;
  left: auto;
  width: min(58%, 620px);
  max-height: none;
  padding: 15px 18px;
  overflow: visible;
  transform: translateY(-50%);
}

.game-over-panel h2 {
  margin: 0 0 8px;
  font-size: clamp(28px, 3.2vw, 42px);
  letter-spacing: -0.055em;
}

.final-summary {
  display: flex;
  justify-content: center;
  gap: 0;
  margin: 0 0 10px;
  padding: 7px 0;
  border-block: 1px solid rgb(129 145 178 / 48%);
}

.final-summary div {
  min-width: 0;
  padding: 0 15px;
  border-right: 1px solid rgb(129 145 178 / 48%);
}

.final-summary div:last-child {
  border: 0;
}

.final-summary dt {
  color: #9eb2d7;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.final-summary dd {
  margin: 3px 0 0;
  color: var(--paper);
  font-size: 18px;
  font-weight: 1000;
}

.final-result-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.final-result-table th,
.final-result-table td {
  padding: 6px 8px;
}

.final-result-table thead th {
  border-bottom: 2px solid #72a5ff;
  color: #72a5ff;
  font-size: 16px;
  letter-spacing: 0.06em;
}

.final-result-table thead th:last-child,
.final-result-table td {
  text-align: right;
}

.final-result-table tbody th {
  color: #dce5f4;
  font-size: 16px;
  font-weight: 800;
}

.final-result-table tbody td {
  color: var(--paper);
  font-size: 18px;
  font-weight: 1000;
}

.final-result-table tbody tr + tr {
  border-top: 1px solid rgb(129 145 178 / 28%);
}

.final-result-table tr[hidden] {
  display: none;
}

.final-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding: 9px 8px;
  border-block: 3px solid #f6c453;
  color: #f6c453;
}

.final-total span,
.final-total strong {
  font-size: 30px;
  font-weight: 1000;
  line-height: 1;
}

.game-over-actions {
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

@keyframes context-in {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes feedback-cycle {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.18);
  }
  10%,
  78% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -55%) scale(0.96);
  }
}

@media (max-height: 520px) {
  .hud {
    top: calc(6px + var(--safe-top));
    right: 8px;
    left: 8px;
  }

  .hud-top {
    grid-template-columns: minmax(122px, 1fr) 72px 94px 42px;
    width: min(100%, 520px);
    gap: 4px;
  }

  .hud-top > .hud-pill:not(.coffee-pill):not(.lives-pill) {
    display: none;
  }

  .score-block,
  .hud-pill,
  .pause-button {
    min-height: 42px;
  }

  .vitals-panel {
    width: min(100%, 520px);
    margin-top: 4px;
    gap: 4px;
  }

  .vital-panel {
    padding: 6px 8px 7px;
  }

  .task-context-panel {
    top: 108px;
    right: 8px;
    width: 260px;
    padding: 11px;
  }

  .task-context-panel.is-visible {
    gap: 7px;
  }

  .game-feedback {
    width: min(76%, 350px);
    padding: 13px 16px;
  }

  .game-over-panel {
    top: 50%;
    right: 2%;
    width: min(64%, 560px);
    padding: 10px 13px;
  }

  .game-over-panel h2 {
    margin-bottom: 5px;
    font-size: 28px;
  }

  .final-summary {
    margin-bottom: 5px;
    padding-block: 4px;
  }

  .final-summary div {
    padding-inline: 10px;
  }

  .final-result-table th,
  .final-result-table td {
    padding: 4px 7px;
  }

  .final-total {
    margin-top: 5px;
    padding-block: 6px;
  }

  .final-total span,
  .final-total strong {
    font-size: 28px;
  }

  .game-over-actions {
    margin-top: 6px;
  }

  .primary-button.compact,
  .secondary-button {
    min-height: 38px;
  }
}

/* Unified pixel interface */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.game-app,
.loading-card,
.record-chip,
.icon-button,
.primary-button,
.secondary-button,
.text-button,
.pause-button,
.dpad-button,
.dpad-center,
.overlay-card,
.game-over-panel,
.new-record,
.score-debug {
  border-radius: 0;
}

.loading-card,
.record-chip,
.icon-button,
.overlay-card,
.game-over-panel {
  border-color: var(--paper);
  background: var(--ink);
  box-shadow: 6px 6px 0 #020917;
}

.game-overlay {
  background: rgb(7 18 37 / 84%);
  backdrop-filter: none;
}

.primary-button,
.secondary-button,
.icon-button,
.text-button,
.pause-button {
  font-family: var(--pixel-font);
  font-weight: 400;
  text-shadow: 2px 2px 0 #071225;
  transition: none;
}

.primary-button,
.secondary-button,
.icon-button {
  border: 3px solid var(--paper);
  background: #155eef;
  box-shadow: 4px 4px 0 #071225;
}

.secondary-button,
.icon-button {
  background: #0c2f73;
}

.primary-button:hover {
  filter: none;
}

.primary-button:active,
.secondary-button:active,
.icon-button:active,
.pause-button:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 #071225;
}

.text-button {
  border: 2px solid #9eb2d7;
  background: #071225;
  text-decoration: none;
  box-shadow: 3px 3px 0 #020917;
}

.play-mark {
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 11px solid var(--paper);
  filter: drop-shadow(2px 2px 0 #071225);
}

.control-hint {
  font-size: 10px;
}

.eyebrow,
.record-chip span,
.icon-button {
  font-size: 10px;
}

.tutorial-card li {
  font-weight: 400;
}

.tutorial-card li span {
  font-size: 10px;
  line-height: 1;
}

.virtual-dpad {
  filter: drop-shadow(4px 4px 0 #071225);
}

.dpad-button,
.dpad-center {
  border: 3px solid var(--paper);
  background: #071225;
}

.dpad-button::before {
  content: "";
  width: 0;
  height: 0;
  border-style: solid;
}

.dpad-up::before {
  border-width: 0 8px 11px;
  border-color: transparent transparent var(--paper);
}

.dpad-down::before {
  border-width: 11px 8px 0;
  border-color: var(--paper) transparent transparent;
}

.dpad-left::before {
  border-width: 8px 11px 8px 0;
  border-color: transparent var(--paper) transparent transparent;
}

.dpad-right::before {
  border-width: 8px 0 8px 11px;
  border-color: transparent transparent transparent var(--paper);
}

.dpad-button.is-pressed,
.dpad-button:active {
  border-color: var(--paper);
  background: #155eef;
  box-shadow: none;
}

.hud.pixel-hud {
  position: absolute;
  z-index: 20;
  top: calc(10px + var(--safe-top));
  right: auto;
  left: calc(14px + var(--safe-left));
  display: grid;
  grid-template-columns:
    minmax(116px, 1.05fr)
    minmax(126px, 1.1fr)
    minmax(118px, 1fr)
    minmax(82px, 0.8fr)
    48px;
  column-gap: clamp(8px, 1.5vw, 24px);
  align-items: start;
  width: calc(100% - 28px - var(--safe-left) - var(--safe-right));
  max-width: none;
  height: auto;
  overflow: visible;
  border: 0;
  background: transparent;
  filter: none;
  pointer-events: none;
}

.hud-module,
.founder-status,
.pause-button {
  width: max-content;
  height: 48px;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.hud.pixel-hud > :not(:first-child) {
  border-left: 0;
}

.founder-status {
  display: grid;
  grid-template-columns: 46px 1fr;
  align-items: center;
  justify-self: start;
  gap: 7px;
}

.avatar-frame {
  display: block;
  width: 44px;
  height: 44px;
  overflow: hidden;
  border: 0;
  background: transparent;
  filter: drop-shadow(3px 3px 0 #020917);
}

.avatar-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.life-readout {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.life-readout .hud-label {
  line-height: 1;
}

.lives-pill .life-segments {
  display: grid;
  width: 82px;
  height: 12px;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.life-segments i {
  display: block;
  min-width: 0;
  border: 1px solid #f7f4ec;
  background: #ff4f5f;
  box-shadow: 2px 2px 0 #020917;
}

.life-segments i.is-empty {
  border-color: #9eb2d7;
  background: #102448;
}

.lives-pill.is-damaged .life-segments {
  animation: life-bar-hit 120ms steps(2, end) 4;
}

.heart-monitor {
  display: grid;
  grid-template-columns: 92px 48px;
  align-items: center;
  justify-self: center;
  gap: 5px;
}

.heart-monitor canvas {
  display: block;
  width: 92px;
  height: 30px;
  min-width: 0;
  border: 0;
  background: transparent;
  filter: drop-shadow(2px 2px 0 #020917);
  image-rendering: pixelated;
}

.heart-monitor > .bpm-readout {
  position: static;
  inset: auto;
  display: grid;
  width: auto;
  min-width: 0;
  height: auto;
  align-content: center;
  justify-items: center;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  transition: none;
}

.bpm-readout > span {
  color: #9eb2d7;
  font-size: 8px;
  line-height: 1;
}

.heart-monitor .bpm-readout strong {
  color: #f7f4ec;
  font-size: 18px;
  font-weight: 400;
  line-height: 1.05;
  text-align: center;
  white-space: nowrap;
}

.heart-monitor[data-zone="attention"] {
  animation: none;
}

.heart-monitor[data-zone="critical"] {
  animation: none;
}

.caffeine-meter {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  justify-self: center;
  gap: 7px;
  padding: 0;
  overflow: visible;
}

.caffeine-meter > span {
  position: static;
  inset: auto;
  width: auto;
  height: auto;
  background: none;
  box-shadow: none;
  filter: none !important;
  animation: none !important;
  transition: none;
}

.hud-label,
.score-block > span {
  color: #f7f4ec;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0;
  text-shadow:
    2px 2px 0 #020917,
    -1px -1px 0 #020917,
    1px -1px 0 #020917,
    -1px 1px 0 #020917;
}

.caffeine-cups {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  filter: drop-shadow(2px 2px 0 #020917);
}

.caffeine-meter .caffeine-cups i {
  position: relative;
  inset: auto;
  left: auto;
  display: block;
  width: 15px;
  height: 17px;
  flex: 0 0 15px;
  border: 2px solid var(--paper);
  border-top-width: 3px;
  background: #102a5c;
}

.caffeine-cups i::before {
  content: "";
  position: absolute;
  right: 2px;
  bottom: 2px;
  left: 2px;
  height: 0;
  background: #f2a65a;
}

.caffeine-cups i::after {
  content: "";
  position: absolute;
  top: 3px;
  right: -6px;
  width: 4px;
  height: 7px;
  border: 2px solid var(--paper);
  border-left: 0;
  background: transparent;
}

.caffeine-cups i[data-fill="half"]::before {
  height: 5px;
}

.caffeine-cups i[data-fill="full"]::before {
  height: 10px;
}

.caffeine-cups i.is-filling {
  animation: cup-fill-step 320ms steps(2, end);
}

.caffeine-cups i.is-emptying {
  animation: cup-empty-step 320ms steps(2, end);
}

.score-block.hud-module {
  display: grid;
  align-content: center;
  justify-items: end;
  justify-self: end;
  min-height: 0;
  padding: 0;
}

.score-block.hud-module strong {
  color: var(--paper);
  font-size: 16px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0;
  text-shadow:
    3px 3px 0 #020917,
    -1px -1px 0 #020917,
    1px -1px 0 #020917,
    -1px 1px 0 #020917;
}

.pause-button {
  position: relative;
  display: grid;
  width: 48px;
  height: 48px;
  min-height: 0;
  padding: 0;
  place-items: center;
  justify-self: end;
  border: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  pointer-events: auto;
}

.pause-button::before {
  content: "";
  position: absolute;
  inset: 2px;
  border: 2px solid var(--paper);
  border-radius: 50%;
  background: #071225;
  box-shadow:
    3px 3px 0 #020917,
    inset 0 0 0 2px #155eef;
  transform: scale(1);
}

.pause-mark,
.pause-mark::after {
  display: block;
  width: 4px;
  height: 16px;
  background: var(--paper);
  box-shadow: 2px 2px 0 #020917;
}

.pause-mark {
  position: relative;
  z-index: 1;
  left: -5px;
}

.pause-mark::after {
  content: "";
  position: absolute;
  left: 10px;
  box-shadow: none;
}

.pause-button:active {
  transform: none;
  box-shadow: none;
}

.pause-button:active::before {
  background: #155eef;
  box-shadow:
    2px 2px 0 #020917,
    inset 0 0 0 2px #72a5ff;
  transform: scale(0.92);
}

.bpm-readout > span,
.heart-monitor .bpm-readout strong {
  text-shadow:
    2px 2px 0 #020917,
    -1px -1px 0 #020917,
    1px -1px 0 #020917,
    -1px 1px 0 #020917;
}

.hud-internal-values {
  display: none !important;
}

.score-debug {
  top: 68px;
  width: 275px;
  background: #071225;
}

.game-over-panel {
  top: 50%;
  right: 3%;
  bottom: auto;
  left: auto;
  width: min(61%, 660px);
  max-height: none;
  padding: 15px 18px;
  overflow: visible;
  border: 4px solid var(--paper);
  background: #071225;
  box-shadow:
    7px 7px 0 #020917,
    inset 0 0 0 3px #155eef;
  transform: translateY(-50%);
}

.game-over-panel h2 {
  margin: 0 0 9px;
  color: var(--paper);
  font-size: clamp(24px, 2.6vw, 34px);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.25;
  text-shadow: 3px 3px 0 #155eef;
}

.new-record {
  border: 2px solid var(--paper);
  background: #155eef;
  font-weight: 400;
}

.final-summary {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin: 0 0 9px;
  padding: 8px 4px;
  border-block: 3px solid #365991;
  color: #9eb2d7;
  font-size: 10px;
  line-height: 1.35;
}

.final-summary span {
  white-space: nowrap;
}

.final-summary b {
  color: var(--paper);
  font-weight: 400;
}

.final-result-table {
  width: 100%;
  border: 3px solid #365991;
  border-collapse: collapse;
  table-layout: fixed;
  background: #071225;
  text-align: left;
}

.final-result-table th,
.final-result-table td {
  padding: 6px 9px;
  border: 0;
  font-weight: 400;
}

.final-result-table thead th {
  border-bottom: 3px solid #72a5ff;
  color: #72a5ff;
  font-size: 12px;
  letter-spacing: 0;
}

.final-result-table thead th:last-child,
.final-result-table td {
  width: 34%;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.final-result-table tbody th {
  color: #dce5f4;
  font-size: 11px;
}

.final-result-table tbody td {
  color: var(--paper);
  font-size: 13px;
}

.final-result-table tbody tr {
  visibility: hidden;
}

.final-result-table tbody tr.is-revealed {
  visibility: visible;
  animation: score-row-in 120ms steps(2, end) both;
}

.final-result-table tbody tr + tr {
  border-top: 2px solid #263858;
}

.final-result-table tr[hidden] {
  display: none;
}

.final-total {
  visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding: 9px 8px;
  border: 3px solid #f6c453;
  color: #f6c453;
  background: #071225;
}

.final-total.is-revealed {
  visibility: visible;
  animation: final-total-pulse 420ms steps(3, end) 2;
}

.final-total span {
  font-size: 17px;
  font-weight: 400;
}

.final-total strong {
  font-size: 24px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.score-skip-hint {
  min-height: 10px;
  margin: 6px 0 0;
  color: #8191b2;
  font-size: 10px;
  line-height: 1;
}

.score-skip-hint.is-hidden {
  visibility: hidden;
}

.game-over-actions {
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 7px;
}

.game-over-actions .primary-button,
.game-over-actions .secondary-button {
  min-height: 40px;
  font-size: 10px;
  box-shadow: 4px 4px 0 #020917;
}

.rotate-phone {
  position: relative;
  width: 70px;
  height: 42px;
  border: 5px solid var(--paper);
  background: #0c2f73;
  transform: none;
}

.rotate-phone::after {
  content: "";
  position: absolute;
  top: 12px;
  right: 4px;
  width: 5px;
  height: 10px;
  background: var(--paper);
}

@keyframes heart-hit {
  50% {
    opacity: 0;
  }
}

@keyframes life-bar-hit {
  50% {
    border-color: #ff4f5f;
    background: #3a1020;
  }
}

@keyframes heart-threatened {
  50% {
    opacity: 0.35;
    transform: translateY(1px);
  }
}

@keyframes monitor-attention {
  50% {
    box-shadow: 0 0 0 2px #f2a65a;
  }
}

@keyframes monitor-critical {
  50% {
    box-shadow: 0 0 0 3px #ff5f6d;
  }
}

@keyframes cup-fill-step {
  25%,
  75% {
    box-shadow:
      -3px -4px 0 -2px #f6c453,
      5px -6px 0 -2px #f7f4ec;
  }
  50% {
    transform: translateY(-2px);
  }
}

@keyframes cup-empty-step {
  50% {
    opacity: 0.55;
    transform: translateY(2px);
  }
}

@keyframes score-row-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes final-total-pulse {
  50% {
    transform: translate(2px, -2px);
  }
}

@media (max-height: 520px) {
  .hud.pixel-hud {
    top: calc(8px + var(--safe-top));
    right: auto;
    left: calc(10px + var(--safe-left));
    grid-template-columns:
      minmax(112px, 1.05fr)
      minmax(118px, 1.05fr)
      minmax(111px, 1fr)
      minmax(78px, 0.75fr)
      44px;
    column-gap: clamp(7px, 1.35vw, 13px);
    width: calc(100% - 20px - var(--safe-left) - var(--safe-right));
    height: auto;
  }

  .hud-module,
  .founder-status,
  .pause-button {
    height: 44px;
  }

  .founder-status {
    grid-template-columns: 38px 1fr;
    gap: 5px;
  }

  .avatar-frame {
    width: 38px;
    height: 38px;
  }

  .life-readout {
    gap: 3px;
  }

  .lives-pill .life-segments {
    width: 69px;
    height: 11px;
    gap: 1px;
  }

  .heart-monitor {
    grid-template-columns: 74px 41px;
    gap: 3px;
  }

  .heart-monitor canvas {
    width: 74px;
    height: 25px;
  }

  .heart-monitor .bpm-readout strong,
  .hud-label,
  .score-block > span {
    font-size: 10px;
  }

  .heart-monitor .bpm-readout strong {
    font-size: 15px;
  }

  .bpm-readout > span {
    font-size: 7px;
  }

  .caffeine-meter {
    gap: 4px;
  }

  .caffeine-cups {
    gap: 3px;
  }

  .caffeine-meter .caffeine-cups i {
    width: 12px;
    height: 15px;
    flex-basis: 12px;
  }

  .caffeine-cups i::after {
    right: -5px;
    width: 3px;
    height: 6px;
  }

  .score-block.hud-module strong {
    font-size: 16px;
  }

  .virtual-dpad {
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(3, 44px);
  }

  .pause-button {
    width: 44px;
    height: 44px;
  }

  .game-over-panel {
    top: 50%;
    right: 1.5%;
    width: min(68%, 570px);
    padding: 9px 11px;
  }

  .game-over-panel h2 {
    margin-bottom: 5px;
    font-size: 21px;
  }

  .final-summary {
    gap: 10px;
    margin-bottom: 5px;
    padding-block: 5px;
    font-size: 10px;
  }

  .final-result-table th,
  .final-result-table td {
    padding: 4px 7px;
  }

  .final-result-table thead th {
    font-size: 10px;
  }

  .final-result-table tbody th {
    font-size: 10px;
  }

  .final-result-table tbody td {
    font-size: 11px;
  }

  .final-total {
    margin-top: 5px;
    padding-block: 6px;
  }

  .final-total span {
    font-size: 14px;
  }

  .final-total strong {
    font-size: 19px;
  }

  .score-skip-hint {
    margin-top: 4px;
    font-size: 10px;
  }

  .game-over-actions {
    margin-top: 4px;
  }

  .game-over-actions .primary-button,
  .game-over-actions .secondary-button {
    min-height: 36px;
    font-size: 10px;
  }

  .eyebrow,
  .tutorial-card li {
    font-size: 10px;
  }
}
