:root {
  --bg: #07131a;
  --panel: rgba(8, 20, 30, 0.78);
  --panel-border: rgba(120, 220, 255, 0.22);
  --cyan: #00f0ff;
  --gold: #ffd400;
  --orange: #ff7a00;
  --emerald: #22c55e;
  --rose: #f43f5e;
  --text: #f1f5f9;
  --muted: #94a3b8;
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

.hidden {
  display: none !important;
}

#gameCanvas,
#overlay2D {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#gameCanvas {
  z-index: 1;
  outline: none;
  cursor: grab;
}

#gameCanvas:active {
  cursor: grabbing;
}

#overlay2D {
  z-index: 3;
  pointer-events: none;
}

#hurtVignette,
#rageVignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  opacity: 0;
  transition: opacity 0.14s ease;
}

#hurtVignette {
  background: radial-gradient(circle at center, transparent 52%, rgba(239, 68, 68, 0.58) 100%);
}

#rageVignette {
  background: radial-gradient(circle at center, transparent 55%, rgba(255, 145, 0, 0.42) 100%);
}

/* Wave Banner */
#waveBanner {
  position: fixed;
  top: 22%;
  left: 50%;
  transform: translate(-50%, -20px) scale(0.92);
  z-index: 9;
  pointer-events: none;
  text-align: center;
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

#waveBanner.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

#waveBannerTitle {
  font-size: clamp(28px, 5vw, 54px);
  font-weight: 900;
  letter-spacing: 0.08em;
  background: linear-gradient(90deg, #ffd400, #fff7cc, #00f0ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 24px rgba(0, 0, 0, 0.78));
}

#waveBannerSub {
  margin-top: 4px;
  font-size: clamp(14px, 2vw, 19px);
  font-weight: 700;
  color: #e2e8f0;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.85);
}

/* Modals */
.modalBackdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: radial-gradient(1100px 680px at 50% 22%, rgba(0, 224, 255, 0.12), rgba(4, 12, 20, 0.72) 68%, rgba(2, 8, 14, 0.86));
  backdrop-filter: blur(5px);
}

.titleCard,
.upgradeCardWrap,
.smallModal,
.endCard {
  background: linear-gradient(180deg, rgba(12, 28, 42, 0.9), rgba(7, 17, 26, 0.94));
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  padding: 26px 28px;
  text-align: center;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.68), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.titleCard {
  width: min(820px, 95vw);
}

.eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.24em;
  color: var(--cyan);
  margin-bottom: 6px;
}

.heroTitle {
  margin: 0;
  font-size: clamp(34px, 6.2vw, 62px);
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1.02;
  background: linear-gradient(95deg, #ffffff 10%, #7de8ff 50%, #ffd400 92%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.heroBadge {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.22em;
  background: linear-gradient(90deg, rgba(0, 240, 255, 0.2), rgba(255, 212, 0, 0.22));
  border: 1px solid rgba(0, 240, 255, 0.45);
  color: #e0fbff;
}

.heroTag {
  margin: 10px 0 18px;
  font-size: clamp(14px, 2.2vw, 18px);
  color: #cbd5e1;
}

.titleGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  text-align: left;
  margin-bottom: 16px;
}

.glassBox {
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 12px 14px;
}

.boxHeading {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 6px;
}

.controlRow {
  font-size: 13px;
  line-height: 1.7;
  color: #e2e8f0;
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.26);
  font-size: 11px;
  font-weight: 800;
  color: #fff;
}

.optionsRow {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  margin-bottom: 20px;
}

.optionGroup {
  display: flex;
  align-items: center;
  gap: 10px;
}

.optLabel {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.segGroup {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}

.segBtn {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  color: #cbd5e1;
  background: transparent;
  transition: all 0.15s ease;
}

.segBtn.active {
  background: linear-gradient(90deg, #00c8ff, #38bdf8);
  color: #031520;
  box-shadow: 0 0 14px rgba(0, 210, 255, 0.4);
}

.btnPrimary,
.btnSecondary {
  cursor: pointer;
  border-radius: 14px;
  padding: 13px 28px;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.06em;
  transition: transform 0.12s ease, box-shadow 0.15s ease;
}

.btnPrimary {
  border: none;
  background: linear-gradient(95deg, #ffd400, #ff8800);
  color: #0a0f18;
  box-shadow: 0 10px 28px rgba(255, 150, 0, 0.38);
}

.btnPrimary:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 36px rgba(255, 180, 0, 0.55);
}

.btnSecondary {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.btnSecondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.bestScoreLine {
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
}

/* HUD */
#hudRoot {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}

.hudTopLeft {
  position: fixed;
  top: 14px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scoreCard {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 9px 14px;
  backdrop-filter: blur(8px);
}

.scoreLabel {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--cyan);
}

.scoreVal {
  font-size: 26px;
  font-weight: 900;
  line-height: 1.1;
  color: #fff;
}

.subStat {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.quickBtns {
  display: flex;
  gap: 6px;
  pointer-events: auto;
}

.iconBtn {
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: #fff;
  font-size: 16px;
  display: grid;
  place-items: center;
}

.iconBtn:hover {
  border-color: var(--cyan);
}

.upgradeIcons {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-width: 190px;
}

.upgBadge {
  background: rgba(255, 212, 0, 0.14);
  border: 1px solid rgba(255, 212, 0, 0.45);
  border-radius: 8px;
  padding: 2px 6px;
  font-size: 13px;
}

/* Top Center */
.hudTopCenter {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(500px, 64vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.waveHeader {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.remainTag strong {
  color: var(--gold);
}

.hpBarOuter,
.rageBarOuter,
.bossBarOuter {
  position: relative;
  width: 100%;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(6, 14, 22, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.hpBarOuter {
  height: 22px;
}

.hpLag {
  position: absolute;
  inset: 0;
  width: 100%;
  background: rgba(255, 255, 255, 0.48);
  transition: width 0.35s ease;
}

.hpFill {
  position: absolute;
  inset: 0;
  width: 100%;
  background: linear-gradient(90deg, #16a34a, #4ade80);
  transition: width 0.08s linear;
}

.hpFill.low {
  background: linear-gradient(90deg, #dc2626, #fb7185);
}

.rageBarOuter {
  height: 15px;
  width: 82%;
}

.rageFill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f59e0b, #f43f5e, #00f0ff);
  transition: width 0.1s linear;
}

.rageBarOuter.ready {
  border-color: var(--gold);
  box-shadow: 0 0 18px rgba(255, 200, 0, 0.72);
  animation: pulseGlow 0.9s infinite;
}

.barText,
.barTextSmall {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 900;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
}

.barText {
  font-size: 12px;
}

.barTextSmall {
  font-size: 10px;
  letter-spacing: 0.1em;
}

.bossBarWrap {
  width: 90%;
  margin-top: 2px;
}

.bossLabel {
  text-align: center;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: var(--gold);
  margin-bottom: 2px;
  text-shadow: 0 2px 6px #000;
}

.bossBarOuter {
  height: 12px;
  border-color: rgba(250, 204, 21, 0.65);
}

.bossFill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #d97706, #facc15);
}

/* Top Right Style Widget */
.hudTopRight {
  position: fixed;
  top: 14px;
  right: 16px;
}

.styleWidget {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 8px 14px;
  backdrop-filter: blur(8px);
}

.rankBadge {
  min-width: 48px;
  height: 48px;
  padding: 0 6px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 900;
  color: #06121c;
  background: #94a3b8;
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.25);
}

.rankTitle {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: var(--gold);
}

.comboLine {
  font-size: 18px;
  font-weight: 900;
  color: #fff;
}

.chainLine {
  font-size: 11px;
  color: var(--cyan);
  font-weight: 700;
}

/* Bottom Center Ability Hotbar */
.abilityBar {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}

.skillSlot {
  position: relative;
  width: 74px;
  height: 64px;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(7, 18, 28, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.18);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.skillFill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100%;
  background: linear-gradient(180deg, rgba(0, 220, 255, 0.28), rgba(0, 140, 220, 0.16));
  transition: height 0.08s linear;
}

.rageSlotFill {
  background: linear-gradient(180deg, rgba(255, 165, 0, 0.45), rgba(244, 63, 94, 0.26));
}

.skillSlot.ready {
  border-color: rgba(0, 240, 255, 0.72);
  box-shadow: 0 0 14px rgba(0, 224, 255, 0.32);
}

.skillSlot.rageReady {
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(255, 195, 0, 0.75);
  animation: pulseGlow 0.85s infinite;
}

.skillKey {
  position: relative;
  z-index: 1;
  font-size: 10px;
  font-weight: 900;
  color: var(--cyan);
}

.skillName {
  position: relative;
  z-index: 1;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.comboPips {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 4px;
  margin-top: 2px;
}

.comboPips span {
  width: 8px;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.2);
}

.comboPips span.lit {
  background: var(--gold);
  box-shadow: 0 0 6px var(--gold);
}

/* Upgrade Cards */
.upgradeCardWrap {
  width: min(860px, 95vw);
}

.modalTitle {
  margin: 0 0 6px;
  font-size: clamp(24px, 4vw, 36px);
  font-weight: 900;
}

.modalSub {
  margin: 0 0 18px;
  color: #cbd5e1;
}

.upgradeChoices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.upgradeChoiceBtn {
  cursor: pointer;
  text-align: left;
  padding: 18px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(0, 240, 255, 0.28);
  color: #fff;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.upgradeChoiceBtn:hover {
  transform: translateY(-4px);
  border-color: var(--gold);
  box-shadow: 0 14px 36px rgba(255, 200, 0, 0.25);
}

.upgKeyTag {
  float: right;
  font-size: 11px;
  font-weight: 900;
  color: var(--cyan);
}

.upgIcon {
  font-size: 32px;
  margin-bottom: 8px;
}

.upgName {
  font-size: 17px;
  font-weight: 900;
  color: var(--gold);
  margin-bottom: 6px;
}

.upgDesc {
  font-size: 13px;
  line-height: 1.45;
  color: #dbeafe;
}

/* Pause & End Screens */
.smallModal {
  width: min(420px, 92vw);
}

.endCard {
  width: min(560px, 94vw);
}

.endStatsGrid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 16px 0 22px;
}

.statTile {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px;
}

.statTileLabel {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.statTileVal {
  font-size: 22px;
  font-weight: 900;
  color: var(--gold);
}

.modalActions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Mobile Touch Controls */
#touchControls {
  position: fixed;
  inset: 0;
  z-index: 12;
  pointer-events: none;
}

#touchJoy {
  position: fixed;
  left: 18px;
  bottom: 22px;
  width: 126px;
  height: 126px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(0, 240, 255, 0.35);
  touch-action: none;
  pointer-events: auto;
}

#touchStick {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 240, 255, 0.45);
  border: 2px solid #fff;
}

.touchRight {
  position: fixed;
  right: 16px;
  bottom: 18px;
  display: grid;
  grid-template-columns: repeat(2, 64px);
  gap: 8px;
  pointer-events: auto;
}

.tSkill,
.tPunch {
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  font-weight: 900;
  color: #fff;
  background: rgba(8, 22, 34, 0.78);
  height: 60px;
  font-size: 11px;
}

.tPunch {
  grid-column: span 2;
  border-radius: 999px;
  height: 58px;
  font-size: 16px;
  color: #09111a;
  background: linear-gradient(95deg, #ffd400, #ff7a00);
}

.tRage {
  border-color: var(--gold);
  color: var(--gold);
}

@keyframes pulseGlow {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.03);
  }
}

@media (max-width: 720px) {
  .abilityBar {
    display: none;
  }
  .hudTopCenter {
    width: 82vw;
  }
  .hudTopRight {
    top: 108px;
  }
}
