/* REINHARDT — Hold the Line. Steel grey, crimson, lion-gold on dusk forest green; sturdy slab-serif. */
@font-face {
  font-family: 'Zilla Slab';
  src: url('vendor/fonts/zilla-slab-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Zilla Slab';
  src: url('vendor/fonts/zilla-slab-700.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --steel: #9aa3ad;
  --steel-dark: #5b636c;
  --crimson: #a02334;
  --crimson-bright: #d3384c;
  --gold: #d9a441;
  --gold-bright: #f4c563;
  --forest: #16211c;
  --forest-mid: #223329;
  --ink: #0d130f;
  --bone: #ece4d0;
  --barrier: #7fd4ff;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--forest); }
body {
  font-family: 'Zilla Slab', Rockwell, 'Courier Bold', serif;
  color: var(--bone);
  -webkit-user-select: none; user-select: none;
  touch-action: none;
}

#scene-root, #scene-root canvas { position: fixed; inset: 0; width: 100%; height: 100%; }
#scene-root canvas { display: block; }

.hidden { display: none !important; }

/* ---------- Loading ---------- */
#loading {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--forest); color: var(--gold); font-size: 20px; letter-spacing: 3px;
  z-index: 60; text-transform: uppercase;
}

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
#hud-top-left { position: absolute; top: 14px; left: 16px; width: 240px; }
.hud-label {
  font-size: 15px; font-weight: 700; letter-spacing: 2px; color: var(--gold);
  text-shadow: 0 1px 0 #000, 0 0 12px rgba(217,164,65,.35);
}
.hud-label.small { font-size: 11px; margin-top: 6px; color: var(--steel); }
.bar-wrap {
  position: relative; height: 16px; margin-top: 3px;
  background: rgba(10,14,11,.72); border: 1px solid rgba(217,164,65,.5);
  box-shadow: 0 2px 6px rgba(0,0,0,.5) inset;
}
.bar { position: absolute; inset: 1px; transform-origin: left center; transition: transform .12s linear; }
.bar-wrap.hp .bar { background: linear-gradient(180deg, var(--crimson-bright), var(--crimson)); }
.bar-wrap.barrier .bar { background: linear-gradient(180deg, #aee6ff, #4aa8d8); }
.bar-wrap.gate .bar { background: linear-gradient(180deg, var(--gold-bright), #8a6420); }
.bar-wrap.broken { animation: barblink .35s steps(2) infinite; }
@keyframes barblink { 50% { border-color: var(--crimson-bright); } }
#hp-text { position: absolute; right: 5px; top: 0; font-size: 11px; line-height: 16px; color: #fff; text-shadow: 0 1px 2px #000; }

#hud-top-right { position: absolute; top: 14px; right: 16px; text-align: right; }
#score { font-size: 34px; font-weight: 700; color: var(--gold-bright); text-shadow: 0 2px 0 #000, 0 0 18px rgba(217,164,65,.4); }
#best-score { font-size: 12px; color: var(--steel); letter-spacing: 2px; }
#wave-label { margin-top: 6px; font-size: 16px; font-weight: 700; letter-spacing: 3px; color: var(--bone); }

#hud-bottom {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  display: flex; gap: 10px;
}
.ability {
  position: relative; width: 92px; height: 54px; overflow: hidden;
  background: rgba(13,19,15,.78); border: 1px solid rgba(154,163,173,.55);
  border-radius: 4px; text-align: center;
  box-shadow: 0 3px 8px rgba(0,0,0,.5);
}
.ability .key { display: block; margin-top: 8px; font-size: 13px; font-weight: 700; color: var(--gold); letter-spacing: 1px; }
.ability .name { display: block; font-size: 9px; letter-spacing: 1px; color: var(--steel); margin-top: 2px; }
.ability .cd {
  position: absolute; left: 0; right: 0; bottom: 0; height: 0%;
  background: rgba(0,0,0,.68); pointer-events: none;
}
.ability.ready { border-color: var(--gold); box-shadow: 0 0 10px rgba(217,164,65,.35); }
.ability.ult.ready { border-color: var(--gold-bright); box-shadow: 0 0 16px rgba(244,197,99,.6); animation: ultpulse 1s ease-in-out infinite; }
@keyframes ultpulse { 50% { box-shadow: 0 0 26px rgba(244,197,99,.9); } }
.ability.active { border-color: var(--barrier); box-shadow: 0 0 12px rgba(127,212,255,.5); }

/* ---------- Barks & popups ---------- */
#barks {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none; z-index: 22; width: min(90vw, 640px); text-align: center;
}
.bark {
  font-size: 20px; font-weight: 700; letter-spacing: 1px; color: var(--bone);
  text-shadow: 0 2px 0 #000, 0 0 14px rgba(0,0,0,.8);
  animation: barkin .18s ease-out; opacity: 1; transition: opacity .5s;
}
.bark small { display: block; font-size: 10px; color: var(--gold); letter-spacing: 3px; font-weight: 400; }
@keyframes barkin { from { transform: scale(1.25); opacity: 0; } }

#popups { position: fixed; inset: 0; pointer-events: none; z-index: 21; }
.popup {
  position: absolute; font-weight: 700; letter-spacing: 2px; color: var(--gold-bright);
  text-shadow: 0 2px 0 #000, 0 0 12px rgba(217,164,65,.6); white-space: nowrap;
  animation: poprise 1.2s ease-out forwards;
}
.popup.style { color: var(--crimson-bright); font-size: 26px; text-shadow: 0 2px 0 #000, 0 0 16px rgba(211,56,76,.7); }
@keyframes poprise {
  0% { transform: translate(-50%,0) scale(.6); opacity: 0; }
  15% { transform: translate(-50%,-12px) scale(1.15); opacity: 1; }
  100% { transform: translate(-50%,-64px) scale(1); opacity: 0; }
}

/* ---------- Vignette / flash ---------- */
#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 15;
  box-shadow: 0 0 140px rgba(160,35,52,0) inset; transition: box-shadow .25s;
}
#vignette.hurt { box-shadow: 0 0 140px rgba(160,35,52,.85) inset; }
#flash { position: fixed; inset: 0; pointer-events: none; z-index: 25; background: #fff; opacity: 0; }

/* ---------- Title screen ---------- */
#title-screen {
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(100deg, rgba(13,19,15,.92) 0%, rgba(13,19,15,.55) 45%, rgba(13,19,15,.15) 100%);
  transition: opacity .6s;
}
#title-screen.gone { opacity: 0; pointer-events: none; }
.title-inner { max-width: 560px; padding: 24px 48px; margin-right: 30vw; }
#title-kicker { font-size: 12px; letter-spacing: 4px; color: var(--steel); margin-bottom: 6px; }
#title-name {
  font-size: clamp(52px, 9vw, 96px); font-weight: 700; letter-spacing: 4px; line-height: .95;
  color: var(--gold-bright); text-shadow: 0 4px 0 #3a2c10, 0 8px 24px rgba(0,0,0,.8);
}
#title-sub {
  font-size: clamp(20px, 3.2vw, 34px); font-weight: 700; letter-spacing: 14px; color: var(--crimson-bright);
  margin: 4px 0 14px; text-shadow: 0 2px 0 #000;
}
#title-story { font-size: 15px; line-height: 1.55; color: #cfc6b2; margin-bottom: 16px; }
#title-story em { color: var(--gold-bright); font-style: normal; }
#controls-card {
  border: 1px solid rgba(217,164,65,.4); background: rgba(13,19,15,.6);
  padding: 10px 14px; margin-bottom: 18px; border-radius: 4px;
}
.ctl { font-size: 13px; color: var(--steel); margin: 3px 0; }
.ctl b { color: var(--bone); font-weight: 700; }
#start-btn, #restart-btn {
  font-family: inherit; font-size: 19px; font-weight: 700; letter-spacing: 3px; cursor: pointer;
  color: var(--ink); background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  border: 0; border-bottom: 4px solid #8a6420; padding: 14px 34px; border-radius: 3px;
  box-shadow: 0 6px 18px rgba(0,0,0,.6);
}
#start-btn:hover, #restart-btn:hover { filter: brightness(1.1); }
#start-btn:active, #restart-btn:active { transform: translateY(2px); border-bottom-width: 2px; }
#title-hint { margin-top: 12px; font-size: 12px; color: var(--steel-dark); letter-spacing: 1px; }

/* ---------- End screen ---------- */
#end-screen {
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(13,19,15,.55) 0%, rgba(13,19,15,.95) 100%);
}
.end-inner { text-align: center; max-width: 640px; padding: 24px; }
#end-title {
  font-size: clamp(56px, 10vw, 110px); font-weight: 700; letter-spacing: 8px;
  color: var(--gold-bright); text-shadow: 0 5px 0 #3a2c10, 0 10px 30px rgba(0,0,0,.9);
}
#end-title.defeat { color: var(--crimson-bright); text-shadow: 0 5px 0 #33060c, 0 10px 30px rgba(0,0,0,.9); }
#end-quote { font-size: 18px; color: var(--bone); margin: 14px 0 20px; line-height: 1.5; }
#end-stats { font-size: 15px; color: var(--steel); letter-spacing: 2px; margin-bottom: 26px; line-height: 1.9; }
#end-stats b { color: var(--gold-bright); font-size: 22px; }

/* ---------- Touch controls ---------- */
#touch-ui { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
#touch-move { position: absolute; left: 14px; bottom: 84px; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: auto; }
.trow { display: flex; gap: 6px; }
.tbtn {
  width: 58px; height: 58px; font-family: inherit; font-size: 20px; font-weight: 700;
  color: var(--bone); background: rgba(13,19,15,.55); border: 1px solid rgba(217,164,65,.55);
  border-radius: 8px; touch-action: none;
}
.tbtn:active, .tbtn.held { background: rgba(217,164,65,.5); }
#touch-actions { position: absolute; right: 12px; bottom: 84px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: auto; }
.tbtn.act { width: 96px; height: 56px; font-size: 14px; letter-spacing: 1px; }
.tbtn.act.small { width: 78px; height: 44px; font-size: 11px; }
.tbtn.act.ult { border-color: var(--gold-bright); color: var(--gold-bright); }

@media (max-width: 760px) {
  #hud-top-left { width: 160px; }
  #hud-bottom { display: none; }
  #barks { bottom: 300px; }
  .bark { font-size: 15px; }
  .title-inner { margin-right: 0; padding: 20px 26px; }
  #title-story { font-size: 13px; }
}
