@font-face {
  font-family: 'Archivo Black';
  src: url('../assets/fonts/ArchivoBlack-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('../assets/fonts/JetBrainsMono-var.ttf') format('truetype');
  font-weight: 100 800;
  font-display: swap;
}
@font-face {
  font-family: 'Space Grotesk';
  src: url('../assets/fonts/SpaceGrotesk-var.ttf') format('truetype');
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --bone: #f5f0e6;
  --ink: #2b2620;
  --ink-2: #1a1713;
  --ochre: #e8a33d;
  --rust: #c8462c;
  --live: #4a9d5f;
  --dim: #8a8175;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --body: 'Space Grotesk', system-ui, sans-serif;
  --display: 'Archivo Black', var(--body);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--ink-2);
  color: var(--bone);
  font-family: var(--body);
  overflow: hidden;
}

#c {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

/* ---------------------------------------------------------------- overlays */
.veil {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(26, 23, 19, 0.88);
  backdrop-filter: blur(3px);
  z-index: 20;
  text-align: center;
  padding: 24px;
}
.veil[hidden] { display: none; }

.veil h1 {
  font-family: var(--display);
  font-size: clamp(34px, 7vw, 66px);
  letter-spacing: -0.02em;
  line-height: 0.95;
  margin-bottom: 10px;
}
.veil h1 .hot { color: var(--ochre); }

.veil .sub {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 22px;
}

.veil p { max-width: 44ch; color: #cfc7b8; line-height: 1.55; margin-bottom: 20px; }

.btn {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: var(--rust);
  color: var(--bone);
  border: 0;
  padding: 14px 30px;
  cursor: pointer;
  transition: transform 0.08s, filter 0.15s;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; border: 1px solid #5a5248; }

/* loading */
#bar {
  width: min(340px, 70vw);
  height: 3px;
  background: #3a342c;
  margin: 16px auto 8px;
  overflow: hidden;
}
#bar i { display: block; height: 100%; width: 0; background: var(--ochre); transition: width 0.2s; }
#loadmsg { font-family: var(--mono); font-size: 10px; color: var(--dim); letter-spacing: 0.1em; }

/* ---------------------------------------------------------------- hud */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud[hidden] { display: none; }

.tl { position: absolute; top: 16px; left: 16px; }
.tr { position: absolute; top: 16px; right: 16px; text-align: right; }
.bc { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); }
.tc { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); text-align: center; }

.label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 4px;
}

.hpwrap { width: 210px; height: 12px; background: rgba(0, 0, 0, 0.45); border: 1px solid #4a4238; }
#hp { height: 100%; width: 100%; background: var(--live); transition: width 0.12s, background 0.2s; }
#hp.low { background: var(--rust); }

#scrap {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
  color: var(--ochre);
  line-height: 1;
}

#wave {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--bone);
  background: rgba(0, 0, 0, 0.5);
  padding: 7px 16px;
  border: 1px solid #4a4238;
}
#wave.boss { color: var(--rust); border-color: var(--rust); }

#bosswrap { margin-top: 8px; width: min(420px, 70vw); display: none; }
#bosswrap.on { display: block; }
#bosshp { height: 6px; background: var(--rust); width: 100%; transition: width 0.15s; }

/* weapon rail */
#rail { display: flex; gap: 6px; }
.slot {
  width: 78px;
  padding: 7px 6px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid #4a4238;
  font-family: var(--mono);
  text-align: center;
}
.slot .k { font-size: 9px; color: var(--dim); }
.slot .n { font-size: 10px; font-weight: 700; letter-spacing: 0.04em; margin: 2px 0 1px; }
.slot .c { font-size: 8px; color: var(--dim); letter-spacing: 0.06em; }
.slot.on { border-color: var(--ochre); background: rgba(232, 163, 61, 0.16); }
.slot.on .n { color: var(--ochre); }
.slot.locked { opacity: 0.42; }
.slot.afford { border-color: var(--live); }
.slot.afford .c { color: var(--live); }

#keys {
  position: absolute;
  bottom: 16px;
  right: 16px;
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.7;
  color: var(--dim);
  text-align: right;
  letter-spacing: 0.08em;
}

#reticle {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 3px;
  height: 3px;
  margin: -1.5px 0 0 -1.5px;
  background: var(--bone);
  opacity: 0.65;
  z-index: 11;
  pointer-events: none;
}
#reticle[hidden] { display: none; }

/* death card */
#stats {
  font-family: var(--mono);
  font-size: 12px;
  color: #cfc7b8;
  margin-bottom: 22px;
  line-height: 2;
}
#stats b { color: var(--ochre); font-weight: 700; }

.fine {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--dim);
  margin-top: 22px;
  letter-spacing: 0.06em;
  max-width: 46ch;
  line-height: 1.7;
}

@media (max-width: 640px) {
  #rail { gap: 4px; }
  .slot { width: 58px; padding: 5px 3px; }
  .slot .n { font-size: 8px; }
  .slot .c { font-size: 7px; }
  #keys { display: none; }
  .hpwrap { width: 140px; }
}

/* ---------------------------------------------------------------- embed mode
   Hero iframe on index.html: no keyboard legend (no room), tighter veils,
   smaller wordmark. The game itself is identical. */
body.embed #keys { display: none; }
body.embed .veil h1 { font-size: clamp(26px, 5vw, 40px); }
body.embed .veil p { font-size: 13px; max-width: 38ch; margin-bottom: 14px; }
body.embed .veil .fine { display: none; }
body.embed .veil .sub { margin-bottom: 14px; }
body.embed .slot { width: 62px; padding: 5px 4px; }
body.embed #scrap { font-size: 20px; }

/* ---------------------------------------------------------------- touch
   Hidden unless main.js found a coarse pointer. Everything here is sized to
   44px minimum — below that, thumbs miss. */
#touch { display: none; }
body.touch #touch { display: block; }

#stick {
  position: fixed;
  width: 108px; height: 108px;
  margin: -54px 0 0 -54px;
  border: 2px solid rgba(245, 240, 230, 0.28);
  border-radius: 50%;
  background: rgba(26, 23, 19, 0.28);
  z-index: 12;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
}
/* Floating, not fixed: the stick appears wherever the thumb lands, which is
   the difference between playable and fighting the UI. */
#stick.on { opacity: 1; }
#knob {
  position: absolute;
  left: 50%; top: 50%;
  width: 44px; height: 44px;
  margin: -22px 0 0 -22px;
  border-radius: 50%;
  background: rgba(245, 240, 230, 0.55);
}

#btnFire, #btnJump {
  position: fixed;
  border-radius: 50%;
  border: 2px solid rgba(245, 240, 230, 0.3);
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--bone);
  z-index: 12;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
}
#btnFire {
  right: 20px; bottom: 96px;
  width: 84px; height: 84px;
  font-size: 12px;
  background: rgba(200, 70, 44, 0.72);
}
#btnFire:active { background: rgba(200, 70, 44, 1); }
#btnJump {
  right: 116px; bottom: 112px;
  width: 60px; height: 60px;
  font-size: 9px;
  background: rgba(43, 38, 32, 0.6);
}
#btnJump:active { background: rgba(43, 38, 32, 0.95); }

/* Reticle is a mouse-aim affordance; there's no cursor to align on a phone. */
body.touch #reticle { display: none; }
body.touch #keys { display: none; }

body.touch .slot {
  /* Rail doubles as the weapon buttons on touch, so it needs real targets. */
  min-height: 46px;
  padding: 6px 5px;
}

/* Stop the browser from treating game gestures as page gestures. */
body.touch, body.touch #c { touch-action: none; overscroll-behavior: none; }

@media (max-width: 640px) {
  #btnFire { width: 76px; height: 76px; right: 16px; bottom: 88px; }
  #btnJump { width: 54px; height: 54px; right: 100px; bottom: 102px; }
  .veil h1 { font-size: clamp(28px, 8vw, 44px); }
  .veil p { font-size: 13px; }
  .tl, .tr, .tc { transform: scale(0.9); }
  .tc { transform: translateX(-50%) scale(0.9); }
}

/* Landscape phone: vertical space is the scarce resource. */
@media (max-height: 480px) and (orientation: landscape) {
  #btnFire { bottom: 64px; width: 66px; height: 66px; }
  #btnJump { bottom: 76px; width: 48px; height: 48px; right: 92px; }
  .bc { bottom: 8px; }
  .veil h1 { font-size: 30px; margin-bottom: 4px; }
  .veil .sub { margin-bottom: 8px; }
  .veil p { display: none; }
}
