:root {
  --bg: #060714;
  --panel: rgba(9, 12, 30, 0.82);
  --panel2: rgba(21, 27, 60, 0.72);
  --text: #f6f7ff;
  --muted: #a7b3e7;
  --gold: #ffd36e;
  --cyan: #4df5ff;
  --pink: #ff4fd8;
  --red: #ff4d6d;
  --green: #71ff8f;
  --blue: #4f8cff;
}

* { box-sizing: border-box; }
html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: radial-gradient(circle at top, #191d4a 0%, var(--bg) 45%, #02020a 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  touch-action: none;
}

#game-root, #game-canvas {
  width: 100vw;
  height: 100vh;
  display: block;
}

#game-canvas {
  position: fixed;
  inset: 0;
  outline: none;
}

.hidden { display: none !important; }

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  padding: clamp(10px, 2vw, 22px);
  z-index: 5;
}

.top-row {
  display: grid;
  grid-template-columns: 1fr minmax(90px, 140px) 1fr;
  gap: clamp(8px, 1.5vw, 18px);
  align-items: start;
}

.fighter-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(5, 7, 21, 0.82), rgba(36, 42, 88, 0.54));
  box-shadow: 0 12px 40px rgba(0,0,0,0.35), inset 0 0 20px rgba(255,255,255,0.05);
  backdrop-filter: blur(14px);
}

.fighter-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-size: clamp(0.72rem, 2vw, 0.95rem);
}

.name { color: var(--gold); text-shadow: 0 0 12px rgba(255, 211, 110, 0.5); }
.enemy-name { color: var(--green); text-shadow: 0 0 12px rgba(113, 255, 143, 0.5); }
.rounds { color: rgba(255,255,255,0.35); letter-spacing: 3px; font-size: 0.8rem; }
.rounds .won { color: var(--gold); text-shadow: 0 0 10px rgba(255, 211, 110, 0.8); }

.bar-frame, .meter-frame {
  width: 100%;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,0.11);
  border: 1px solid rgba(255,255,255,0.16);
}

.bar-frame { height: clamp(18px, 3vw, 28px); }
.meter-frame { margin-top: 7px; height: 8px; }

.health-fill, .meter-fill {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  transform-origin: left center;
  transition: width 180ms ease;
}
.health-fill {
  background: linear-gradient(90deg, #3eff8b, #e6ff5a, #ff6b3e);
  box-shadow: 0 0 18px rgba(91,255,136,0.45);
}
.enemy-health {
  background: linear-gradient(90deg, #ff3d67, #ff8c42, #ffef5c);
  box-shadow: 0 0 18px rgba(255,75,100,0.45);
}
.meter-fill { background: linear-gradient(90deg, #1fd1ff, #826bff); box-shadow: 0 0 16px rgba(77,245,255,0.5); width: 0; }
.enemy-meter { background: linear-gradient(90deg, #82ff69, #ffe66a); }

.timer-wrap {
  text-align: center;
  padding: 10px 8px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0, 0, 0, 0.44);
  box-shadow: 0 12px 36px rgba(0,0,0,0.4);
  backdrop-filter: blur(12px);
}
#round-label {
  color: var(--muted);
  font-size: clamp(0.65rem, 1.8vw, 0.85rem);
  font-weight: 800;
  letter-spacing: 1.5px;
}
#timer {
  font-size: clamp(2rem, 8vw, 4.4rem);
  line-height: 0.95;
  font-weight: 1000;
  color: #fff;
  text-shadow: 0 0 20px rgba(77,245,255,0.45);
}

#combo-text {
  position: fixed;
  left: 50%;
  top: 20%;
  transform: translateX(-50%);
  min-width: 220px;
  text-align: center;
  pointer-events: none;
  font-size: clamp(1.3rem, 4vw, 3rem);
  font-weight: 1000;
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 0 0 18px var(--pink), 0 4px 0 rgba(0,0,0,0.55);
  opacity: 0;
  transition: opacity 150ms ease, transform 150ms ease;
}
#combo-text.show {
  opacity: 1;
  transform: translateX(-50%) scale(1.08);
}

#pause-btn {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 46px;
  height: 46px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.22);
  color: #fff;
  background: rgba(0,0,0,0.42);
  pointer-events: auto;
  font-weight: 1000;
  font-size: 1.2rem;
  backdrop-filter: blur(12px);
}

.panel {
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(94vw, 680px);
  max-height: 88vh;
  overflow: auto;
  transform: translate(-50%, -50%) scale(0.98);
  opacity: 0;
  pointer-events: none;
  z-index: 10;
  padding: clamp(22px, 5vw, 52px);
  border-radius: 34px;
  border: 1px solid rgba(255,255,255,0.18);
  background: linear-gradient(145deg, rgba(8, 10, 24, 0.86), rgba(33, 40, 88, 0.72));
  box-shadow: 0 32px 100px rgba(0,0,0,0.58), inset 0 0 36px rgba(255,255,255,0.05);
  backdrop-filter: blur(24px);
  text-align: center;
  transition: 220ms ease;
}
.panel.active {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}
.logo-mark {
  width: 86px;
  height: 86px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  border-radius: 28px;
  font-size: 3rem;
  background: radial-gradient(circle at 35% 25%, rgba(113,255,143,0.95), rgba(24,91,41,0.5) 48%, rgba(0,0,0,0.35));
  box-shadow: 0 0 30px rgba(113, 255, 143, 0.35), inset 0 0 20px rgba(255,255,255,0.18);
}
.eyebrow {
  margin: 0;
  color: var(--cyan);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 2px;
}
h1 {
  margin: 4px 0 0;
  font-size: clamp(2.8rem, 12vw, 6.2rem);
  line-height: 0.9;
  font-weight: 1000;
  letter-spacing: -4px;
  text-shadow: 0 0 28px rgba(77,245,255,0.34), 0 8px 0 rgba(0,0,0,0.35);
}
h2 {
  margin: 4px 0 14px;
  font-size: clamp(1.6rem, 6vw, 3rem);
  font-weight: 1000;
  letter-spacing: -1px;
  color: var(--gold);
}
.tagline, .small-note {
  color: var(--muted);
  max-width: 520px;
  margin: 12px auto;
}
.small-note { font-size: 0.88rem; }
.menu-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 24px;
}
button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.primary-btn, .ghost-btn {
  min-width: 150px;
  border: none;
  border-radius: 18px;
  padding: 14px 22px;
  color: #06101a;
  font-weight: 1000;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  background: linear-gradient(135deg, #62f7ff, #ffe66e);
  box-shadow: 0 14px 36px rgba(77,245,255,0.18), inset 0 -3px 0 rgba(0,0,0,0.22);
}
.ghost-btn {
  color: var(--text);
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: inset 0 0 22px rgba(255,255,255,0.05);
}
.primary-btn:active, .ghost-btn:active, .touch-btn:active { transform: translateY(2px) scale(0.98); }
.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  text-align: left;
  margin: 24px auto;
  max-width: 560px;
  color: #dfe6ff;
}
.control-grid > div {
  padding: 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
}
.round-panel {
  position: fixed;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  z-index: 9;
  text-align: center;
  pointer-events: none;
  text-transform: uppercase;
}
.round-panel h2 {
  font-size: clamp(3rem, 13vw, 9rem);
  line-height: 0.9;
  margin: 0;
  color: #fff;
  text-shadow: 0 0 34px var(--cyan), 0 10px 0 rgba(0,0,0,0.55);
}
.round-panel p {
  margin: 8px 0 0;
  font-size: clamp(1.4rem, 5vw, 3.5rem);
  font-weight: 1000;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(255, 211, 110, 0.6);
}

#mobile-controls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  z-index: 6;
  pointer-events: none;
}
.mobile-left, .mobile-right {
  display: flex;
  gap: 10px;
  align-items: end;
  pointer-events: auto;
}
.mobile-right { flex-wrap: wrap; justify-content: flex-end; max-width: min(54vw, 420px); }
.touch-btn {
  width: clamp(58px, 13vw, 82px);
  height: clamp(52px, 12vw, 72px);
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.18);
  color: #fff;
  background: rgba(7, 10, 25, 0.54);
  box-shadow: 0 10px 30px rgba(0,0,0,0.35), inset 0 0 18px rgba(255,255,255,0.08);
  backdrop-filter: blur(12px);
  font-weight: 1000;
  font-size: clamp(0.68rem, 2vw, 0.9rem);
}
.touch-btn.attack { background: linear-gradient(145deg, rgba(255,79,216,0.45), rgba(255,106,61,0.45)); }
.touch-btn.special { background: linear-gradient(145deg, rgba(77,245,255,0.55), rgba(130,107,255,0.55)); }
.touch-btn.block { background: linear-gradient(145deg, rgba(255,255,255,0.24), rgba(90,100,130,0.38)); }
.touch-btn.jump { background: linear-gradient(145deg, rgba(255,211,110,0.4), rgba(255,120,80,0.3)); }

@media (hover: hover) and (pointer: fine) {
  #mobile-controls { display: none !important; }
}

@media (max-width: 720px) {
  .top-row {
    grid-template-columns: 1fr 74px 1fr;
    gap: 7px;
  }
  .fighter-card { padding: 8px; border-radius: 14px; }
  .fighter-meta { font-size: 0.62rem; margin-bottom: 5px; }
  .rounds { letter-spacing: 1px; }
  .bar-frame { height: 16px; }
  .timer-wrap { padding: 8px 4px; border-radius: 15px; }
  h1 { letter-spacing: -2px; }
  .panel { border-radius: 24px; }
  .control-grid { grid-template-columns: 1fr; }
  #pause-btn { bottom: 110px; right: 14px; }
}

@media (max-height: 540px) {
  .panel { padding: 18px; }
  .logo-mark { display: none; }
  h1 { font-size: 2.4rem; }
  h2 { font-size: 1.4rem; }
}
