:root {
  --bg: #101018;
  --surface: #17171f;
  --raised: #1f1f2a;
  --text: #ebe8f2;
  --muted: #8d8998;
  --accent: #ff3b4e;
  --accent-2: #ff6b35;
  --player: #00e5ff;
  --player-2: #00b4d4;
  --enemy: #ff3b4e;
  --gold: #ffc14a;
  --line: rgba(255, 255, 255, 0.08);
  --radius: 12px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --pop: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #101018;
  color: #ebe8f2;
  font-family: "Rajdhani", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

img { display: block; max-width: 100%; }

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

#vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 28%, rgba(4, 2, 10, 0.42) 68%, rgba(2, 1, 6, 0.82) 100%);
}

#ko-flash {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  background: #fff8f0;
  opacity: 0;
}

#floaters {
  position: fixed;
  inset: 0;
  z-index: 7;
  pointer-events: none;
}

.floater {
  position: absolute;
  font-family: "Orbitron", sans-serif;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
  transform: translate(-50%, -50%);
  will-change: transform, opacity;
}

.screen {
  position: fixed;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

.screen.overlay {
  z-index: 20;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(10, 10, 16, 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

button {
  font-family: "Orbitron", sans-serif;
  border: 0;
  cursor: pointer;
  color: #ebe8f2;
  background: transparent;
}

button:focus-visible {
  outline: 2px solid var(--player);
  outline-offset: 3px;
}

.btn-primary {
  min-height: 52px;
  padding: 0 28px;
  border-radius: 12px;
  background: linear-gradient(110deg, #ff3b4e, #ff6b35);
  color: #1a0a0c;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.1em;
  box-shadow: 0 8px 28px rgba(255, 59, 78, 0.35);
  transition: transform 120ms ease-out, filter 200ms var(--ease);
}

.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled {
  filter: grayscale(0.4) brightness(0.7);
  box-shadow: none;
  cursor: default;
  color: #2a1518;
}

#btn-start {
  box-shadow:
    0 0 0 1px rgba(255, 186, 92, 0.4),
    0 0 18px rgba(255, 107, 53, 0.7),
    0 0 42px rgba(255, 80, 40, 0.45),
    0 10px 28px rgba(255, 59, 78, 0.38);
}

#btn-start:hover {
  filter: brightness(1.12) saturate(1.08);
}

#btn-start:active {
  transform: scale(0.94);
  filter: brightness(1.2);
  box-shadow:
    0 0 0 1px rgba(255, 210, 130, 0.65),
    0 0 14px rgba(255, 140, 60, 0.95),
    0 0 28px rgba(255, 90, 40, 0.55);
}

.btn-ghost {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  color: #ebe8f2;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
  transition: transform 120ms ease-out, background 200ms var(--ease);
}

.btn-ghost:active { transform: scale(0.97); background: rgba(255, 255, 255, 0.1); }

.title-row .btn-ghost {
  min-width: 132px;
  border-radius: 14px;
  background: rgba(8, 10, 18, 0.78);
  color: #f4f7ff;
}

#btn-howto {
  border: 2px solid #00e5ff;
  box-shadow: inset 0 0 16px rgba(0, 229, 255, 0.18), 0 0 12px rgba(0, 229, 255, 0.2);
}

#btn-records {
  border: 2px solid #ff3b4e;
  box-shadow: inset 0 0 16px rgba(255, 59, 78, 0.18), 0 0 12px rgba(255, 59, 78, 0.2);
}

#btn-howto:active {
  transform: scale(0.95);
  background: rgba(0, 229, 255, 0.28);
  color: #ffffff;
  box-shadow: inset 0 0 22px rgba(0, 229, 255, 0.4), 0 0 18px rgba(0, 229, 255, 0.45);
}

#btn-records:active {
  transform: scale(0.95);
  background: rgba(255, 59, 78, 0.28);
  color: #ffffff;
  box-shadow: inset 0 0 22px rgba(255, 59, 78, 0.4), 0 0 18px rgba(255, 59, 78, 0.45);
}

.btn-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  color: #ebe8f2;
}

.btn-icon:active { transform: scale(0.96); }

.eyebrow {
  font-family: "Orbitron", sans-serif;
  font-size: 11px;
  letter-spacing: 0.22em;
  color: #8d8998;
  font-weight: 700;
}

/* TITLE */
#screen-title {
  align-items: center;
  justify-content: flex-end;
  text-align: center;
  padding: 24px 20px 52px;
}

.title-inner {
  max-width: 420px;
  width: 100%;
}

#screen-title .eyebrow {
  color: #eafcff;
  letter-spacing: 0.36em;
  text-shadow: 0 0 18px rgba(0, 229, 255, 0.55);
}

.tagline {
  font-size: 18px;
  color: #f2fbff;
  margin: 10px 0 28px;
  letter-spacing: 0.1em;
  text-shadow: 0 0 14px rgba(0, 229, 255, 0.28);
}

.title-actions { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.title-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* SELECT */
#screen-select {
  padding: 12px 16px 16px;
  gap: 12px;
  background: linear-gradient(180deg, rgba(10, 10, 16, 0.55) 0%, rgba(10, 10, 16, 0.2) 40%, rgba(10, 10, 16, 0.72) 100%);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.topbar-title {
  flex: 1;
  text-align: center;
  font-family: "Orbitron", sans-serif;
  font-size: 14px;
  letter-spacing: 0.16em;
  font-weight: 800;
  color: #ebe8f2;
}

.topbar-spacer { width: 44px; }

.roster {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  flex: 1;
  min-height: 0;
}

.fighter-card {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #17171f;
  color: #ebe8f2;
  min-height: 0;
  display: flex;
  flex-direction: column;
  transition: transform 160ms var(--ease), border-color 200ms var(--ease);
}

.fighter-card:active { transform: scale(0.98); }

.fighter-card.selected {
  border-color: var(--player);
  box-shadow: 0 0 0 1px var(--player), 0 8px 24px rgba(0, 229, 255, 0.18);
}

.fighter-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  flex: 1;
  min-height: 88px;
}

.fighter-card .card-meta {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 28px 10px 8px;
  background: linear-gradient(transparent, rgba(8, 8, 14, 0.92));
  text-align: left;
}

.fighter-card .card-name {
  font-family: "Orbitron", sans-serif;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.fighter-card .card-style {
  font-size: 12px;
  color: #8d8998;
}

.select-detail {
  background: rgba(23, 23, 31, 0.88);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  flex-shrink: 0;
  min-height: 92px;
  color: #ebe8f2;
}

.detail-empty {
  color: #8d8998;
  font-size: 15px;
  text-align: center;
  padding: 16px 8px;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.detail-head h3 {
  font-family: "Orbitron", sans-serif;
  font-size: 16px;
  letter-spacing: 0.06em;
  color: #ebe8f2;
}

.detail-head span { font-size: 13px; color: #8d8998; }

.stat-row {
  display: grid;
  grid-template-columns: 56px 1fr 20px;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8d8998;
}

.stat-bar {
  height: 6px;
  background: #2a2a36;
  border-radius: 99px;
  overflow: hidden;
}

.stat-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #00b4d4, #00e5ff);
  border-radius: 99px;
}

.stat-row b { color: #ebe8f2; font-weight: 700; text-align: right; }

.btn-fight { width: 100%; flex-shrink: 0; }

/* VERSUS */
#screen-versus {
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 16, 0.55);
  padding: 24px;
}

.versus-inner {
  width: min(520px, 100%);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
}

.versus-card {
  background: #17171f;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  color: #ebe8f2;
}

.versus-card img { width: 100%; aspect-ratio: 3/4; object-fit: cover; }
.versus-name {
  font-family: "Orbitron", sans-serif;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 8px 8px 0;
  font-size: 13px;
  color: #ebe8f2;
}
.versus-side {
  font-size: 11px;
  letter-spacing: 0.16em;
  color: #8d8998;
  padding: 2px 8px 10px;
}
.versus-card.p1 { box-shadow: 0 0 0 1px rgba(0, 229, 255, 0.35); }
.versus-card.p2 { box-shadow: 0 0 0 1px rgba(255, 59, 78, 0.35); }
.versus-mid { text-align: center; width: 72px; }
.versus-vs {
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  font-size: 28px;
  color: #ffc14a;
}
.versus-status { font-size: 11px; color: #8d8998; margin: 8px 0; }
.versus-track {
  height: 4px;
  background: #2a2a36;
  border-radius: 99px;
  overflow: hidden;
}
#vs-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00e5ff, #ff3b4e);
}

/* FIGHT HUD */
#screen-fight { pointer-events: none; z-index: 5; }

.hud { padding: 10px 10px 0; }

.hud-top {
  display: grid;
  grid-template-columns: 1fr 56px 1fr;
  gap: 8px;
  align-items: start;
}

.fighter-col { min-width: 0; }
.fighter-col.right { text-align: right; }

.nameplate {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  font-family: "Orbitron", sans-serif;
  font-size: 11px;
  letter-spacing: 0.1em;
  font-weight: 800;
  color: #ebe8f2;
}

.fighter-col.right .nameplate { justify-content: flex-end; }

.pips { display: flex; gap: 4px; }
.pip {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid #ffc14a;
  background: transparent;
}
.pip.on { background: #ffc14a; box-shadow: 0 0 8px #ffc14a; }

.hp-shell {
  position: relative;
  height: 16px;
  background: #14141c;
  border: 1px solid rgba(255, 255, 255, 0.12);
  transform: skewX(-14deg);
  overflow: hidden;
  border-radius: 2px;
}

.hp-delay, .hp-now {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
}

.hp-delay { background: #c45a22; }
.hp-now.p { background: linear-gradient(90deg, #007a8a, #00e5ff); }
.hp-now.e { background: linear-gradient(90deg, #ff6b35, #ff3b4e); left: auto; right: 0; }
.hp-shell.enemy .hp-delay { left: auto; right: 0; }

.timer-col { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.btn-pause { width: 36px; height: 36px; pointer-events: auto; }
.timer {
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  font-size: 26px;
  color: #ffc14a;
  line-height: 1;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}

.combo-pop {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 0.06em;
  color: #ffc14a;
  text-shadow: 0 0 18px rgba(255, 193, 74, 0.45);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}

.announce {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  font-size: clamp(36px, 12vw, 64px);
  letter-spacing: 0.08em;
  color: #ebe8f2;
  text-shadow: 0 6px 30px rgba(0, 0, 0, 0.7);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}

.counter-tag {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: "Orbitron", sans-serif;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.2em;
  color: #ff3b4e;
  opacity: 0;
  pointer-events: none;
}

.controls {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 8px 12px 14px;
  pointer-events: none;
  gap: 12px;
}

.stick-wrap, .action-wrap {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.stick-base {
  width: 124px;
  height: 124px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #2a2a36, #14141c);
  border: 2px solid rgba(255, 255, 255, 0.1);
  position: relative;
  touch-action: none;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.45);
}

.stick-knob {
  position: absolute;
  width: 56px;
  height: 56px;
  left: 50%;
  top: 50%;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: linear-gradient(160deg, #3a3a48, #1a1a22);
  border: 2px solid rgba(0, 229, 255, 0.35);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
  will-change: transform;
}

.ctrl-label {
  font-family: "Orbitron", sans-serif;
  font-size: 9px;
  letter-spacing: 0.16em;
  color: #8d8998;
}

.atk-grid {
  display: grid;
  grid-template-columns: 68px 68px;
  grid-template-rows: 68px 68px;
  gap: 8px;
}

.atk-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  color: #1a1010;
  font-family: "Orbitron", sans-serif;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
  transition: transform 100ms ease-out, filter 100ms ease-out;
}

.atk-btn:active, .atk-btn.pressed { transform: scale(0.93); filter: brightness(1.15); }
.atk-btn.lp { background: linear-gradient(160deg, #5ad4ff, #00b4d4); }
.atk-btn.rp { background: linear-gradient(160deg, #ffe066, #ffc14a); color: #2a1c00; }
.atk-btn.lk { background: linear-gradient(160deg, #6dffb0, #1dbf70); }
.atk-btn.rk { background: linear-gradient(160deg, #ff7a6e, #ff3b4e); }
.atk-btn.block {
  width: 56px;
  height: 40px;
  border-radius: 20px;
  flex-direction: row;
  gap: 4px;
  background: linear-gradient(160deg, #3a3a48, #23232e);
  color: #ebe8f2;
  margin-left: auto;
}

.btn-block-row { width: 100%; display: flex; justify-content: flex-end; }

@media (max-width: 429px) {
  .hud-top { grid-template-columns: minmax(0, 1fr) 48px minmax(0, 1fr); gap: 6px; }
  .nameplate { font-size: 10px; }
  .timer { font-size: 22px; }
  .stick-base { width: 112px; height: 112px; }
  .atk-grid { grid-template-columns: 64px 64px; grid-template-rows: 64px 64px; }
  .atk-btn { width: 64px; height: 64px; }
}

@media (pointer: coarse) {
  .kb-hint { display: none; }
}

/* PANELS */
.panel {
  width: min(420px, 100%);
  background: #17171f;
  color: #ebe8f2;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px 20px 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  max-height: 92%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel h2 {
  font-family: "Orbitron", sans-serif;
  font-size: 22px;
  letter-spacing: 0.08em;
  margin-bottom: 16px;
  color: #ebe8f2;
}

.panel-scroll { overflow-y: auto; touch-action: pan-y; }

.help-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.help-list li {
  font-size: 15px;
  line-height: 1.5;
  color: #c8c4d2;
  padding-left: 12px;
  border-left: 2px solid rgba(0, 229, 255, 0.4);
}

.help-list strong { color: #ebe8f2; font-weight: 700; }

.help-keys {
  font-size: 13px;
  color: #8d8998;
  margin-bottom: 16px;
  line-height: 1.5;
}

.movelist {
  overflow-y: auto;
  touch-action: pan-y;
  max-height: 42vh;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.move-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  background: #1f1f2a;
  border-radius: 10px;
  font-size: 14px;
  color: #c8c4d2;
}

.move-row b { color: #00e5ff; font-family: "Orbitron", sans-serif; font-size: 11px; letter-spacing: 0.06em; }

.panel-actions { display: flex; flex-direction: column; gap: 8px; }

.records-body { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }

.rec-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  background: #1f1f2a;
  border-radius: 10px;
  color: #c8c4d2;
}

.rec-row b { color: #ffc14a; font-family: "Orbitron", sans-serif; }

.fatal-copy { color: #c8c4d2; margin-bottom: 16px; line-height: 1.5; }

/* RESULT */
#screen-result {
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(10, 10, 16, 0.35), rgba(10, 10, 16, 0.78));
  text-align: center;
  padding: 24px;
}

.result-inner { width: min(400px, 100%); }

#result-title {
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  font-size: clamp(36px, 12vw, 56px);
  letter-spacing: -0.02em;
  margin: 8px 0 20px;
  color: #ebe8f2;
}

#result-title.win {
  background: linear-gradient(110deg, #00e5ff, #7dffa8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

#result-title.lose { color: #ff3b4e; }

.result-stats {
  background: rgba(23, 23, 31, 0.9);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  margin-bottom: 20px;
}

.result-actions { display: flex; flex-direction: column; gap: 8px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}