:root {
  --bg: #0a0e14;
  --panel: #12182699;
  --accent: #ffd23f;
  --accent-2: #ff4d4d;
  --green: #35d07f;
  --blue: #3fa7ff;
  --purple: #b25cff;
  --text: #f2f4f8;
  --muted: #93a0b4;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

#game-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

#fx-layer {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  overflow: hidden;
}

#app {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.screen.active { display: flex; }

.menu-panel {
  pointer-events: auto;
  background: linear-gradient(180deg, rgba(18, 24, 38, 0.92), rgba(10, 14, 20, 0.92));
  border: 2px solid #2a3550;
  border-radius: 16px;
  padding: 2.2rem 2.6rem;
  min-width: 320px;
  max-width: 520px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.wide-panel { max-width: 640px; width: 90vw; max-height: 85vh; overflow-y: auto; }

.title {
  font-size: 3rem;
  margin: 0 0 0.2rem;
  letter-spacing: 2px;
  color: var(--accent);
  text-shadow: 0 0 18px rgba(255, 210, 63, 0.5), 3px 3px 0 #7a1f1f;
}
.title-bang { color: var(--accent-2); }

.subtitle { color: var(--muted); margin: 0 0 1.6rem; }

.menu-list { display: flex; flex-direction: column; gap: 0.7rem; margin-top: 1.2rem; }

.btn {
  font-size: 1.05rem;
  padding: 0.85rem 1.2rem;
  border-radius: 10px;
  border: 2px solid #34405f;
  background: #182135;
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.5px;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: #202b45; border-color: #4a5b85; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: linear-gradient(180deg, #ffd23f, #f3a712); color: #201400; border-color: #a9720a; }
.btn-primary:hover { background: linear-gradient(180deg, #ffe07a, #ffb52e); }

.hint { color: var(--muted); font-size: 0.85rem; margin-top: 1.4rem; }

/* ===================== HUD ===================== */

.hud { position: absolute; inset: 0; pointer-events: none; font-variant-numeric: tabular-nums; }

.hud-top-left {
  position: absolute; top: 14px; left: 14px; width: 240px;
  display: flex; flex-direction: column; gap: 6px;
}
.hud-top-right {
  position: absolute; top: 14px; right: 14px; text-align: right;
  display: flex; flex-direction: column; gap: 4px;
}
.hud-top-center {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px; width: 46vw; min-width: 260px;
}

.bar-row { display: flex; align-items: center; gap: 8px; }
.bar-label { font-size: 0.7rem; color: var(--muted); width: 46px; text-shadow: 0 1px 2px #000; }
.bar { flex: 1; height: 14px; background: #1a2233; border: 1px solid #2c3a58; border-radius: 7px; overflow: hidden; }
.bar-fill { height: 100%; width: 100%; transition: width 0.15s ease; }
.bar-hp .bar-fill { background: linear-gradient(90deg, #ff4d4d, #ff9a3f); }
.bar-shield .bar-fill { background: linear-gradient(90deg, #3fa7ff, #7fd7ff); }
.bar-boss .bar-fill { background: linear-gradient(90deg, #b25cff, #ff4d9e); }

.boss-hud { width: 100%; text-align: center; }
.boss-hud.hidden { display: none; }
.boss-name { font-weight: 800; letter-spacing: 2px; color: #ffb0e6; text-shadow: 0 2px 4px #000; margin-bottom: 3px; }

.wave-progress { width: 100%; height: 6px; background: #1a2233; border-radius: 3px; overflow: hidden; border: 1px solid #2c3a58; }
.wave-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--green), var(--accent)); transition: width 0.3s ease; }

.score-display { font-size: 1.5rem; font-weight: 800; text-shadow: 0 2px 4px #000; }
.score-label { font-size: 0.65rem; color: var(--muted); display: block; letter-spacing: 1px; }
.weapon-display { font-size: 0.8rem; color: var(--accent); }
.weapon-level { color: var(--muted); margin-left: 4px; }

.hud-bottom {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 18px;
}
.ability {
  position: relative; width: 64px; height: 64px; border-radius: 12px;
  background: #141b2c; border: 2px solid #2c3a58; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.ability-key { position: absolute; top: 3px; left: 6px; font-weight: 800; font-size: 0.9rem; color: var(--text); z-index: 2; }
.ability-label { position: absolute; bottom: 3px; width: 100%; text-align: center; font-size: 0.55rem; letter-spacing: 1px; color: var(--muted); z-index: 2; }
.ability-charges { position: absolute; top: 3px; right: 6px; font-size: 0.7rem; font-weight: 700; color: var(--accent); z-index: 2; }
.ability-fill {
  position: absolute; left: 0; bottom: 0; width: 100%; height: 0%;
  background: linear-gradient(0deg, rgba(255,77,77,0.55), rgba(255,77,77,0.15));
  transition: height 0.1s linear;
}
.ability.ready .ability-fill { background: linear-gradient(0deg, rgba(53,208,127,0.5), rgba(53,208,127,0.15)); height: 100%; }

.overlay {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  background: rgba(4,6,10,0.72); pointer-events: auto;
}
.overlay.hidden { display: none; }

/* ===================== Result / Scoreboard ===================== */

.result-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem 1rem; text-align: left; margin: 1rem 0; font-size: 0.95rem; }
.result-stats span.k { color: var(--muted); }
.result-stats span.v { font-weight: 700; text-align: right; }

.tag-entry { margin: 1rem 0 0.4rem; display: flex; flex-direction: column; gap: 6px; }
.tag-entry label { font-size: 0.75rem; color: var(--muted); }
#tag-input {
  font-size: 1.6rem; letter-spacing: 6px; text-align: center; text-transform: uppercase;
  padding: 0.5rem; border-radius: 8px; border: 2px solid #34405f; background: #0e1420; color: var(--accent);
  font-weight: 800;
}

.scoreboard-list { text-align: left; margin: 1rem 0; max-height: 50vh; overflow-y: auto; }
.scoreboard-row {
  display: grid; grid-template-columns: 2rem 1fr auto; gap: 0.6rem; padding: 0.4rem 0.5rem;
  border-bottom: 1px solid #202b45; align-items: center;
}
.scoreboard-row:nth-child(odd) { background: rgba(255,255,255,0.02); }
.scoreboard-rank { color: var(--muted); font-weight: 700; }
.scoreboard-tag { font-weight: 800; letter-spacing: 2px; color: var(--accent); }
.scoreboard-meta { font-size: 0.75rem; color: var(--muted); }
.scoreboard-score { font-weight: 800; text-align: right; }

/* ===================== Settings ===================== */

.settings-grid { display: flex; flex-direction: column; gap: 0.9rem; text-align: left; margin: 1rem 0; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.setting-row label { color: var(--muted); font-size: 0.9rem; }
.setting-row input[type="range"] { width: 160px; }
.setting-row select {
  background: #0e1420; color: var(--text); border: 2px solid #34405f; border-radius: 6px; padding: 0.3rem 0.5rem;
}
.setting-row input[type="checkbox"] { width: 20px; height: 20px; }
.control-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.key-btn {
  background: #0e1420; border: 2px solid #34405f; border-radius: 6px; color: var(--accent);
  padding: 0.3rem 0.7rem; font-weight: 700; cursor: pointer; min-width: 90px;
}
.key-btn.listening { border-color: var(--accent); color: #fff; animation: pulse 1s infinite; }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

.about-content { text-align: left; line-height: 1.5; color: #d8deea; }
.about-content code { background: #0e1420; padding: 0.1rem 0.4rem; border-radius: 4px; }

/* ===================== Floating FX (score text etc) ===================== */

.floating-text {
  position: absolute; font-weight: 800; text-shadow: 0 2px 4px #000;
  pointer-events: none; will-change: transform, opacity;
  transform: translate(-50%, -50%);
}

.upgrade-label {
  position: absolute; pointer-events: none; transform: translate(-50%, -50%);
  padding: 2px 8px; border-radius: 6px; font-weight: 800; font-size: 0.8rem;
  text-shadow: 0 1px 3px #000; white-space: nowrap; border: 2px solid rgba(255,255,255,0.35);
  will-change: transform;
}

.hidden { display: none !important; }

@media (max-width: 680px) {
  .hud-top-center { width: 70vw; }
  .title { font-size: 2.2rem; }
}
