/* SCHOOL TAG - Pilla Pilla. HUD: school stationery kit. */

:root {
  --cream: #E8E2D6;
  --paper: #F4EFE4;
  --ink: #1B2A4A;
  --chalk: #F2B33D;
  --red: #E23B2E;
  --blue: #2F7DE1;
  --green: #2E6B63;
  --terracotta: #C2643C;
  --tape: rgba(232, 214, 154, 0.82);
  --grid-line: rgba(47, 125, 225, 0.115);
  --shadow: 0 3px 0 rgba(27, 42, 74, 0.12), 0 8px 18px rgba(27, 42, 74, 0.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #14181c;
  color: var(--ink);
  font-family: "Barlow Semi Condensed", "Arial Narrow", system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  height: 100dvh;
  width: 100vw;
}

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
}

/* ---------- full-screen effects ---------- */

#speedlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
  mix-blend-mode: screen;
  z-index: 2;
}
#speedlines canvas { width: 100%; height: 100%; display: block; }

#tint {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  transition: box-shadow 0.6s ease, background 0.6s ease;
  box-shadow: inset 0 0 90px 8px rgba(47, 125, 225, 0.24);
}
#tint.chaser {
  box-shadow: inset 0 0 110px 10px rgba(226, 59, 46, 0.32);
}
#tint.flash-red { background: rgba(226, 59, 46, 0.22); transition: background 0.08s ease; }
#tint.flash-blue { background: rgba(47, 125, 225, 0.16); transition: background 0.08s ease; }

/* ---------- HUD shell ---------- */

#vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  background: radial-gradient(ellipse at 50% 46%, rgba(8, 8, 6, 0) 42%, rgba(8, 8, 6, 0.26) 100%);
  mix-blend-mode: multiply;
}

#hud {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}
#hud.live { opacity: 1; }

.hud-top {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  right: max(10px, env(safe-area-inset-right));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.counter {
  position: relative;
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 6px;
  min-width: clamp(118px, 12vw, 190px);
  padding: clamp(5px, 0.7vw, 10px) clamp(10px, 1.1vw, 16px) clamp(4px, 0.5vw, 8px);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 9px 9px;
  border-radius: 3px 9px 4px 7px;
  box-shadow: var(--shadow);
  transform: rotate(-1.6deg);
}
.counter-chase { transform: rotate(1.5deg); }
.counter::after {
  content: "";
  position: absolute;
  top: -7px;
  left: 18%;
  width: 42%;
  height: 15px;
  background: var(--tape);
  transform: rotate(-2.5deg);
  box-shadow: 0 1px 0 rgba(27, 42, 74, 0.08);
}
.counter img {
  width: clamp(36px, 4.6vw, 64px);
  height: auto;
  grid-row: 1 / span 2;
  filter: drop-shadow(0 1px 1px rgba(27, 42, 74, 0.18));
}
.counter-num {
  font-family: "Bungee", "Barlow Semi Condensed", sans-serif;
  font-size: clamp(30px, 4.2vw, 58px);
  line-height: 0.95;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.5);
}
.counter-free .counter-num { color: #245c9e; }
.counter-chase .counter-num { color: #a52a20; }
.counter-label {
  font-family: "Barlow Semi Condensed", sans-serif;
  font-weight: 700;
  font-size: clamp(8px, 0.85vw, 12px);
  letter-spacing: 0.16em;
  color: rgba(27, 42, 74, 0.7);
}

.timer-strip {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
  padding: clamp(5px, 0.65vw, 9px) clamp(16px, 2.2vw, 34px);
  background-color: var(--paper);
  background-image: linear-gradient(rgba(27, 42, 74, 0.035) 1px, transparent 1px);
  background-size: 100% 5px;
  box-shadow: var(--shadow);
  transform: rotate(-0.4deg);
  clip-path: polygon(2% 0, 98% 2%, 100% 20%, 98.6% 48%, 100% 78%, 97% 100%, 1.4% 98%, 0 72%, 1.2% 44%, 0 16%);
}
.timer-strip::before, .timer-strip::after {
  content: "";
  position: absolute;
  width: 34px;
  height: 14px;
  background: var(--tape);
  top: -6px;
}
.timer-strip::before { left: 8%; transform: rotate(-6deg); }
.timer-strip::after { right: 8%; transform: rotate(5deg); }
.timer-strip .timer-icon {
  width: clamp(20px, 2.1vw, 30px);
  height: auto;
}
#timerText {
  font-family: "JetBrains Mono", "Barlow Semi Condensed", monospace;
  font-weight: 700;
  font-size: clamp(26px, 3.2vw, 46px);
  letter-spacing: 0.03em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.timer-strip.low {
  background-color: #f5dc9a;
}
.timer-strip.low #timerText { color: #7a4a05; }
.timer-strip.urgent { animation: timerPulse 1s steps(2) infinite; }
@keyframes timerPulse {
  0%, 100% { transform: rotate(-0.4deg) scale(1); }
  50% { transform: rotate(0.6deg) scale(1.035); }
}

.help-btn {
  position: absolute;
  top: clamp(74px, 10.5vh, 116px);
  left: 50%;
  transform: translateX(-50%) rotate(3deg);
  width: clamp(26px, 2.2vw, 34px);
  height: clamp(26px, 2.2vw, 34px);
  padding: 0;
  border: 2px solid rgba(27, 42, 74, 0.65);
  border-radius: 50% 46% 52% 48%;
  background: var(--paper);
  color: var(--ink);
  font-family: "Bungee", sans-serif;
  font-size: clamp(12px, 1.1vw, 16px);
  line-height: 1;
  pointer-events: auto;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(27, 42, 74, 0.15);
  z-index: 12;
}
.help-btn:hover { background: #fff9ea; }

.state-chip {
  position: absolute;
  left: 50%;
  bottom: clamp(20px, 4.4vh, 40px);
  transform: translateX(-50%) rotate(-1.2deg);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px 3px 4px;
  background: var(--paper);
  border-radius: 2px 7px 3px 6px;
  box-shadow: var(--shadow);
  transition: background-color 0.3s ease, color 0.3s ease;
}
.state-chip img {
  width: clamp(24px, 2.4vw, 34px);
  height: auto;
}
.state-chip span {
  font-family: "Bungee", sans-serif;
  font-size: clamp(10px, 1vw, 14px);
  letter-spacing: 0.06em;
  color: var(--ink);
}
.state-chip.pursuing { background: #f6d7d2; }
.state-chip.pursuing span { color: #8f2118; }
.state-chip.escaping { background: #e2ecfa; }
.state-chip.escaping span { color: #1f4f8d; }

.banners {
  position: absolute;
  top: clamp(78px, 13vh, 150px);
  left: 50%;
  transform: translateX(-50%);
  width: min(38vw, 540px);
  pointer-events: none;
  z-index: 11;
}
.banner {
  display: block;
  width: 100%;
  height: auto;
  opacity: 0;
  transform: translate(-50%, -180%) rotate(-8deg);
  position: absolute;
  left: 50%;
  top: 0;
  filter: drop-shadow(0 8px 10px rgba(27, 42, 74, 0.25));
  will-change: transform, opacity;
}
.banner.show {
  animation: bannerSlam 2.65s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes bannerSlam {
  0%   { opacity: 0; transform: translate(-50%, -190%) rotate(-10deg) scale(1.08); }
  12%  { opacity: 1; transform: translate(-50%, 8px) rotate(2deg) scale(1.02); }
  17%  { transform: translate(-50%, -1px) rotate(-1.5deg) scale(1); }
  21%  { transform: translate(-50%, 3px) rotate(1.2deg) scale(1); }
  82%  { opacity: 1; transform: translate(-50%, 2px) rotate(-1deg) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -14px) rotate(4deg) scale(0.96); }
}

.stamina-wrap {
  position: absolute;
  left: max(10px, env(safe-area-inset-left));
  bottom: max(10px, env(safe-area-inset-bottom));
  width: clamp(190px, 26vw, 348px);
  padding: 6px 10px 4px;
  background-color: rgba(244, 239, 228, 0.92);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 9px 9px;
  border-radius: 3px 8px 4px 7px;
  box-shadow: var(--shadow);
  transform: rotate(-0.9deg);
}
.stamina-frame { position: relative; width: 100%; }
.stamina-frame > img {
  display: block;
  width: 100%;
  height: auto;
  filter: contrast(1.18) drop-shadow(0 1px 1px rgba(27, 42, 74, 0.16));
}
.stamina-fill {
  position: absolute;
  left: 18.5%;
  right: 2.2%;
  top: 20%;
  height: 26%;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--blue), var(--red));
  width: 0%;
  transition: width 0.18s linear;
  opacity: 0.9;
  mix-blend-mode: multiply;
}
.stamina-label {
  margin-top: -2px;
  margin-left: 19%;
  font-family: "Barlow Semi Condensed", sans-serif;
  font-weight: 700;
  font-size: clamp(8px, 0.75vw, 11px);
  letter-spacing: 0.22em;
  color: rgba(27, 42, 74, 0.67);
  text-shadow: 0 1px 0 rgba(232, 226, 214, 0.8);
}

.action-arc {
  position: absolute;
  right: max(8px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  gap: clamp(2px, 0.5vw, 7px);
  pointer-events: auto;
}
.action-btn {
  position: relative;
  width: clamp(78px, 8.6vw, 130px);
  height: auto;
  aspect-ratio: 0.9;
  padding: 4px;
  border: 0;
  border-radius: 50%;
  background: rgba(244, 239, 228, 0.95);
  box-shadow: 0 2px 0 rgba(27, 42, 74, 0.16), 0 5px 12px rgba(27, 42, 74, 0.2);
  cursor: pointer;
  touch-action: none;
  transform-origin: 50% 92%;
  transition: transform 0.1s ease, filter 0.1s ease;
  filter: drop-shadow(0 3px 4px rgba(27, 42, 74, 0.16));
  pointer-events: auto;
}
.action-btn img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
.action-btn:nth-child(1) { transform: rotate(-9deg) translateY(3px); }
.action-btn:nth-child(2) { transform: rotate(-1deg) translateY(-9px); }
.action-btn:nth-child(3) { transform: rotate(8deg) translateY(2px); }
.action-btn:nth-child(1).held { transform: rotate(-9deg) translateY(3px) scale(0.9); }
.action-btn:nth-child(2).held { transform: rotate(-1deg) translateY(-9px) scale(0.9); }
.action-btn:nth-child(3).held { transform: rotate(8deg) translateY(2px) scale(0.9); }
.action-btn.held { filter: brightness(1.16) drop-shadow(0 0 12px rgba(242, 179, 61, 0.55)); }
.action-btn:focus-visible { outline: 3px dashed var(--ink); outline-offset: 3px; border-radius: 50%; }

#reticle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(28px, 2.4vw, 38px);
  height: auto;
  transform: translate(-50%, -50%);
  opacity: 0.8;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(20, 25, 30, 0.8)) drop-shadow(0 0 4px rgba(232, 226, 214, 0.35));
}

.toast {
  position: absolute;
  left: 50%;
  top: clamp(150px, 26vh, 250px);
  transform: translate(-50%, -8px) rotate(-1deg);
  padding: 6px 16px;
  background: var(--paper);
  border-left: 4px solid var(--chalk);
  box-shadow: var(--shadow);
  font-family: "Barlow Semi Condensed", sans-serif;
  font-weight: 700;
  font-size: clamp(12px, 1.2vw, 17px);
  letter-spacing: 0.08em;
  color: var(--ink);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  white-space: nowrap;
  z-index: 9;
}
.toast.show { opacity: 1; transform: translate(-50%, 0) rotate(-1deg); }

.feed {
  position: absolute;
  right: max(12px, env(safe-area-inset-right));
  top: clamp(92px, 15vh, 140px);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  width: min(28vw, 280px);
  pointer-events: none;
}
.feed-line {
  padding: 3px 10px 3px 8px;
  background: rgba(244, 239, 228, 0.94);
  border-left: 3px solid var(--ink);
  font-family: "Barlow Semi Condensed", sans-serif;
  font-weight: 700;
  font-size: clamp(10px, 0.85vw, 13px);
  letter-spacing: 0.06em;
  color: var(--ink);
  box-shadow: 0 2px 4px rgba(27, 42, 74, 0.12);
  animation: feedIn 0.35s ease both;
  transition: opacity 0.5s ease;
}
.feed-line.red { border-left-color: var(--red); }
.feed-line.blue { border-left-color: var(--blue); }
.feed-line.fade { opacity: 0; }
@keyframes feedIn {
  from { opacity: 0; transform: translateX(14px) rotate(1.5deg); }
  to { opacity: 1; transform: none; }
}

/* ---------- touch stick ---------- */

#stick {
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  bottom: clamp(104px, 17vh, 170px);
  width: clamp(96px, 22vw, 132px);
  height: clamp(96px, 22vw, 132px);
  border-radius: 50%;
  border: 2px dashed rgba(232, 226, 214, 0.55);
  background: rgba(27, 42, 74, 0.16);
  z-index: 13;
  pointer-events: none;
  opacity: 0.85;
}
#stick[hidden] { display: none; }
#stick .stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46%;
  height: 46%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(244, 239, 228, 0.85);
  border: 2px solid rgba(27, 42, 74, 0.45);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* ---------- overlays ---------- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: radial-gradient(ellipse at 60% 35%, rgba(20, 24, 28, 0.18), rgba(17, 21, 25, 0.78));
  transition: opacity 0.3s ease;
}
.overlay.hidden { display: none; }
.overlay.dim { background: rgba(17, 21, 25, 0.62); backdrop-filter: blur(2px); }

.paper-card {
  position: relative;
  width: min(92vw, 480px);
  padding: clamp(20px, 3vw, 34px);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 12px 12px;
  border-radius: 4px 12px 6px 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), inset 0 0 0 2px rgba(27, 42, 74, 0.08);
  transform: rotate(-0.5deg);
}
.paper-card::before {
  content: "";
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  width: 94px;
  height: 24px;
  background: var(--tape);
}
.paper-card h2 {
  margin: 0 0 18px;
  font-family: "Bungee", sans-serif;
  font-size: clamp(24px, 3.6vw, 38px);
  text-align: center;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.paper-btn {
  position: relative;
  display: block;
  width: 100%;
  margin: 10px 0 0;
  padding: clamp(10px, 1.4vw, 15px) 16px;
  border: 2.5px solid var(--ink);
  border-radius: 4px 10px 5px 9px;
  background: var(--cream);
  color: var(--ink);
  font-family: "Bungee", sans-serif;
  font-size: clamp(16px, 2vw, 23px);
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 3px 3px 0 rgba(27, 42, 74, 0.18);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background-color 0.15s ease;
  touch-action: manipulation;
}
.paper-btn:hover { background: #fffaec; transform: rotate(-0.6deg); }
.paper-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 rgba(27, 42, 74, 0.18); }
.paper-btn.primary {
  background: var(--chalk);
  font-size: clamp(20px, 2.6vw, 30px);
  padding: clamp(13px, 1.8vw, 19px) 18px;
  border-width: 3px;
}
.paper-btn.primary:hover { background: #ffc657; }
.paper-btn.small { font-size: clamp(13px, 1.3vw, 16px); padding: 9px 12px; }

.controls-hint {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 2px dashed rgba(27, 42, 74, 0.28);
  font-family: "Barlow Semi Condensed", sans-serif;
  font-weight: 600;
  font-size: clamp(11px, 1.05vw, 14px);
  line-height: 1.5;
  color: rgba(27, 42, 74, 0.85);
}
.controls-hint b { font-weight: 800; letter-spacing: 0.06em; }
.controls-hint .keys {
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  background: rgba(27, 42, 74, 0.08);
  padding: 0 4px;
  border-radius: 2px;
}
.ctrl-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 13px;
  margin-top: 6px;
}
.ctrl-grid span { white-space: nowrap; }
.ctrl-grid .keys { font-size: 0.92em; }

/* menu */
.menu { align-items: flex-end; justify-content: flex-start; background: linear-gradient(to top, rgba(16, 20, 24, 0.82) 0%, rgba(16, 20, 24, 0.42) 46%, rgba(16, 20, 24, 0.12) 78%); }
.menu-inner {
  display: flex;
  width: 100%;
  align-items: flex-end;
  justify-content: space-between;
  gap: clamp(16px, 4vw, 60px);
  padding: clamp(6px, 1.5vw, 20px);
}
.menu-left { position: relative; width: min(46vw, 560px); }
.menu-sheet {
  position: relative;
  padding: clamp(14px, 2vw, 24px) clamp(14px, 2.2vw, 30px) clamp(18px, 2.4vw, 28px);
  background-color: rgba(244, 239, 228, 0.96);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 14px 14px;
  border-radius: 3px 14px 6px 10px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.42), inset 0 0 0 2px rgba(27, 42, 74, 0.07);
  transform: rotate(-1.2deg);
}
.menu-sheet::before, .menu-sheet::after {
  content: "";
  position: absolute;
  width: 86px;
  height: 24px;
  background: var(--tape);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}
.menu-sheet::before { top: -13px; left: 10%; transform: rotate(-5deg); }
.menu-sheet::after { bottom: -12px; right: 12%; transform: rotate(4deg); }
.menu-logo {
  display: block;
  width: min(100%, 440px);
  height: auto;
  margin: 0 auto;
  filter: drop-shadow(0 4px 3px rgba(27, 42, 74, 0.15));
}
.menu-kicker {
  display: inline-block;
  margin: 0 0 10px 4px;
  padding: 3px 10px;
  background: var(--ink);
  color: var(--cream);
  font-family: "Barlow Semi Condensed", sans-serif;
  font-weight: 700;
  font-size: clamp(9px, 0.9vw, 12px);
  letter-spacing: 0.18em;
  transform: rotate(-1.6deg);
}
.menu-blurb {
  margin: 10px 4px 0;
  font-size: clamp(12px, 1.2vw, 16px);
  font-weight: 600;
  line-height: 1.4;
  color: rgba(27, 42, 74, 0.85);
}
.menu-right {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(30vw, 340px);
  margin-bottom: 4px;
}
.menu-actions {
  position: relative;
  padding: 18px 16px 12px;
  background: rgba(244, 239, 228, 0.96);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 12px 12px;
  border-radius: 10px 4px 12px 5px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.36);
  transform: rotate(0.8deg);
}
.menu-actions::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 12%;
  width: 72px;
  height: 20px;
  background: var(--tape);
  transform: rotate(4deg);
}
.menu-note {
  align-self: flex-end;
  padding: 7px 12px;
  background: rgba(232, 226, 214, 0.92);
  border-bottom: 3px solid var(--chalk);
  font-family: "Barlow Semi Condensed", sans-serif;
  font-weight: 700;
  font-size: clamp(10px, 0.9vw, 13px);
  letter-spacing: 0.1em;
  color: var(--ink);
  transform: rotate(1.5deg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* help & settings */
.help-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px 14px;
  margin: 4px 0 18px;
  font-size: clamp(12px, 1.2vw, 16px);
  font-weight: 600;
  color: rgba(27, 42, 74, 0.9);
}
.help-grid .k {
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  font-size: clamp(10px, 1vw, 13px);
  background: rgba(27, 42, 74, 0.08);
  border: 1.5px solid rgba(27, 42, 74, 0.25);
  border-radius: 3px;
  padding: 1px 6px;
  white-space: nowrap;
  text-align: center;
}
.help-goal {
  margin: 0 0 16px;
  padding: 10px 12px;
  background: rgba(242, 179, 61, 0.18);
  border-left: 4px solid var(--chalk);
  font-size: clamp(12px, 1.2vw, 16px);
  font-weight: 600;
  line-height: 1.45;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 16px 0;
  font-weight: 700;
  font-size: clamp(12px, 1.2vw, 16px);
  letter-spacing: 0.04em;
}
.setting-row input[type="range"] {
  width: 55%;
  accent-color: var(--terracotta);
}
.setting-row select {
  font-family: "Barlow Semi Condensed", sans-serif;
  font-weight: 700;
  padding: 4px 8px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--cream);
  color: var(--ink);
}
.setting-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--terracotta);
}

/* result */
.result-card { text-align: center; }
.result-card .result-kicker {
  font-family: "Barlow Semi Condensed", sans-serif;
  font-weight: 800;
  letter-spacing: 0.2em;
  font-size: clamp(10px, 1vw, 13px);
  color: rgba(27, 42, 74, 0.7);
}
.result-title {
  margin: 6px 0 12px;
  font-family: "Bungee", sans-serif;
  font-size: clamp(26px, 4.4vw, 48px);
  line-height: 1.05;
  color: var(--ink);
}
.result-title.win { color: #1f5d3a; }
.result-title.caught { color: #a52a20; }
.result-stats {
  display: flex;
  justify-content: center;
  gap: clamp(14px, 3vw, 32px);
  margin: 8px 0 20px;
}
.result-stat {
  min-width: 80px;
  padding: 8px 10px;
  background: rgba(232, 226, 214, 0.75);
  border: 2px dashed rgba(27, 42, 74, 0.25);
  border-radius: 6px;
}
.result-stat .n {
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  font-size: clamp(20px, 2.6vw, 32px);
  line-height: 1;
}
.result-stat .l {
  font-weight: 700;
  font-size: clamp(8px, 0.8vw, 11px);
  letter-spacing: 0.12em;
  color: rgba(27, 42, 74, 0.65);
}

/* loading */
.loading { background: #171c21; z-index: 60; flex-direction: column; gap: 18px; }
.loading-text {
  font-family: "Bungee", sans-serif;
  color: var(--cream);
  font-size: clamp(14px, 1.6vw, 20px);
  letter-spacing: 0.12em;
  text-align: center;
}
.loading-bar {
  width: min(60vw, 300px);
  height: 10px;
  border: 2px solid var(--cream);
  border-radius: 6px;
  overflow: hidden;
}
.loading-bar i {
  display: block;
  height: 100%;
  width: 20%;
  background: var(--chalk);
  animation: loadSlide 1.4s ease-in-out infinite;
}
@keyframes loadSlide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(520%); }
}

/* pointer lock hint */
.lock-hint {
  position: absolute;
  left: 50%;
  top: 58%;
  transform: translate(-50%, 0);
  padding: 8px 16px;
  background: rgba(232, 226, 214, 0.9);
  border-radius: 4px;
  font-weight: 700;
  font-size: clamp(11px, 1.1vw, 14px);
  letter-spacing: 0.06em;
  color: var(--ink);
  z-index: 12;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.lock-hint.show { opacity: 1; }

/* ---------- narrow / portrait ---------- */

@media (max-width: 820px) {
  .hud-top { gap: 4px; }
  .counter { min-width: 0; padding: 4px 7px 3px; column-gap: 3px; }
  .counter::after { width: 50%; height: 11px; top: -5px; }
  .counter img { width: clamp(28px, 7.4vw, 44px); }
  .counter-num { font-size: clamp(24px, 6.4vw, 40px); }
  .counter-label { font-size: 7.5px; letter-spacing: 0.1em; }
  .timer-strip { padding: 4px 12px; gap: 4px; margin-top: 2px; }
  .timer-strip .timer-icon { width: 16px; }
  #timerText { font-size: clamp(20px, 5.4vw, 32px); }
  .timer-strip::before, .timer-strip::after { width: 18px; height: 10px; top: -5px; }
  .help-btn { top: clamp(58px, 9.5vh, 86px); width: 26px; height: 26px; font-size: 12px; }
  .action-btn { width: clamp(74px, 20vw, 98px); padding: 3px; }
  .stamina-wrap { width: clamp(120px, 33vw, 220px); bottom: max(6px, env(safe-area-inset-bottom)); padding: 4px 7px 3px; }
  .state-chip {
    top: calc(env(safe-area-inset-top, 0px) + 58px);
    bottom: auto;
    padding: 2px 8px 2px 3px;
    transform: translateX(-50%) rotate(-1deg);
  }
  .state-chip img { width: 22px; }
  .state-chip span { font-size: 9px; }
  .help-btn { top: calc(env(safe-area-inset-top, 0px) + 58px); left: max(12px, env(safe-area-inset-left)); transform: rotate(3deg); width: 27px; height: 27px; }
  .banners { width: min(76vw, 420px); top: calc(env(safe-area-inset-top, 0px) + clamp(84px, 15vh, 140px)); }
  #reticle { width: 18px; }
  .feed { display: none; }
  .toast { white-space: normal; text-align: center; max-width: 78vw; top: calc(env(safe-area-inset-top, 0px) + clamp(290px, 44vh, 400px)); }

  .menu { align-items: flex-end; background: linear-gradient(to top, rgba(16, 20, 24, 0.9) 0%, rgba(16, 20, 24, 0.55) 50%, rgba(16, 20, 24, 0.2) 85%); }
  .menu-inner { flex-direction: column; align-items: stretch; justify-content: flex-end; gap: 12px; padding: 0; }
  .menu-left { width: 100%; }
  .menu-sheet { padding: 12px 14px 14px; transform: rotate(-0.8deg); }
  .menu-logo { width: min(80%, 360px); }
  .menu-kicker { font-size: 9px; margin-bottom: 6px; }
  .menu-blurb { font-size: 12px; margin-top: 6px; }
  .menu-right { width: 100%; gap: 8px; }
  .menu-actions { padding: 14px 12px 8px; }
  .paper-btn { margin-top: 8px; padding: 10px 12px; font-size: 16px; }
  .paper-btn.primary { font-size: 21px; padding: 12px; }
  .menu-note { align-self: center; font-size: 9px; }
  .controls-hint { font-size: 11px; margin-top: 12px; }
  .paper-card { width: min(94vw, 430px); }
}

@media (max-height: 640px) {
  .paper-card { max-height: calc(100dvh - 18px); overflow-y: auto; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .menu-inner { max-height: calc(100dvh - 8px); overflow-y: auto; }
  .menu-inner { align-items: flex-end; }
  .menu-sheet { padding: 8px 12px 10px; }
  .menu-logo { width: min(60%, 300px); }
  .menu-blurb { display: none; }
  .menu-actions { padding: 10px 10px 6px; }
  .paper-btn { padding: 7px 10px; font-size: 14px; margin-top: 5px; }
  .paper-btn.primary { font-size: 18px; padding: 9px; }
  .controls-hint { display: none; }
  .banners { top: 64px; width: min(34vw, 380px); }
  .feed { display: none; }
  .stamina-wrap { width: clamp(150px, 24vw, 250px); }
  .action-btn { width: clamp(62px, 9vw, 96px); }
}

@media (hover: none) and (pointer: coarse) {
  .lock-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .banner.show { animation-duration: 2.2s; }
  .timer-strip.urgent { animation: none; }
}
