/* MOIRA — A Biotic Continuum
   Palette: jaundice gold #f2c14e · decay violet #8a5cff · clinical white #e8f0ee · deep teal-black #04100f */

@font-face {
  font-family: 'Exo 2';
  src: url('fonts/exo2-var.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --gold: #f2c14e;
  --gold-dim: #9c7c2f;
  --violet: #8a5cff;
  --violet-dim: #553a9e;
  --clinic: #e8f0ee;
  --bg: #04100f;
  --teal: #0b2a26;
  --danger: #ff5470;
  --font: 'Exo 2', 'Helvetica Neue', 'Segoe UI', sans-serif;
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: var(--font);
  color: var(--clinic);
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

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

#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 2;
  background: radial-gradient(ellipse at center, transparent 52%, rgba(2, 8, 8, 0.55) 100%);
}

.hidden { display: none !important; }

/* ============ Barks & floating text ============ */
#barks { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.bark {
  position: absolute; transform: translate(-50%, -100%);
  font-size: 12px; font-weight: 300; letter-spacing: 0.08em;
  color: var(--clinic); white-space: nowrap;
  text-shadow: 0 1px 6px rgba(0,0,0,0.9);
  opacity: 0; transition: opacity 0.25s;
}
.bark.ally { color: #cfe6dd; }
.bark.ally b { color: var(--gold); font-weight: 500; }
.bark.score { color: var(--gold); font-weight: 400; letter-spacing: 0.14em; }
.bark.score.violet { color: var(--violet); }
.bark.enemy-hp { width: 46px; height: 4px; background: rgba(0,0,0,0.6); border: 1px solid rgba(138,92,255,0.4); transition: none; }
.bark.enemy-hp .hpf { height: 100%; background: var(--violet); }

/* ============ Feed ============ */
#feed {
  position: fixed; right: 14px; top: 34%; z-index: 5; pointer-events: none;
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
  max-width: 44vw;
}
.feed-item {
  font-size: 11px; letter-spacing: 0.12em; font-weight: 300;
  color: rgba(232,240,238,0.85);
  background: rgba(4,16,15,0.55);
  border-right: 2px solid var(--gold);
  padding: 3px 10px 3px 12px;
  animation: feedin 0.25s ease-out;
  text-align: right;
}
.feed-item.violet { border-right-color: var(--violet); }
.feed-item.danger { border-right-color: var(--danger); color: #ffd7de; }
@keyframes feedin { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.feed-item.fadeout { opacity: 0; transition: opacity 0.6s; }

/* ============ HUD ============ */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 4; }
#hud button { pointer-events: auto; }

#topbar {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 14px 18px;
}
.tb-left { text-align: left; }
.tb-right { display: flex; gap: 8px; align-items: center; }
#wave-label { font-size: 13px; font-weight: 500; letter-spacing: 0.3em; color: var(--gold); }
#objective { font-size: 10px; font-weight: 200; letter-spacing: 0.24em; color: rgba(232,240,238,0.6); margin-top: 3px; }
#score-label { font-size: 13px; font-weight: 300; letter-spacing: 0.22em; color: var(--clinic); }
#score-label span { color: var(--gold); font-weight: 500; }

#mute-btn, #pause-btn {
  font-family: var(--font); font-size: 10px; letter-spacing: 0.18em; font-weight: 300;
  background: rgba(11,42,38,0.6); color: rgba(232,240,238,0.75);
  border: 1px solid rgba(138,92,255,0.35); padding: 5px 10px; cursor: pointer;
}
#mute-btn:hover, #pause-btn:hover { border-color: var(--gold); color: var(--gold); }

#allies-panel {
  position: absolute; top: 64px; right: 14px;
  display: flex; flex-direction: column; gap: 6px; width: 168px;
}
.ally-chip {
  background: rgba(4,16,15,0.55); border: 1px solid rgba(138,92,255,0.25);
  border-left: 3px solid var(--violet); padding: 5px 9px;
}
.ally-chip.dead { opacity: 0.38; border-left-color: var(--danger); }
.ally-chip .ac-name { font-size: 10px; font-weight: 500; letter-spacing: 0.16em; color: var(--clinic); }
.ally-chip .ac-role { font-size: 8px; font-weight: 200; letter-spacing: 0.14em; color: rgba(232,240,238,0.5); }
.ally-chip .bar { margin-top: 4px; }

.bar { position: relative; height: 6px; background: rgba(232,240,238,0.12); overflow: hidden; }
.bar .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; transform-origin: left; }
.hp-bar .fill, .ally-chip .fill { background: linear-gradient(90deg, #57d9a3, #a8e6cf); }
.ally-chip .fill.low, .hp-bar .fill.low { background: linear-gradient(90deg, #ff5470, #ff8a5c); }

#bottombar {
  position: absolute; left: 0; right: 0; bottom: 12px;
  display: flex; justify-content: space-between; align-items: flex-end;
  padding: 0 18px; gap: 14px;
}

#moira-status { width: 220px; }
.ms-name { font-size: 10px; font-weight: 500; letter-spacing: 0.28em; color: rgba(232,240,238,0.8); margin-bottom: 4px; }
#moira-status .hp-bar { height: 8px; border: 1px solid rgba(232,240,238,0.2); }
#ult-row { margin-top: 6px; display: flex; align-items: center; gap: 8px; }
.ult-bar { flex: 1; height: 5px; }
.ult-bar .fill { background: linear-gradient(90deg, var(--violet), var(--gold)); transform: scaleX(0); }
.ult-bar .fill.ready { animation: ultpulse 1s ease-in-out infinite alternate; }
@keyframes ultpulse { from { filter: brightness(1); } to { filter: brightness(1.8); } }
#ult-label { font-size: 9px; font-weight: 300; letter-spacing: 0.2em; color: rgba(232,240,238,0.6); white-space: nowrap; }
#ult-label.ready { color: var(--gold); }

#reservoir-wrap { flex: 1; max-width: 460px; text-align: center; }
#reservoir-label { font-size: 11px; font-weight: 300; letter-spacing: 0.42em; color: var(--gold); margin-bottom: 4px; text-shadow: 0 0 12px rgba(242,193,78,0.4); }
.reservoir-bar { height: 14px; border: 1px solid rgba(242,193,78,0.45); background: rgba(4,16,15,0.7); }
.reservoir-bar .fill { background: linear-gradient(90deg, #7a5c17, var(--gold)); box-shadow: 0 0 14px rgba(242,193,78,0.5); }
#reservoir-ghost { background: rgba(138,92,255,0.35); mix-blend-mode: screen; }
#reservoir-hint { font-size: 9px; font-weight: 200; letter-spacing: 0.14em; color: rgba(232,240,238,0.45); margin-top: 4px; }
.reservoir-bar.dry { animation: dryblink 0.5s steps(2) 3; }
@keyframes dryblink { 50% { border-color: var(--danger); box-shadow: 0 0 18px rgba(255,84,112,0.6); } }

#abilities { display: flex; gap: 8px; }
.ability {
  position: relative; width: 58px; height: 58px;
  border: 1px solid rgba(138,92,255,0.4); background: rgba(4,16,15,0.6);
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  padding-bottom: 5px; overflow: hidden;
}
.ability .ab-key { font-size: 9px; font-weight: 500; letter-spacing: 0.1em; color: var(--gold); }
.ability .ab-name { font-size: 7px; font-weight: 200; letter-spacing: 0.12em; color: rgba(232,240,238,0.55); }
.ability .ab-cd {
  position: absolute; left: 0; right: 0; bottom: 0; height: 0%;
  background: rgba(138,92,255,0.28); pointer-events: none;
}
.ability.ready { border-color: var(--gold); box-shadow: 0 0 10px rgba(242,193,78,0.25) inset; }
.ability.active { border-color: var(--gold); background: rgba(242,193,78,0.14); }

#controls-hint {
  position: absolute; bottom: 84px; left: 50%; transform: translateX(-50%);
  font-size: 9px; font-weight: 200; letter-spacing: 0.16em; white-space: nowrap;
  color: rgba(232,240,238,0.4);
}

#coalescence-banner {
  position: absolute; top: 18%; left: 50%; transform: translateX(-50%);
  font-size: 30px; font-weight: 200; letter-spacing: 0.7em; text-indent: 0.7em;
  background: linear-gradient(90deg, var(--gold), var(--violet));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: coalglow 0.6s ease-in-out infinite alternate;
}
@keyframes coalglow { from { filter: brightness(0.9); } to { filter: brightness(1.5); } }

#wave-banner {
  position: absolute; top: 30%; left: 50%; transform: translate(-50%, -50%);
  font-size: 22px; font-weight: 200; letter-spacing: 0.5em; text-indent: 0.5em;
  color: var(--clinic); text-align: center; text-shadow: 0 0 24px rgba(138,92,255,0.6);
}
#wave-banner small { display: block; font-size: 11px; letter-spacing: 0.3em; color: rgba(232,240,238,0.55); margin-top: 8px; }

#dry-flash {
  position: absolute; bottom: 120px; left: 50%; transform: translateX(-50%);
  font-size: 12px; font-weight: 400; letter-spacing: 0.3em; color: var(--danger);
  text-shadow: 0 0 16px rgba(255,84,112,0.7); white-space: nowrap;
  animation: dryblink 0.4s steps(2) 4;
}

/* ============ Fullscreen overlays ============ */
#title-screen, #pause-screen, #end-screen {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(11,42,38,0.88), rgba(2,8,8,0.96) 75%);
  overflow-y: auto;
}
.t-inner, .p-inner, .e-inner { text-align: center; max-width: 640px; padding: 40px 24px; }

.t-eyebrow { font-size: 10px; font-weight: 300; letter-spacing: 0.42em; color: rgba(138,92,255,0.85); }
.t-logo {
  font-size: clamp(64px, 14vw, 128px); font-weight: 100; letter-spacing: 0.34em; text-indent: 0.34em;
  color: var(--clinic); line-height: 1.05; margin: 14px 0 2px;
  text-shadow: 0 0 42px rgba(138,92,255,0.45), 0 0 12px rgba(242,193,78,0.25);
}
.t-sub { font-size: 13px; font-weight: 300; letter-spacing: 0.62em; text-indent: 0.62em; color: var(--gold); margin-bottom: 26px; }
.t-brief {
  font-size: 14px; font-weight: 200; line-height: 1.75; letter-spacing: 0.04em;
  color: rgba(232,240,238,0.8); margin-bottom: 24px;
}
.t-brief em { color: var(--gold); font-style: normal; letter-spacing: 0.08em; }
.t-rules {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 22px; text-align: left;
  font-size: 11px; font-weight: 200; line-height: 1.6; letter-spacing: 0.05em;
  color: rgba(232,240,238,0.68); margin-bottom: 30px;
}
.t-rules b { font-weight: 500; letter-spacing: 0.14em; }
.gold { color: var(--gold); } .violet { color: var(--violet); }

#start-btn, #resume-btn, #restart-btn, #restart-btn-p {
  font-family: var(--font); font-size: 14px; font-weight: 400; letter-spacing: 0.4em; text-indent: 0.4em;
  color: var(--bg); background: linear-gradient(90deg, var(--gold), #e0a83a);
  border: none; padding: 15px 44px; cursor: pointer;
  transition: box-shadow 0.2s, transform 0.15s;
}
#start-btn:hover, #resume-btn:hover, #restart-btn:hover, #restart-btn-p:hover {
  box-shadow: 0 0 32px rgba(242,193,78,0.55); transform: translateY(-1px);
}
.ghost-btn { background: transparent !important; color: rgba(232,240,238,0.7) !important; border: 1px solid rgba(138,92,255,0.4) !important; margin-left: 10px; }
.ghost-btn:hover { border-color: var(--gold) !important; color: var(--gold) !important; box-shadow: none !important; }
.t-foot { margin-top: 22px; font-size: 9px; font-weight: 200; letter-spacing: 0.3em; color: rgba(232,240,238,0.35); }

#pause-screen h2, #end-screen h2 {
  font-size: clamp(34px, 7vw, 58px); font-weight: 100; letter-spacing: 0.3em; text-indent: 0.3em;
  color: var(--clinic); margin: 12px 0 14px;
}
#end-screen.win h2 { color: var(--gold); text-shadow: 0 0 34px rgba(242,193,78,0.5); }
#end-screen.lose h2 { color: var(--violet); text-shadow: 0 0 34px rgba(138,92,255,0.55); }
#end-flavor { font-size: 13px; font-weight: 200; line-height: 1.7; color: rgba(232,240,238,0.7); margin-bottom: 24px; font-style: italic; }
#end-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px;
  margin-bottom: 30px;
}
.stat-cell { border: 1px solid rgba(138,92,255,0.25); padding: 10px 6px; background: rgba(4,16,15,0.5); }
.stat-cell .sv { font-size: 22px; font-weight: 300; color: var(--gold); }
.stat-cell .sk { font-size: 8px; font-weight: 300; letter-spacing: 0.2em; color: rgba(232,240,238,0.5); margin-top: 4px; }
.p-inner p { font-size: 13px; font-weight: 200; color: rgba(232,240,238,0.6); margin-bottom: 26px; font-style: italic; }
#resume-btn { margin-right: 0; }

#fatal {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
  background: var(--bg); text-align: center; font-size: 13px; font-weight: 300;
  letter-spacing: 0.1em; line-height: 2; color: var(--clinic);
}
#fatal-detail { color: var(--violet); font-size: 10px; }

/* ============ Touch ============ */
#touch-ui { position: fixed; inset: 0; z-index: 6; pointer-events: none; }
#joystick {
  position: absolute; left: 26px; bottom: 110px; width: 120px; height: 120px;
  border: 1px solid rgba(138,92,255,0.5); border-radius: 50%;
  background: rgba(4,16,15,0.35); pointer-events: auto;
}
#joystick-knob {
  position: absolute; left: 50%; top: 50%; width: 48px; height: 48px;
  transform: translate(-50%, -50%); border-radius: 50%;
  background: radial-gradient(circle, rgba(242,193,78,0.85), rgba(242,193,78,0.25));
}
#touch-buttons {
  position: absolute; right: 16px; bottom: 96px;
  display: grid; grid-template-columns: repeat(2, 64px); gap: 8px; pointer-events: auto;
}
.tbtn {
  font-family: var(--font); font-size: 10px; font-weight: 500; letter-spacing: 0.1em;
  height: 52px; border-radius: 6px; border: 1px solid rgba(138,92,255,0.55);
  background: rgba(4,16,15,0.55); color: var(--clinic);
}
.tbtn:active, .tbtn.on { background: rgba(138,92,255,0.35); }
.tbtn.gold { border-color: var(--gold); color: var(--gold); }
.tbtn.violet { border-color: var(--violet); color: var(--violet); }
.tbtn.ult { grid-column: span 2; border-color: var(--gold); background: linear-gradient(90deg, rgba(242,193,78,0.2), rgba(138,92,255,0.2)); }

/* ============ Small viewports ============ */
@media (max-width: 760px) {
  #controls-hint { display: none; }
  #moira-status { width: 130px; }
  #reservoir-wrap { max-width: none; }
  #abilities { display: none; }
  #allies-panel { width: 120px; top: 58px; }
  .t-rules { grid-template-columns: 1fr; }
  #feed { top: 26%; max-width: 56vw; }
  #bottombar { padding: 0 10px; bottom: 8px; }
  #reservoir-hint { display: none; }
  #joystick { bottom: 150px; left: 16px; }
  #touch-buttons { bottom: 136px; right: 10px; }
}
