/* =====================================================================
   PARK IT — FORM 42-B
   A page from a 1974 driver's-education manual, reproduced in ink on cream.
   Sections: TOKENS · RESET · PAGE · HEADER · STAGE FRAME · HUD ·
             OVERLAYS · SCORECARD · BUTTONS · TOUCH CONTROLS · TOAST ·
             UTILITIES · REDUCED MOTION
   ===================================================================== */

/* ============================== TOKENS ============================== */
:root {
  --paper: #efe9d9;
  --paper-2: #e6dec8;
  --paper-3: #d9cfb5;
  --ink: #1c3a55;
  --ink-2: #3d5573;
  --ink-3: #7a8899;
  --red: #b03a22;
  --green: #3a6b3f;
  --graphite: #4a463b;

  --rule: 1.5px solid var(--ink);
  --rule-dash: 1px dashed var(--ink-3);
  --shadow: 3px 3px 0 rgba(28, 58, 85, 0.12);

  --sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

/* =============================== RESET ============================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

h1,
h2,
h3,
p,
figure {
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

canvas {
  display: block;
}

[hidden] {
  display: none !important;
}

/* =============================== PAGE =============================== */
html {
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
}

body {
  position: relative;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Paper grain — fixed, non-interactive, nothing but tooth. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  opacity: 0.55;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
}

#app {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 26px 18px 46px;
}

/* ============================== HEADER ============================== */
.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding-bottom: 10px;
  border-bottom: var(--rule);
  margin-bottom: 20px;
}

.wordmark {
  font-family: var(--sans);
  font-size: 22px;
  font-weight: 700;
  font-variant: small-caps;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  line-height: 1;
}

.subtitle {
  margin-top: 7px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--ink-3);
  text-transform: uppercase;
}

.masthead-tail {
  display: flex;
  align-items: center;
  gap: 18px;
}

.mute-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  border: 1px solid var(--ink-3);
  background: var(--paper-2);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  border-radius: 2px;
  transition: transform 60ms ease;
}

.mute-btn:active {
  transform: translate(1px, 1px);
}

.mute-btn .mute-label {
  line-height: 1;
  white-space: nowrap;
}

.mute-btn .mute-cross {
  display: none;
}

.mute-btn[aria-pressed="true"] .mute-wave {
  display: none;
}

.mute-btn[aria-pressed="true"] .mute-cross {
  display: inline;
}

.mute-btn[aria-pressed="true"] {
  color: var(--red);
  border-color: var(--red);
}

.ledger {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink-2);
  white-space: nowrap;
}

/* =========================== STAGE FRAME ============================ */
#stage-wrap {
  position: relative;
}

#stage-frame {
  position: relative;
  padding: 8px;
  border: var(--rule);
  background: var(--paper);
  box-shadow: var(--shadow);
}

#stage {
  width: 100%;
  height: auto;
  aspect-ratio: 1200 / 760;
  image-rendering: auto;
  background: var(--paper);
  touch-action: manipulation;
}

/* Corner crosshairs on the frame. */
.xh {
  position: absolute;
  width: 13px;
  height: 13px;
  pointer-events: none;
}

.xh::before,
.xh::after {
  content: "";
  position: absolute;
  background: var(--ink);
}

.xh::before {
  left: 0;
  top: 6px;
  width: 13px;
  height: 1.5px;
}

.xh::after {
  top: 0;
  left: 6px;
  height: 13px;
  width: 1.5px;
}

.xh-tl { top: -6px; left: -6px; }
.xh-tr { top: -6px; right: -6px; }
.xh-bl { bottom: -6px; left: -6px; }
.xh-br { bottom: -6px; right: -6px; }

.fig-caption {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.2em;
  color: var(--ink-3);
  text-transform: uppercase;
}

/* ================================ HUD =============================== */
#hud {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 10px 5px;
  background: rgba(239, 233, 217, 0.92);
  border-bottom: 1px dashed var(--ink-3);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink);
  text-transform: uppercase;
  pointer-events: none;
}

.hud-cell {
  white-space: nowrap;
}

.hud-timer {
  color: var(--ink-2);
}

.hud-right {
  text-align: right;
  letter-spacing: 0.08em;
}

.hud-label {
  color: var(--ink-3);
  font-size: 9.5px;
}

.hud-sep {
  color: var(--ink-3);
  margin: 0 4px;
}

#spot-score {
  display: inline-block;
  min-width: 1.6em;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

#spot-score.is-penalty {
  color: var(--red);
}

#timer,
#total,
#spot-num {
  font-variant-numeric: tabular-nums;
}

/* ============================= OVERLAYS ============================= */
#overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  background: rgba(239, 233, 217, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  overflow: auto;
}

#overlay-inner {
  position: relative;
  width: 100%;
  max-width: 620px;
  background: var(--paper-2);
  border: var(--rule);
  box-shadow: 4px 4px 0 rgba(28, 58, 85, 0.14);
  padding: 34px 38px 32px;
  text-align: center;
}

#overlay-inner:focus {
  outline: none;
}

/* Crosshairs on the card corners (injected with the card markup). */
.xcorner {
  position: absolute;
  width: 11px;
  height: 11px;
  pointer-events: none;
}

.xcorner::before,
.xcorner::after {
  content: "";
  position: absolute;
  background: var(--ink-3);
}

.xcorner::before {
  left: 0;
  top: 5px;
  width: 11px;
  height: 1px;
}

.xcorner::after {
  top: 0;
  left: 5px;
  height: 11px;
  width: 1px;
}

.xcorner-tl { top: -6px; left: -6px; }
.xcorner-tr { top: -6px; right: -6px; }
.xcorner-bl { bottom: -6px; left: -6px; }
.xcorner-br { bottom: -6px; right: -6px; }

.card-kicker {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.card-title {
  margin-top: 12px;
  font-family: var(--sans);
  font-size: 27px;
  font-weight: 700;
  font-variant: small-caps;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  line-height: 1.15;
  color: var(--ink);
}

.card-title.is-small {
  font-size: 19px;
  letter-spacing: 0.2em;
}

.card-sub {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.07em;
  color: var(--ink-2);
}

.card-note {
  margin-top: 12px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: var(--ink-2);
}

.rule-dash {
  height: 0;
  border-top: var(--rule-dash);
  margin: 16px 0;
}

.card-best {
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--ink-3);
  text-transform: uppercase;
}

/* Countdown numerals, printed one per second. */
.countdown-num {
  font-family: var(--mono);
  font-size: 96px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.06em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.countdown-num.is-go {
  font-size: 62px;
  letter-spacing: 0.2em;
  color: var(--green);
}

/* Spot result block. */
.result-score {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 64px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.result-score .den {
  font-size: 24px;
  font-weight: 400;
  color: var(--ink-3);
  letter-spacing: 0.02em;
}

.result-reason {
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.09em;
  color: var(--ink-2);
}

.perfect-line {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--green);
  animation: flicker 900ms steps(2, end) infinite;
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  42% { opacity: 0.2; }
  58% { opacity: 0.95; }
  74% { opacity: 0.35; }
}

/* ============================== STAMPS ============================== */
.stamp {
  display: inline-block;
  margin-top: 20px;
  padding: 7px 20px 8px;
  border: 2px solid currentColor;
  font-family: var(--mono);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  text-indent: 0.3em;
  text-shadow: 0.5px 0.5px 0 rgba(0, 0, 0, 0.12);
  transform: rotate(-6deg);
  position: relative;
}

.stamp::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid currentColor;
  pointer-events: none;
}

.stamp.is-red { color: var(--red); }
.stamp.is-green { color: var(--green); }
.stamp.is-ink { color: var(--ink); }

.stamp.is-small {
  font-size: 12.5px;
  letter-spacing: 0.22em;
  padding: 5px 13px 6px;
  border-width: 1.5px;
  margin-top: 16px;
}

.stamp.is-small::before {
  inset: 2px;
  border-width: 1px;
}

/* ============================ SCORECARD ============================= */
.score-big {
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 96px;
  font-weight: 700;
  line-height: 0.92;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.score-big .den {
  font-size: 32px;
  font-weight: 400;
  color: var(--ink-3);
  letter-spacing: 0.01em;
}

.comment {
  margin-top: 6px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: var(--ink-2);
}

.sc-table {
  margin-top: 4px;
  text-align: left;
}

.sc-row {
  display: grid;
  grid-template-columns: 64px 1fr 58px;
  align-items: center;
  gap: 12px;
  padding: 8px 0 6px;
  border-top: var(--rule-dash);
}

.sc-left {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
}

.sc-bar {
  position: relative;
  height: 8px;
  background: var(--paper-3);
  border: 1px solid var(--ink-3);
}

.sc-bar > i {
  position: absolute;
  inset: 0 auto 0 0;
  display: block;
  background: var(--ink);
}

.sc-right {
  text-align: right;
  font-family: var(--mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.sc-right .den {
  font-size: 10px;
  color: var(--ink-3);
}

.sc-note {
  margin: -2px 0 0;
  padding-bottom: 4px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 12px;
  color: var(--ink-3);
}

.share-grid {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 4px;
}

.sq {
  width: 24px;
  height: 24px;
  border: 1.5px solid var(--ink);
}

.sq.is-green { background: var(--green); }
.sq.is-paper { background: var(--paper-3); }
.sq.is-red { background: var(--red); }
.sq.is-ink { background: var(--ink); }

.best-line {
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.best-line .is-new {
  color: var(--red);
  font-weight: 700;
}

/* ============================== BUTTONS ============================= */
.btn {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--paper-2);
  border: var(--rule);
  box-shadow: var(--shadow);
  padding: 12px 22px;
  min-height: 44px;
  border-radius: 2px;
  transition: transform 60ms ease, box-shadow 60ms ease;
}

.btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 rgba(28, 58, 85, 0.12);
}

.btn:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.btn-primary {
  background: var(--ink);
  color: var(--paper);
}

.btn-row {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 18px;
}

/* =========================== TOUCH CONTROLS ========================= */
#touch-controls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--paper-2);
  border-top: var(--rule);
  box-shadow: 0 -3px 0 rgba(28, 58, 85, 0.12);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.tc-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.tc-cluster {
  display: flex;
  gap: 10px;
}

.tc-drive {
  flex-direction: column;
  gap: 8px;
}

.tc-btn {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 20px;
  color: var(--ink);
  background: var(--paper-2);
  border: var(--rule);
  box-shadow: 3px 3px 0 rgba(28, 58, 85, 0.12);
  border-radius: 2px;
  touch-action: none;
}

.tc-drive .tc-btn {
  width: 64px;
  height: 44px;
  font-size: 16px;
}

.tc-btn.is-held,
.tc-brake.is-held {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 rgba(28, 58, 85, 0.12);
  background: var(--paper-3);
}

.tc-brake {
  width: 100%;
  min-height: 44px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.24em;
  color: var(--paper);
  background: var(--ink);
  border: var(--rule);
  box-shadow: 3px 3px 0 rgba(28, 58, 85, 0.12);
  border-radius: 2px;
  touch-action: none;
}

/* =============================== TOAST ============================== */
#toast {
  position: fixed;
  left: 50%;
  bottom: 108px;
  transform: translateX(-50%);
  z-index: 60;
  padding: 8px 18px;
  background: var(--ink);
  color: var(--paper);
  border: var(--rule);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  box-shadow: 3px 3px 0 rgba(28, 58, 85, 0.16);
  pointer-events: none;
}

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

/* ============================== CAMPAIGN ============================ */
/* Level HUD: level number, name, live stars and collision count. */
#hud-level {
  font-weight: 700;
  letter-spacing: 0.14em;
}

#hud-level-name {
  margin-left: 8px;
  font-size: 9.5px;
  letter-spacing: 0.18em;
  color: var(--ink-3);
}

.hud-level-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46%;
}

#hud-stars {
  display: inline-flex;
  gap: 3px;
  vertical-align: -1px;
}

#hud-stars i {
  display: block;
  width: 11px;
  height: 11px;
  line-height: 11px;
  font-size: 11px;
  font-style: normal;
  text-align: center;
}

#hud-stars i::before {
  content: "\2606";
  color: var(--ink-3);
}

#hud-stars i.is-on::before {
  content: "\2605";
  color: var(--green);
}

#timer-target {
  color: var(--ink-3);
}

#hits {
  display: inline-block;
  min-width: 1.2em;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  transition: color 120ms linear;
}

#hits.is-penalty {
  color: var(--red);
}

/* Wider card for the level select and the final screen. */
#overlay-inner.is-wide {
  max-width: 760px;
  padding: 30px 34px 28px;
}

/* Card action rows (level select, intro, result, failed, final). */
.card-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 22px;
}

.card-actions.is-ls-actions {
  margin-top: 18px;
  padding-top: 14px;
  border-top: var(--rule-dash);
}

.btn-secondary {
  background: var(--paper-2);
  color: var(--ink);
}

.btn-tertiary {
  background: transparent;
  border-style: dashed;
  border-color: var(--ink-3);
  color: var(--ink-2);
  box-shadow: none;
}

.btn-tertiary:active {
  transform: none;
  box-shadow: none;
}

.btn[disabled] {
  cursor: not-allowed;
  opacity: 0.45;
}

/* ---------------------------- LEVEL SELECT -------------------------- */
.ls-header {
  font-size: 10px;
  letter-spacing: 0.3em;
  color: var(--ink-2);
}

.ls-subtitle {
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  color: var(--ink-3);
  text-transform: uppercase;
}

.ls-world {
  margin-top: 16px;
  text-align: left;
}

.ls-world-label {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.24em;
  color: var(--ink-3);
  text-transform: uppercase;
  padding-bottom: 6px;
  border-bottom: var(--rule-dash);
}

.ls-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 9px;
}

.ls-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 62px;
  padding: 7px 8px 8px;
  text-align: left;
  background: var(--paper);
  border: 1.5px solid var(--ink-2);
  border-radius: 2px;
  box-shadow: 2px 2px 0 rgba(28, 58, 85, 0.1);
  transition: transform 60ms ease, box-shadow 60ms ease, border-color 90ms linear;
}

.ls-tile:hover:not([disabled]),
.ls-tile:focus-visible {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 rgba(28, 58, 85, 0.16);
  border-color: var(--ink);
}

.ls-tile:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.ls-tile.is-locked {
  background: transparent;
  border-style: dashed;
  border-color: var(--ink-3);
  box-shadow: none;
  opacity: 0.55;
}

.ls-tile.is-cleared {
  border-color: var(--green);
}

.ls-tile.is-next {
  border-color: var(--ink);
  border-width: 2px;
  background: var(--paper-3);
}

.ls-tile.is-next::after {
  content: "NEXT";
  position: absolute;
  top: -7px;
  right: 6px;
  padding: 0 4px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.16em;
}

.ls-num {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.ls-tile.is-locked .ls-num {
  color: var(--ink-3);
}

.ls-name {
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1.25;
  letter-spacing: 0.1em;
  color: var(--ink-2);
  text-transform: uppercase;
}

.ls-stars {
  margin-top: auto;
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--green);
}

.ls-tile.is-locked .ls-stars {
  color: var(--ink-3);
}

.ls-lock {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 12px;
  height: 12px;
  color: var(--ink-3);
}

/* ---------------------------- LEVEL INTRO --------------------------- */
.oi-title {
  margin-top: 10px;
  font-family: var(--sans);
  font-size: 24px;
  font-weight: 700;
  font-variant: small-caps;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  line-height: 1.2;
  color: var(--ink);
}

.oi-hint {
  margin-top: 10px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  line-height: 1.35;
  color: var(--ink-2);
}

.oi-criteria {
  list-style: none;
  margin: 16px auto 0;
  padding: 12px 14px;
  max-width: 380px;
  border-top: var(--rule-dash);
  border-bottom: var(--rule-dash);
  text-align: left;
}

.oi-crit {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 3px 0;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.09em;
  color: var(--ink-2);
  text-transform: uppercase;
}

.oi-crit-star {
  color: var(--ink-3);
  font-size: 10px;
}

.oi-best {
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--ink-3);
  text-transform: uppercase;
}

@media (max-width: 720px) {
  #app {
    padding: 16px 10px 40px;
  }

  .wordmark {
    font-size: 18px;
    letter-spacing: 0.28em;
  }

  .masthead {
    gap: 10px;
    margin-bottom: 12px;
  }

  #overlay-inner {
    padding: 24px 18px 22px;
  }

  .score-big {
    font-size: 68px;
  }

  .score-big .den {
    font-size: 24px;
  }

  .result-score {
    font-size: 48px;
  }

  #hud {
    font-size: 9.5px;
    gap: 8px;
    padding: 3px 7px 4px;
  }

  #spot-score {
    font-size: 13px;
  }

  .hud-label {
    display: none;
  }

  .btn {
    padding: 12px 16px;
    font-size: 10.5px;
    letter-spacing: 0.16em;
  }
}

@media (max-width: 420px) {
  .card-title {
    font-size: 21px;
  }

  .countdown-num {
    font-size: 72px;
  }

  .sc-row {
    grid-template-columns: 54px 1fr 48px;
    gap: 8px;
  }
}

/* =========================== REDUCED MOTION ========================= */
@media (prefers-reduced-motion: reduce) {
  .btn,
  .mute-btn,
  .tc-btn,
  .tc-brake {
    transition: none;
  }

  .perfect-line {
    animation: none;
  }

  .stamp {
    transform: rotate(-2deg);
  }
}

/* ========================= CAMPAIGN · RESULTS ======================= */
.rc-headline {
  margin-top: 10px;
  font-family: var(--sans);
  font-size: 26px;
  font-weight: 700;
  font-variant: small-caps;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  line-height: 1.15;
  color: var(--ink);
}

.rc-headline-small {
  font-size: 15px;
  letter-spacing: 0.12em;
  font-variant: normal;
  color: var(--ink-2);
}

.rc-stars {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}

.rc-star {
  font-size: 34px;
  line-height: 1;
  color: var(--ink-3);
  transform-origin: 50% 60%;
}

.rc-star.is-earned {
  color: var(--green);
  animation: star-pop 420ms cubic-bezier(0.2, 1.5, 0.4, 1) both;
}

.rc-star.is-empty {
  color: var(--ink-3);
  opacity: 0.6;
}

@keyframes star-pop {
  0% { transform: scale(0.4) rotate(-18deg); opacity: 0; }
  60% { transform: scale(1.14) rotate(4deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.rc-stats {
  list-style: none;
  margin: 16px auto 0;
  padding: 0;
  max-width: 400px;
  border-top: var(--rule-dash);
}

.rc-stat {
  display: grid;
  grid-template-columns: 1fr auto 18px;
  align-items: baseline;
  gap: 10px;
  padding: 6px 2px;
  border-bottom: var(--rule-dash);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: left;
}

.rc-stat-label { color: var(--ink-3); }
.rc-stat-value { color: var(--ink); font-variant-numeric: tabular-nums; }
.rc-stat-mark { text-align: right; font-size: 11px; }
.rc-stat-mark.is-ok { color: var(--green); }
.rc-stat-mark.is-bad { color: var(--red); }

.rc-best {
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--ink-3);
  text-transform: uppercase;
}

/* ========================== CAMPAIGN · STAMPS ======================= */
.stamp-fail {
  color: var(--red);
  margin-top: 24px;
  animation: stamp-down 260ms cubic-bezier(0.3, 1.6, 0.5, 1) both;
}

.final-stamp {
  color: var(--green);
  margin-top: 22px;
  animation: stamp-down 320ms cubic-bezier(0.3, 1.6, 0.5, 1) both;
}

@keyframes stamp-down {
  0% { transform: translateY(-14px) rotate(-6deg) scale(1.35); opacity: 0; }
  70% { transform: translateY(0) rotate(-6deg) scale(0.97); opacity: 1; }
  100% { transform: translateY(0) rotate(-6deg) scale(1); opacity: 1; }
}

/* ========================= CAMPAIGN · FINAL CARD ==================== */
.final-sub {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.28em;
  color: var(--ink-3);
  text-transform: uppercase;
}

.final-score {
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 54px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.final-slash {
  font-size: 26px;
  font-weight: 400;
  color: var(--ink-3);
  margin: 0 4px;
}

.final-grade {
  margin-top: 12px;
  font-family: var(--sans);
  font-size: 17px;
  font-weight: 700;
  font-variant: small-caps;
  letter-spacing: 0.26em;
  color: var(--green);
}

.final-foot {
  margin-top: 10px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--ink-2);
}

/* The overlay picks up a tint from the card it is showing. */
#overlay[data-result="complete"] #overlay-inner { border-color: var(--green); }
#overlay[data-result="failed"] #overlay-inner { border-color: var(--red); }
#overlay[data-result="final"] #overlay-inner { border-color: var(--ink); }

/* ==================== CAMPAIGN · SMALL SCREENS ====================== */
@media (max-width: 720px) {
  #overlay-inner.is-wide {
    padding: 22px 16px 20px;
  }

  .ls-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .ls-tile {
    min-height: 56px;
  }

  .ls-name {
    font-size: 7.5px;
  }

  .oi-title,
  .rc-headline {
    font-size: 20px;
  }

  .rc-star {
    font-size: 28px;
  }

  .final-score {
    font-size: 42px;
  }

  .card-actions {
    gap: 9px;
  }

  #hud-stars i {
    width: 9px;
    height: 9px;
    font-size: 9px;
  }

  #hud-level-name {
    display: none;
  }
}

@media (max-width: 420px) {
  .ls-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .rc-stat {
    font-size: 9.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rc-star.is-earned,
  .stamp-fail,
  .final-stamp {
    animation: none;
  }

  .ls-tile {
    transition: none;
  }
}


