:root {
  --paper: #f2e3bd;
  --paper-deep: #d7c596;
  --ink: #1d211c;
  --orange: #f05a28;
  --orange-dark: #a93019;
  --acid: #d8f044;
  --cream: #fff1ca;
  --focus: #1b53d2;
  --shadow: 7px 7px 0 var(--ink);
  color-scheme: light;
  font-family: "Avenir Next Condensed", "Trebuchet MS", "Gill Sans", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html {
  min-width: 300px;
  background: var(--paper-deep);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 15% 20%, rgb(29 33 28 / 8%) 0 1px, transparent 1.5px),
    radial-gradient(circle at 80% 70%, rgb(240 90 40 / 8%) 0 1px, transparent 1.5px),
    linear-gradient(112deg, transparent 0 49.6%, rgb(29 33 28 / 3%) 50%, transparent 50.4%);
  background-size: 17px 19px, 23px 29px, 100% 100%;
  padding: max(0.65rem, env(safe-area-inset-top)) max(0.65rem, env(safe-area-inset-right)) max(0.8rem, env(safe-area-inset-bottom)) max(0.65rem, env(safe-area-inset-left));
}

button { font: inherit; }

button:focus { outline: none; }

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

.game-page {
  width: min(100%, 1120px);
  margin: 0 auto;
}

.masthead {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 0.55rem;
}

.brand-lockup { transform: rotate(-0.5deg); }

.kicker,
.label,
.memo,
.footer-note,
.action-sub,
.charge-label {
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.kicker {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  color: var(--paper);
  background: var(--ink);
  font-size: clamp(0.58rem, 1.4vw, 0.75rem);
}

h1 {
  margin: 0;
  font-family: "Rockwell Extra Bold", "Cooper Black", Georgia, serif;
  font-size: clamp(2.05rem, 7vw, 4.4rem);
  font-weight: 900;
  line-height: 0.76;
  letter-spacing: -0.075em;
  text-transform: uppercase;
  text-shadow: 3px 3px 0 var(--paper), 6px 6px 0 var(--ink);
}

h1 span { color: var(--orange); }

.utility-controls {
  display: flex;
  align-items: center;
  gap: 0.42rem;
  padding-bottom: 0.1rem;
}

.icon-button {
  min-width: 44px;
  min-height: 44px;
  border: 3px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  background: var(--cream);
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  transition: transform 120ms cubic-bezier(0.25, 1, 0.5, 1), box-shadow 120ms cubic-bezier(0.25, 1, 0.5, 1);
}

.icon-button.wide { padding-inline: 0.55rem; }

.icon-button[aria-pressed="false"] { color: var(--paper); background: var(--orange-dark); }

@media (hover: hover) {
  .icon-button:hover,
  .start-button:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
  .action-button:hover { background: #e9ff4f; }
}

.icon-button:active,
.start-button:active,
.action-button:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 var(--ink);
}

.score-strip {
  display: grid;
  grid-template-columns: auto minmax(8rem, 1fr) auto auto;
  align-items: center;
  gap: clamp(0.55rem, 2.4vw, 1.6rem);
  padding: 0.45rem 0.75rem;
  border: 3px solid var(--ink);
  border-bottom: 0;
  background: var(--acid);
  font-variant-numeric: tabular-nums;
}

.score-strip > div { display: grid; }
.score-strip .label { font-size: 0.58rem; line-height: 1; }
.score-strip strong { font-size: clamp(0.8rem, 2vw, 1.1rem); line-height: 1.1; }
.distance-wrap { min-width: 0; }

.progress-track {
  height: 0.48rem;
  margin-top: 0.18rem;
  border: 2px solid var(--ink);
  overflow: hidden;
  background: var(--paper);
}

#progress-fill {
  display: block;
  width: 0;
  height: 100%;
  background: var(--orange);
}

.game-shell {
  position: relative;
  aspect-ratio: 16 / 9;
  border: 4px solid var(--ink);
  overflow: hidden;
  background: #e8d6ac;
  box-shadow: var(--shadow);
  isolation: isolate;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: pan-y;
}

.paper-card {
  position: absolute;
  z-index: 5;
  top: 50%;
  left: 50%;
  width: min(31rem, calc(100% - 2rem));
  padding: clamp(1rem, 3vw, 2rem);
  border: 4px solid var(--ink);
  background:
    repeating-linear-gradient(0deg, transparent 0 28px, rgb(29 33 28 / 7%) 29px 30px),
    var(--cream);
  box-shadow: 10px 10px 0 rgb(29 33 28 / 88%);
  transform: translate(-50%, -50%) rotate(-1deg);
  text-align: left;
}

.paper-card[hidden] { display: none; }
.paper-card::before {
  content: "";
  position: absolute;
  top: -0.55rem;
  right: 2.5rem;
  width: 4.2rem;
  height: 1.1rem;
  background: rgb(240 90 40 / 78%);
  transform: rotate(4deg);
}

.paper-card h2 {
  margin: 0.25rem 0 0.55rem;
  font-family: "Rockwell Extra Bold", "Cooper Black", Georgia, serif;
  font-size: clamp(1.9rem, 5vw, 3.7rem);
  line-height: 0.92;
  letter-spacing: -0.06em;
}

.paper-card p { margin: 0.55rem 0; line-height: 1.35; font-weight: 650; }
.memo { color: var(--orange-dark); font-size: 0.7rem; }

.rule-diagram {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 1rem 0;
  font-size: clamp(0.75rem, 2vw, 1rem);
}

.mouse-glyph,
.burst {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border: 3px solid var(--ink);
  background: var(--acid);
}

.burst { color: var(--paper); background: var(--orange); font-size: 1.5rem; }
.arrow { font-size: 1.5rem; font-weight: 900; }

.start-button {
  min-height: 48px;
  padding: 0.62rem 1.2rem;
  border: 3px solid var(--ink);
  border-radius: 0;
  color: var(--paper);
  background: var(--orange);
  box-shadow: 5px 5px 0 var(--ink);
  cursor: pointer;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: transform 120ms cubic-bezier(0.25, 1, 0.5, 1), box-shadow 120ms cubic-bezier(0.25, 1, 0.5, 1);
}

.start-card small { display: block; margin-top: 0.85rem; font-size: 0.62rem; font-weight: 850; letter-spacing: 0.08em; }

.result-card { text-align: center; }
.result-card h2 { color: var(--orange); }
.result-stamp {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  border: 3px solid var(--orange-dark);
  color: var(--orange-dark);
  font-size: 0.8rem;
  font-weight: 950 !important;
  letter-spacing: 0.18em;
  transform: rotate(-4deg);
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 1rem 0;
  border-block: 3px solid var(--ink);
}

.result-stats div { padding: 0.5rem; }
.result-stats div + div { border-left: 2px solid var(--ink); }
.result-stats dt { font-size: 0.6rem; font-weight: 900; letter-spacing: 0.12em; }
.result-stats dd { margin: 0; font-size: 1.15rem; font-weight: 950; font-variant-numeric: tabular-nums; }

.pause-card { width: min(20rem, calc(100% - 2rem)); text-align: center; }

.stage-stamp {
  position: absolute;
  z-index: 4;
  top: 19%;
  left: 50%;
  max-width: 80%;
  padding: 0.3rem 0.75rem;
  border: 4px solid var(--orange-dark);
  color: var(--orange-dark);
  background: rgb(242 227 189 / 87%);
  font-size: clamp(0.8rem, 3vw, 1.7rem);
  font-weight: 950;
  letter-spacing: 0.08em;
  opacity: 0;
  pointer-events: none;
  text-align: center;
  text-transform: uppercase;
  transform: translate(-50%, -20px) rotate(-2deg);
}

.stage-stamp.show { animation: stamp-in 1.35s cubic-bezier(0.16, 1, 0.3, 1) both; }

@keyframes stamp-in {
  0% { opacity: 0; transform: translate(-50%, -40px) scale(1.5) rotate(-7deg); }
  16%, 68% { opacity: 1; transform: translate(-50%, 0) scale(1) rotate(-2deg); }
  100% { opacity: 0; transform: translate(-50%, 0) scale(0.98) rotate(-2deg); }
}

.fail-caption {
  position: absolute;
  z-index: 4;
  top: 12%;
  left: 50%;
  padding: 0.24rem 0.7rem;
  color: var(--paper);
  background: var(--ink);
  font-size: clamp(0.72rem, 2.5vw, 1.15rem);
  font-weight: 950;
  letter-spacing: 0.08em;
  opacity: 0;
  pointer-events: none;
  text-transform: uppercase;
  transform: translateX(-50%) rotate(1deg);
  white-space: nowrap;
}

.fail-caption.show { opacity: 1; }

.charge-meter {
  position: absolute;
  z-index: 3;
  left: clamp(0.5rem, 2vw, 1rem);
  bottom: clamp(0.5rem, 2vw, 1rem);
  width: clamp(5.4rem, 16vw, 10rem);
  padding: 0.3rem;
  border: 3px solid var(--ink);
  background: var(--paper);
  pointer-events: none;
  transform: rotate(-1deg);
}

.charge-label { display: block; font-size: 0.55rem; }
.charge-track { height: 0.62rem; border: 2px solid var(--ink); background: var(--cream); overflow: hidden; }
#charge-fill { display: block; width: 0; height: 100%; background: var(--orange); transform-origin: left; }

.action-button {
  position: absolute;
  z-index: 3;
  right: clamp(0.5rem, 2vw, 1rem);
  bottom: clamp(0.5rem, 2vw, 1rem);
  display: grid;
  min-width: clamp(9.5rem, 27vw, 17rem);
  min-height: 58px;
  place-items: center;
  padding: 0.48rem 0.75rem;
  border: 4px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  background: var(--acid);
  box-shadow: 5px 5px 0 var(--ink);
  cursor: pointer;
  touch-action: none;
  user-select: none;
}

.action-main { font-size: clamp(0.78rem, 2.4vw, 1.25rem); font-weight: 950; line-height: 1; }
.action-sub { font-size: clamp(0.42rem, 1.2vw, 0.62rem); line-height: 1; }
.action-button.charging { color: var(--paper); background: var(--orange); transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.action-button[disabled] { opacity: 0.45; cursor: default; }

.footer-note {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.7rem;
  padding-inline: 0.25rem;
  font-size: 0.58rem;
}

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

@media (max-width: 560px) {
  body { padding-inline: 0.35rem; }
  .masthead { align-items: center; }
  .kicker { display: none; }
  h1 { font-size: clamp(1.75rem, 11vw, 3.1rem); text-shadow: 2px 2px 0 var(--paper), 4px 4px 0 var(--ink); }
  .utility-controls { gap: 0.25rem; }
  .icon-button { min-width: 38px; min-height: 38px; font-size: 0.55rem; }
  .score-strip { grid-template-columns: auto 1fr auto; gap: 0.45rem; padding: 0.34rem 0.45rem; }
  .score-strip > div:last-child { display: none; }
  .score-strip .label { font-size: 0.48rem; }
  .score-strip strong { font-size: 0.72rem; }
  .game-shell { border-width: 3px; box-shadow: 4px 4px 0 var(--ink); }
  .paper-card { padding: 0.85rem; border-width: 3px; box-shadow: 6px 6px 0 var(--ink); }
  .paper-card h2 { font-size: clamp(1.25rem, 7vw, 2rem); }
  .paper-card p { font-size: 0.72rem; margin: 0.35rem 0; }
  .rule-diagram { margin: 0.45rem 0; }
  .start-card small { display: none; }
  .start-button { min-height: 42px; padding: 0.35rem 0.75rem; font-size: 0.72rem; }
  .result-stats { margin: 0.5rem 0; }
  .result-stats div { padding: 0.25rem; }
  .result-stats dd { font-size: 0.82rem; }
  .action-button { min-height: 47px; border-width: 3px; }
  .charge-meter { border-width: 2px; }
  .footer-note span:last-child { display: none; }
}

@media (pointer: coarse) {
  .action-button { min-height: 64px; }
  .icon-button { min-width: 46px; min-height: 46px; }
}

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