:root {
  --bg: #100c1c;
  --ink: #f4efe8;
  --muted: #b7aebf;
  --accent: #ff5a1f;
  --gold: #f4d35e;
  --panel: rgba(16, 12, 28, 0.82);
  --stroke: rgba(244, 239, 232, 0.14);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: Manrope, "Segoe UI", sans-serif;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
}

#app {
  position: fixed;
  inset: 0;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hidden { display: none !important; }

.screen {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: calc(28px + var(--safe-top)) 22px calc(28px + var(--safe-bot));
  pointer-events: none;
  background: linear-gradient(180deg, transparent 18%, rgba(16, 12, 28, 0.88) 62%);
}

.screen > * { pointer-events: auto; }

.screen.dim {
  background: rgba(8, 6, 16, 0.55);
  justify-content: center;
}

.brand { margin-bottom: 18px; }

.eyebrow {
  margin: 0 0 8px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--gold);
}

h1, h2 {
  font-family: Unbounded, Manrope, sans-serif;
  margin: 0;
}

h1 {
  font-size: clamp(42px, 14vw, 64px);
  line-height: 0.9;
  text-transform: uppercase;
}

h2 { font-size: 26px; margin-bottom: 14px; }

.tag {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.menu-actions, .panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 22px;
  padding: 22px 18px;
  backdrop-filter: blur(10px);
}

.panel ul {
  margin: 0 0 16px;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.55;
}

.btn {
  border: 0;
  border-radius: 16px;
  padding: 14px 16px;
  font: 800 16px/1 Unbounded, Manrope, sans-serif;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.btn.primary {
  background: var(--accent);
  color: #1a0c08;
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--stroke);
}

.btn:disabled {
  opacity: 0.4;
}

.best {
  margin: 16px 0 0;
  color: var(--muted);
}

.panel h2 { margin-bottom: 4px; }

.chars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 8px 0 4px;
}

.char {
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  padding: 12px;
  color: var(--ink);
  min-height: 132px;
}

.char.picked {
  border-color: var(--accent);
  background: rgba(255, 90, 31, 0.16);
}

.char .who {
  font-family: Unbounded, sans-serif;
  font-size: 14px;
}

.char .role {
  color: var(--gold);
  font-size: 11px;
  margin: 2px 0 2px;
}

.char .slogan {
  color: var(--gold);
  font-size: 11px;
  margin: 0 0 8px;
}

.char-art {
  display: block;
  width: 100px;
  height: 140px;
  margin: 0 auto 4px;
}

.char .stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--muted);
  margin-top: 3px;
}

.bar {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  background: var(--accent);
}

.char .abl {
  margin-top: 8px;
  font-size: 11px;
  color: var(--ink);
}

#hud {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  padding: calc(10px + var(--safe-top)) 14px calc(18px + var(--safe-bot));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hud-top, .hud-bot {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.hp-wrap { flex: 1; }

.hp-name, .label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
}

.hp-bar, .cd-bar {
  margin-top: 6px;
  height: 10px;
  background: rgba(0,0,0,0.45);
  border-radius: 8px;
  overflow: hidden;
}

#hp-fill { height: 100%; width: 100%; background: #e85d4c; }
#cd-fill { height: 100%; width: 100%; background: #7c5cff; }

.hud-score {
  text-align: right;
  min-width: 84px;
}

#hud-score {
  font-family: Unbounded, sans-serif;
  font-size: 22px;
}

#btn-pause {
  pointer-events: auto;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: var(--panel);
  color: var(--ink);
  font-weight: 800;
}

#combo {
  align-self: center;
  font-family: Unbounded, sans-serif;
  font-size: 28px;
  color: var(--gold);
  text-shadow: 0 2px 0 #000;
}

#banner {
  align-self: center;
  font-family: Unbounded, sans-serif;
  font-size: 18px;
  background: var(--accent);
  color: #1a0c08;
  padding: 8px 14px;
  border-radius: 12px;
}

.hud-bot {
  align-items: flex-end;
  padding-bottom: 118px;
}

.cd-wrap { width: 42%; }

.hud-wave {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

#controls {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

#stick, #btns {
  position: absolute;
  bottom: calc(18px + var(--safe-bot));
  pointer-events: auto;
}

#stick { left: 18px; }

#stick-base {
  width: 118px;
  height: 118px;
  border-radius: 50%;
  background: rgba(16, 12, 28, 0.35);
  border: 1px solid var(--stroke);
  position: relative;
}

#stick-knob {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(244, 239, 232, 0.85);
  position: absolute;
  left: 35px;
  top: 35px;
}

#btns {
  right: 18px;
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

#btn-abl, #btn-atk {
  pointer-events: auto;
  border: 0;
  color: #1a0c08;
  font: 800 12px/1 Unbounded, sans-serif;
  text-transform: uppercase;
}

#btn-abl {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #7c5cff;
}

#btn-atk {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: var(--accent);
}

#btn-abl.down, #btn-atk.down { transform: scale(0.94); }

.over-score {
  font-size: 18px;
  margin: 0 0 6px;
}

.over-best { color: var(--muted); margin: 0 0 12px; }

#rotate {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 20;
  background: var(--bg);
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  font-family: Unbounded, sans-serif;
}

@media (min-width: 900px) {
  .chars { grid-template-columns: 1fr 1fr 1fr 1fr; }
  .char { min-height: 0; }
}

@media (orientation: landscape) and (max-height: 500px) {
  #rotate { display: flex; }
}
