:root {
  color-scheme: light;
  --ink: #1e1d1b;
  --paper: #f4f0e5;
  --white: #fffdf7;
  --blue: #2f6dff;
  --red: #ef4c3c;
  --yellow: #ffd84b;
  --mint: #63d7ad;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-width: 320px;
  min-height: 100%;
  background: #cfcabf;
  color: var(--ink);
  font-family: "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none;
}

body {
  min-height: 100dvh;
  padding: clamp(8px, 1.4vw, 18px);
  display: grid;
  place-items: center;
}

button,
a { -webkit-tap-highlight-color: transparent; }

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

.game-shell {
  width: min(1600px, 100%);
  height: min(960px, calc(100dvh - clamp(16px, 2.8vw, 36px)));
  min-height: 560px;
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr) 34px;
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 10px 10px 0 rgba(30, 29, 27, 0.2);
  overflow: hidden;
}

.topbar,
.footer-strip {
  display: flex;
  align-items: center;
  gap: 22px;
  padding-inline: clamp(12px, 2vw, 28px);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar { border-bottom: 2px solid var(--ink); }
.footer-strip {
  justify-content: space-between;
  border-top: 2px solid var(--ink);
  background: var(--yellow);
  font-size: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--white);
  font-size: 11px;
  letter-spacing: -0.04em;
  transform: rotate(-2deg);
}

.run-status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: clamp(12px, 2vw, 28px);
}

.focus-wrap { display: flex; align-items: center; gap: 8px; }
.focus-track {
  width: clamp(75px, 11vw, 154px);
  height: 12px;
  padding: 2px;
  border: 1.5px solid var(--ink);
  background: var(--white);
}

.focus-track i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--mint);
  transform-origin: left;
  transition: transform 120ms linear, background-color 160ms;
}

.stat b { font-size: 14px; font-variant-numeric: tabular-nums; }

.sound-button {
  min-width: 86px;
  padding: 7px 9px;
  border: 1.5px solid var(--ink);
  background: var(--white);
  color: inherit;
  font: inherit;
  font-size: 9px;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
}

.sound-button:active { transform: translate(2px, 2px); box-shadow: none; }

.game-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: var(--paper);
  isolation: isolate;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.paper-overlay {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background-color: rgba(244, 240, 229, 0.94);
  background-image: linear-gradient(rgba(30, 29, 27, 0.035) 1px, transparent 1px), linear-gradient(90deg, rgba(30, 29, 27, 0.025) 1px, transparent 1px);
  background-size: 24px 24px;
  transition: opacity 240ms ease, visibility 240ms;
}

.paper-overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.intro-copy {
  width: min(610px, 92%);
  text-align: center;
  transform: rotate(-0.3deg);
}

.eyebrow,
.tiny-note {
  margin: 0;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

h1 {
  margin: 9px 0 8px;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: clamp(54px, 9.2vh, 104px);
  line-height: 0.76;
  letter-spacing: -0.055em;
  text-transform: uppercase;
}

h1 em {
  color: var(--red);
  font-style: normal;
  -webkit-text-stroke: 2px var(--ink);
  text-shadow: 5px 5px 0 var(--yellow);
}

.lede {
  max-width: 460px;
  margin: 16px auto 18px;
  font-size: clamp(14px, 1.6vw, 19px);
  line-height: 1.3;
  font-weight: 650;
}

.mission-card {
  position: relative;
  width: min(470px, 96%);
  margin: 0 auto 18px;
  padding: 13px 21px;
  border: 2px solid var(--ink);
  background: var(--white);
  box-shadow: 5px 5px 0 var(--ink);
  font-family: Georgia, serif;
  font-size: 13px;
  line-height: 1.35;
  transform: rotate(0.6deg);
}

.mission-card p { margin: 0; }
.mission-card p + p { margin-top: 5px; }
.mission-card strong { font-family: Arial, sans-serif; text-transform: uppercase; letter-spacing: 0.12em; font-size: 10px; }

.tape {
  position: absolute;
  width: 78px;
  height: 19px;
  top: -11px;
  left: 50%;
  background: rgba(255, 216, 75, 0.78);
  transform: translateX(-50%) rotate(-2deg);
}

.desktop-keys {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin: 13px 0 16px;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.desktop-keys span { display: flex; align-items: center; gap: 4px; }
kbd {
  min-width: 27px;
  padding: 5px 7px;
  border: 1.5px solid var(--ink);
  border-radius: 2px;
  background: var(--white);
  box-shadow: 2px 2px 0 var(--ink);
  font: 800 10px Arial, sans-serif;
}

.primary-button {
  padding: 13px 25px 12px;
  border: 2px solid var(--ink);
  background: var(--blue);
  color: white;
  box-shadow: 5px 5px 0 var(--ink);
  font: 900 14px Arial, sans-serif;
  letter-spacing: 0.12em;
  cursor: pointer;
  transform: rotate(-1deg);
}

.primary-button:hover { background: var(--red); }
.primary-button:active { transform: translate(4px, 4px) rotate(-1deg); box-shadow: 1px 1px 0 var(--ink); }
.primary-button span { margin-left: 10px; }
.tiny-note { margin-top: 15px; font-size: 8px; opacity: 0.63; }

.doodle {
  position: absolute;
  font-family: Georgia, serif;
  font-size: clamp(40px, 7vw, 90px);
  color: var(--blue);
  pointer-events: none;
}

.burst-one { top: 16%; left: 10%; transform: rotate(-12deg); }
.burst-two { right: 12%; bottom: 15%; color: var(--red); transform: rotate(9deg); }

.announcement,
.combo-pop {
  position: absolute;
  z-index: 4;
  left: 50%;
  pointer-events: none;
  opacity: 0;
  text-align: center;
}

.announcement {
  top: 9%;
  padding: 8px 13px;
  border: 2px solid var(--ink);
  background: var(--yellow);
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transform: translate(-50%, -12px) rotate(-1deg);
  transition: opacity 170ms, transform 170ms;
}

.announcement.show { opacity: 1; transform: translate(-50%, 0) rotate(-1deg); }

.combo-pop {
  top: 24%;
  color: var(--red);
  font: 900 clamp(24px, 4vw, 48px) Impact, sans-serif;
  -webkit-text-stroke: 1px var(--ink);
  text-shadow: 3px 3px 0 var(--yellow);
  transform: translate(-50%, 0) rotate(-5deg);
}

.combo-pop.pop { animation: combo 700ms ease-out; }
@keyframes combo {
  0% { opacity: 0; transform: translate(-50%, 20px) scale(0.6) rotate(-5deg); }
  25% { opacity: 1; transform: translate(-50%, 0) scale(1.15) rotate(-3deg); }
  100% { opacity: 0; transform: translate(-50%, -28px) scale(1) rotate(2deg); }
}

.touch-controls {
  position: absolute;
  z-index: 3;
  left: 14px;
  right: 14px;
  bottom: 12px;
  display: none;
  justify-content: space-between;
  pointer-events: none;
}

.touch-group { display: flex; gap: 9px; }
.touch-controls button {
  width: 54px;
  height: 54px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: rgba(255, 253, 247, 0.88);
  box-shadow: 3px 3px 0 var(--ink);
  color: var(--ink);
  font: 900 21px Arial, sans-serif;
  pointer-events: auto;
  touch-action: none;
}

.touch-controls .touch-action { width: 62px; height: 62px; font-size: 9px; letter-spacing: .05em; }
.touch-controls .attack { background: rgba(255, 216, 75, 0.92); }
.touch-controls button.is-pressed { transform: translate(3px, 3px); box-shadow: none; background: var(--mint); }

.end-score {
  display: inline-block;
  margin: 10px 0 15px;
  padding: 8px 14px;
  border: 2px solid var(--ink);
  background: var(--yellow);
  font: 900 22px Impact, sans-serif;
  letter-spacing: .04em;
  box-shadow: 4px 4px 0 var(--ink);
}

@media (pointer: coarse), (max-width: 760px) {
  .touch-controls { display: flex; }
  .desktop-keys { display: none; }
  .game-shell { min-height: 490px; }
  .footer-joke { display: none; }
  .stat:last-child { display: none; }
  .brand > span:last-child { display: none; }
  .topbar { gap: 10px; }
  .run-status { gap: 10px; }
  .intro-copy { margin-top: -20px; }
  .lede { margin-block: 11px; }
  .mission-card { margin-bottom: 13px; }
}

@media (max-height: 680px) {
  .game-shell { grid-template-rows: 48px minmax(0, 1fr) 28px; min-height: 470px; }
  .brand-mark { width: 27px; height: 27px; }
  .footer-strip { font-size: 8px; }
  h1 { font-size: clamp(48px, 12vh, 78px); }
  .lede { margin-block: 10px; }
  .mission-card { padding-block: 9px; margin-bottom: 10px; }
  .desktop-keys { margin-block: 9px 12px; }
  .tiny-note { margin-top: 10px; }
}

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