:root {
  --ink: #100e0c;
  --paper: #efe6d6;
  --brass: #d6b36a;
  --brass-2: #f0d7a2;
  --blood: #ff3b30;
  --muted: rgba(239, 230, 214, 0.62);
  --line: rgba(239, 230, 214, 0.14);
  --serif: "Fraunces", Georgia, serif;
  --sans: "Outfit", "Avenir Next", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--paper); }
body {
  font-family: var(--sans);
  font-weight: 400;
  overflow: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 3px; }
body.locked, body.locked * { cursor: none !important; }

body::before {
  content: "";
  position: fixed;
  inset: -20%;
  pointer-events: none;
  z-index: 1;
  opacity: 0.045;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  background: #0e0c0a;
}

#boot {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: #0e0c0a;
  color: var(--brass);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 12px;
}
body.ready #boot { display: none; }

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

#intro {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  background: #0e0c0a;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.85s ease;
}
#intro::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 130vmin;
  height: 80vmin;
  transform: translate(-50%, -50%) scale(0.55);
  background: radial-gradient(closest-side, rgba(214, 179, 106, 0.2), rgba(214, 179, 106, 0.05) 60%, transparent);
  opacity: 0;
}
.intro-inner {
  position: relative;
  text-align: center;
  transition: transform 0.9s cubic-bezier(0.4, 0, 0.2, 1), filter 0.9s ease;
}
.intro-name {
  margin: 0;
  font-family: var(--serif);
  font-weight: 560;
  font-size: clamp(54px, 11vw, 148px);
  line-height: 0.95;
  letter-spacing: -0.04em;
  color: var(--paper);
}
.intro-letters { display: flex; flex-wrap: wrap; justify-content: center; column-gap: 0.26em; }
.intro-word { display: inline-flex; white-space: nowrap; }
.intro-word span {
  display: inline-block;
  opacity: 0;
  transform: translateY(0.38em) rotate(5deg);
  filter: blur(10px);
}
.intro-rule {
  display: block;
  width: min(340px, 62vw);
  height: 1px;
  margin: 28px auto 20px;
  background: linear-gradient(90deg, transparent, var(--brass) 30%, var(--brass-2) 50%, var(--brass) 70%, transparent);
  transform: scaleX(0);
}
.intro-presents {
  margin: 0;
  padding-left: 0.72em;
  color: var(--brass);
  font-size: clamp(12px, 1.5vw, 16px);
  font-weight: 500;
  letter-spacing: 0.72em;
  text-transform: uppercase;
  opacity: 0;
}
#intro.go::before { animation: intro-glow 2.6s ease-out 0.1s forwards; }
/* Letters rise out of a blur, then a brass shine ripples through them once the name has settled. */
#intro.go .intro-word span {
  animation:
    intro-letter 0.95s cubic-bezier(0.2, 0.7, 0.2, 1) forwards,
    intro-shine 0.8s ease-in-out;
  animation-delay: calc(0.2s + var(--i) * 0.07s), calc(1.8s + var(--i) * 0.06s);
}
#intro.go .intro-rule { animation: intro-rule 1.05s cubic-bezier(0.6, 0, 0.2, 1) 1.05s forwards; }
#intro.go .intro-presents { animation: intro-presents 1.3s cubic-bezier(0.2, 0.7, 0.2, 1) 1.35s forwards; }
@keyframes intro-glow { to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes intro-letter { to { opacity: 1; transform: none; filter: blur(0); } }
@keyframes intro-shine { 50% { color: #fff7e6; text-shadow: 0 0 22px rgba(240, 215, 162, 0.7); } }
@keyframes intro-rule { to { transform: scaleX(1); } }
@keyframes intro-presents {
  from { letter-spacing: 1.3em; padding-left: 1.3em; }
  to { opacity: 1; letter-spacing: 0.72em; padding-left: 0.72em; }
}
body.intro-out #intro { opacity: 0; pointer-events: none; }
body.intro-out .intro-inner { transform: scale(1.06); filter: blur(6px); }

/* The welcome page rises in once the terms are accepted. */
#welcome .welcome-copy > :nth-child(1) { --d: 0.25s; }
#welcome .welcome-copy > :nth-child(2) { --d: 0.33s; }
#welcome .welcome-copy > :nth-child(3) { --d: 0.41s; }
#welcome .welcome-copy > :nth-child(4) { --d: 0.49s; }
#welcome .welcome-copy > :nth-child(5) { --d: 0.57s; }
#welcome .welcome-copy > :nth-child(6) { --d: 0.65s; }
#welcome .welcome-copy > :nth-child(7) { --d: 0.73s; }
#welcome .hero-frame { --d: 0.4s; }
#welcome .hints { --d: 0.75s; }
body.welcome-enter #welcome :is(.welcome-copy > *, .hero-frame, .hints) {
  animation: rise-in 1s cubic-bezier(0.2, 0.7, 0.2, 1) var(--d) both;
}
@keyframes rise-in { from { opacity: 0; transform: translateY(18px); } }
/* The terms card rises in as the intro clears. An animation (not a transition) so the card is
   guaranteed visible once the intro classes are removed, whatever state the animation reached. */
body.intro #terms .terms-card { opacity: 0; }
body.intro-out #terms .terms-card {
  opacity: 1;
  animation: rise-in 1.1s cubic-bezier(0.2, 0.7, 0.2, 1) 0.25s both;
}
@media (prefers-reduced-motion: reduce) {
  #intro.go::before, #intro.go .intro-rule, #intro.go .intro-presents {
    animation-duration: 0.4s;
    animation-delay: 0s;
  }
  #intro.go .intro-word span { animation: intro-letter 0.4s ease forwards; transform: none; filter: none; }
  body.welcome-enter #welcome :is(.welcome-copy > *, .hero-frame, .hints) { animation-name: fade-in; }
  body.intro-out #terms .terms-card { animation-name: fade-in; }
}
@keyframes fade-in { from { opacity: 0; } }

#terms {
  display: grid;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  background:
    radial-gradient(760px 480px at 50% 38%, rgba(214, 179, 106, 0.13), transparent 65%),
    #0e0c0a;
}
/* Auto margins centre the card but fall back to the top when it is taller than the screen, so nothing is cut off. */
#terms .terms-card { margin: auto; width: min(620px, 100%); }
.terms-card h2 { font-size: clamp(36px, 6vw, 52px); }
.terms-lead { margin: 14px 0 0; color: var(--muted); line-height: 1.45; }
.terms-list {
  counter-reset: term;
  list-style: none;
  margin: 22px 0 26px;
  padding: 0;
  display: grid;
  gap: 14px;
}
.terms-list li {
  counter-increment: term;
  display: grid;
  grid-template-columns: 34px 1fr;
  column-gap: 4px;
  padding: 16px 18px 16px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(239, 230, 214, 0.03);
}
.terms-list li::before {
  content: counter(term);
  grid-row: span 2;
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1;
  color: var(--brass);
  text-align: center;
}
.terms-list h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 520;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.terms-list p { margin: 6px 0 0; color: rgba(239, 230, 214, 0.82); line-height: 1.5; }
.terms-card .card-actions button { flex: 1 1 140px; }
#terms-agree { font-family: var(--serif); font-size: 18px; }
#terms[data-state="pending"] .terms-declined,
#terms[data-state="declined"] .terms-pending { display: none; }
.terms-declined { animation: fade-in 0.4s ease; }
.terms-declined .eyebrow { color: var(--blood); }
.terms-declined .card-actions { margin-top: 24px; }

.screen {
  position: fixed;
  inset: 0;
  z-index: 5;
  overflow: auto;
}

#welcome {
  display: grid;
  grid-template-columns: minmax(320px, 640px) minmax(280px, 1fr);
  grid-template-rows: 1fr auto;
  gap: 28px 48px;
  padding: 7vh 6vw 28px;
  background:
    radial-gradient(900px 560px at 78% 42%, rgba(214, 179, 106, 0.16), transparent 62%),
    radial-gradient(640px 420px at 8% 100%, rgba(255, 59, 48, 0.08), transparent 55%),
    #0e0c0a;
}
.welcome-copy { align-self: center; max-width: 640px; }
.eyebrow {
  margin: 0 0 12px;
  color: var(--brass);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 500;
}
h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 560;
  font-size: clamp(92px, 13vw, 168px);
  line-height: 0.78;
  letter-spacing: -0.045em;
}
h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 520;
  font-size: clamp(42px, 5vw, 76px);
  letter-spacing: -0.04em;
  line-height: 0.9;
}
.lede {
  max-width: 46ch;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.45;
  font-weight: 300;
}
.owner {
  margin: 28px 0 22px;
  font-family: var(--serif);
  font-size: clamp(28px, 3vw, 42px);
  font-weight: 500;
  letter-spacing: -0.03em;
}
.owner strong { font-weight: 560; }
.fine { color: var(--muted); font-size: 13px; letter-spacing: 0.02em; }
.difficulty { margin: 0 0 24px; }
.diff-label {
  margin: 0 0 8px;
  color: var(--muted);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 11px;
}
.diff-options {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.diff {
  padding: 9px 16px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}
.diff[aria-pressed="true"] { background: var(--accent); color: var(--ink); }
.diff-note { margin: 10px 0 0; max-width: 46ch; color: var(--muted); font-size: 13px; line-height: 1.4; }
button {
  border: 0;
  background: var(--paper);
  color: var(--ink);
  border-radius: 999px;
  padding: 14px 22px;
  letter-spacing: 0.02em;
}
button.ghost {
  background: transparent;
  color: var(--paper);
  border: 1px solid var(--line);
}
/* Hover only where a real pointer hovers; touch browsers keep :hover stuck on the last tapped button. */
@media (hover: hover) {
  button:hover { background: #fff8ec; }
  button.ghost:hover { border-color: var(--brass); background: rgba(214, 179, 106, 0.08); }
  .gun:not(.on):hover, .swatch:hover { background: rgba(239, 230, 214, 0.06); }
  .diff[aria-pressed="false"]:hover { background: rgba(239, 230, 214, 0.08); color: var(--paper); }
}

.hero-frame { align-self: stretch; display: flex; flex-direction: column; min-height: 62vh; }
#hero-mount, #preview-mount { position: relative; flex: 1; min-height: 320px; }
#hero-mount canvas, #preview-mount canvas { width: 100%; height: 100%; display: block; }
.hero-caption {
  margin: 8px 0 0;
  color: var(--brass);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 11px;
}
.hints {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  list-style: none;
  padding: 0;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
kbd {
  display: inline-block;
  margin-right: 6px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  color: var(--paper);
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.04em;
}

body.in-run #armory {
  background: rgba(14, 12, 10, 0.78);
  backdrop-filter: blur(16px);
}
#armory {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 28px 16px;
  background: #0e0c0a;
}
.armory-head, .armory-foot {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
}
.armory-actions, .card-actions { display: flex; flex-wrap: wrap; gap: 8px; }
#fusion-parents { margin: 8px 0 0; color: var(--brass); letter-spacing: 0.08em; text-transform: uppercase; font-size: 12px; }
#fusion-blurb { margin: 8px 0 0; max-width: 62ch; color: var(--muted); }
#traits { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
#traits span, .swatch span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brass-2);
}
.armory-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(210px, 280px) minmax(280px, 1fr) minmax(210px, 280px);
  gap: 16px;
}
.col-wrap { min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.col-label {
  margin: 0;
  color: var(--muted);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 11px;
}
.col { overflow: auto; display: flex; flex-direction: column; gap: 8px; min-height: 0; padding-right: 4px; }
.gun {
  width: 100%;
  text-align: left;
  border-radius: 14px;
  background: transparent;
  color: var(--paper);
  border: 1px solid transparent;
  padding: 10px 12px;
  display: grid;
  gap: 2px;
}
.gun .role { color: var(--brass); letter-spacing: 0.14em; text-transform: uppercase; font-size: 10px; }
.gun .gname { font-family: var(--serif); font-size: 22px; letter-spacing: -0.03em; }
.gun .gblurb { color: var(--muted); font-size: 13px; }
.gun[data-kind="blast"] .role { color: #ff7a62; }
.gun[data-kind="arc"] .role { color: #9fd4ff; }
.gun[data-kind="fire"] .role { color: #ffb15a; }
.gun.on {
  background: linear-gradient(90deg, rgba(214, 179, 106, 0.16), transparent 78%);
  box-shadow: inset 2px 0 0 var(--brass);
}
.stage { display: flex; flex-direction: column; min-height: 0; gap: 8px; }
#preview-mount {
  flex: 1;
  min-height: 240px;
  border-radius: 18px;
  background:
    radial-gradient(420px 220px at 50% 60%, rgba(214, 179, 106, 0.13), transparent 70%),
    rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
  overflow: hidden;
}
.stat { display: grid; grid-template-columns: 72px 1fr auto; gap: 8px; align-items: center; margin: 4px 0; font-size: 12px; color: var(--muted); }
.stat b { font-weight: 500; color: var(--paper); }
.track { height: 4px; background: rgba(239, 230, 214, 0.1); border-radius: 99px; overflow: hidden; }
.track i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--brass), var(--paper)); }
.wrap-block { display: flex; flex-direction: column; gap: 8px; }
.wraps { display: flex; gap: 6px; overflow: auto; padding-bottom: 4px; }
.swatch {
  width: 108px;
  flex: 0 0 auto;
  background: transparent;
  color: var(--paper);
  border-radius: 14px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
.swatch i {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--trim), var(--base) 62%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}
.swatch.on i { box-shadow: 0 0 0 2px #0e0c0a, 0 0 0 4px var(--brass); }
#deploy { padding: 16px 22px; font-family: var(--serif); font-size: 18px; }
.foot-nav { display: flex; gap: 8px; }
.armory-steps, #step-prev, #step-next { display: none; }

#hud { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
.hud-top, .hud-bottom {
  position: absolute;
  left: 28px;
  right: 28px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.hud-top { top: 22px; }
.hud-bottom { bottom: 22px; align-items: end; }
#wave { margin: 0; letter-spacing: 0.16em; text-transform: uppercase; font-size: 12px; color: var(--brass); }
#score { margin: 4px 0; font-family: var(--serif); font-size: 42px; line-height: 0.9; }
#score.pop { animation: pop 0.28s ease; }
@keyframes pop { from { color: var(--brass); transform: scale(1.08); } }
#map {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 1px solid rgba(214, 179, 106, 0.7);
  background: rgba(14, 12, 10, 0.45);
}
#banner {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--serif);
  font-size: clamp(40px, 6vw, 68px);
  letter-spacing: -0.04em;
  opacity: 0;
  transition: opacity 0.3s ease;
  text-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}
#banner.on { opacity: 1; }
#prompt {
  position: absolute;
  left: 50%;
  bottom: 18%;
  transform: translateX(-50%);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 13px;
  color: var(--brass-2);
  background: rgba(14, 12, 10, 0.55);
  border: 1px solid rgba(214, 179, 106, 0.4);
  border-radius: 999px;
  padding: 8px 14px;
}
#cross {
  --k: 0.02;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%) scale(calc(1 + var(--k) * 7));
}
#cross span {
  position: absolute;
  background: var(--paper);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}
#cross span:nth-child(1), #cross span:nth-child(2) { width: 2px; height: 7px; left: 10px; }
#cross span:nth-child(3), #cross span:nth-child(4) { height: 2px; width: 7px; top: 10px; }
#cross span:nth-child(1) { top: 0; }
#cross span:nth-child(2) { bottom: 0; }
#cross span:nth-child(3) { left: 0; }
#cross span:nth-child(4) { right: 0; }
#cross.hot span { background: var(--brass); }
#cross.off { opacity: 0; }
#hitmarker {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%) rotate(0deg);
  opacity: 0;
}
#hitmarker.on { opacity: 1; }
#hitmarker i, #hitmarker b {
  position: absolute;
  left: 2px;
  top: 10px;
  width: 18px;
  height: 2px;
  background: #fffaf2;
}
#hitmarker i { transform: rotate(45deg); }
#hitmarker b { transform: rotate(-45deg); }
#hitmarker.head i, #hitmarker.head b { background: var(--brass); }
#scope {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at center, transparent 0 16%, rgba(8, 7, 6, 0.18) 18%, rgba(8, 7, 6, 0.72) 26%, rgba(8, 7, 6, 0.94) 42%);
}
#scope::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(34vmin, 420px);
  height: min(34vmin, 420px);
  transform: translate(-50%, -50%);
  border: 1px solid rgba(214, 179, 106, 0.85);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(214, 179, 106, 0.3);
}
#aimhint {
  position: absolute;
  left: 50%;
  top: calc(50% + 36px);
  transform: translateX(-50%);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--paper);
}
.hp { width: min(280px, 34vw); height: 8px; background: rgba(239, 230, 214, 0.12); border-radius: 99px; overflow: hidden; }
.hp i { display: block; height: 100%; width: 100%; transform-origin: left center; background: linear-gradient(90deg, #b8893a, var(--paper)); }
.hp.low i { background: var(--blood); }
.ammo-block { text-align: right; }
.ammo-row { margin: 0; font-family: var(--serif); line-height: 0.8; }
#ammo { font-size: 64px; }
#cap { margin-left: 8px; color: var(--muted); font-size: 22px; }
#gun-name { margin: 6px 0 0; font-family: var(--serif); font-size: 22px; }
.controls-hint { align-self: end; color: rgba(239, 230, 214, 0.45); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
#vignette {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 35%, rgba(90, 8, 6, 0.92) 100%);
  opacity: 0;
}
.card-screen {
  display: grid;
  place-items: center;
  background: rgba(8, 7, 6, 0.46);
  backdrop-filter: blur(8px);
}
.card {
  width: min(520px, calc(100% - 32px));
  padding: 28px;
  border-radius: 22px;
  background: rgba(16, 14, 12, 0.92);
  border: 1px solid rgba(214, 179, 106, 0.28);
}
.tally { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; margin: 18px 0; }
.tally dt { color: var(--muted); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; }
.tally dd { margin: 2px 0 0; font-family: var(--serif); font-size: 32px; }
#death-gun { color: var(--brass); letter-spacing: 0.08em; text-transform: uppercase; font-size: 13px; }

body.touch .hints-keys { display: none; }
body:not(.touch) .hints-touch { display: none; }
body.touch #aimhint { display: none !important; }

#touch {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}
#lookpad { position: absolute; inset: 0; pointer-events: auto; touch-action: none; }
#touch button, #stick { pointer-events: auto; touch-action: none; -webkit-tap-highlight-color: transparent; }
#touch-pause {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  left: calc(14px + env(safe-area-inset-left));
  min-width: 64px;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(14, 12, 10, 0.55);
  color: var(--paper);
  border: 1px solid rgba(239, 230, 214, 0.28);
}
#stick {
  position: absolute;
  left: calc(18px + env(safe-area-inset-left));
  bottom: calc(22px + env(safe-area-inset-bottom));
  width: 128px;
  height: 128px;
  border-radius: 50%;
  border: 1px solid rgba(239, 230, 214, 0.35);
  background: rgba(14, 12, 10, 0.28);
}
.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: rgba(239, 230, 214, 0.88);
}
.touch-cluster {
  position: absolute;
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(18px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 72px 92px;
  grid-template-areas:
    "sprint aim"
    "reload fire"
    "forge forge";
  gap: 10px;
  align-items: center;
  justify-items: center;
}
#touch-sprint { grid-area: sprint; }
#touch-aim { grid-area: aim; }
#touch-reload { grid-area: reload; }
#touch-fire { grid-area: fire; }
#touch-forge { grid-area: forge; }
.touch-cluster button {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  padding: 0;
  background: rgba(14, 12, 10, 0.45);
  color: var(--paper);
  border: 1px solid rgba(239, 230, 214, 0.4);
  letter-spacing: 0.04em;
}
#touch-fire {
  width: 92px;
  height: 92px;
  background: rgba(239, 230, 214, 0.92);
  color: var(--ink);
  border: 0;
  font-family: var(--serif);
  font-size: 22px;
}
#touch-forge { width: 100%; height: 46px; border-radius: 999px; }
#touch-fire.held, #touch-aim.held, #touch-sprint.on, #touch-forge.hot {
  background: var(--brass);
  color: var(--ink);
  border-color: var(--brass);
}
body.touch .hud-top {
  top: calc(14px + env(safe-area-inset-top));
  left: calc(92px + env(safe-area-inset-left));
  right: calc(16px + env(safe-area-inset-right));
}
body.touch .hud-bottom {
  top: calc(86px + env(safe-area-inset-top));
  bottom: auto;
  left: calc(16px + env(safe-area-inset-left));
  right: auto;
  width: min(210px, 54vw);
  flex-direction: column;
  align-items: flex-start;
}
body.touch .ammo-block { text-align: left; }
body.touch #gun-name { font-size: 18px; margin-top: 2px; }
body.touch #score { font-size: 32px; }
body.touch #ammo { font-size: 40px; }
body.touch #map { width: 88px; height: 88px; }
body.touch .controls-hint { display: none; }
body.touch #prompt { bottom: 46%; }

@media (max-width: 980px) {
  #welcome {
    grid-template-columns: 1fr;
    padding: calc(20px + env(safe-area-inset-top)) 18px calc(24px + env(safe-area-inset-bottom));
  }
  h1 { font-size: clamp(76px, 18vw, 120px); }
  .owner { font-size: 30px; }
  .hero-frame { min-height: 280px; height: 280px; }
  #hero-mount { min-height: 220px; height: 220px; flex: none; }
  .hints { margin-top: 14px; }
  /* Armory becomes a one-screen-per-step wizard: first gun, second gun, wrap. */
  #armory {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(96px, 1fr) auto auto auto auto;
    grid-template-areas:
      "steps steps"
      "stage stage"
      "info actions"
      "stats stats"
      "pick pick"
      "foot foot";
    gap: 0 12px;
    padding:
      calc(10px + env(safe-area-inset-top))
      calc(14px + env(safe-area-inset-right))
      calc(10px + env(safe-area-inset-bottom))
      calc(14px + env(safe-area-inset-left));
  }
  .armory-head, .armory-grid, .stage { display: contents; }
  .armory-steps {
    grid-area: steps;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .step-tab {
    min-width: 0;
    display: grid;
    gap: 2px;
    text-align: left;
    padding: 4px 2px 7px;
    border-radius: 0;
    background: transparent;
    color: var(--paper);
    border-bottom: 2px solid var(--line);
  }
  .step-tab:hover { background: transparent; }
  .step-tab.done { border-bottom-color: rgba(214, 179, 106, 0.4); }
  .step-tab[aria-current="step"] { border-bottom-color: var(--brass); }
  .step-label, .step-pick { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .step-label { color: var(--muted); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; }
  .step-tab[aria-current="step"] .step-label { color: var(--brass); }
  .step-pick { font-family: var(--serif); font-size: 15px; letter-spacing: -0.02em; }

  #preview-mount { grid-area: stage; height: auto; min-height: 0; margin-top: 10px; }
  #preview-mount canvas { position: absolute; inset: 0; }

  .fusion-info { grid-area: info; min-width: 0; align-self: center; margin-top: 10px; }
  .fusion-info .eyebrow { display: none; }
  #fusion-name { font-size: 30px; }
  #fusion-parents { margin-top: 6px; font-size: 11px; }
  #fusion-blurb { margin-top: 6px; font-size: 13px; line-height: 1.35; }
  #traits { margin-top: 8px; }
  #armory:not([data-step="3"]) :is(#fusion-parents, #fusion-blurb, #traits) { display: none; }
  .armory-actions { grid-area: actions; align-self: start; margin-top: 10px; }
  #surprise { padding: 8px 14px; font-size: 13px; }
  #back { display: none; }

  #stats {
    grid-area: stats;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 16px;
    margin-top: 8px;
  }
  #armory:not([data-step="3"]) #stats { display: none; }
  .stat { grid-template-columns: 52px minmax(0, 1fr) auto; margin: 3px 0; font-size: 11px; }

  #armory [data-for] { grid-area: pick; display: none; margin-top: 12px; }
  #armory[data-step="1"] [data-for="1"],
  #armory[data-step="2"] [data-for="2"],
  #armory[data-step="3"] [data-for="3"] { display: flex; }
  .col-label { display: none; }
  .col {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    overflow: visible;
    padding: 0;
  }
  .gun { align-content: start; padding: 9px 12px; border-color: var(--line); border-radius: 12px; }
  .gun .gname { font-size: 18px; line-height: 1.1; }
  .gun .gblurb { display: none; }
  .gun.on { background: rgba(214, 179, 106, 0.14); border-color: var(--brass); box-shadow: none; }
  .wraps { gap: 4px; overflow: visible; padding: 0; }
  .swatch { flex: 1 1 0; width: auto; min-width: 0; min-height: 44px; padding: 6px 0; align-items: center; justify-content: center; }
  .swatch i { width: 30px; height: 30px; }
  .swatch span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .armory-foot {
    grid-area: foot;
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 6px;
    margin-top: 12px;
  }
  .foot-notes p { margin: 0; text-align: center; font-size: 11px; }
  .foot-notes p:first-child { display: none; }
  #step-prev { display: block; flex: none; padding: 14px 16px; }
  #step-next, #deploy { flex: 1; min-width: 0; padding: 14px 12px; }
  #step-next { display: block; }
  #deploy { font-size: clamp(14px, 4vw, 16px); line-height: 1.15; }
  #armory[data-step="3"] #step-next,
  #armory:not([data-step="3"]) #deploy { display: none; }
  .controls-hint { display: none; }
  .card { padding: 22px 18px; }
  #terms .terms-card { padding: 22px 16px; }
  .terms-list li { grid-template-columns: 28px 1fr; padding: 14px 14px 14px 8px; }
  .terms-list li::before { font-size: 23px; }
  .terms-list h3 { font-size: 19px; }
  .terms-list p { font-size: 15px; line-height: 1.45; }
}
@media (max-width: 980px) and (max-height: 560px) and (orientation: landscape) {
  /* Content rows are auto-sized so the pick list can never run under the nav; the spare row absorbs leftover height. */
  #armory {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas:
      "stage steps"
      "stage pick"
      "stage ."
      "info foot";
    column-gap: 18px;
  }
  #armory[data-step="3"] {
    grid-template-areas:
      "stage steps"
      "stage stats"
      "stage pick"
      "info foot";
  }
  #preview-mount { margin-top: 0; }
  .armory-actions {
    grid-area: stage;
    position: relative;
    z-index: 1;
    justify-self: end;
    margin: 10px;
  }
  #surprise { background: rgba(14, 12, 10, 0.55); }
  .fusion-info { align-self: start; }
  #armory [data-for] { margin-top: 10px; align-self: start; }
  .col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .gun { padding: 7px 10px; }
  .gun .gname { font-size: 16px; }
  #fusion-name { font-size: 26px; }
  #fusion-blurb { display: none; }
  #stats { margin-top: 10px; }
  .armory-foot { margin-top: 10px; }
}
@media (max-height: 520px) {
  #stick { width: 96px; height: 96px; }
  .stick-knob { width: 42px; height: 42px; margin: -21px 0 0 -21px; }
  #touch-fire { width: 72px; height: 72px; font-size: 18px; }
  .touch-cluster button { width: 56px; height: 56px; }
  .touch-cluster { grid-template-columns: 60px 76px; gap: 8px; }
  body.touch .hud-bottom { top: calc(72px + env(safe-area-inset-top)); }
}
