:root {
  --ink: #04070a;
  --ink-2: #090e13;
  --bone: #d9d3bd;
  --bone-dim: #8e8d80;
  --steel: #65717a;
  --steel-dark: #323b43;
  --blood: #a51e29;
  --blood-bright: #d7353f;
  --rust: #b65b35;
  --amber: #e2b269;
  --acid: #a9bb83;
  --ui: clamp(9px, 1vw, 16px);
  --display: "Bahnschrift Condensed", "Arial Narrow", "Impact", "Segoe UI", sans-serif;
  --mono: "Cascadia Mono", "Consolas", "SFMono-Regular", "Courier New", monospace;
  --cn: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  background: #020305;
  overflow: hidden;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bone);
  font-family: var(--display);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 46%, rgba(28, 43, 51, 0.22), transparent 64%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 80px);
  pointer-events: none;
}

button {
  font: inherit;
  color: inherit;
}

#stage {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  overflow: hidden;
  background: #060a0e;
  box-shadow:
    0 0 0 1px #1d262c,
    0 0 70px rgba(0, 0, 0, 0.92),
    0 0 140px rgba(23, 46, 55, 0.16);
  isolation: isolate;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #080d12;
}

#stage.is-playing,
#stage.is-playing #game {
  cursor: none;
}

/* ------------------------------------------------------------------ */
/* CRT / film treatment                                               */
/* ------------------------------------------------------------------ */

.screen-fx {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  overflow: hidden;
}

.scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.22) 0,
    rgba(0, 0, 0, 0.22) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 0.28;
  mix-blend-mode: multiply;
}

.grain {
  position: absolute;
  inset: -20%;
  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='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.65'/%3E%3C/svg%3E");
  opacity: 0.055;
  animation: grain-shift 0.32s steps(2) infinite;
  mix-blend-mode: soft-light;
}

.vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 50%, transparent 45%, rgba(0, 0, 0, 0.42) 75%, rgba(0, 0, 0, 0.86) 100%),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.34), transparent 18%, transparent 74%, rgba(0, 0, 0, 0.56));
  transition: opacity 0.9s ease;
}

#stage[data-phase="day"] .vignette {
  opacity: 0.58;
}

#stage[data-phase="dawn"] .vignette,
#stage[data-phase="dusk"] .vignette {
  opacity: 0.78;
}

#stage[data-phase="day"] .grain {
  opacity: 0.035;
}

#stage[data-phase="day"] .scanlines {
  opacity: 0.22;
}

.edge-wear {
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 38px 4px rgba(0, 0, 0, 0.66);
}

@keyframes grain-shift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2%, 1%); }
  50% { transform: translate(1%, -2%); }
  75% { transform: translate(2%, 2%); }
  100% { transform: translate(-1%, -1%); }
}

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

.hud {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  font-family: var(--mono);
  font-size: var(--ui);
  letter-spacing: 0.06em;
  opacity: 1;
  transition: opacity 0.35s ease;
  text-shadow: 0 1px 0 #000, 0 0 8px rgba(0, 0, 0, 0.8);
}

.hud.is-hidden {
  opacity: 0;
}

.hud::before,
.hud::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  pointer-events: none;
}

.hud::before {
  top: 0;
  height: 18%;
  background: linear-gradient(180deg, rgba(2, 5, 8, 0.74), rgba(2, 5, 8, 0.22) 58%, transparent);
}

.hud::after {
  bottom: 0;
  height: 23%;
  background: linear-gradient(0deg, rgba(2, 5, 8, 0.38), transparent);
}

.hud-top {
  position: absolute;
  inset: 2.1% 3.1% auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.52em;
  color: var(--bone-dim);
  font-size: 0.78em;
  letter-spacing: 0.18em;
  animation: flicker-soft 9s infinite;
}

.brand-glyph {
  color: var(--acid);
  font-size: 1.5em;
  filter: drop-shadow(0 0 5px rgba(169, 187, 131, 0.4));
}

.brand-main {
  color: var(--bone);
  font-weight: 800;
  letter-spacing: 0.16em;
}

.brand-sub {
  color: #646a68;
}

.build-count {
  margin-left: 0.65em;
  padding-left: 0.8em;
  border-left: 1px solid rgba(217, 211, 189, 0.14);
  color: #6f7a72;
  font-family: var(--cn);
  font-size: 0.88em;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.build-count b {
  color: var(--amber);
  font-family: var(--mono);
  font-weight: 400;
}

.mutation-strip {
  position: absolute;
  left: 3.1%;
  top: 6.7em;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  gap: 0.65em;
  max-width: 25em;
  font-family: var(--cn);
  text-shadow: 0 1px 0 #000;
}

.mutation-strip.is-hidden {
  display: none;
}

.mutation-label {
  flex: none;
  padding-top: 0.16em;
  color: #7c6e5b;
  font-family: var(--mono);
  font-size: 0.56em;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.mutation-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35em;
}

.relic-strip {
  top: 10.4em;
}

.relic-chip {
  --mut: #93e0c5;
  border-color: rgba(167, 224, 200, 0.36);
  color: #b9e6d5;
  background: rgba(41, 74, 64, 0.35);
  box-shadow: 0 0 8px rgba(127, 214, 186, 0.08);
}

.boss-bar {
  position: absolute;
  z-index: 3;
  top: 5.2em;
  left: 50%;
  transform: translateX(-50%);
  width: min(31em, 48%);
  padding: 0.38em 0.65em 0.5em;
  background: linear-gradient(180deg, rgba(8, 5, 7, 0.88), rgba(8, 5, 7, 0.38));
  border-top: 1px solid rgba(203, 91, 67, 0.48);
  clip-path: polygon(0.7em 0, calc(100% - 0.7em) 0, 100% 100%, 0 100%);
  pointer-events: none;
}

.boss-bar.is-hidden {
  display: none;
}

.boss-head {
  display: flex;
  align-items: baseline;
  gap: 0.7em;
  margin-bottom: 0.3em;
  font-family: var(--cn);
  font-size: 0.58em;
  letter-spacing: 0.12em;
}

.boss-label {
  color: var(--blood-bright);
  font-family: var(--mono);
  font-size: 0.9em;
  letter-spacing: 0.24em;
}

.boss-head strong {
  color: #e6d7bb;
  font-weight: 400;
}

.boss-head em {
  margin-left: auto;
  color: #c38a74;
  font-family: var(--mono);
  font-style: normal;
}

.boss-meter {
  height: 0.38em;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.boss-meter i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #8d2730, #d35d49, #e4a16d);
  box-shadow: 0 0 9px rgba(211, 93, 73, 0.45);
  transition: width 0.1s linear;
}

.boss-bar.enraged .boss-meter i {
  background: linear-gradient(90deg, #d1533a, #ffb06b);
  box-shadow: 0 0 12px rgba(255, 122, 80, 0.65);
}

.mutation-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.24em 0.48em;
  border: 1px solid color-mix(in srgb, var(--mut) 45%, transparent);
  background: color-mix(in srgb, var(--mut) 8%, rgba(4, 8, 8, 0.72));
  color: color-mix(in srgb, var(--mut) 72%, #ddd6c4);
  font-size: 0.58em;
  letter-spacing: 0.08em;
  white-space: nowrap;
  clip-path: polygon(0 0, calc(100% - 4px) 0, 100% 4px, 100% 100%, 0 100%);
}

.mutation-chip::before {
  content: "";
  width: 3px;
  height: 3px;
  background: var(--mut);
  box-shadow: 0 0 5px var(--mut);
}

.wave-readout {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 9em;
  padding: 0.25em 1.5em 0.5em;
  border-top: 1px solid rgba(217, 211, 189, 0.28);
  position: relative;
}

.wave-readout::before,
.wave-readout::after {
  content: "";
  position: absolute;
  top: -1px;
  width: 0.8em;
  height: 1px;
  background: var(--blood);
}

.wave-readout::before { left: 0; }
.wave-readout::after { right: 0; }

.micro-label {
  color: #7f8989;
  font-size: 0.62em;
  letter-spacing: 0.22em;
  white-space: nowrap;
}

.wave-readout strong {
  font-family: var(--display);
  font-size: 2.2em;
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: 0.05em;
  color: var(--bone);
  font-variant-numeric: tabular-nums;
}

.wave-sub {
  display: flex;
  align-items: center;
  gap: 0.48em;
  margin-top: 0.28em;
  color: #8b958f;
  font-family: var(--cn);
  font-size: 0.65em;
  letter-spacing: 0.2em;
}

.wave-sub i {
  width: 0.5em;
  height: 0.5em;
  display: inline-block;
  border-radius: 50%;
  background: var(--blood-bright);
  box-shadow: 0 0 7px var(--blood-bright);
  animation: pulse 1.2s infinite;
}

.phase-label {
  margin-left: 0.5em;
  padding-left: 0.55em;
  border-left: 1px solid rgba(217, 211, 189, 0.2);
  color: var(--amber);
  font-family: var(--cn);
  font-size: 0.86em;
  font-weight: 400;
  letter-spacing: 0.08em;
}

.score-readout {
  justify-self: end;
  text-align: right;
  display: flex;
  flex-direction: column;
  padding-top: 0.15em;
}

.score-readout strong {
  font-family: var(--display);
  font-size: 1.5em;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0.13em;
  font-variant-numeric: tabular-nums;
}

.score-sub {
  color: #858b83;
  font-size: 0.62em;
  letter-spacing: 0.16em;
}

.score-sub span {
  color: var(--amber);
}

.hud-bottom {
  position: absolute;
  left: 3.1%;
  right: 3.1%;
  bottom: 3.6%;
  display: grid;
  grid-template-columns: minmax(180px, 1.1fr) minmax(0, 1.7fr) minmax(220px, 1.2fr);
  align-items: end;
  gap: 3%;
}

.vitals {
  width: min(100%, 30em);
  padding: 0.65em 0.85em 0.72em;
  background: linear-gradient(105deg, rgba(4, 8, 11, 0.86), rgba(4, 8, 11, 0.38));
  border-left: 2px solid rgba(217, 211, 189, 0.42);
  clip-path: polygon(0 0, 100% 0, calc(100% - 0.7em) 100%, 0 100%);
  position: relative;
}

.vitals::before {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 38%;
  height: 1px;
  background: var(--blood);
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 0.64em;
  letter-spacing: 0.18em;
  color: #88918a;
}

.panel-head span:last-child {
  color: var(--bone);
  font-size: 1.5em;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.meter {
  position: relative;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.07);
}

.health-meter {
  height: 0.72em;
  margin-top: 0.45em;
  border: 1px solid rgba(217, 211, 189, 0.26);
}

.health-meter i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #7e1b24, #bc3039 68%, #d94b4b);
  box-shadow: 0 0 8px rgba(190, 40, 50, 0.4);
  transition: width 0.18s ease;
}

.health-meter.low i {
  background: linear-gradient(90deg, #7f1118, #d12831);
  animation: critical-pulse 0.65s infinite;
}

.meter-ticks {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0, transparent 9%, rgba(0, 0, 0, 0.55) 9%, rgba(0, 0, 0, 0.55) 10%);
}

.stamina-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.6em;
  margin-top: 0.48em;
  color: #76817c;
  font-family: var(--cn);
  font-size: 0.56em;
  letter-spacing: 0.14em;
}

.stamina-meter {
  height: 0.27em;
}

.stamina-meter i {
  display: block;
  width: 100%;
  height: 100%;
  background: #9aa886;
  transition: width 0.1s linear, background 0.2s;
}

.stamina-meter.exhausted i {
  background: var(--rust);
}

.fuel-row {
  margin-top: 0.28em;
}

.fuel-meter {
  height: 0.34em;
}

.fuel-meter i {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #b1783b, #f0c274);
  box-shadow: 0 0 7px rgba(240, 194, 116, 0.34);
  transition: width 0.1s linear, background 0.2s;
}

.fuel-meter.low i {
  background: linear-gradient(90deg, #6f2e2c, #b94a38);
}

.key-hint {
  font-family: var(--mono);
  font-size: 0.82em;
  color: #59625f;
}

.field-tip {
  justify-self: center;
  display: flex;
  gap: 1.18em;
  align-items: center;
  padding-bottom: 0.45em;
  color: #949c92;
  font-family: var(--cn);
  font-size: 0.66em;
  letter-spacing: 0.06em;
  white-space: nowrap;
  opacity: 0.9;
  transition: opacity 1.2s ease;
}

.field-tip.faded {
  opacity: 0;
}

.field-tip span {
  display: flex;
  align-items: center;
  gap: 0.42em;
}

.field-tip b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4em;
  height: 1.35em;
  padding: 0 0.28em;
  border: 1px solid rgba(217, 211, 189, 0.25);
  color: var(--bone);
  font-family: var(--mono);
  font-size: 0.84em;
  font-weight: 400;
}

.loadout {
  justify-self: end;
  width: min(100%, 26em);
  padding: 0.55em 0.8em 0.62em;
  text-align: right;
  background: linear-gradient(255deg, rgba(4, 8, 11, 0.88), rgba(4, 8, 11, 0.34));
  border-right: 2px solid rgba(217, 211, 189, 0.42);
  clip-path: polygon(0.7em 0, 100% 0, 100% 100%, 0 100%);
}

.weapon-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
  color: #77817b;
  font-family: var(--cn);
  font-size: 0.62em;
  letter-spacing: 0.12em;
}

.weapon-head .micro-label {
  font-family: var(--mono);
}

.weapon-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1em;
  margin-top: 0.1em;
}

#weaponName {
  font-family: var(--display);
  font-size: 1.18em;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--bone);
  white-space: nowrap;
}

.ammo {
  display: flex;
  align-items: baseline;
  gap: 0.18em;
  font-family: var(--display);
  font-variant-numeric: tabular-nums;
}

.ammo strong {
  font-size: 2.15em;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: var(--bone);
}

.ammo strong.empty {
  color: var(--blood-bright);
  animation: critical-pulse 0.7s infinite;
}

.ammo-slash {
  color: #505a58;
  font-size: 1em;
}

.ammo em {
  font-style: normal;
  color: #858d85;
  font-size: 0.92em;
  letter-spacing: 0.05em;
}

.reload-track {
  position: relative;
  height: 2px;
  margin: 0.32em 0 0.42em;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  transition: height 0.12s ease, background 0.12s ease;
}

.reload-track i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #b2763d, #f0c274);
  box-shadow: 0 0 7px rgba(226, 178, 105, 0.7);
  transition: width 0.06s linear;
}

.reload-track.is-reloading {
  height: 4px;
  background: rgba(226, 178, 105, 0.14);
  box-shadow: 0 0 10px rgba(226, 178, 105, 0.18);
}

.reload-track.is-reloading::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 24%;
  background: linear-gradient(90deg, transparent, rgba(255, 239, 190, 0.62), transparent);
  animation: reload-scan 0.45s linear infinite;
}

.loadout.is-reloading #weaponTag {
  color: var(--amber);
  text-shadow: 0 0 8px rgba(240, 194, 116, 0.55);
}

#ammoReserve.low {
  color: var(--blood-bright);
  text-shadow: 0 0 7px rgba(215, 53, 63, 0.4);
}

@keyframes reload-scan {
  from { transform: translateX(-120%); }
  to { transform: translateX(520%); }
}

.spin-track {
  display: flex;
  align-items: center;
  gap: 0.55em;
  height: 0.62em;
  margin: 0.15em 0 0.42em;
}

.spin-track.is-hidden {
  display: none;
}

.spin-track span {
  flex: none;
  min-width: 4.6em;
  color: #a67b52;
  font-family: var(--mono);
  font-size: 0.52em;
  letter-spacing: 0.08em;
  text-align: left;
}

.spin-meter {
  flex: 1;
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.spin-meter i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #9a5e36, #e6ae5e);
  box-shadow: 0 0 6px rgba(226, 164, 92, 0.55);
  transition: width 0.03s linear;
}

.weapon-slots {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.3em 0.9em;
  color: #6b746e;
  font-size: 0.62em;
  letter-spacing: 0.04em;
}

.weapon-slots span {
  white-space: nowrap;
  transition: color 0.2s, opacity 0.2s;
  opacity: 0.62;
}

.weapon-slots span.active {
  color: var(--amber);
  opacity: 1;
}

.weapon-slots b {
  display: inline-block;
  min-width: 1.2em;
  margin-right: 0.35em;
  padding: 0 0.2em;
  border: 1px solid currentColor;
  font-size: 0.88em;
  font-weight: 400;
  text-align: center;
}

.ability-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
  margin-top: 0.38em;
  color: #707970;
  font-family: var(--cn);
  font-size: 0.56em;
  letter-spacing: 0.07em;
}

.grenade-chip,
.jet-chip {
  white-space: nowrap;
}

.grenade-chip b,
.jet-chip b {
  display: inline-block;
  margin-right: 0.3em;
  padding: 0 0.3em;
  border: 1px solid rgba(217, 211, 189, 0.2);
  color: #c6b88f;
  font-family: var(--mono);
  font-size: 0.85em;
  font-weight: 400;
}

.grenade-chip em {
  color: var(--amber);
  font-family: var(--mono);
  font-style: normal;
  font-size: 1.1em;
}

.pause-btn {
  position: absolute;
  top: 9.35em;
  right: 3.1%;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.38em 0.55em;
  background: rgba(5, 9, 12, 0.4);
  border: 1px solid rgba(217, 211, 189, 0.16);
  color: #7d8780;
  font-family: var(--mono);
  font-size: 0.58em;
  letter-spacing: 0.13em;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.pause-btn:hover,
.pause-btn:focus-visible {
  color: var(--bone);
  border-color: rgba(217, 211, 189, 0.48);
  outline: none;
}

.corner {
  position: absolute;
  width: 1.6em;
  height: 1.6em;
  border-color: rgba(217, 211, 189, 0.22);
  border-style: solid;
}

.corner-tl { top: 1.25em; left: 2.2%; border-width: 1px 0 0 1px; }
.corner-tr { top: 1.25em; right: 2.2%; border-width: 1px 1px 0 0; }
.corner-bl { bottom: 1.25em; left: 2.2%; border-width: 0 0 1px 1px; }
.corner-br { bottom: 1.25em; right: 2.2%; border-width: 0 1px 1px 0; }

/* ------------------------------------------------------------------ */
/* Wave banner / toast                                                */
/* ------------------------------------------------------------------ */

.wave-banner {
  position: absolute;
  z-index: 22;
  top: 21%;
  left: 50%;
  width: min(80%, 44em);
  transform: translate(-50%, -12px);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, transform 0.55s cubic-bezier(0.16, 0.8, 0.26, 1);
  text-shadow: 0 2px 0 #000, 0 0 22px rgba(0, 0, 0, 0.9);
}

.wave-banner.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.wave-banner::before,
.wave-banner::after {
  content: "";
  position: absolute;
  top: 53%;
  width: 21%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(217, 211, 189, 0.45));
}

.wave-banner::before { left: 0; }
.wave-banner::after {
  right: 0;
  background: linear-gradient(90deg, rgba(217, 211, 189, 0.45), transparent);
}

.wave-banner span {
  display: block;
  color: var(--blood-bright);
  font-family: var(--mono);
  font-size: clamp(8px, 0.68vw, 12px);
  letter-spacing: 0.42em;
  margin-bottom: 0.5em;
}

.wave-banner strong {
  display: block;
  font-family: var(--cn);
  font-size: clamp(20px, 2.35vw, 38px);
  font-weight: 300;
  letter-spacing: 0.25em;
  color: var(--bone);
}

.wave-banner p {
  margin: 0.55em 0 0;
  color: #92978a;
  font-family: var(--cn);
  font-size: clamp(9px, 0.78vw, 14px);
  letter-spacing: 0.15em;
}

.wave-banner.breach strong {
  color: #e9dfce;
  text-shadow: 0 0 18px rgba(190, 45, 50, 0.65), 0 2px 0 #000;
}

.toast {
  position: absolute;
  z-index: 23;
  left: 50%;
  bottom: 19%;
  display: flex;
  align-items: center;
  gap: 0.65em;
  padding: 0.5em 0.8em;
  transform: translate(-50%, 8px);
  background: rgba(4, 8, 11, 0.82);
  border: 1px solid rgba(217, 211, 189, 0.18);
  color: var(--bone);
  font-family: var(--cn);
  font-size: clamp(9px, 0.72vw, 12px);
  letter-spacing: 0.1em;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
}

.toast.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.toast span:first-child {
  color: var(--amber);
  font-family: var(--mono);
  font-size: 1.2em;
}

.toast.blood span:first-child {
  color: var(--blood-bright);
}

/* ------------------------------------------------------------------ */
/* Overlays                                                           */
/* ------------------------------------------------------------------ */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.45s ease, visibility 0.45s;
}

.overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.75em;
  color: #8b938a;
  font-family: var(--mono);
  font-size: clamp(8px, 0.7vw, 12px);
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  flex: none;
  background: var(--blood-bright);
  box-shadow: 0 0 9px rgba(215, 53, 63, 0.9);
  animation: pulse 1.6s infinite;
}

.slash {
  color: #464d4b;
}

/* Title ------------------------------------------------------------ */

.title-screen {
  display: flex;
  align-items: stretch;
  background:
    linear-gradient(90deg, rgba(3, 6, 9, 0.97) 0%, rgba(3, 6, 9, 0.88) 31%, rgba(3, 6, 9, 0.35) 59%, rgba(3, 6, 9, 0.04) 100%),
    linear-gradient(0deg, rgba(3, 5, 8, 0.66), transparent 42%);
}

.title-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(137, 24, 31, 0.16), transparent 42%),
    radial-gradient(ellipse at 72% 44%, transparent 20%, rgba(0, 0, 0, 0.28) 70%);
  pointer-events: none;
}

.title-screen::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--blood) 0 18%, #222 18% 100%);
  opacity: 0.7;
}

.title-copy {
  position: relative;
  z-index: 2;
  width: 61%;
  max-width: 58em;
  padding: clamp(24px, 5.3vh, 58px) 0 4.6vh clamp(24px, 6vw, 92px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.title-copy h1 {
  display: flex;
  align-items: flex-end;
  gap: 0.45em;
  margin: clamp(12px, 2.4vh, 28px) 0 0;
  line-height: 0.74;
  font-family: var(--display);
  font-weight: 900;
  text-transform: uppercase;
}

.title-main {
  position: relative;
  display: block;
  color: #ddd7c4;
  font-size: min(10.8vw, 17.2vh);
  letter-spacing: -0.045em;
  text-shadow:
    0 2px 0 #1a1c1b,
    0 4px 0 #0c0e0d,
    0 0 40px rgba(0, 0, 0, 0.8);
}

.title-tide {
  color: var(--blood);
  position: relative;
}

.title-tide::before {
  content: "";
  position: absolute;
  left: 2%;
  right: 6%;
  bottom: 14%;
  height: 4%;
  background: rgba(160, 25, 33, 0.7);
  filter: blur(1px);
  transform: rotate(-1.5deg);
}

.title-cn {
  writing-mode: vertical-rl;
  font-family: var(--cn);
  font-size: clamp(15px, 1.7vw, 28px);
  font-weight: 200;
  letter-spacing: 0.15em;
  color: var(--blood-bright);
  opacity: 0.9;
  padding-left: 0.58em;
  border-left: 2px solid rgba(165, 30, 41, 0.66);
  transform: translateY(0.28em);
  text-shadow: 0 0 16px rgba(165, 30, 41, 0.38);
}

.tagline {
  margin: clamp(16px, 2.4vh, 26px) 0 0;
  color: #a9a99b;
  font-family: var(--cn);
  font-size: clamp(11px, 0.95vw, 16px);
  font-weight: 300;
  line-height: 1.9;
  letter-spacing: 0.14em;
}

.title-actions {
  display: flex;
  align-items: stretch;
  gap: 0.7em;
  margin-top: clamp(18px, 3.4vh, 36px);
}

.pixel-btn {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-width: 10.6em;
  padding: 0.72em 1.35em 0.66em;
  border: 1px solid rgba(217, 211, 189, 0.36);
  background: transparent;
  color: var(--bone);
  text-align: left;
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 9px 100%, 0 calc(100% - 9px));
  transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.18s;
}

.pixel-btn::before,
.pixel-btn::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  border: 1px solid currentColor;
  opacity: 0.45;
  transition: opacity 0.18s;
}

.pixel-btn::before {
  top: 5px;
  right: 5px;
  border-left: 0;
  border-bottom: 0;
}

.pixel-btn::after {
  left: 5px;
  bottom: 5px;
  border-right: 0;
  border-top: 0;
}

.pixel-btn span {
  font-family: var(--cn);
  font-size: clamp(12px, 1.08vw, 18px);
  font-weight: 500;
  letter-spacing: 0.2em;
  line-height: 1.3;
}

.pixel-btn em {
  margin-top: 0.35em;
  color: #777e77;
  font-family: var(--mono);
  font-size: clamp(6px, 0.52vw, 9px);
  font-style: normal;
  letter-spacing: 0.2em;
  transition: color 0.18s;
}

.pixel-btn.primary {
  background: var(--blood);
  border-color: #d4474f;
  color: #f5e9dc;
  box-shadow: 0 0 28px rgba(165, 30, 41, 0.22);
}

.pixel-btn.primary::before,
.pixel-btn.primary::after {
  opacity: 0.7;
}

.pixel-btn.primary em {
  color: #e7b5ae;
}

.pixel-btn.ghost {
  min-width: 8.4em;
  background: rgba(12, 18, 21, 0.5);
}

.pixel-btn:hover,
.pixel-btn:focus-visible {
  transform: translateY(-2px);
  border-color: var(--bone);
  outline: none;
}

.pixel-btn.primary:hover,
.pixel-btn.primary:focus-visible {
  background: #bb2833;
  border-color: #ed7b7c;
}

.pixel-btn.ghost:hover,
.pixel-btn.ghost:focus-visible {
  background: rgba(217, 211, 189, 0.08);
}

.pixel-btn:hover em {
  color: inherit;
}

.title-warning {
  display: flex;
  align-items: flex-start;
  gap: 0.8em;
  width: min(29em, 100%);
  margin-top: clamp(16px, 2.8vh, 30px);
  color: #6f756e;
  font-family: var(--cn);
  font-size: clamp(8px, 0.68vw, 11px);
  line-height: 1.7;
  letter-spacing: 0.06em;
}

.title-warning p {
  margin: 0;
}

.title-warning b {
  color: var(--rust);
  margin-right: 0.5em;
  font-weight: 500;
}

.warning-stripes {
  flex: none;
  width: 3px;
  align-self: stretch;
  margin-top: 2px;
  background: repeating-linear-gradient(-45deg, var(--rust) 0 2px, transparent 2px 5px);
  opacity: 0.7;
}

.title-meta {
  position: relative;
  z-index: 2;
  margin-left: auto;
  width: 34%;
  padding: clamp(30px, 6vh, 70px) clamp(24px, 4vw, 62px) 7vh 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-end;
  text-align: right;
}

.meta-stamp {
  align-self: flex-end;
  margin-bottom: clamp(16px, 3vh, 30px);
  padding: 0.7em 0.75em;
  border: 1px solid rgba(165, 30, 41, 0.6);
  color: rgba(215, 53, 63, 0.8);
  font-family: var(--cn);
  font-size: clamp(10px, 0.9vw, 15px);
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0.18em;
  transform: rotate(2.5deg);
  box-shadow: inset 0 0 0 3px rgba(165, 30, 41, 0.08);
}

.meta-stamp b {
  display: block;
  font-family: var(--mono);
  font-size: 0.55em;
  font-weight: 400;
  letter-spacing: 0.16em;
  opacity: 0.7;
}

.title-meta dl {
  width: 100%;
  max-width: 18em;
  margin: 0;
  border-top: 1px solid rgba(217, 211, 189, 0.18);
}

.title-meta dl div {
  display: flex;
  justify-content: space-between;
  gap: 2em;
  padding: 0.52em 0;
  border-bottom: 1px solid rgba(217, 211, 189, 0.09);
  font-family: var(--cn);
  font-size: clamp(8px, 0.66vw, 11px);
  letter-spacing: 0.16em;
}

.title-meta dt {
  color: #646d66;
}

.title-meta dd {
  margin: 0;
  color: #bdb9a8;
}

.meta-line {
  margin: 1.3em 0 0;
  color: #656c65;
  font-family: var(--cn);
  font-size: clamp(8px, 0.64vw, 11px);
  letter-spacing: 0.16em;
  line-height: 1.7;
}

.title-foot {
  position: absolute;
  z-index: 3;
  left: clamp(24px, 6vw, 92px);
  right: clamp(24px, 4vw, 62px);
  bottom: 2.4vh;
  display: flex;
  gap: 1.7em;
  color: #6b746e;
  font-family: var(--mono);
  font-size: clamp(7px, 0.54vw, 9px);
  letter-spacing: 0.16em;
  border-top: 1px solid rgba(217, 211, 189, 0.1);
  padding-top: 1em;
}

.title-foot span:last-child {
  margin-left: auto;
}

.title-foot b {
  color: #aeb4a8;
  font-weight: 400;
}

/* Help / pause / game over ----------------------------------------- */

.help-screen,
.menu-screen,
.gameover-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4vh 4vw;
  background: rgba(2, 5, 8, 0.78);
  backdrop-filter: blur(3px);
}

.help-card,
.menu-card,
.gameover-card {
  position: relative;
  width: min(38em, 92%);
  max-height: 88%;
  overflow: auto;
  padding: clamp(22px, 3.7vh, 42px) clamp(24px, 3.6vw, 52px);
  background:
    linear-gradient(135deg, rgba(17, 25, 28, 0.96), rgba(5, 9, 12, 0.98) 62%),
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, 0.015) 3px 4px);
  border: 1px solid rgba(217, 211, 189, 0.2);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.72), inset 0 0 56px rgba(0, 0, 0, 0.22);
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 18px 100%, 0 calc(100% - 18px));
  scrollbar-width: thin;
}

.help-card::before,
.menu-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: clamp(24px, 3.6vw, 52px);
  width: 34%;
  height: 2px;
  background: var(--blood);
}

.help-card h2,
.menu-card h2 {
  margin: 0.65em 0 0.85em;
  color: var(--bone);
  font-family: var(--cn);
  font-size: clamp(21px, 2.2vw, 36px);
  font-weight: 300;
  letter-spacing: 0.14em;
}

.help-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6em 2em;
  margin: 1.6em 0;
}

.help-grid div {
  display: flex;
  align-items: center;
  gap: 0.5em;
  min-height: 2.8em;
  padding: 0.35em 0;
  border-bottom: 1px solid rgba(217, 211, 189, 0.08);
}

.help-grid span {
  margin-left: auto;
  color: #9a9e91;
  font-family: var(--cn);
  font-size: clamp(9px, 0.72vw, 12px);
  letter-spacing: 0.08em;
}

.keycap {
  display: inline-flex;
  min-width: 1.8em;
  height: 1.8em;
  padding: 0 0.45em;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(217, 211, 189, 0.24);
  background: rgba(255, 255, 255, 0.03);
  color: var(--bone);
  font-family: var(--mono);
  font-size: clamp(8px, 0.65vw, 11px);
  font-weight: 400;
  letter-spacing: 0.05em;
}

.keycap.wide {
  min-width: 4.2em;
}

.help-note {
  margin: 1.5em 0 1.8em;
  padding-left: 0.9em;
  border-left: 2px solid var(--blood);
  color: #6f756d;
  font-family: var(--cn);
  font-size: clamp(9px, 0.7vw, 12px);
  line-height: 1.8;
  letter-spacing: 0.06em;
}

@media (max-height: 600px) {
  .help-card {
    max-height: 92%;
    padding: 16px 22px;
  }

  .help-card h2 {
    margin: 0.35em 0 0.5em;
    font-size: clamp(20px, 2.2vw, 26px);
  }

  .help-grid {
    gap: 0.35em 1.4em;
    margin: 0.8em 0;
  }

  .help-grid div {
    min-height: 2.1em;
    padding: 0.12em 0;
  }

  .help-note {
    margin: 0.8em 0 0.9em;
    line-height: 1.55;
  }

  .help-card .pixel-btn {
    margin-top: 0.2em;
  }
}

.help-card .pixel-btn,
.menu-card .pixel-btn {
  width: 100%;
  margin-top: 0.6em;
  align-items: center;
  text-align: center;
}

.menu-card {
  width: min(25em, 90%);
  text-align: center;
}

.menu-card::before {
  left: 33%;
  width: 34%;
}

.menu-card .eyebrow {
  justify-content: center;
}

.menu-card h2 {
  margin: 0.35em 0 0;
  font-size: clamp(30px, 3.5vw, 56px);
  letter-spacing: 0.3em;
  text-indent: 0.3em;
}

.menu-sub {
  margin: 0.5em 0 1.8em;
  color: #777f77;
  font-family: var(--cn);
  font-size: clamp(9px, 0.72vw, 12px);
  letter-spacing: 0.12em;
}

.menu-controls {
  display: flex;
  justify-content: center;
  gap: 1.5em;
  margin-top: 1.6em;
  color: #555e58;
  font-family: var(--cn);
  font-size: clamp(8px, 0.6vw, 10px);
  letter-spacing: 0.08em;
}

.menu-controls b {
  color: #a3a698;
  font-family: var(--mono);
  font-weight: 400;
}

/* Upgrade draft ----------------------------------------------------- */

.upgrade-screen {
  z-index: 32;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3.2vh 3.4vw;
  background:
    radial-gradient(ellipse at 50% 22%, rgba(112, 38, 32, 0.16), transparent 48%),
    linear-gradient(0deg, rgba(2, 5, 7, 0.9), rgba(2, 5, 7, 0.79));
  backdrop-filter: blur(3px) saturate(0.64);
}

.upgrade-shell {
  position: relative;
  width: min(74em, 96%);
  max-height: 92%;
  overflow: auto;
  padding: clamp(20px, 3.2vh, 36px) clamp(20px, 2.5vw, 38px) clamp(16px, 2.4vh, 26px);
  background:
    linear-gradient(145deg, rgba(19, 27, 28, 0.97), rgba(5, 9, 11, 0.98) 65%),
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, 0.014) 3px 4px);
  border: 1px solid rgba(217, 211, 189, 0.2);
  box-shadow: 0 36px 110px rgba(0, 0, 0, 0.8), inset 0 0 80px rgba(0, 0, 0, 0.22);
  clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 20px, 100% 100%, 20px 100%, 0 calc(100% - 20px));
  scrollbar-width: thin;
}

.upgrade-shell::before {
  content: "";
  position: absolute;
  top: 0;
  left: clamp(20px, 2.5vw, 38px);
  width: 32%;
  height: 2px;
  background: linear-gradient(90deg, var(--blood), transparent);
}

.upgrade-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2em;
  margin-bottom: clamp(16px, 2.4vh, 26px);
}

.upgrade-header h2 {
  margin: 0.45em 0 0;
  color: var(--bone);
  font-family: var(--cn);
  font-size: clamp(22px, 2.4vw, 38px);
  font-weight: 200;
  letter-spacing: 0.16em;
}

.upgrade-sub {
  margin: 0.55em 0 0;
  color: #727a71;
  font-family: var(--cn);
  font-size: clamp(8px, 0.7vw, 12px);
  letter-spacing: 0.1em;
}

.upgrade-run-info {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 0.55em;
  align-items: flex-end;
  color: #7b847c;
  font-family: var(--cn);
  font-size: clamp(8px, 0.65vw, 11px);
  letter-spacing: 0.08em;
  text-align: right;
}

.upgrade-run-info b {
  color: var(--amber);
  font-family: var(--mono);
  font-size: 1.3em;
  font-weight: 400;
}

.upgrade-run-info em {
  color: #a07668;
  font-style: normal;
}

.upgrade-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(8px, 1.2vw, 18px);
}

.upgrade-card {
  --rarity: #b1bcb3;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 15.6em;
  padding: clamp(14px, 1.5vw, 22px) clamp(13px, 1.5vw, 22px) clamp(12px, 1.4vw, 18px);
  border: 1px solid color-mix(in srgb, var(--rarity) 46%, rgba(217, 211, 189, 0.16));
  background:
    linear-gradient(150deg, color-mix(in srgb, var(--rarity) 15%, rgba(17, 26, 27, 0.94)), rgba(6, 10, 12, 0.97) 58%),
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, 0.016) 3px 4px);
  color: var(--bone);
  text-align: left;
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  overflow: hidden;
}

.upgrade-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--rarity), transparent 72%);
  opacity: 0.8;
}

.upgrade-card::after {
  content: "";
  position: absolute;
  right: -18%;
  bottom: -35%;
  width: 70%;
  height: 70%;
  background: radial-gradient(ellipse, color-mix(in srgb, var(--rarity) 21%, transparent), transparent 68%);
  opacity: 0.38;
  transition: opacity 0.18s;
  pointer-events: none;
}

.upgrade-card.rarity-rare {
  --rarity: #e2b269;
}

.upgrade-card.rarity-epic {
  --rarity: #d85258;
}

.upgrade-card.rarity-relic {
  --rarity: #93e0c5;
}

.upgrade-card.rarity-relic .upgrade-rarity {
  letter-spacing: 0.2em;
}

.upgrade-card:hover,
.upgrade-card:focus-visible {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--rarity) 72%, #fff 10%);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.38), 0 0 22px color-mix(in srgb, var(--rarity) 12%, transparent);
  outline: none;
}

.upgrade-card:hover::after,
.upgrade-card:focus-visible::after {
  opacity: 1;
}

.upgrade-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7em;
  color: var(--rarity);
  font-family: var(--mono);
  font-size: clamp(7px, 0.57vw, 10px);
  letter-spacing: 0.2em;
}

.upgrade-index {
  color: #5e6762;
  font-size: 1.1em;
  letter-spacing: 0.05em;
}

.upgrade-glyph {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.3em;
  height: 3.3em;
  margin: clamp(14px, 2.2vh, 24px) 0 clamp(11px, 1.7vh, 17px);
  border: 1px solid color-mix(in srgb, var(--rarity) 52%, transparent);
  color: var(--rarity);
  font-family: var(--display);
  font-size: clamp(17px, 1.7vw, 28px);
  font-weight: 800;
  letter-spacing: 0.02em;
  background: color-mix(in srgb, var(--rarity) 8%, transparent);
  box-shadow: inset 0 0 22px color-mix(in srgb, var(--rarity) 7%, transparent);
  clip-path: polygon(0 0, calc(100% - 7px) 0, 100% 7px, 100% 100%, 7px 100%, 0 calc(100% - 7px));
}

.upgrade-name {
  display: block;
  margin-top: 0;
  color: #ebe5d2;
  font-family: var(--cn);
  font-size: clamp(15px, 1.25vw, 21px);
  font-weight: 500;
  letter-spacing: 0.1em;
  line-height: 1.35;
}

.upgrade-cat {
  margin-top: 0.4em;
  color: color-mix(in srgb, var(--rarity) 72%, #858d82);
  font-family: var(--mono);
  font-size: clamp(6px, 0.52vw, 9px);
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.upgrade-desc {
  min-height: 3.1em;
  margin: 0.9em 0 1.2em;
  color: #afb3a7;
  font-family: var(--cn);
  font-size: clamp(9px, 0.72vw, 12px);
  line-height: 1.75;
  letter-spacing: 0.04em;
}

.upgrade-pick {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 0.7em;
  border-top: 1px solid rgba(217, 211, 189, 0.12);
  color: #d6cfb9;
  font-family: var(--cn);
  font-size: clamp(8px, 0.64vw, 11px);
  letter-spacing: 0.12em;
}

.upgrade-pick b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7em;
  height: 1.45em;
  margin-left: 0.7em;
  border: 1px solid color-mix(in srgb, var(--rarity) 46%, transparent);
  color: var(--rarity);
  font-family: var(--mono);
  font-size: 0.86em;
  font-weight: 400;
}

.upgrade-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5em;
  margin-top: clamp(13px, 2vh, 21px);
  padding-top: clamp(11px, 1.8vh, 17px);
  border-top: 1px solid rgba(217, 211, 189, 0.1);
}

.upgrade-hint {
  color: #626b63;
  font-family: var(--cn);
  font-size: clamp(7px, 0.56vw, 10px);
  letter-spacing: 0.08em;
}

.upgrade-hint b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5em;
  height: 1.5em;
  margin: 0 0.16em;
  border: 1px solid rgba(217, 211, 189, 0.2);
  color: #aeb0a1;
  font-family: var(--mono);
  font-weight: 400;
}

.upgrade-reroll {
  flex: none;
  min-width: 11em;
  padding: 0.55em 1.1em;
  align-items: center;
  text-align: center;
}

.upgrade-reroll:disabled {
  opacity: 0.34;
  cursor: not-allowed;
  transform: none;
}

.upgrade-reroll em {
  margin-top: 0.2em;
  color: #7c847b;
}

@media (max-width: 900px), (max-height: 520px) {
  .upgrade-screen {
    padding: 2vh 3vw;
  }

  .upgrade-shell {
    max-height: 96%;
    padding: 15px 18px 13px;
  }

  .upgrade-header {
    align-items: flex-start;
    margin-bottom: 11px;
  }

  .upgrade-header h2 {
    font-size: clamp(17px, 2.4vw, 26px);
  }

  .upgrade-sub {
    display: none;
  }

  .upgrade-run-info {
    padding-top: 0.2em;
    font-size: 8px;
  }

  .upgrade-grid {
    gap: 8px;
  }

  .upgrade-card {
    min-height: 12.6em;
    padding: 10px 11px;
  }

  .upgrade-glyph {
    margin: 8px 0 7px;
    width: 2.1em;
    height: 2.1em;
    font-size: 13px;
  }

  .upgrade-name {
    font-size: clamp(11px, 1.2vw, 14px);
  }

  .upgrade-desc {
    min-height: 0;
    margin: 0.6em 0 0.8em;
    font-size: 8px;
    line-height: 1.5;
  }

  .upgrade-foot {
    margin-top: 10px;
    padding-top: 9px;
  }

  .upgrade-reroll {
    min-width: 9em;
    padding: 0.45em 0.8em;
  }
}

@media (max-width: 620px) {
  .upgrade-grid {
    grid-template-columns: 1fr;
  }

  .upgrade-card {
    min-height: 0;
  }

  .upgrade-glyph {
    float: left;
    margin-right: 10px;
  }

  .upgrade-run-info,
  .upgrade-hint {
    display: none;
  }
}

.gameover-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4vh 4vw;
  overflow: hidden;
}

.gameover-screen {
  background:
    radial-gradient(ellipse at 50% 46%, rgba(113, 19, 24, 0.2), transparent 52%),
    rgba(2, 3, 5, 0.87);
  backdrop-filter: blur(4px) saturate(0.5);
}

.death-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 22%, rgba(80, 5, 9, 0.3) 62%, rgba(10, 0, 1, 0.88) 100%);
  animation: death-breathe 3.2s ease-in-out infinite;
}

.gameover-card {
  z-index: 1;
  width: min(42em, 92%);
  text-align: center;
  background: transparent;
  border: 0;
  box-shadow: none;
  clip-path: none;
  overflow: visible;
}

.death-label {
  color: var(--blood-bright);
  font-family: var(--mono);
  font-size: clamp(8px, 0.68vw, 12px);
  letter-spacing: 0.5em;
  text-indent: 0.5em;
  animation: flicker 2.7s infinite;
}

.gameover-card h2 {
  margin: 0.35em 0 0.6em;
  font-family: var(--cn);
  font-size: clamp(34px, 4.7vw, 76px);
  font-weight: 200;
  line-height: 1.16;
  letter-spacing: 0.1em;
  color: #d4cbb6;
  text-shadow: 0 0 26px rgba(0, 0, 0, 0.9);
}

.gameover-card h2 span {
  color: var(--blood-bright);
  font-weight: 500;
}

.epitaph {
  margin: 0 0 1.8em;
  color: #767d75;
  font-family: var(--cn);
  font-size: clamp(9px, 0.76vw, 13px);
  letter-spacing: 0.14em;
}

.run-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 0 auto 1.3em;
  width: min(34em, 100%);
  border-top: 1px solid rgba(217, 211, 189, 0.18);
  border-bottom: 1px solid rgba(217, 211, 189, 0.18);
}

.run-stats div {
  padding: 0.85em 0.4em;
  border-right: 1px solid rgba(217, 211, 189, 0.09);
  display: flex;
  flex-direction: column;
  gap: 0.35em;
}

.run-stats div:last-child {
  border-right: 0;
}

.run-stats span {
  color: #697069;
  font-family: var(--cn);
  font-size: clamp(7px, 0.57vw, 10px);
  letter-spacing: 0.15em;
}

.run-stats strong {
  color: var(--bone);
  font-family: var(--display);
  font-size: clamp(18px, 2vw, 32px);
  font-weight: 800;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}

.run-extra {
  display: flex;
  justify-content: center;
  gap: 0.6em;
  margin: -0.5em 0 0.85em;
  color: #7a8178;
  font-family: var(--cn);
  font-size: clamp(8px, 0.66vw, 11px);
  letter-spacing: 0.12em;
}

.run-extra b {
  color: #c6b88f;
  font-family: var(--mono);
  font-weight: 400;
}

.best-line {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.8em;
  margin-bottom: 1.5em;
  color: #5c655e;
  font-family: var(--cn);
  font-size: clamp(8px, 0.63vw, 11px);
  letter-spacing: 0.1em;
}

.best-line b {
  color: #a3a698;
  font-family: var(--mono);
  font-weight: 400;
}

.new-best {
  display: none;
  padding: 0.2em 0.5em;
  background: var(--blood);
  color: #f5e9dc;
  font-family: var(--mono);
  font-size: 0.82em;
  letter-spacing: 0.12em;
}

.new-best.show {
  display: inline-block;
  animation: flicker 1.7s infinite;
}

.gameover-card .pixel-btn {
  width: min(18em, 100%);
  align-items: center;
  text-align: center;
}

.gameover-hint {
  margin: 1.1em 0 0;
  color: #4e5650;
  font-family: var(--cn);
  font-size: clamp(8px, 0.58vw, 10px);
  letter-spacing: 0.1em;
}

.gameover-hint b {
  color: #8b9085;
  font-family: var(--mono);
  font-weight: 400;
}

/* Misc -------------------------------------------------------------- */

.rotate-hint {
  display: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.75); }
}

@keyframes critical-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes flicker {
  0%, 18%, 22%, 25%, 53%, 57%, 100% { opacity: 1; }
  20%, 24%, 55% { opacity: 0.35; }
}

@keyframes flicker-soft {
  0%, 100% { opacity: 0.8; }
  47% { opacity: 0.8; }
  48% { opacity: 0.55; }
  49% { opacity: 0.8; }
  78% { opacity: 0.68; }
  79% { opacity: 0.8; }
}

@keyframes death-breathe {
  0%, 100% { opacity: 0.65; }
  50% { opacity: 1; }
}

@keyframes boot-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.title-copy > * {
  animation: boot-in 0.8s both;
}

.title-copy > :nth-child(1) { animation-delay: 0.08s; }
.title-copy > :nth-child(2) { animation-delay: 0.16s; }
.title-copy > :nth-child(3) { animation-delay: 0.26s; }
.title-copy > :nth-child(4) { animation-delay: 0.35s; }
.title-copy > :nth-child(5) { animation-delay: 0.44s; }

.title-screen.is-hidden .title-copy > * {
  animation: none;
}

/* Responsive -------------------------------------------------------- */

@media (max-width: 960px) {
  .title-copy {
    width: 76%;
    padding-left: 6vw;
  }

  .title-meta {
    width: 24%;
    padding-right: 4vw;
  }

  .title-meta dl {
    max-width: 13em;
  }

  .field-tip {
    display: none;
  }

  .hud-bottom {
    grid-template-columns: minmax(150px, 1fr) minmax(180px, auto);
  }

  .loadout {
    grid-column: 2;
  }

  .title-foot span:nth-child(1),
  .title-foot span:nth-child(2) {
    display: none;
  }
}

@media (max-width: 700px), (max-height: 440px) {
  :root {
    --ui: clamp(8px, 1.25vw, 12px);
  }

  .title-meta {
    display: none;
  }

  .title-copy {
    width: 100%;
    padding-left: 7vw;
    padding-right: 7vw;
    justify-content: flex-end;
    padding-bottom: 9vh;
    background: linear-gradient(0deg, rgba(3, 6, 9, 0.92), rgba(3, 6, 9, 0.2) 68%, transparent);
  }

  .title-main {
    font-size: min(17vw, 20vh);
  }

  .title-cn {
    font-size: clamp(13px, 2vw, 20px);
  }

  .title-warning {
    display: none;
  }

  .tagline {
    font-size: clamp(10px, 1.5vw, 13px);
  }

  .title-foot {
    left: 7vw;
    right: 7vw;
    bottom: 1.6vh;
    padding-top: 0.6em;
  }

  .hud-top {
    inset: 2.2% 3% auto;
  }

  .brand-sub,
  .build-count,
  .pause-btn span {
    display: none;
  }

  .mutation-strip {
    top: 5.2em;
    left: 3%;
    max-width: 55%;
  }

  .mutation-label {
    display: none;
  }

  .mutation-chip {
    font-size: 0.52em;
  }

  .pause-btn {
    top: 6.5em;
    right: 3%;
    font-size: 0.65em;
  }

  .hud-bottom {
    left: 3%;
    right: 3%;
    bottom: 2.6%;
    grid-template-columns: 1fr 1fr;
    gap: 1em;
  }

  .vitals,
  .loadout {
    padding: 0.45em 0.55em;
  }

  .weapon-slots,
  .stamina-row .key-hint {
    display: none;
  }

  .score-sub {
    display: none;
  }

  .wave-banner {
    top: 27%;
  }

  .run-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .run-stats div:nth-child(2) {
    border-right: 0;
  }

  .run-stats div:nth-child(-n + 2) {
    border-bottom: 1px solid rgba(217, 211, 189, 0.09);
  }

  .help-grid {
    gap: 0.3em 1em;
  }

  .help-grid span {
    font-size: 8px;
  }

  .toast {
    bottom: 22%;
  }
}

@media (orientation: portrait) and (max-width: 820px) {
  .rotate-hint {
    position: absolute;
    z-index: 60;
    top: 50%;
    left: 50%;
    width: 80%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    gap: 0.5em;
    align-items: center;
    padding: 1.2em;
    background: rgba(3, 6, 9, 0.9);
    border: 1px solid rgba(217, 211, 189, 0.22);
    color: #8d948b;
    font-family: var(--cn);
    font-size: 12px;
    letter-spacing: 0.12em;
    text-align: center;
    pointer-events: none;
  }

  .rotate-hint strong {
    color: var(--bone);
    font-size: 18px;
    font-weight: 400;
  }
}
