:root {
  --sand: #c4a574;
  --dust: #8a6a3e;
  --dusk: #2a1c12;
  --ink: #140e0a;
  --cream: #f2e4c9;
  --rust: #b84a28;
  --blood: #8b1e1e;
  --sage: #6b7f4a;
  --gold: #e0a84a;
  --line: rgba(242, 228, 201, 0.28);
  --panel: rgba(20, 14, 10, 0.88);
  --font-display: "Bebas Neue", Impact, sans-serif;
  --font-body: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(176, 120, 54, 0.22), transparent 50%),
    var(--sky, var(--ink));
  color: var(--cream);
  font-family: var(--font-body);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
#wrap-fade {
  position: fixed;
  inset: 0;
  z-index: 18;
  pointer-events: none;
  opacity: 0;
  /* Proximity sand wash near adobe walls (not a teleport fade). */
  background:
    radial-gradient(ellipse at 50% 58%, rgba(196, 150, 82, 0.42), transparent 62%),
    rgba(52, 34, 22, 0.48);
  transition: none;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--sky, #b8894a);
}

.back-link {
  position: fixed;
  top: 22px;
  left: 14px;
  z-index: 40;
  color: var(--cream);
  text-decoration: none;
  font-size: 11px;
  letter-spacing: 0.12em;
  opacity: 0.75;
  text-shadow: 0 1px 0 #000;
}
.back-link:hover { opacity: 1; color: var(--gold); }

.hidden { display: none !important; }

#hud {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}
#hud .hud-mute { pointer-events: auto; }

/* Vampire Survivors / Mega Bonk — full-bleed XP rail */
.xp-rail {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 24;
  height: 14px;
  pointer-events: none;
}
.xp-rail .xp-track {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.xp-rail .xp-track i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #4a6b32, #8fbf4a 45%, #e0a84a 78%, #f2e4c9);
  transform-origin: left center;
  transition: transform 0.12s linear;
  box-shadow: 0 0 12px rgba(224, 168, 74, 0.35);
}
.xp-rail.flash .xp-track i {
  animation: xp-flash 0.45s ease-out;
}
.xp-rail.tick .xp-track i {
  animation: xp-tick 0.22s ease-out;
}
@keyframes xp-flash {
  0% { filter: brightness(1.8); }
  100% { filter: brightness(1); }
}
@keyframes xp-tick {
  0% { filter: brightness(1.45); box-shadow: 0 0 10px rgba(224, 168, 74, 0.55); }
  100% { filter: brightness(1); box-shadow: none; }
}
.xp-rail .xp-lvl {
  position: absolute;
  top: 0;
  left: 10px;
  z-index: 1;
  height: 14px;
  display: flex;
  align-items: center;
  font-size: 9px;
  letter-spacing: 0.16em;
  color: rgba(242, 228, 201, 0.95);
  text-shadow: 0 1px 2px #000, 0 0 6px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
  pointer-events: none;
}
.xp-rail .xp-lvl b {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 0.04em;
  color: #fff8e8;
  margin-left: 4px;
}

.hud-mute {
  position: absolute;
  top: 20px;
  right: 12px;
  z-index: 25;
  padding: 5px 9px;
  font-size: 9px;
  letter-spacing: 0.14em;
  opacity: 0.5;
  border-color: rgba(242, 228, 201, 0.18);
  background: rgba(0, 0, 0, 0.32);
}
.hud-mute:hover { opacity: 1; }

.hud-time {
  position: absolute;
  left: 50%;
  top: 22px;
  transform: translateX(-50%);
  z-index: 23;
  pointer-events: none;
  text-align: center;
  text-shadow: 0 2px 0 #000, 0 0 14px rgba(0, 0, 0, 0.65);
}
.hud-time b {
  font-family: var(--font-display);
  font-size: clamp(28px, 4.2vw, 40px);
  letter-spacing: 0.08em;
  color: var(--gold);
  font-weight: 400;
  line-height: 1;
}
.boss-bar:not(.hidden) ~ .hud-time,
body:has(.boss-bar:not(.hidden)) .hud-time {
  top: 58px;
}

.hud-bl {
  position: absolute;
  left: 16px;
  bottom: 16px;
  display: grid;
  gap: 8px;
  width: min(280px, calc(100vw - 32px));
  align-content: end;
}
.gold-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  text-shadow: 0 1px 2px #000;
}
.gold-coin {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #ffe29a 0%, #e0a84a 42%, #a86e18 78%, #6a4208 100%);
  border: 1.5px solid #f2e4c9;
  box-shadow:
    inset 0 0 0 2px rgba(120, 70, 10, 0.35),
    0 1px 3px rgba(0, 0, 0, 0.55);
  position: relative;
  flex-shrink: 0;
}
.gold-coin::after {
  content: '$';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 11px;
  line-height: 1;
  color: #5a3208;
  text-shadow: 0 1px 0 rgba(255, 230, 160, 0.45);
}
.gold-row b {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.04em;
  color: var(--gold);
  font-weight: 400;
}
.gold-row.collect-pop {
  animation: collect-pop 0.22s ease-out;
}
@keyframes collect-pop {
  0% { transform: scale(1); filter: brightness(1); }
  40% { transform: scale(1.12); filter: brightness(1.35); }
  100% { transform: scale(1); filter: brightness(1); }
}
.hp-wrap.heal-pop .bar i {
  animation: heal-flash 0.28s ease-out;
}
@keyframes heal-flash {
  0% { filter: brightness(1.6); box-shadow: 0 0 12px rgba(120, 220, 100, 0.55); }
  100% { filter: brightness(1); box-shadow: none; }
}
.res b.kill-pop {
  animation: kill-pop 0.28s ease-out;
}
@keyframes kill-pop {
  0% { transform: scale(1); color: var(--cream); }
  35% { transform: scale(1.25); color: var(--gold); }
  100% { transform: scale(1); color: var(--cream); }
}
.gun-chip {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  width: fit-content;
  padding: 3px 8px 2px;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(224, 168, 74, 0.28);
  text-shadow: 0 1px 2px #000;
}
.gun-chip::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: calc(var(--chamber, 1) * 100%);
  background: linear-gradient(90deg, #8a6a2a, #f2d27a);
  opacity: 0.85;
  pointer-events: none;
}
.gun-chip.chambering {
  border-color: rgba(224, 168, 74, 0.55);
}
.gun-chip.hot::after {
  box-shadow: 0 0 6px rgba(242, 210, 122, 0.45);
}
.gun-chip em {
  font-style: normal;
  font-size: 9px;
  letter-spacing: 0.16em;
  color: rgba(242, 228, 201, 0.55);
}
.gun-chip b {
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.06em;
  color: var(--cream);
  font-weight: 400;
}
.gun-chip.legend b { color: var(--gold); }
.gun-chip.rare b { color: #d8c090; }
.gun-chip.packed {
  border-color: rgba(255, 120, 60, 0.45);
  box-shadow: 0 0 10px rgba(255, 100, 40, 0.18);
}
.pause-iron {
  margin: 0 0 14px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(224, 168, 74, 0.28);
  display: grid;
  gap: 4px;
}
.pause-iron strong {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.06em;
  color: var(--gold);
  font-weight: 400;
}
.pause-iron span {
  font-size: 11px;
  letter-spacing: 0.06em;
  color: rgba(242, 228, 201, 0.65);
}
.bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  letter-spacing: 0.16em;
  color: rgba(242, 228, 201, 0.72);
  text-shadow: 0 1px 2px #000;
}
.bar {
  flex: 1;
  height: 12px;
  border: 1px solid rgba(184, 74, 40, 0.4);
  background: rgba(0, 0, 0, 0.55);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4);
}
.bar i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #6e1212, var(--rust) 55%, #d84a28);
  transform-origin: left center;
  transition: transform 0.12s linear;
}
.hp-wrap .bar { height: 13px; }

.hud-br {
  position: absolute;
  right: 14px;
  bottom: 16px;
  pointer-events: none;
}
.res-dock {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px 14px;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(242, 228, 201, 0.12);
}
.res {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: 9px;
  letter-spacing: 0.14em;
  color: rgba(242, 228, 201, 0.55);
  text-shadow: 0 1px 2px #000;
}
.res.quiet { opacity: 0.72; }
.res em {
  font-style: normal;
}
.res b {
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.04em;
  color: var(--cream);
  font-weight: 400;
}
.res b { color: var(--cream); }

.iron-plaque { display: none !important; }

.item-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-width: 100%;
  pointer-events: none;
}
.item-chip {
  position: relative;
  overflow: hidden;
  min-width: 36px;
  padding: 4px 7px 3px;
  border: 1px solid rgba(224, 168, 74, 0.35);
  background: rgba(0, 0, 0, 0.5);
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--sand);
  text-align: center;
}
.item-chip .item-charge {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: calc(var(--charge, 1) * 100%);
  background: linear-gradient(90deg, #c9a24a, #f2d27a);
  opacity: 0.85;
  pointer-events: none;
}
.item-chip.ready {
  border-color: rgba(242, 210, 122, 0.7);
  box-shadow: 0 0 8px rgba(224, 168, 74, 0.28);
}
.item-chip span {
  display: block;
  margin-top: 1px;
  font-family: var(--font-mono, "IBM Plex Mono", monospace);
  font-size: 7px;
  letter-spacing: 0.06em;
  color: rgba(242, 228, 201, 0.45);
  text-transform: uppercase;
}

.pip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  pointer-events: none;
}
.whiskey-pip {
  width: 14px;
  height: 14px;
  border: 2px solid #c9a24a;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f2d27a, #8a5a18 70%);
  box-shadow: 0 0 8px rgba(224, 168, 74, 0.4);
  pointer-events: none;
}
.whiskey-pip.empty {
  background: transparent;
  box-shadow: none;
  opacity: 0.45;
}
.dead-eye-pip {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(120, 190, 255, 0.75);
  border-radius: 50%;
  background: conic-gradient(#7ec8ff calc(var(--charge, 1) * 1turn), rgba(20, 30, 40, 0.55) 0);
  box-shadow: 0 0 8px rgba(100, 180, 255, 0.35);
  pointer-events: none;
}
.dead-eye-pip.ready {
  box-shadow: 0 0 12px rgba(140, 210, 255, 0.65);
}
.dead-eye-pip.active {
  border-color: #d8f0ff;
  box-shadow: 0 0 14px rgba(180, 230, 255, 0.8);
}
.partner-chip {
  min-width: 64px;
  margin-bottom: 6px;
  padding: 4px 8px 3px;
  border: 1px solid rgba(224, 168, 74, 0.4);
  background: rgba(0, 0, 0, 0.55);
  font-family: var(--font-display);
  letter-spacing: 0.08em;
  color: var(--sand);
  text-align: center;
  pointer-events: none;
}
.partner-chip em {
  display: block;
  font-style: normal;
  font-family: var(--font-mono, "IBM Plex Mono", monospace);
  font-size: 7px;
  letter-spacing: 0.1em;
  color: rgba(242, 228, 201, 0.5);
}
.partner-chip b {
  font-size: 16px;
  font-weight: 400;
  color: var(--cream);
}

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border: 1px solid rgba(242, 228, 201, 0.95);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45), 0 0 10px rgba(224, 168, 74, 0.25);
}
#crosshair::before,
#crosshair::after {
  content: "";
  position: absolute;
  background: rgba(242, 228, 201, 0.95);
}
#crosshair::before {
  left: 50%;
  top: -8px;
  width: 2px;
  height: 32px;
  margin-left: -1px;
}
#crosshair::after {
  top: 50%;
  left: -8px;
  width: 32px;
  height: 2px;
  margin-top: -1px;
}
#crosshair.ads {
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-color: #ffe08a;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 0 14px rgba(255, 200, 80, 0.45);
}
#crosshair.ads::before { height: 22px; top: -6px; }
#crosshair.ads::after { width: 22px; left: -6px; }
#crosshair.dead-eye-ready {
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45), 0 0 12px rgba(224, 168, 74, 0.6);
}
#crosshair.dead-eye {
  border-color: #ffe08a;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 0 18px rgba(255, 196, 64, 0.9);
}
#crosshair.flash {
  border-color: #ffe08a;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45), 0 0 16px rgba(255, 200, 80, 0.7);
}

#hitmarker {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid #ffe08a;
  transform: rotate(45deg);
  opacity: 0.95;
  box-shadow: 0 0 12px rgba(255, 200, 80, 0.55);
  animation: hit-pop 0.18s ease-out;
}
#hitmarker.crit {
  border-color: #ff6a3d;
  box-shadow: 0 0 16px rgba(255, 80, 40, 0.85);
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
}
@keyframes hit-pop {
  from { opacity: 0; transform: rotate(45deg) scale(0.6); }
  to { opacity: 0.95; transform: rotate(45deg) scale(1); }
}

#hint {
  position: absolute;
  top: 44px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(920px, calc(100vw - 24px));
  font-size: 10px;
  letter-spacing: 0.1em;
  opacity: 0.5;
  text-align: center;
  white-space: normal;
  line-height: 1.45;
  transition: opacity 0.4s ease;
}
#hint.cage-call {
  color: var(--gold);
  letter-spacing: 0.16em;
  font-size: 12px;
  text-shadow: 0 1px 0 #000, 0 0 14px rgba(224, 168, 74, 0.55);
  animation: cage-call-pulse 1.8s ease-in-out infinite;
}
@keyframes cage-call-pulse {
  0%, 100% { text-shadow: 0 1px 0 #000, 0 0 10px rgba(224, 168, 74, 0.35); }
  50% { text-shadow: 0 1px 0 #000, 0 0 22px rgba(255, 210, 122, 0.85); }
}

#wave-banner {
  position: absolute;
  top: 28%;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-size: clamp(26px, 5.2vw, 56px);
  letter-spacing: 0.06em;
  color: var(--gold);
  text-shadow: 0 3px 0 #000, 0 0 30px rgba(224, 168, 74, 0.4);
  animation: banner-in 0.45s ease-out;
  text-align: center;
  max-width: min(92vw, 960px);
  line-height: 1.18;
  white-space: pre-line;
}
#wave-banner.toast {
  top: 18%;
  font-size: clamp(16px, 2.8vw, 28px);
  letter-spacing: 0.1em;
  color: var(--cream);
  text-shadow: 0 2px 0 #000, 0 0 14px rgba(224, 168, 74, 0.28);
  opacity: 0.92;
}
@keyframes banner-in {
  from { opacity: 0; transform: translate(-50%, 12px) scale(0.96); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 50% 18%, rgba(224, 168, 74, 0.18), transparent 55%),
    linear-gradient(180deg, rgba(61, 42, 24, 0.92), rgba(20, 14, 10, 0.96));
}
.panel {
  width: min(460px, 100%);
  border: 1px solid rgba(224, 168, 74, 0.28);
  background:
    linear-gradient(180deg, rgba(32, 22, 14, 0.94), rgba(14, 10, 7, 0.97));
  padding: 26px 24px 22px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.5);
}
.death-panel .death-hero {
  margin: 14px 0 4px;
  font-family: var(--font-display);
  font-size: clamp(28px, 6vw, 40px);
  letter-spacing: 0.06em;
  color: var(--gold);
  text-shadow: 0 2px 0 #000;
}
.death-sub { margin-top: 0; }
.pause-panel h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: clamp(36px, 8vw, 52px);
  letter-spacing: 0.06em;
  color: var(--cream);
}
.pause-panel .row + .row { margin-top: 10px; }
.settings-block {
  margin: 16px 0 6px;
  padding: 12px 12px 10px;
  border: 1px solid rgba(224, 168, 74, 0.28);
  background: rgba(0, 0, 0, 0.28);
}
.settings-label {
  margin: 0 0 10px;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--gold);
}
.fx-toggles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.fx-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: rgba(242, 228, 201, 0.85);
  cursor: pointer;
}
.fx-toggle input {
  accent-color: var(--gold);
  width: 14px;
  height: 14px;
}
.volume-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0 4px;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: rgba(242, 228, 201, 0.85);
}
.volume-row input[type="range"] {
  flex: 1;
  accent-color: var(--gold);
  height: 4px;
}

/* Grit grade overlays */
#grade {
  position: fixed;
  inset: 0;
  z-index: 25;
  pointer-events: none;
  opacity: 0;
}
body.fx-grain #grade,
body.fx-vignette #grade,
body.fx-crush #grade,
body.fx-bleach #grade,
body.fx-noir #grade,
body.fx-heat #grade,
body.fx-blood #grade,
body.fx-dust #grade {
  opacity: 1;
}
body.fx-grain #grade {
  background-image:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.35' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.75'/%3E%3C/svg%3E");
  background-size: 110px 110px;
  mix-blend-mode: overlay;
  opacity: 0.55;
}
body.fx-vignette #grade::after,
body.fx-crush #grade::before,
body.fx-dust #grade::before {
  content: "";
  position: absolute;
  inset: 0;
}
body.fx-vignette #grade::after {
  background: radial-gradient(ellipse at center, transparent 28%, rgba(8, 4, 1, 0.92) 100%);
}
body.fx-crush #game {
  filter: contrast(1.55) saturate(0.75) brightness(0.88);
}
body.fx-bleach #game {
  filter: saturate(0.25) contrast(1.45) brightness(1.12);
}
body.fx-crush.fx-bleach #game {
  filter: saturate(0.2) contrast(1.6) brightness(0.95);
}
body.fx-noir #game {
  filter: grayscale(0.92) contrast(1.65) brightness(0.9);
}
body.fx-heat #grade {
  background: linear-gradient(180deg, rgba(255, 140, 40, 0.22), rgba(180, 40, 10, 0.28));
  mix-blend-mode: soft-light;
  opacity: 0.85;
}
body.fx-heat #game {
  filter: saturate(1.25) contrast(1.08) brightness(1.05) blur(0.35px);
}
body.fx-blood #grade {
  background: radial-gradient(ellipse at center, rgba(120, 0, 10, 0.15) 20%, rgba(90, 0, 8, 0.55) 100%);
  mix-blend-mode: multiply;
  opacity: 0.9;
}
body.fx-blood #game {
  filter: sepia(0.35) saturate(1.4) hue-rotate(-18deg) contrast(1.2) brightness(0.92);
}
body.fx-dust #grade::before {
  background:
    radial-gradient(ellipse at 30% 40%, rgba(180, 140, 80, 0.35), transparent 55%),
    radial-gradient(ellipse at 70% 60%, rgba(140, 100, 50, 0.4), transparent 50%),
    linear-gradient(180deg, rgba(160, 120, 70, 0.18), rgba(90, 60, 30, 0.32));
  mix-blend-mode: soft-light;
}
body.fx-dust #grade {
  opacity: 0.95;
}
body.fx-grain.fx-vignette #grade {
  opacity: 1;
  background-image:
    radial-gradient(ellipse at center, transparent 28%, rgba(8, 4, 1, 0.88) 100%),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.35' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.75'/%3E%3C/svg%3E");
  background-size: auto, 110px 110px;
  mix-blend-mode: soft-light;
}
.boot-status {
  margin: 12px 0 0;
  min-height: 1.4em;
  color: var(--gold);
}
.eyebrow {
  margin: 0 0 8px;
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--sand);
}
h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(52px, 12vw, 78px);
  line-height: 0.9;
  letter-spacing: 0.04em;
  color: var(--cream);
  text-shadow: 0 3px 0 #000;
}
.blurb {
  margin: 14px 0 18px;
  font-size: 12px;
  line-height: 1.65;
  color: rgba(242, 228, 201, 0.78);
}
.controls {
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
  font-size: 11px;
  color: rgba(242, 228, 201, 0.7);
}
.controls kbd {
  display: inline-block;
  min-width: 1.4em;
  padding: 1px 5px;
  margin-right: 2px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  font: inherit;
  color: var(--gold);
  text-align: center;
}
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
button, .ghost, .primary {
  font-family: var(--font-body);
  font-size: 12px;
  letter-spacing: 0.12em;
  cursor: pointer;
  border: 1px solid rgba(242, 228, 201, 0.28);
  background: transparent;
  color: var(--cream);
  padding: 10px 16px;
  transition: border-color 0.15s ease, color 0.15s ease, filter 0.15s ease, background 0.15s ease;
}
.primary {
  background: linear-gradient(180deg, #c45530, var(--rust));
  border-color: #d45a34;
  color: #fff8ee;
}
.primary:hover { filter: brightness(1.1); }
.ghost:hover { border-color: var(--gold); color: var(--gold); background: rgba(224, 168, 74, 0.08); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.board {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.board strong {
  display: block;
  margin-bottom: 8px;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--gold);
}
.board ul {
  list-style: none;
  margin: 0;
  padding: 0;
  min-height: 88px;
  font-size: 12px;
}
.board li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(242, 228, 201, 0.08);
  color: rgba(242, 228, 201, 0.85);
}
.board li span:last-child { color: var(--gold); }
.submit-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 12px;
}
#player-name {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--line);
  color: var(--cream);
  font: 12px var(--font-body);
  padding: 10px 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
#player-name:focus {
  outline: none;
  border-color: var(--gold);
}

body.hurt #game { filter: saturate(0.7) contrast(1.05); }
body.hurt::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 15;
  background: radial-gradient(circle at center, transparent 40%, rgba(139, 30, 30, 0.45));
}
body.venom #game { filter: saturate(0.85) hue-rotate(-8deg) contrast(1.04); }
body.venom::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 14;
  background: radial-gradient(circle at center, transparent 48%, rgba(40, 110, 40, 0.38));
  animation: venom-pulse 0.9s ease-in-out infinite alternate;
}
@keyframes venom-pulse {
  from { opacity: 0.55; }
  to { opacity: 1; }
}
body.sand-blind #game {
  filter: saturate(0.35) contrast(0.92) brightness(0.92);
}
body.sand-blind::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 14;
  background:
    radial-gradient(circle at center, transparent 35%, rgba(90, 70, 40, 0.42)),
    repeating-linear-gradient(0deg, rgba(180, 140, 80, 0.04) 0 1px, transparent 1px 3px);
}

.xp-wrap .bar.xp {
  background: rgba(0, 0, 0, 0.45);
}
.xp-wrap .bar.xp i {
  background: linear-gradient(90deg, #6b7f4a, #e0a84a);
}
/* Level-up sits in the lower third so cards aren't under the crosshair. */
#levelup.overlay {
  place-items: end center;
  align-content: end;
  padding: 0 16px 7vh;
  background:
    linear-gradient(180deg, transparent 28%, rgba(20, 14, 10, 0.55) 58%, rgba(20, 14, 10, 0.92) 100%);
  pointer-events: none;
}
#levelup .levelup-panel {
  pointer-events: auto;
  width: min(860px, 100%);
  padding: 16px 18px 14px;
  background:
    linear-gradient(180deg, rgba(36, 24, 16, 0.92), rgba(16, 11, 8, 0.96));
}
.levelup-panel h2 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: clamp(26px, 5vw, 36px);
  letter-spacing: 0.06em;
  color: var(--gold);
}
.levelup-panel .blurb {
  margin: 4px 0 0;
  font-size: 11px;
}
.upgrade-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}
@media (max-width: 720px) {
  .upgrade-row {
    grid-template-columns: 1fr;
  }
}
.upgrade-card {
  display: grid;
  gap: 4px;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid rgba(242, 228, 201, 0.22);
  background: rgba(0, 0, 0, 0.42);
  color: var(--cream);
  cursor: pointer;
  font-family: var(--font-body);
  transition: border-color 0.15s ease, background 0.15s ease;
}
#levelup.locked .upgrade-card,
.upgrade-card:disabled {
  opacity: 0.45;
  cursor: wait;
  pointer-events: none;
}
.upgrade-card strong {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.08em;
  color: var(--gold);
}
.upgrade-card span {
  font-size: 12px;
  opacity: 0.8;
  letter-spacing: 0.04em;
}
.upgrade-card:hover {
  border-color: var(--gold);
  background: rgba(224, 168, 74, 0.12);
}

.touch-controls {
  position: fixed;
  inset: 0;
  z-index: 25;
  pointer-events: none;
}
.touch-controls .stick-zone,
.touch-controls .look-zone,
.touch-controls .touch-actions,
.touch-controls .touch-btn {
  pointer-events: auto;
}
.stick-zone {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 46%;
  height: 42%;
}
.stick-base {
  position: absolute;
  left: 28px;
  bottom: 28px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  border: 1px solid rgba(242, 228, 201, 0.28);
  background: rgba(20, 14, 10, 0.35);
}
.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  border-radius: 50%;
  border: 1px solid rgba(224, 168, 74, 0.55);
  background: rgba(184, 74, 40, 0.55);
}
.look-zone {
  position: absolute;
  right: 0;
  top: 18%;
  width: 54%;
  height: 52%;
}
.touch-actions {
  position: absolute;
  right: 16px;
  bottom: 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(64px, 78px));
  gap: 8px;
}
.touch-btn {
  min-height: 52px;
  padding: 8px 6px;
  border: 1px solid rgba(242, 228, 201, 0.3);
  background: rgba(20, 14, 10, 0.55);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 11px;
  letter-spacing: 0.1em;
}
.touch-btn.fire {
  background: rgba(184, 74, 40, 0.72);
  border-color: #d45a34;
  grid-column: 2 / 4;
}
.touch-btn.aim {
  border-color: rgba(224, 168, 74, 0.55);
  color: var(--gold);
}
.touch-btn:active,
.touch-btn.active {
  filter: brightness(1.15);
  background: rgba(224, 168, 74, 0.22);
}

body.touch-ui #hint { display: none; }
body.touch-ui .hud-bl { bottom: 148px; }
body.touch-ui .hud-br { bottom: 148px; }
body.touch-ui #crosshair { opacity: 0.85; }

@media (max-width: 720px) {
  .back-link { top: 10px; left: 10px; font-size: 10px; }
  .res b { font-size: 15px; }
  .res-dock { gap: 3px 10px; padding: 5px 8px; }
  .panel { padding: 22px 18px 18px; }
  h1 { font-size: clamp(44px, 14vw, 64px); }
  .hud-mute { top: 18px; right: 8px; padding: 4px 7px; }
}

.boss-bar {
  position: absolute;
  left: 50%;
  top: 22px;
  transform: translateX(-50%);
  width: min(380px, calc(100vw - 120px));
  display: grid;
  gap: 4px;
  justify-items: center;
  pointer-events: none;
  z-index: 22;
}
.boss-bar:not(.hidden) {
  top: 22px;
}
.hud-time.with-boss {
  top: 58px;
}
.boss-bar span {
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 0.14em;
  color: #f2e4c9;
  text-shadow: 0 2px 0 #000, 0 0 10px rgba(184, 74, 40, 0.4);
}
.boss-track {
  width: 100%;
  height: 10px;
  border: 1px solid rgba(242, 228, 201, 0.28);
  background: rgba(0, 0, 0, 0.55);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.boss-track i {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left center;
  background: linear-gradient(90deg, #8b1e1e, #c45a28 55%, #e0a84a);
  transition: transform 0.12s linear;
}
