:root {
  --bg-deep: #0b1120;
  --bg-panel: rgba(15, 23, 42, 0.88);
  --border-cyan: rgba(56, 189, 248, 0.38);
  --accent-cyan: #38bdf8;
  --accent-sky: #7dd3fc;
  --btn-blue: #0369a1;
  --btn-amber: #b45309;
  --btn-green: #15803d;
  --btn-violet: #6d28d9;
  --btn-rose: #be185d;
  --text-main: #f1f5f9;
  --text-muted: #cbd5e1;
}

[hidden] { display: none !important; }
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg-deep);
  color: var(--text-main);
  overflow-x: hidden;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 8px 14px;
  background: #0f172a;
  border-bottom: 1px solid var(--border-cyan);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--accent-sky);
  letter-spacing: 0.01em;
}

.subbadge {
  font-size: 0.76rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(3, 105, 161, 0.45);
  border: 1px solid var(--border-cyan);
  color: #e0f2fe;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  background: var(--btn-blue);
  border: 1px solid rgba(125, 211, 252, 0.45);
  border-radius: 7px;
  padding: 6px 11px;
  cursor: pointer;
}
button:hover { filter: brightness(1.12); }
button.btn-amber { background: var(--btn-amber); }
button.btn-green { background: var(--btn-green); }
button.btn-violet { background: var(--btn-violet); }
button.btn-rose { background: var(--btn-rose); }
button[aria-pressed="true"] { outline: 2px solid #fde047; }

.stage-wrap {
  position: relative;
  width: 100%;
  height: calc(100vh - 134px);
  min-height: 460px;
  background: #090d16;
}

#glStage {
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
}

.hud-grid {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 8px;
  pointer-events: none;
}

.hud-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-cyan);
  border-radius: 10px;
  padding: 8px 11px;
  min-width: 0;
}

.hud-label { font-size: 0.74rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.hud-val { font-size: 1rem; font-weight: 700; color: #f8fafc; margin-top: 2px; }
.meter { height: 7px; background: #1e293b; border-radius: 99px; overflow: hidden; margin-top: 5px; }
.meter > span { display: block; height: 100%; background: linear-gradient(90deg, #38bdf8, #34d399); }

.mutation-bar {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 64%;
  pointer-events: none;
}

.mut-pill {
  font-size: 0.78rem;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: #94a3b8;
}
.mut-pill.unlocked {
  background: rgba(21, 128, 61, 0.88);
  border-color: #86efac;
  color: #ffffff;
  font-weight: 700;
}

.touch-pads {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.lore-banner {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 58px;
  width: min(92%, 620px);
  background: rgba(15, 23, 42, 0.93);
  border: 1px solid #7dd3fc;
  border-radius: 12px;
  padding: 10px 14px;
  text-align: center;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
}
.lore-banner strong { color: #7dd3fc; display: block; margin-bottom: 3px; }
.lore-banner p { margin: 0; font-size: 0.88rem; color: #e2e8f0; line-height: 1.38; }

.end-modal {
  position: absolute;
  inset: 0;
  background: rgba(11, 17, 32, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.end-card {
  max-width: 480px;
  background: #0f172a;
  border: 2px solid #38bdf8;
  border-radius: 14px;
  padding: 20px;
  text-align: center;
}

.footer-note {
  padding: 8px 14px;
  font-size: 0.80rem;
  color: var(--text-muted);
  background: #0f172a;
  border-top: 1px solid rgba(56, 189, 248, 0.24);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}
