:root {
  --ink: #273d43;
  --cream: #fff5df;
  --line: #b8b8a4;
  --gold: #e8bd76;
  color-scheme: dark;
  font-family:
    system-ui,
    -apple-system,
    "Hiragino Kaku Gothic ProN",
    "Yu Gothic",
    sans-serif;
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #111d2a;
}
button,
a,
input {
  touch-action: manipulation;
}
button {
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  border-radius: 12px;
  min-height: 48px;
  padding: 10px 20px;
}
button:disabled {
  opacity: 0.35;
  cursor: default;
}
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid #d6934e;
  outline-offset: 4px;
}
[hidden] {
  display: none !important;
}
#app {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
}
#scene {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
#vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse at 50% 45%,
    transparent 35%,
    #07101a77 100%
  );
}
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(22px, env(safe-area-inset-top))
    max(22px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom))
    max(22px, env(safe-area-inset-left));
  overflow: auto;
  background: #101d2c69;
  backdrop-filter: blur(3px);
  z-index: 10;
  touch-action: pan-y;
}
#menu {
  justify-content: center;
  background: linear-gradient(180deg, #111d2ad9, #101d2c22);
}
.titleCard {
  width: min(430px, 100%);
  display: flex;
  flex-direction: column;
  gap: 16px;
  color: var(--cream);
}
h1 {
  font-size: clamp(34px, 7.2vw, 52px);
  line-height: 1.3;
  white-space: nowrap;
  margin: 0 0 30px;
  letter-spacing: 0.015em;
  font-weight: 850;
}
.titleCard button {
  color: var(--cream);
  border-color: #e3d8bd88;
}
.primary {
  background: var(--ink);
  color: var(--cream);
  border-color: var(--ink);
  box-shadow: 0 4px 0 #172d3320;
}
.titleCard .primary {
  background: var(--cream);
  color: var(--ink);
  height: 58px;
}
.menuLinks {
  display: flex;
  gap: 28px;
  margin-top: 10px;
}
.textButton {
  border: 0;
  min-height: 40px;
  padding: 6px 0;
  font-weight: 500;
  font-size: 17px;
}
.titleCard .textButton {
  color: #e7dfcc;
}
.titleCard #loading:empty {
  display: none;
}
#loading {
  font-size: 17px;
  line-height: 1.5;
}
#hud {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: max(18px, env(safe-area-inset-left));
  right: max(18px, env(safe-area-inset-right));
  z-index: 4;
  pointer-events: none;
  color: var(--cream);
}
.hudMain {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding-right: 90px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 6px #000;
}
#modeLabel {
  font-size: 16px;
  font-weight: 750;
}
#distance {
  font-size: 24px;
  font-weight: 800;
}
#score {
  font-size: 23px;
  font-weight: 800;
}
.hudButtons {
  position: absolute;
  right: 0;
  top: 0;
  display: flex;
  gap: 9px;
  pointer-events: auto;
}
.hudButtons button {
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 50%;
  font-size: 20px;
  background: #fff4deec;
  border-color: #c7c1a7;
  color: var(--ink);
}
#progressTrack {
  width: min(340px, 65vw);
  height: 3px;
  background: #ffffff35;
  margin: 14px auto 0;
  border-radius: 3px;
  overflow: hidden;
}
#progressFill {
  height: 100%;
  display: block;
  background: var(--gold);
  width: 0;
}
#chain {
  width: max-content;
  margin: 13px auto 0;
  padding: 7px 14px;
  border-radius: 20px;
  background: #fff1d6ee;
  color: #785337;
  font-weight: 800;
  font-size: 18px;
}
#reticle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 19px;
  height: 19px;
  border: 1.5px solid #fff5d9;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 0 0 1px #162936a0;
}
#reticle:before,
#reticle:after {
  content: "";
  position: absolute;
  background: #fff5d9;
}
#reticle:before {
  width: 1px;
  height: 29px;
  top: -6px;
  left: 7px;
}
#reticle:after {
  height: 1px;
  width: 29px;
  left: -6px;
  top: 7px;
}
#reticle i {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #fff5d9;
  left: 6px;
  top: 6px;
}
.grazeRing {
  position: absolute;
  width: var(--graze-diameter, 44px);
  height: var(--graze-diameter, 44px);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 1.5px solid #fff3d36b;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #1b2e3844;
}
#reticle.nearPerson .grazeRing {
  border-color: #87e3b1;
  box-shadow: 0 0 10px #80d9aa66;
}
#reticle.onPerson .grazeRing {
  border-color: #f29366;
}
#grazeAward {
  position: absolute;
  pointer-events: none;
  color: #ffdf9b;
  font-size: 23px;
  font-weight: 850;
  text-shadow: 0 2px 3px #112332;
  z-index: 4;
  white-space: nowrap;
}
#countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  color: var(--cream);
  font-size: 80px;
  font-weight: 850;
  text-shadow: 0 3px 20px #000;
  pointer-events: none;
  z-index: 6;
}
#aimPad {
  position: absolute;
  left: max(24px, env(safe-area-inset-left));
  bottom: max(25px, env(safe-area-inset-bottom));
  width: 112px;
  height: 112px;
  padding: 0;
  border: 2px solid #c6c3ad;
  border-radius: 50%;
  background: #fff8e8b8;
  box-shadow:
    inset 0 0 0 12px #fff8e824,
    0 4px 12px #0003;
  touch-action: none;
  z-index: 5;
}
#aimPad svg {
  width: 100%;
  height: 100%;
  fill: #46666b99;
  pointer-events: none;
}
#aimKnob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42px;
  height: 42px;
  transform: translate(-50%, -50%);
  border: 2px solid #657c76;
  border-radius: 50%;
  background: #fff8e8ee;
  box-shadow: 0 3px 6px #273f4933;
  pointer-events: none;
}
#aimPad.active {
  border-color: #6ac6a2;
}
body:not(.touch) #aimPad {
  display: none;
}
#jump {
  position: absolute;
  right: max(24px, env(safe-area-inset-right));
  bottom: max(25px, env(safe-area-inset-bottom));
  width: 104px;
  height: 104px;
  border-radius: 50%;
  padding: 13px;
  background: #fff4dfdc;
  box-shadow: 0 3px 12px #0003;
  border: 2px solid #d4ccb4;
  color: var(--ink);
  z-index: 5;
  touch-action: none;
}
#jump svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  width: 38px;
  height: 38px;
  margin: auto;
  pointer-events: none;
}
#jump span {
  font-size: 16px;
  white-space: nowrap;
  pointer-events: none;
}
#jump.urgent {
  border-color: #ffc269;
  box-shadow:
    0 0 0 6px #e0a14e44,
    0 0 25px #ffd47788;
}
#jump.pressed {
  background: #ebc487;
}
.stageCard,
.resultCard {
  background: var(--cream);
  color: var(--ink);
  border: 1px solid #a9afa0;
  border-radius: 22px;
  width: min(440px, 100%);
  padding: 26px;
  max-height: 100%;
  overflow: auto;
}
.stageCard h2,
.resultCard h2 {
  font-size: 27px;
  line-height: 1.35;
  margin: 0 0 22px;
  text-align: center;
}
#stages {
  display: grid;
  gap: 10px;
}
#stages button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 12px 15px;
  font-size: 18px;
  background: #fbf0d7;
}
#stages button.cleared {
  border-color: #588f79;
}
#stages .stageGoal {
  font-size: 17px;
  font-weight: 550;
  white-space: nowrap;
}
#stageBack {
  width: 100%;
  margin-top: 18px;
}
.resultCard {
  text-align: center;
}
#resultTitle {
  font-size: 27px;
  font-weight: 850;
}
.resultCard.failed #resultTitle {
  color: #a4563c;
  font-size: 30px;
}
.scoreValue {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 22px;
}
.scoreValue span {
  font-size: 18px;
}
.scoreValue b {
  font-size: clamp(42px, 10vw, 58px);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.runStats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 22px;
}
.runStats span {
  display: block;
  font-size: 16px;
  margin-bottom: 8px;
  white-space: nowrap;
}
.runStats b {
  font-size: 21px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
#resultButtons {
  display: grid;
  gap: 10px;
}
#resultButtons button,
#resultButtons a {
  width: 100%;
  min-height: 46px;
  font-size: 18px;
}
.shareButton {
  display: grid;
  place-content: center;
  text-decoration: none;
  background: #18242d;
  color: #fff5df;
  border-radius: 12px;
  border: 1px solid #18242d;
  font-weight: 700;
}
.creditText {
  font-size: 17px;
  line-height: 1.7;
  margin: 0 0 20px;
  text-align: left;
}
#helpModal {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: #101f2b88;
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  touch-action: pan-y;
}
.help-dismissed #helpModal {
  display: none;
}
.comicCard {
  color: var(--ink);
  background: var(--cream);
  border: 1px solid #b9bca8;
  border-radius: 22px;
  padding: 20px;
  width: min(480px, 100%);
  max-height: calc(100dvh - 36px);
  overflow: auto;
  touch-action: pan-y;
}
.helpTop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.helpTop h2 {
  margin: 0;
  font-size: 24px;
}
.helpTop button {
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 50%;
  font-size: 26px;
  line-height: 1;
}
#helpImage {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16/9;
  object-fit: contain;
  border: 3px solid #c5aa78;
  border-radius: 10px;
  background: #15222e;
}
.comicWords {
  padding: 16px 0 3px;
  min-height: 130px;
}
#helpHeading {
  margin: 0 0 10px;
  font-size: 22px;
  line-height: 1.45;
  font-weight: 850;
}
#helpCopy {
  margin: 0;
  font-size: 18px;
  line-height: 1.6;
  font-weight: 650;
}
.helpPreference {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  line-height: 1.5;
  margin: 6px 0 12px;
}
.helpPreference input {
  appearance: auto;
  width: 23px;
  height: 23px;
  margin: 0;
  accent-color: #41695a;
}
.helpNav {
  display: grid;
  grid-template-columns: 72px 1fr 110px;
  gap: 12px;
  align-items: center;
  margin-top: 15px;
}
.helpNav span {
  text-align: center;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}
.helpNav button {
  height: 46px;
  min-height: 46px;
  padding: 0 12px;
  font-size: 18px;
}
.helpNav .primary {
  grid-column: 3;
}
.help-open {
  touch-action: pan-y;
}
#impactFX {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  overflow: hidden;
  --burst: 0;
  --flash: 0;
}
#impactFX > div {
  position: absolute;
  inset: -15%;
}
.speedLines {
  background: repeating-conic-gradient(
    from 6deg,
    transparent 0deg 8deg,
    #ffe1a699 8.4deg 9.2deg,
    transparent 9.7deg 18deg
  );
  opacity: 0.9;
  mask-image: radial-gradient(ellipse, transparent 12%, #000 65%);
}
.impactFlash {
  background: #fff5ce;
  opacity: var(--flash);
}
.impactBurst {
  background: radial-gradient(
    ellipse,
    transparent 15%,
    #ffd98c88 60%,
    #de754766 100%
  );
  transform: scale(calc(0.75 + var(--burst) * 0.4));
  opacity: calc(0.9 - var(--burst) * 0.6);
}
.impactRing {
  border: 12px solid #ffdaa7;
  border-radius: 50%;
  width: 50vmin;
  height: 50vmin;
  left: calc(50% - 25vmin) !important;
  top: calc(50% - 25vmin) !important;
  transform: scale(calc(0.2 + var(--burst) * 4));
  opacity: calc(1 - var(--burst));
  box-shadow: 0 0 0 5px #f7f0d3aa;
}
#impactFX:not(.released) .impactRing {
  opacity: 0;
}
@media (orientation: portrait) {
  .hudMain {
    flex-wrap: wrap;
    gap: 8px 14px;
    justify-content: flex-start;
    padding-right: 84px;
  }
  #modeLabel {
    width: 100%;
    font-size: 16px;
  }
  #distance {
    font-size: 23px;
  }
  #score {
    font-size: 21px;
  }
  .hudButtons {
    top: 2px;
  }
  #progressTrack {
    width: 100%;
    margin-top: 13px;
  }
  #chain {
    margin-top: 12px;
  }
  h1 {
    font-size: clamp(32px, 8.3vw, 40px);
  }
  .runStats {
    gap: 6px;
  }
  .runStats span {
    font-size: 16px;
  }
  .runStats b {
    font-size: 20px;
  }
  .resultCard {
    padding: 24px 18px;
  }
}
@media (orientation: landscape) and (max-height: 500px) {
  .titleCard {
    width: 360px;
    gap: 11px;
  }
  h1 {
    font-size: 38px;
    margin-bottom: 14px;
  }
  .titleCard .primary {
    height: 48px;
  }
  .menuLinks {
    margin-top: 0;
  }
  .screen {
    padding: 14px;
  }
  .stageCard {
    padding: 18px 24px;
    width: 600px;
  }
  .stageCard h2 {
    font-size: 23px;
    margin-bottom: 12px;
  }
  #stages {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  #stages button {
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    padding: 8px 12px;
    min-height: 58px;
  }
  #stageBack {
    margin-top: 10px;
    min-height: 40px;
  }
  .comicCard {
    width: min(740px, 100%);
    padding: 15px 20px;
    max-height: calc(100dvh - 24px);
  }
  .helpTop {
    margin-bottom: 8px;
  }
  .comicBody {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 20px;
    align-items: center;
  }
  .comicWords {
    min-height: 0;
    padding: 0;
  }
  #helpHeading {
    font-size: 21px;
  }
  #helpCopy {
    font-size: 17px;
  }
  .helpNav {
    margin-top: 10px;
  }
  .helpPreference {
    margin: 4px 0;
  }
  #aimPad {
    width: 96px;
    height: 96px;
    bottom: max(14px, env(safe-area-inset-bottom));
  }
  #jump {
    width: 88px;
    height: 88px;
    bottom: max(14px, env(safe-area-inset-bottom));
    padding: 8px;
  }
  #jump svg {
    width: 33px;
    height: 33px;
  }
  #jump span {
    font-size: 15px;
  }
  .resultCard {
    width: 650px;
    padding: 17px 24px;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    column-gap: 24px;
  }
  .resultCard h2 {
    grid-column: 1/-1;
    font-size: 24px !important;
    margin-bottom: 10px;
  }
  .scoreValue {
    margin-bottom: 12px;
    gap: 3px;
  }
  .scoreValue b {
    font-size: 43px;
  }
  .runStats {
    margin-bottom: 0;
  }
  .runStats span {
    font-size: 16px;
  }
  .runStats b {
    font-size: 19px;
  }
  #resultButtons {
    align-self: center;
    gap: 7px;
  }
  #resultButtons button,
  #resultButtons a {
    min-height: 40px;
    font-size: 17px;
  }
  #overlay.pauseScreen .resultCard,
  #overlay.creditScreen .resultCard {
    display: block;
    width: 400px;
  }
}
@media (max-width: 350px) and (orientation: portrait) {
  .comicCard {
    padding: 16px;
    max-height: calc(100dvh - 24px);
  }
  #helpHeading {
    font-size: 20px;
  }
  #helpCopy {
    font-size: 17px;
  }
  .comicWords {
    min-height: 115px;
    padding-top: 12px;
  }
  #aimPad {
    width: 96px;
    height: 96px;
    left: 16px;
  }
  #jump {
    width: 92px;
    height: 92px;
    right: 16px;
  }
  .resultCard {
    padding: 20px 14px;
  }
  .runStats span {
    font-size: 15px;
  }
  .runStats b {
    font-size: 18px;
  }
  .stageCard {
    padding: 20px 15px;
  }
  .hudMain {
    gap: 6px 10px;
  }
  #distance {
    font-size: 21px;
  }
  #score {
    font-size: 19px;
  }
}

/* Keep instruction lines balanced and stage goals readable on narrow phones. */
#helpHeading {
  text-wrap: balance;
}
#helpCopy {
  text-wrap: pretty;
}
.comicCard {
  color-scheme: light;
}
#stages button {
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}
@media (max-width: 350px) and (orientation: portrait) {
  .resultCard.failed #resultTitle {
    font-size: 26px;
  }
}

/* Relative touchpad: position follows each drag, with no held-input velocity. */
#aimPad {
  width: 156px;
  height: 106px;
  border-radius: 20px;
  background: #f5efdf20;
  border: 1.5px solid #f2e9cf99;
  box-shadow: inset 0 0 0 5px #f5efdf0a;
}
#aimPad svg {
  fill: none;
  stroke: #f7edcba6;
  stroke-width: 1.7;
}
#aimPad.active {
  background: #f5efdf38;
  border-color: #c2ecd9;
}
#pursuit {
  width: max-content;
  margin: 10px auto 0;
  padding: 5px 12px;
  font-size: 17px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  color: #e9f6e9;
  background: #172d39c9;
  border: 1px solid #b9ccb366;
  border-radius: 18px;
}
#pursuit.urgent {
  color: #ffd0a5;
  border-color: #e89a6b;
  background: #482f2bdb;
}
@media (orientation: landscape) and (max-height: 500px) {
  #aimPad {
    width: 144px;
    height: 88px;
  }
  #pursuit {
    font-size: 16px;
    margin-top: 8px;
  }
}
@media (max-width: 350px) and (orientation: portrait) {
  #aimPad {
    width: 128px;
    height: 96px;
  }
}

#startHint {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(36px, 9vh, 92px);
  padding: max(28px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  background: #000;
  color: #f6f0df;
  text-align: center;
  touch-action: none;
}
.startHintStatus { font-size: 21px; line-height: 1.5; }
#startHintText { width: 100%; max-width: 760px; font-size: clamp(20px, 3.8vw, 27px); font-weight: 650; line-height: 1.75; }
#startHintText p { margin: 0; text-wrap: balance; }
@media (orientation: landscape) and (max-height: 500px) {
  #startHint { gap: 24px; }
  #startHintText { font-size: 20px; line-height: 1.6; }
}
