@font-face {
  font-family: 'Pirata One';
  src: url('./assets/fonts/pirata-one.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Space Grotesk';
  src: url('./assets/fonts/space-grotesk-400.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Space Grotesk';
  src: url('./assets/fonts/space-grotesk-500.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Space Grotesk';
  src: url('./assets/fonts/space-grotesk-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Barlow Condensed';
  src: url('./assets/fonts/barlow-condensed-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Barlow Condensed';
  src: url('./assets/fonts/barlow-condensed-800.woff2') format('woff2');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #080711;
  --ink-2: #100d1d;
  --cream: #f2e6cd;
  --muted: rgba(242, 230, 205, 0.62);
  --faint: rgba(242, 230, 205, 0.34);
  --gold: #e7bb64;
  --gold-hi: #ffe6a8;
  --gold-lo: #a97c2c;
  --blood: #a92b34;
  --blood-hi: #e0535c;
  --moon: #9cc4ff;
  --display: 'Pirata One', 'Times New Roman', serif;
  --ui: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --cond: 'Barlow Condensed', 'Arial Narrow', sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--ui);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

body {
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
}

a {
  color: var(--gold);
}

#app {
  position: fixed;
  inset: 0;
  isolation: isolate;
}

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

/* ---------- film treatment ---------- */
.fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.fx.grain {
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 220px 220px;
  animation: grain 0.42s steps(3) infinite;
  mix-blend-mode: overlay;
}
.fx.scanlines {
  opacity: 0.16;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.45) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}
.fx.vignette {
  background:
    radial-gradient(ellipse at 50% 46%, transparent 38%, rgba(3, 2, 8, 0.55) 82%, rgba(3, 2, 8, 0.92) 100%),
    linear-gradient(to bottom, rgba(4, 3, 10, 0.5), transparent 18%, transparent 76%, rgba(4, 3, 10, 0.72));
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  33% { transform: translate(-3%, 2%); }
  66% { transform: translate(2%, -3%); }
  100% { transform: translate(0, 0); }
}

#flash {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.28s ease-out;
  background: rgba(255, 60, 60, 0.3);
}
#flash.show {
  opacity: 1;
  transition: opacity 0.04s;
}

/* ---------- shared bits ---------- */
.hidden {
  display: none !important;
}
.screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}
.screen button,
.screen a,
.screen .how-panel,
.screen .modal-card {
  pointer-events: auto;
}
.end-kicker,
.hud-kicker,
.kicker {
  font-family: var(--cond);
  font-weight: 700;
  letter-spacing: 0.22em;
  font-size: 0.68rem;
  text-transform: uppercase;
  color: var(--gold);
}
kbd {
  display: inline-block;
  min-width: 1.55em;
  padding: 0.12em 0.38em;
  border: 1px solid rgba(242, 230, 205, 0.28);
  border-bottom-width: 2px;
  border-radius: 3px;
  font-family: var(--cond);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--cream);
  background: rgba(255, 255, 255, 0.05);
}

/* ---------- buttons ---------- */
.big-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.7em;
  padding: 0.92em 1.5em;
  border: 0;
  background: linear-gradient(180deg, #f4d188 0%, #d8a64e 58%, #b07d2b 100%);
  color: #1a1206;
  font-family: var(--cond);
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  text-decoration: none;
  clip-path: polygon(0 0, calc(100% - 15px) 0, 100% 15px, 100% 100%, 15px 100%, 0 calc(100% - 15px));
  box-shadow: 0 10px 30px rgba(231, 187, 100, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.55);
  cursor: pointer;
  transition: transform 0.16s ease, filter 0.16s ease, box-shadow 0.16s ease;
}
.big-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.07);
  box-shadow: 0 16px 42px rgba(231, 187, 100, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.big-btn:active {
  transform: translateY(1px);
}
.big-btn span {
  font-size: 1.1em;
}
.big-btn.small {
  font-size: 1.05rem;
  padding: 0.8em 1.2em;
}
.link-btn {
  border: 0;
  border-bottom: 1px solid rgba(231, 187, 100, 0.34);
  background: none;
  padding: 0.35em 0.1em;
  color: var(--muted);
  font-family: var(--cond);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.link-btn:hover {
  color: var(--gold-hi);
  border-color: var(--gold);
}

/* ---------- menu ---------- */
.menu {
  display: grid;
  align-items: center;
  padding: 5vh 6vw 4vh;
  overflow-y: auto;
  background:
    linear-gradient(100deg, rgba(6, 5, 12, 0.97) 0%, rgba(6, 5, 12, 0.91) 32%, rgba(6, 5, 12, 0.48) 58%, rgba(6, 5, 12, 0.02) 82%),
    linear-gradient(to top, rgba(6, 5, 12, 0.85), transparent 40%);
  transition: opacity 0.4s ease;
}
.menu.hidden {
  display: none;
}
.menu-vhs {
  position: absolute;
  top: 3.2vh;
  right: 4vw;
  font-family: var(--cond);
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.26em;
  color: rgba(242, 230, 205, 0.42);
}
.menu-vhs::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 0.7em;
  border-radius: 50%;
  background: var(--blood-hi);
  box-shadow: 0 0 10px var(--blood-hi);
  animation: rec 2s infinite;
}
@keyframes rec {
  0%, 45% { opacity: 1; }
  50%, 100% { opacity: 0.15; }
}
.menu-inner {
  width: min(760px, 94vw);
  padding-bottom: 2vh;
}
.menu .kicker {
  display: flex;
  align-items: center;
  gap: 0.7em;
  margin-bottom: 1.2rem;
  color: var(--gold);
}
.menu .kicker .dot {
  width: 7px;
  height: 7px;
  background: var(--blood-hi);
  box-shadow: 0 0 12px var(--blood-hi);
  transform: rotate(45deg);
}
.title {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(5.4rem, 15vw, 12.5rem);
  line-height: 0.76;
  letter-spacing: 0.005em;
  background: linear-gradient(178deg, #fff5cf 0%, #f0cd82 26%, #d5a447 54%, #9d6c25 76%, #f4d995 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 5px 0 rgba(30, 15, 0, 0.7)) drop-shadow(0 0 38px rgba(231, 187, 100, 0.28));
  transform: rotate(-1.2deg);
  transform-origin: left center;
  animation: title-in 1s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}
.title span {
  display: inline-block;
  margin-left: 0.12em;
  padding-right: 0.08em;
}
@keyframes title-in {
  from { opacity: 0; transform: translateY(18px) rotate(-1.2deg) scale(0.98); }
  to { opacity: 1; transform: translateY(0) rotate(-1.2deg) scale(1); }
}
.subtitle {
  margin-top: 1.1rem;
  font-family: var(--cond);
  font-weight: 700;
  font-size: clamp(0.85rem, 1.5vw, 1.05rem);
  letter-spacing: 0.34em;
  color: var(--cream);
  text-shadow: 0 0 24px rgba(0, 0, 0, 0.9);
}
.subtitle::before {
  content: '';
  display: inline-block;
  width: 2.2rem;
  height: 1px;
  margin-right: 0.9em;
  vertical-align: middle;
  background: linear-gradient(to right, transparent, var(--gold));
}
.blurb {
  max-width: 50ch;
  margin: 1.35rem 0 1.7rem;
  font-size: clamp(0.92rem, 1.15vw, 1.02rem);
  line-height: 1.62;
  color: rgba(242, 230, 205, 0.78);
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.8);
}
.blurb em {
  color: var(--gold);
  font-style: normal;
}
.menu-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.4rem;
}
.menu-actions .big-btn {
  margin-right: 0.4rem;
}
.menu-foot {
  margin-top: 2.6rem;
  padding-top: 1.1rem;
  border-top: 1px solid rgba(242, 230, 205, 0.12);
}
.menu-tip {
  font-family: var(--display);
  font-size: 1.55rem;
  line-height: 1.2;
  color: var(--gold);
  opacity: 0.9;
  min-height: 1.4em;
  transition: opacity 0.3s;
}
.credits {
  margin-top: 0.7rem;
  font-size: 0.68rem;
  line-height: 1.7;
  letter-spacing: 0.03em;
  color: var(--faint);
}
.credits a {
  color: rgba(231, 187, 100, 0.75);
  text-decoration: none;
  border-bottom: 1px dotted rgba(231, 187, 100, 0.4);
}
.credits a:hover {
  color: var(--gold-hi);
}

/* how to play panel */
.how-panel {
  position: fixed;
  right: 4vw;
  bottom: 5vh;
  z-index: 24;
  width: min(390px, 92vw);
  max-height: 74vh;
  overflow-y: auto;
  padding: 1.4rem 1.5rem 1.2rem;
  background: linear-gradient(160deg, rgba(24, 18, 36, 0.97), rgba(10, 8, 18, 0.97));
  border: 1px solid rgba(231, 187, 100, 0.3);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.how-panel.open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.how-panel h3 {
  margin: 0 0 0.8rem;
  font-family: var(--cond);
  font-weight: 800;
  letter-spacing: 0.2em;
  font-size: 0.95rem;
  color: var(--gold);
}
.how-panel ul {
  margin: 0 0 1.1rem;
  padding-left: 1.1rem;
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--muted);
}
.how-panel li {
  margin-bottom: 0.5rem;
}
.how-panel b {
  color: var(--cream);
  font-weight: 500;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  font-family: var(--ui);
}
#hud.hidden {
  display: none;
}
.hud-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.4rem;
  padding: clamp(12px, 2vw, 26px);
}
.hud-card {
  background: linear-gradient(160deg, rgba(15, 12, 26, 0.82), rgba(8, 7, 16, 0.72));
  border: 1px solid rgba(231, 187, 100, 0.26);
  border-top-color: rgba(231, 187, 100, 0.45);
  padding: 0.72rem 0.9rem 0.78rem;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.34);
}
.objective-card {
  min-width: 236px;
}
#objective {
  margin-top: 0.28rem;
  font-family: var(--cond);
  font-weight: 800;
  font-size: 1.32rem;
  letter-spacing: 0.045em;
  color: var(--cream);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}
.steps {
  display: flex;
  gap: 0.28rem;
  margin-top: 0.55rem;
  flex-wrap: wrap;
}
.step {
  padding: 0.16em 0.46em;
  border: 1px solid rgba(242, 230, 205, 0.14);
  font-family: var(--cond);
  font-weight: 700;
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  color: var(--faint);
}
.step.active {
  color: #1a1206;
  background: var(--gold);
  border-color: var(--gold);
}
.step.done {
  color: rgba(242, 230, 205, 0.4);
  text-decoration: line-through;
  border-color: rgba(242, 230, 205, 0.08);
}
.timer {
  width: clamp(190px, 26vw, 360px);
  margin-top: 0.35rem;
  text-align: center;
}
.timer-label {
  font-family: var(--cond);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.24em;
  color: var(--muted);
}
.timer-label b {
  margin-left: 0.5em;
  font-family: var(--cond);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  color: var(--cream);
}
.timer-track {
  height: 7px;
  margin-top: 0.4rem;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(242, 230, 205, 0.14);
  overflow: hidden;
}
#timer-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #7fc8a9, #e7bb64 62%, #e0535c);
  transition: width 0.15s linear;
}
.timer.danger .timer-label b {
  color: var(--blood-hi);
  animation: blink 0.9s infinite;
}
.timer.danger .timer-track {
  border-color: rgba(224, 83, 92, 0.6);
  box-shadow: 0 0 18px rgba(224, 83, 92, 0.35);
}
@keyframes blink {
  50% { opacity: 0.35; }
}
.resource-card {
  display: flex;
  gap: 1.1rem;
  align-items: center;
}
.resources {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.gold-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.pips {
  display: flex;
  gap: 0.3rem;
}
.pips i {
  width: 11px;
  height: 11px;
  border: 1px solid rgba(231, 187, 100, 0.5);
  transform: rotate(45deg);
  background: transparent;
  transition: background 0.2s, box-shadow 0.2s;
}
.pips i.on {
  background: var(--gold);
  box-shadow: 0 0 12px rgba(231, 187, 100, 0.7);
}
.hearts {
  display: flex;
  gap: 0.22rem;
  font-size: 1.02rem;
  line-height: 1;
  color: #d8535c;
}
.hearts i {
  font-style: normal;
  text-shadow: 0 0 10px rgba(216, 83, 92, 0.45);
  transition: opacity 0.2s;
}
.hearts i.lost {
  opacity: 0.16;
  text-shadow: none;
}
.hud-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
}
.icon-btn {
  width: 30px;
  height: 30px;
  border: 1px solid rgba(242, 230, 205, 0.22);
  background: rgba(255, 255, 255, 0.04);
  color: var(--cream);
  font-family: var(--cond);
  font-weight: 700;
  font-size: 0.72rem;
  cursor: pointer;
  pointer-events: auto;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover {
  background: rgba(231, 187, 100, 0.18);
  color: var(--gold-hi);
}
.icon-btn.off {
  color: var(--blood-hi);
}
.alert-banner {
  position: absolute;
  top: 6.2rem;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 1rem;
  background: linear-gradient(180deg, rgba(169, 43, 52, 0.95), rgba(110, 20, 28, 0.95));
  border: 1px solid rgba(255, 140, 140, 0.55);
  box-shadow: 0 0 30px rgba(224, 83, 92, 0.35);
  font-family: var(--cond);
  font-weight: 800;
  letter-spacing: 0.16em;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
}
.alert-banner.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  animation: alert-pulse 0.8s infinite;
}
.alert-banner span {
  color: #ffdcdc;
  font-size: 0.72rem;
}
.alert-banner b {
  color: #fff3f3;
}
@keyframes alert-pulse {
  50% { box-shadow: 0 0 46px rgba(224, 83, 92, 0.65); }
}
.hidden-badge {
  position: absolute;
  left: 50%;
  bottom: 7.2rem;
  transform: translateX(-50%) translateY(6px);
  padding: 0.32rem 0.9rem;
  border: 1px solid rgba(156, 196, 255, 0.5);
  background: rgba(18, 30, 54, 0.8);
  color: #cfe3ff;
  font-family: var(--cond);
  font-weight: 800;
  letter-spacing: 0.2em;
  font-size: 0.74rem;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
}
.hidden-badge.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.hud-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.2rem;
  padding: clamp(12px, 2vw, 26px);
  padding-bottom: max(clamp(12px, 2vw, 26px), env(safe-area-inset-bottom));
}
.noise {
  width: clamp(190px, 22vw, 270px);
}
.noise-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--cond);
  font-weight: 700;
  font-size: 0.66rem;
  letter-spacing: 0.17em;
  color: var(--muted);
}
.noise-head b {
  font-weight: 800;
  color: var(--cream);
}
.noise-track {
  height: 9px;
  margin-top: 0.35rem;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(242, 230, 205, 0.16);
  overflow: hidden;
}
#noise-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #8fe3b0, #d9f2b0);
  transition: width 0.12s linear, background 0.2s;
}
.noise.hot {
  animation: noise-shake 0.16s infinite;
}
@keyframes noise-shake {
  50% { transform: translateX(1px); }
}
.prompt {
  align-self: center;
  margin-bottom: 0.5rem;
  padding: 0.55rem 1.1rem;
  background: rgba(9, 7, 17, 0.82);
  border: 1px solid rgba(231, 187, 100, 0.32);
  border-left: 3px solid var(--gold);
  font-family: var(--cond);
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.12em;
  color: var(--cream);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s, transform 0.2s;
  text-align: center;
}
.prompt.show {
  opacity: 1;
  transform: none;
}
.legend {
  display: flex;
  gap: 0.9rem;
  font-family: var(--cond);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--faint);
  white-space: nowrap;
}
.legend span {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* toast */
.toast {
  position: absolute;
  top: 17%;
  left: 50%;
  z-index: 26;
  transform: translate(-50%, -8px);
  padding: 0.6rem 1.2rem;
  background: rgba(8, 7, 16, 0.9);
  border: 1px solid rgba(231, 187, 100, 0.3);
  border-left: 4px solid var(--gold);
  font-family: var(--cond);
  font-weight: 800;
  font-size: 1.02rem;
  letter-spacing: 0.09em;
  color: var(--cream);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: min(86vw, 620px);
  text-align: center;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.5);
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast.bad {
  border-left-color: var(--blood-hi);
  color: #ffdede;
}
.toast.good {
  border-left-color: var(--gold);
  color: #fff2cd;
}
.toast.warn {
  border-left-color: #ff9a5c;
}
.toast.info {
  border-left-color: var(--moon);
}

/* ---------- end / pause ---------- */
#end {
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(6, 5, 12, 0.45), rgba(4, 3, 9, 0.88));
  overflow-y: auto;
  padding: 4vh 4vw;
}
.end-card,
.pause-card {
  width: min(570px, 94vw);
  padding: 2rem 2.2rem 1.8rem;
  background: linear-gradient(165deg, rgba(25, 19, 38, 0.97), rgba(8, 7, 16, 0.98));
  border: 1px solid rgba(231, 187, 100, 0.32);
  box-shadow: 0 40px 90px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  text-align: left;
  animation: card-in 0.45s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(18px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
.end-card h2,
.pause-card h2 {
  margin: 0.2rem 0 0.6rem;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(3.2rem, 8vw, 5.2rem);
  line-height: 0.9;
  background: linear-gradient(180deg, #fff5cf, #e7bb64 55%, #a97c2c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.55));
}
#end-sub,
.pause-card p {
  margin: 0.4rem 0 1.2rem;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--muted);
}
.end-score-row {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  padding: 1rem 0 1.1rem;
  border-top: 1px solid rgba(242, 230, 205, 0.1);
  border-bottom: 1px solid rgba(242, 230, 205, 0.1);
}
.rank {
  width: 5.2rem;
  height: 5.2rem;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: 4rem;
  line-height: 1;
  color: var(--gold);
  border: 2px solid rgba(231, 187, 100, 0.45);
  background: radial-gradient(circle at 50% 40%, rgba(231, 187, 100, 0.16), transparent 70%);
}
.rank[data-rank='S'] { color: #ffe6a8; box-shadow: 0 0 34px rgba(231, 187, 100, 0.35); }
.rank[data-rank='A'] { color: #d9dde6; border-color: rgba(217, 221, 230, 0.4); }
.rank[data-rank='B'] { color: #d6a273; border-color: rgba(214, 162, 115, 0.4); }
.rank[data-rank='X'] { color: var(--blood-hi); border-color: rgba(224, 83, 92, 0.35); font-size: 2.4rem; }
.end-score-label {
  font-family: var(--cond);
  font-weight: 700;
  font-size: 0.66rem;
  letter-spacing: 0.24em;
  color: var(--faint);
}
.end-score {
  font-family: var(--cond);
  font-weight: 800;
  font-size: 2.7rem;
  line-height: 1;
  color: var(--cream);
}
.end-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.1rem 1.6rem;
  margin: 1rem 0 0.6rem;
}
.end-stats > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.36rem 0;
  border-bottom: 1px dotted rgba(242, 230, 205, 0.1);
}
.end-stats span {
  font-family: var(--cond);
  font-size: 0.64rem;
  letter-spacing: 0.14em;
  color: var(--faint);
}
.end-stats b {
  font-family: var(--cond);
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--cream);
  white-space: nowrap;
}
.end-line {
  margin: 1rem 0 1.3rem;
  font-family: var(--display);
  font-size: 1.25rem;
  color: var(--gold);
  opacity: 0.85;
}
.end-actions {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  flex-wrap: wrap;
}
#pause {
  display: grid;
  place-items: center;
  background: rgba(5, 4, 11, 0.72);
}
.pause-card {
  text-align: center;
  width: min(430px, 92vw);
}
.pause-card .big-btn {
  margin: 0.4rem 0 0.9rem;
}
.pause-card .link-btn {
  display: block;
  margin: 0.5rem auto 0;
}

/* ---------- port modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 4vh 4vw;
  background: rgba(4, 3, 9, 0.78);
  pointer-events: auto;
  overflow-y: auto;
}
.modal-card {
  width: min(760px, 96vw);
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.8rem 2rem;
  background: linear-gradient(165deg, rgba(24, 18, 36, 0.99), rgba(8, 7, 16, 0.99));
  border: 1px solid rgba(231, 187, 100, 0.3);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.8);
}
.modal-card h2 {
  margin: 0.2rem 0 0.8rem;
  font-family: var(--cond);
  font-weight: 800;
  font-size: clamp(1.5rem, 3vw, 2rem);
  letter-spacing: 0.04em;
  color: var(--cream);
}
.modal-card p {
  font-size: 0.86rem;
  line-height: 1.65;
  color: var(--muted);
}
.modal-card code {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 0.78em;
  color: var(--gold);
  background: rgba(231, 187, 100, 0.08);
  padding: 0.1em 0.35em;
  border: 1px solid rgba(231, 187, 100, 0.16);
}
.port-grid {
  display: grid;
  gap: 0.35rem;
  margin: 1rem 0;
}
.port-grid > div {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.7rem;
  align-items: center;
  padding: 0.45rem 0.6rem;
  border: 1px solid rgba(242, 230, 205, 0.1);
  background: rgba(255, 255, 255, 0.02);
}
.port-grid span {
  color: var(--faint);
  font-size: 0.8rem;
}
.modal-note {
  margin-top: 1.1rem;
}
.modal-card .big-btn {
  margin: 0.4rem 0 0.9rem;
}
.modal-card .link-btn {
  display: block;
}

/* ---------- mobile controls ---------- */
.mobile-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 12;
  display: none;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 20px calc(20px + env(safe-area-inset-bottom));
  pointer-events: none;
}
.touch .mobile-controls {
  display: flex;
}
.touch.menu-open .mobile-controls {
  display: none;
}
.touch .legend {
  display: none;
}
.touch .prompt {
  bottom: 17rem;
}
.joystick {
  position: relative;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  border: 1px solid rgba(231, 187, 100, 0.35);
  background: radial-gradient(circle, rgba(20, 16, 32, 0.55), rgba(8, 7, 16, 0.35));
  pointer-events: auto;
  touch-action: none;
}
#joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 240, 200, 0.95), rgba(231, 187, 100, 0.75));
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
  transition: transform 0.06s linear;
}
.mobile-buttons {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
}
.round-btn {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 1px solid rgba(231, 187, 100, 0.5);
  background: radial-gradient(circle at 40% 30%, rgba(60, 45, 24, 0.8), rgba(15, 12, 22, 0.82));
  color: var(--gold-hi);
  font-family: var(--cond);
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  pointer-events: auto;
  touch-action: none;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45);
  user-select: none;
}
.round-btn.held,
.round-btn:active {
  background: radial-gradient(circle at 40% 30%, rgba(255, 230, 168, 0.9), rgba(180, 130, 50, 0.9));
  color: #1a1206;
}
.round-btn.sprint {
  width: 92px;
  height: 92px;
}

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .menu {
    background:
      linear-gradient(180deg, rgba(6, 5, 12, 0.78) 0%, rgba(6, 5, 12, 0.9) 46%, rgba(6, 5, 12, 0.98) 100%),
      linear-gradient(100deg, rgba(6, 5, 12, 0.6), transparent);
  }
  .title {
    font-size: clamp(5rem, 21vw, 9.5rem);
  }
  .menu-inner {
    width: min(620px, 92vw);
  }
  .hud-top {
    gap: 0.7rem;
  }
  .objective-card {
    min-width: 0;
  }
  .legend {
    display: none;
  }
  .prompt {
    position: absolute;
    left: 50%;
    transform: translateX(-50%) translateY(6px);
    bottom: 5.2rem;
    white-space: nowrap;
    max-width: 92vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .prompt.show {
    transform: translateX(-50%);
  }
  .hud-bottom {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .menu {
    padding: 4vh 6vw;
    align-items: start;
  }
  .menu-vhs {
    display: none;
  }
  .menu-inner {
    padding-top: 2vh;
  }
  .title {
    font-size: clamp(4.4rem, 24vw, 8rem);
  }
  .subtitle {
    letter-spacing: 0.2em;
    font-size: 0.76rem;
  }
  .blurb {
    font-size: 0.86rem;
    line-height: 1.55;
  }
  .menu-actions {
    gap: 0.9rem;
  }
  .menu-actions .big-btn {
    width: 100%;
    justify-content: center;
  }
  .menu-foot {
    margin-top: 1.6rem;
  }
  .menu-tip {
    font-size: 1.25rem;
  }
  .hud-top {
    flex-wrap: wrap;
    padding: 10px 10px 0;
  }
  .objective-card {
    flex: 1;
    padding: 0.55rem 0.65rem;
  }
  #objective {
    font-size: 1.02rem;
    letter-spacing: 0.02em;
  }
  .steps {
    margin-top: 0.35rem;
  }
  .step {
    font-size: 0.55rem;
  }
  .timer {
    order: 3;
    width: 100%;
    margin-top: 0;
    padding: 0 2px;
  }
  .timer-label {
    font-size: 0.62rem;
  }
  .resource-card {
    gap: 0.6rem;
    padding: 0.55rem 0.6rem;
  }
  .hud-buttons {
    flex-direction: row;
  }
  .icon-btn {
    width: 26px;
    height: 26px;
  }
  .alert-banner {
    top: 8.6rem;
    font-size: 0.75rem;
    max-width: 92vw;
  }
  .hud-bottom {
    padding: 10px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  .noise {
    width: 46vw;
  }
  .noise-head {
    font-size: 0.56rem;
  }
  .hidden-badge {
    bottom: 6rem;
  }
  .toast {
    top: 20%;
    font-size: 0.86rem;
    padding: 0.5rem 0.8rem;
  }
  .end-card,
  .pause-card {
    padding: 1.4rem 1.2rem;
  }
  .end-stats {
    grid-template-columns: 1fr;
  }
  .end-card h2 {
    font-size: 3.4rem;
  }
  .rank {
    width: 4rem;
    height: 4rem;
    font-size: 3rem;
  }
  .end-score {
    font-size: 2.1rem;
  }
  .modal-card {
    padding: 1.2rem 1rem;
  }
  .port-grid > div {
    grid-template-columns: 1fr;
    gap: 0.15rem;
    font-size: 0.72rem;
  }
  .port-grid span {
    display: none;
  }
  .how-panel {
    right: 4vw;
    left: 4vw;
    width: auto;
    bottom: 3vh;
  }
}

@media (max-height: 640px) and (min-width: 721px) {
  .title {
    font-size: clamp(4rem, 12vh, 8rem);
  }
  .blurb {
    margin: 0.8rem 0 1rem;
  }
  .menu-foot {
    margin-top: 1.2rem;
  }
}

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

/* overlays that need to scroll must receive the pointer */
.menu,
#end,
#pause {
  pointer-events: auto;
}
