:root {
  --bg: #050b12;
  --surface: rgba(10, 18, 31, 0.94);
  --surface-strong: rgba(12, 22, 37, 0.98);
  --surface-soft: rgba(19, 31, 49, 0.86);
  --border: rgba(134, 175, 245, 0.16);
  --text: #eff5ff;
  --muted: #97a9c8;
  --muted-strong: #cad5e8;
  --accent: #63f2c3;
  --accent-alt: #73a7ff;
  --accent-warm: #ffb566;
  --accent-danger: #ff748e;
  --shadow-soft: 0 24px 60px rgba(0, 0, 0, 0.34);
  --shadow-card: 0 16px 38px rgba(0, 0, 0, 0.28);
  --radius-xl: 30px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
}

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

html,
body {
  min-height: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100svh;
  overflow-y: auto;
  font-family: "Poppins", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(115, 167, 255, 0.16), transparent 28%),
    radial-gradient(circle at 88% 12%, rgba(99, 242, 195, 0.14), transparent 22%),
    linear-gradient(180deg, #050b12 0%, #07111c 46%, #081521 100%);
}

body::selection,
::selection {
  background: rgba(99, 242, 195, 0.22);
  color: var(--text);
}

button,
input,
textarea,
select {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.game-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  min-height: 100svh;
  height: auto;
  padding: 10px;
  gap: 10px;
}

.mobile-fallback {
  display: none;
  width: 100%;
  height: 100svh;
  padding: 18px;
}

.mobile-fallback-card {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 1rem;
  width: 100%;
  height: 100%;
  padding: 1.5rem;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(15, 25, 40, 0.84), rgba(8, 14, 24, 0.92)),
    rgba(8, 14, 24, 0.92);
  box-shadow: var(--shadow-soft);
}

.mobile-fallback-card h2 {
  max-width: 18ch;
  font-size: clamp(1.9rem, 6vw, 3.2rem);
  line-height: 1;
  letter-spacing: -0.04em;
}

.mobile-fallback-card p:not(.hero-kicker) {
  max-width: 34ch;
  color: var(--muted-strong);
  font-size: 1rem;
  line-height: 1.6;
}

.mobile-fallback-link {
  min-width: 160px;
}

.game-header,
.battle-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(15, 25, 40, 0.78), rgba(8, 14, 24, 0.84)),
    rgba(8, 14, 24, 0.8);
  box-shadow: var(--shadow-soft);
}

.game-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.9rem;
  min-height: 82px;
  padding: 0.8rem 1rem;
}

.back-link,
.ghost-btn,
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0.68rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted-strong);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.primary-btn {
  border: 0;
  color: #04120f;
  background: linear-gradient(135deg, rgba(99, 242, 195, 0.96), rgba(115, 167, 255, 0.78));
}

.header-copy {
  min-width: 0;
}

.hero-kicker,
.selection-kicker,
.overlay-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.wave {
  display: inline-block;
  transform-origin: 70% 70%;
  animation: waveHit 2.8s ease-in-out infinite;
}

.header-copy h1 {
  font-size: clamp(1.35rem, 2vw, 1.9rem);
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.8rem;
  min-width: 0;
}

.control-strip {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.control-strip span {
  display: inline-flex;
  align-items: center;
  gap: 0.34rem;
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 26px;
  padding: 0 0.4rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 700;
}

.sound-toggle[aria-pressed="true"] {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
}

.game-main {
  min-height: 0;
}

.battle-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  padding: 0.75rem;
  gap: 0.75rem;
}

.battle-hud {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 0.75rem;
}

.hud-card,
.hud-center {
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02)),
    rgba(11, 20, 33, 0.84);
}

.hud-card {
  padding: 0.82rem;
}

.hud-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.hud-icon {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    rgba(10, 18, 30, 0.92);
}

.hud-icon img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.hud-role {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hud-card h2 {
  margin-bottom: 0.12rem;
  font-size: 1rem;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.hud-special {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
}

.hud-meter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.35rem;
  color: var(--muted-strong);
  font-size: 0.78rem;
  font-weight: 600;
}

.hud-meter-row-power {
  margin-top: 0.55rem;
}

.hud-meter {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.hud-meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(99, 242, 195, 0.96), rgba(115, 167, 255, 0.82));
}

.hud-meter-power {
  position: relative;
  transition: box-shadow 0.3s ease;
}

.hud-meter-power span {
  background: linear-gradient(135deg, rgba(255, 181, 102, 0.98), rgba(255, 125, 151, 0.78));
  transition: width 0.08s linear;
}

.hud-meter-power.is-ready {
  box-shadow: 0 0 0 1px rgba(99, 242, 195, 0.4), 0 0 14px rgba(99, 242, 195, 0.42);
  animation: powerReadyPulse 1.3s ease-in-out infinite;
}

.hud-meter-power.is-ready span {
  background: linear-gradient(135deg, rgba(99, 242, 195, 0.98), rgba(115, 167, 255, 0.82));
}

.hud-meter-row-power .hud-power-ready-tag {
  margin-left: 0.4rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #04120f;
  background: linear-gradient(135deg, rgba(99, 242, 195, 0.96), rgba(115, 167, 255, 0.85));
  opacity: 0;
  transition: opacity 0.2s ease;
}

.hud-meter-row-power.is-ready .hud-power-ready-tag {
  opacity: 1;
}

@keyframes powerReadyPulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(99, 242, 195, 0.4), 0 0 12px rgba(99, 242, 195, 0.35); }
  50%      { box-shadow: 0 0 0 1px rgba(99, 242, 195, 0.6), 0 0 22px rgba(99, 242, 195, 0.55); }
}

.hud-meter-enemy span {
  background: linear-gradient(135deg, rgba(255, 181, 102, 0.96), rgba(255, 125, 151, 0.82));
}

.hud-center {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 0.65rem;
  min-width: 174px;
  padding: 0.75rem;
}

.arena-badge {
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted-strong);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hud-actions {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  justify-content: center;
}

.arena-stage {
  position: relative;
  min-height: 0;
  height: 100%;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
  contain: layout paint;
  isolation: isolate;
  background:
    radial-gradient(circle at 50% 18%, rgba(99, 242, 195, 0.15), transparent 24%),
    radial-gradient(circle at 20% 18%, rgba(115, 167, 255, 0.16), transparent 20%),
    linear-gradient(180deg, rgba(13, 24, 40, 0.96), rgba(6, 11, 19, 1));
}

.arena-grid,
.arena-sun,
.arena-floor-glow,
.arena-ground,
.arena-platform,
.arena-centerline,
.arena-effects,
.arena-particles,
.selection-screen,
.match-overlay {
  position: absolute;
}

.arena-grid {
  inset: 0;
  opacity: 0.16;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 88px 88px;
}

.arena-sun {
  top: 4%;
  left: 50%;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  transform: translateX(-50%);
  background:
    radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.24), transparent 18%),
    radial-gradient(circle, rgba(99, 242, 195, 0.22), rgba(115, 167, 255, 0.12), transparent 68%);
  filter: blur(8px);
}

.arena-floor-glow {
  inset: auto 8% 24px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 242, 195, 0.16), transparent 65%);
  filter: blur(10px);
}

.arena-ground {
  inset: auto 0 0;
  height: 98px;
  background:
    linear-gradient(180deg, rgba(99, 242, 195, 0.08), rgba(10, 18, 30, 0)),
    linear-gradient(180deg, rgba(18, 33, 52, 0.18), rgba(8, 15, 25, 0.94));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.arena-platform {
  bottom: 124px;
  width: 140px;
  height: 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.06);
}

.platform-left {
  left: 14%;
}

.platform-right {
  right: 14%;
}

.arena-centerline {
  inset: 0 auto 0 50%;
  width: 1px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.18), transparent);
  opacity: 0.5;
}

.arena-effects,
.arena-particles {
  inset: 0;
  pointer-events: none;
  contain: layout paint;
}

.arena-fighter {
  position: absolute;
  left: 0;
  bottom: 52px;
  width: 88px;
  height: 150px;
  transform-origin: bottom center;
  pointer-events: none;
  will-change: transform, opacity;
  --fighter-primary: #73a7ff;
  --fighter-accent: #63f2c3;
}

.fighter-preview {
  position: relative;
  left: auto;
  bottom: auto;
  width: 124px;
  height: 210px;
  transform: none !important;
}

.fighter-preview .fighter-shadow {
  width: 86px;
  height: 20px;
}

.fighter-preview .fighter-aura,
.selection-preview-glow {
  display: none;
}

.fighter-preview .fighter-head {
  top: 16px;
  left: 42px;
  width: 38px;
  height: 38px;
}

.fighter-preview .fighter-torso {
  top: 56px;
  left: 31px;
  width: 60px;
  height: 74px;
}

.fighter-preview .fighter-badge {
  display: none;
}

.fighter-preview .fighter-badge img {
  width: 28px;
  height: 28px;
}

.fighter-preview .fighter-arm {
  top: 62px;
  height: 68px;
  width: 12px;
}

.fighter-preview .fighter-arm-left {
  left: 18px;
}

.fighter-preview .fighter-arm-right {
  right: 18px;
}

.fighter-preview .fighter-leg {
  top: 122px;
  height: 78px;
  width: 12px;
}

.fighter-preview .fighter-leg-left {
  left: 36px;
}

.fighter-preview .fighter-leg-right {
  right: 36px;
}

.fighter-preview .fighter-weapon {
  top: 74px;
  right: 8px;
  width: 10px;
  height: 56px;
}

.fighter-shadow {
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 70px;
  height: 18px;
  border-radius: 999px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.28);
  filter: blur(3px);
}

.fighter-model {
  position: absolute;
  inset: 0;
  will-change: transform, filter;
}

.fighter-preview .fighter-model {
  animation: idleBob 2.6s ease-in-out infinite;
}

.fighter-aura {
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--fighter-accent) 28%, transparent), transparent 70%);
  opacity: 0.18;
  filter: blur(8px);
}

.fighter-head,
.fighter-torso,
.fighter-arm,
.fighter-leg,
.fighter-weapon {
  position: absolute;
  background: linear-gradient(180deg, color-mix(in srgb, var(--fighter-primary) 88%, white), var(--fighter-accent));
}

.fighter-head {
  top: 10px;
  left: 30px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.16);
}

.fighter-torso {
  top: 40px;
  left: 24px;
  width: 40px;
  height: 48px;
  border-radius: 18px 18px 16px 16px;
}

.fighter-badge {
  position: absolute;
  inset: 8px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(5, 11, 18, 0.38);
}

.fighter-badge img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  transform: scaleX(var(--badge-flip, 1));
}

.fighter-arm,
.fighter-leg {
  width: 10px;
  border-radius: 999px;
  transform-origin: top center;
}

.fighter-arm {
  top: 44px;
  height: 52px;
}

.fighter-arm-left {
  left: 16px;
  transform: rotate(16deg);
}

.fighter-arm-right {
  right: 16px;
  transform: rotate(-16deg);
}

.fighter-leg {
  top: 84px;
  height: 56px;
}

.fighter-leg-left {
  left: 28px;
  transform: rotate(8deg);
}

.fighter-leg-right {
  right: 28px;
  transform: rotate(-8deg);
}

.fighter-weapon {
  display: none;
}

.arena-fighter.is-attacking .fighter-arm-right {
  transform: rotate(-68deg) translateY(-3px);
}

.arena-fighter.is-attacking .fighter-weapon {
  transform: rotate(-26deg) translate(8px, -4px);
}

.arena-fighter.is-power .fighter-aura {
  opacity: 0.9;
  transform: scale(1.3);
}

.arena-fighter.is-hit .fighter-model {
  filter: brightness(1.35);
}

.arena-fighter.is-jumping .fighter-shadow {
  transform: translateX(-50%) scale(0.72);
  opacity: 0.34;
}

.arena-fighter.is-dead .fighter-model {
  opacity: 0.45;
  transform: rotate(90deg);
  transform-origin: bottom center;
}

.ai-feedback,
.player-feedback {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background:
    linear-gradient(180deg, rgba(20, 32, 50, 0.96), rgba(8, 14, 24, 0.92));
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.28);
  z-index: 5;
}

/* Counter the enemy sprite's scaleX(-1) so the text reads correctly */
.fighter-enemy .ai-feedback,
.fighter-enemy .player-feedback {
  transform: translate(-50%, 8px) scaleX(-1);
}

.fighter-player .ai-feedback,
.fighter-player .player-feedback {
  transform: translate(-50%, 8px);
}

.ai-feedback::after,
.player-feedback::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 8px;
  height: 8px;
  background: inherit;
  border-right: 1px solid rgba(255, 255, 255, 0.16);
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.fighter-enemy .ai-feedback.is-visible,
.fighter-enemy .player-feedback.is-visible {
  opacity: 1;
  transform: translate(-50%, 0) scaleX(-1);
}

.fighter-player .ai-feedback.is-visible,
.fighter-player .player-feedback.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.ai-feedback.is-alert,
.player-feedback.is-alert {
  border-color: rgba(255, 134, 134, 0.5);
  color: #ffd6d6;
  box-shadow: 0 0 0 1px rgba(255, 134, 134, 0.25), 0 10px 22px rgba(0, 0, 0, 0.32);
}

.ai-feedback.is-power,
.player-feedback.is-power {
  border-color: rgba(99, 242, 195, 0.5);
  color: #c8fff0;
  box-shadow: 0 0 0 1px rgba(99, 242, 195, 0.25), 0 10px 22px rgba(0, 0, 0, 0.32);
  animation: feedbackPulse 1.4s ease-in-out infinite;
}

@keyframes feedbackPulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(99, 242, 195, 0.25), 0 10px 22px rgba(0, 0, 0, 0.32); }
  50%      { box-shadow: 0 0 0 1px rgba(99, 242, 195, 0.55), 0 0 24px rgba(99, 242, 195, 0.45); }
}

/* === ARCHETYPES — variations distinctives par catégorie === */

/* MAGE (IA, Code) — halo lumineux + antenne au sommet */
.arena-fighter.is-mage .fighter-head::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--fighter-fx) 55%, transparent), transparent 70%);
  filter: blur(3px);
  animation: archetypeMageHalo 2.4s ease-in-out infinite;
  pointer-events: none;
}
.arena-fighter.is-mage .fighter-head::after {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 3px;
  height: 8px;
  border-radius: 2px;
  background: var(--fighter-fx);
  box-shadow: 0 -3px 6px var(--fighter-fx);
}
@keyframes archetypeMageHalo {
  0%, 100% { opacity: 0.45; transform: scale(1); }
  50%      { opacity: 0.85; transform: scale(1.12); }
}

/* TANK (CMS) — armure visuelle + torse renforcé */
.arena-fighter.is-tank .fighter-torso {
  border: 2px solid rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.22);
}
.arena-fighter.is-tank .fighter-torso::after {
  content: "";
  position: absolute;
  inset: 4px 5px auto 5px;
  height: 6px;
  border-radius: 4px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.32), transparent);
  pointer-events: none;
}

/* SUPPORT (CRM, Emailing, Fidélisation) — antennes/satellites */
.arena-fighter.is-support .fighter-head::before {
  content: "";
  position: absolute;
  top: -6px;
  left: -3px;
  width: 5px;
  height: 12px;
  border-radius: 999px;
  background: var(--fighter-fx);
  transform: rotate(-18deg);
  box-shadow: 0 0 6px var(--fighter-fx);
}
.arena-fighter.is-support .fighter-head::after {
  content: "";
  position: absolute;
  top: -6px;
  right: -3px;
  width: 5px;
  height: 12px;
  border-radius: 999px;
  background: var(--fighter-fx);
  transform: rotate(18deg);
  box-shadow: 0 0 6px var(--fighter-fx);
  animation: archetypeSupportBlink 2.1s ease-in-out infinite;
}
@keyframes archetypeSupportBlink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

/* ARTIST (UX/UI, Design) — forme géométrique flottante */
.arena-fighter.is-artist .fighter-torso::before {
  content: "";
  position: absolute;
  top: -16px;
  right: -10px;
  width: 10px;
  height: 10px;
  background: var(--fighter-fx);
  transform: rotate(45deg);
  border-radius: 2px;
  box-shadow: 0 0 8px var(--fighter-fx);
  animation: archetypeArtistFloat 2.6s ease-in-out infinite;
}
@keyframes archetypeArtistFloat {
  0%, 100% { transform: translateY(0) rotate(45deg); }
  50%      { transform: translateY(-4px) rotate(135deg); }
}

/* SCOUT (Data, Analyse) — visière/lunettes */
.arena-fighter.is-scout .fighter-head::before {
  content: "";
  position: absolute;
  top: 9px;
  left: 4px;
  right: 4px;
  height: 4px;
  background: rgba(5, 11, 18, 0.72);
  border-radius: 2px;
  box-shadow: 0 0 6px var(--fighter-fx);
}
.arena-fighter.is-scout .fighter-head::after {
  content: "";
  position: absolute;
  top: 10px;
  left: 6px;
  width: 4px;
  height: 2px;
  border-radius: 1px;
  background: var(--fighter-fx);
  box-shadow: 8px 0 0 var(--fighter-fx);
}

.selection-screen,
.match-overlay {
  inset: 0;
  display: grid;
  place-items: stretch center;
  padding: 1rem 1rem 1.45rem;
}

.match-overlay {
  place-items: center;
}

.selection-screen {
  background: rgba(4, 9, 16, 0.34);
}

.selection-screen[hidden],
.match-overlay[hidden] {
  display: none;
}

.selection-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.72fr) minmax(0, 1.28fr);
  align-items: stretch;
  gap: 0.8rem;
  width: min(1240px, calc(100% - 8px));
  height: 100%;
  max-height: 100%;
  min-height: 0;
}

.selection-preview-card,
.selection-panel,
.overlay-card {
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(16, 28, 45, 0.94), rgba(10, 18, 30, 0.96)),
    rgba(8, 14, 24, 0.92);
  box-shadow: var(--shadow-card);
}

.selection-preview-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0.62rem;
  padding: 1rem 0.9rem;
}

.selection-preview-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  max-height: 318px;
  border-radius: 24px;
  background:
    radial-gradient(circle at 50% 30%, rgba(99, 242, 195, 0.16), transparent 30%),
    linear-gradient(180deg, rgba(10, 18, 30, 0.96), rgba(8, 13, 22, 0.98));
  overflow: hidden;
}

.selection-preview-glow {
  position: absolute;
  inset: auto 10% 10%;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 242, 195, 0.16), transparent 66%);
  filter: blur(14px);
}

.selection-copy h2 {
  margin-bottom: 0.1rem;
  font-size: clamp(1.34rem, 1.95vw, 1.76rem);
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.selection-role {
  margin-bottom: 0.12rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.selection-special {
  margin-bottom: 0.16rem;
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 700;
}

.selection-stats {
  color: var(--muted-strong);
  font-size: 0.8rem;
  line-height: 1.32;
}

.selection-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-content: stretch;
  gap: 0.7rem;
  padding: 1rem 0.82rem;
  min-height: 0;
}

.selection-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.62rem;
}

.selection-topbar h2 {
  font-size: clamp(1.28rem, 1.8vw, 1.64rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.selection-actions {
  display: flex;
  gap: 0.48rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.selection-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  padding: 0.2rem 0.4rem 0.6rem 0.16rem;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.selection-grid::-webkit-scrollbar {
  width: 8px;
}
.selection-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}
.selection-grid::-webkit-scrollbar-track {
  background: transparent;
}

.roster-card {
  position: relative;
  height: 210px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  perspective: 1200px;
  color: var(--text);
  text-align: center;
}

.roster-card-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.roster-card:hover .roster-card-inner,
.roster-card:focus-visible .roster-card-inner,
.roster-card.is-flipped .roster-card-inner,
.roster-card.is-selected .roster-card-inner {
  transform: rotateY(180deg);
}

.roster-card-face,
.roster-card-back {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: start;
  gap: 0.3rem;
  padding: 1.7rem 0.6rem 0.65rem;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    rgba(12, 21, 35, 0.82);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}

.roster-card-face {
  align-content: start;
  justify-items: center;
  gap: 0.25rem;
}

.roster-card-back {
  transform: rotateY(180deg);
  align-content: start;
  text-align: left;
  gap: 0.34rem;
}

.roster-card.is-selected .roster-card-face,
.roster-card.is-selected .roster-card-back {
  border-color: rgba(99, 242, 195, 0.42);
  background:
    linear-gradient(180deg, rgba(99, 242, 195, 0.14), rgba(115, 167, 255, 0.08)),
    rgba(12, 21, 35, 0.92);
  box-shadow: 0 0 0 1px rgba(99, 242, 195, 0.18), 0 10px 28px rgba(0, 0, 0, 0.28);
}

.roster-rank {
  position: absolute;
  top: 0.55rem;
  left: 0.7rem;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--muted);
  opacity: 0.78;
}

.roster-archetype-tag {
  position: absolute;
  top: 0.55rem;
  right: 0.7rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted-strong);
}

.roster-card.is-mage .roster-archetype-tag {
  color: #73a7ff;
  border-color: rgba(115, 167, 255, 0.3);
  background: rgba(115, 167, 255, 0.1);
}
.roster-card.is-tank .roster-archetype-tag {
  color: #ffb27d;
  border-color: rgba(255, 178, 125, 0.3);
  background: rgba(255, 178, 125, 0.1);
}
.roster-card.is-support .roster-archetype-tag {
  color: #ffd34d;
  border-color: rgba(255, 211, 77, 0.3);
  background: rgba(255, 211, 77, 0.1);
}
.roster-card.is-artist .roster-archetype-tag {
  color: #ff7fd6;
  border-color: rgba(255, 127, 214, 0.3);
  background: rgba(255, 127, 214, 0.1);
}
.roster-card.is-scout .roster-archetype-tag {
  color: #63f2c3;
  border-color: rgba(99, 242, 195, 0.3);
  background: rgba(99, 242, 195, 0.1);
}

.roster-icon {
  display: grid;
  place-items: center;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    rgba(10, 18, 30, 0.9);
}

.roster-icon img {
  object-fit: contain;
}

.roster-icon-large {
  width: 78px;
  height: 78px;
  border-radius: 18px;
  margin-top: 0.2rem;
  margin-bottom: 0.25rem;
}

.roster-icon-large img {
  width: 44px;
  height: 44px;
}

.roster-icon-small {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  justify-self: start;
  margin-bottom: 0.1rem;
}

.roster-icon-small img {
  width: 20px;
  height: 20px;
}

.roster-name {
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.15;
}

.roster-role {
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.2;
}

.roster-special-name {
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.roster-stats {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.26rem;
}

.roster-stats li {
  display: grid;
  grid-template-columns: 38px 32px 1fr;
  align-items: center;
  gap: 0.32rem;
  font-size: 0.66rem;
  line-height: 1;
}

.roster-stat-label {
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
}

.roster-stats li b {
  font-weight: 700;
  font-size: 0.74rem;
  text-align: right;
}

.roster-bar {
  position: relative;
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.roster-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  width: var(--p, 50%);
  background: linear-gradient(90deg, var(--accent), var(--accent-alt, var(--accent-strong)));
  border-radius: inherit;
}

.roster-flavor {
  color: var(--muted-strong);
  font-size: 0.66rem;
  line-height: 1.34;
  font-style: italic;
}

.match-overlay {
  background: rgba(4, 9, 16, 0.42);
}

.overlay-card {
  max-width: 520px;
  padding: 1.2rem;
  text-align: center;
}

.overlay-kicker {
  margin-bottom: 0.4rem;
}

.overlay-card h2 {
  margin-bottom: 0.55rem;
  font-size: clamp(1.5rem, 2.6vw, 2.35rem);
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.overlay-card p:last-of-type {
  color: var(--muted-strong);
  line-height: 1.58;
}

.overlay-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.effect {
  position: absolute;
  left: 0;
  bottom: 0;
  pointer-events: none;
  will-change: transform, opacity;
}

.effect-projectile,
.effect-burst,
.effect-wave,
.effect-cloud,
.effect-trap {
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: transparent;
  font-size: 0;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.effect-projectile {
  width: 30px;
  height: 30px;
  background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.36), var(--fx-color, rgba(99, 242, 195, 0.88)));
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.effect-burst,
.effect-wave,
.effect-cloud {
  border: 1px solid color-mix(in srgb, var(--fx-color, #63f2c3) 48%, transparent);
}

.effect-burst {
  width: 68px;
  height: 68px;
  background: radial-gradient(circle, color-mix(in srgb, var(--fx-color, #63f2c3) 18%, transparent), transparent 70%);
}

.effect-wave {
  width: 120px;
  height: 120px;
  background: radial-gradient(circle, color-mix(in srgb, var(--fx-color, #63f2c3) 12%, transparent), transparent 72%);
}

.effect-cloud {
  width: 74px;
  height: 74px;
  background: radial-gradient(circle, color-mix(in srgb, var(--fx-color, #63f2c3) 16%, transparent), transparent 72%);
}

.effect-trap {
  width: 80px;
  height: 18px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--fx-color, #63f2c3) 18%, transparent), var(--fx-color, #63f2c3), color-mix(in srgb, var(--fx-color, #63f2c3) 18%, transparent));
  box-shadow: none;
}

.damage-label {
  position: absolute;
  left: 0;
  bottom: 0;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 800;
  white-space: nowrap;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
}

.damage-label.is-heal {
  color: var(--accent);
}

.damage-label.is-status {
  color: var(--accent-warm);
}

.arena-stage.is-selection .arena-effects,
.arena-stage.is-selection .arena-particles,
.arena-stage.is-selection .arena-fighter:not(.fighter-preview) {
  display: none;
}

.mobile-demo-stage {
  position: relative;
  width: min(100%, 540px);
  height: 280px;
  margin-top: 0.35rem;
  border-radius: 30px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(circle at 20% 22%, rgba(115, 167, 255, 0.12), transparent 28%),
    radial-gradient(circle at 78% 22%, rgba(99, 242, 195, 0.16), transparent 28%),
    linear-gradient(180deg, rgba(13, 24, 40, 0.96), rgba(6, 11, 19, 1));
}

.mobile-demo-floor {
  position: absolute;
  inset: auto 0 0;
  height: 74px;
  background:
    linear-gradient(180deg, rgba(99, 242, 195, 0.08), rgba(10, 18, 30, 0)),
    linear-gradient(180deg, rgba(18, 33, 52, 0.22), rgba(8, 15, 25, 0.96));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.demo-fighter {
  bottom: 42px;
  width: 92px;
  height: 156px;
}

.demo-fighter .fighter-model {
  animation: idleBob 1.9s ease-in-out infinite;
}

.demo-fighter-left {
  left: 28%;
  --fighter-primary: #8dd63f;
  --fighter-accent: #d6ff8d;
  animation: demoLeftFighter 1.8s ease-in-out infinite alternate;
}

.demo-fighter-right {
  left: 58%;
  --badge-flip: -1;
  --fighter-primary: #ffffff;
  --fighter-accent: #f0f2ff;
  animation: demoRightFighter 1.8s ease-in-out infinite alternate;
}

.demo-fighter-left .fighter-arm-right,
.demo-fighter-right .fighter-arm-left {
  animation: demoStrike 0.72s ease-in-out infinite alternate;
}

.demo-fighter-left .fighter-weapon,
.demo-fighter-right .fighter-weapon {
  animation: demoWeaponStrike 0.72s ease-in-out infinite alternate;
}

.mobile-demo-impact {
  position: absolute;
  top: 44%;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 1px solid rgba(99, 242, 195, 0.28);
  background: radial-gradient(circle, rgba(99, 242, 195, 0.14), transparent 70%);
  opacity: 0.5;
  animation: demoImpactPulse 0.92s ease-in-out infinite;
}

.mobile-demo-impact-left {
  left: calc(50% - 52px);
}

.mobile-demo-impact-right {
  left: calc(50% - 16px);
  animation-delay: 0.32s;
}

@keyframes idleBob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

@keyframes waveHit {
  0%,
  100% {
    transform: rotate(0deg);
  }
  20% {
    transform: rotate(14deg);
  }
  40% {
    transform: rotate(-8deg);
  }
  60% {
    transform: rotate(10deg);
  }
  80% {
    transform: rotate(-4deg);
  }
}

@keyframes demoLeftFighter {
  0% {
    transform: translate3d(0, 0, 0) scaleX(1);
  }
  100% {
    transform: translate3d(22px, -4px, 0) scaleX(1);
  }
}

@keyframes demoRightFighter {
  0% {
    transform: translate3d(0, 0, 0) scaleX(-1);
  }
  100% {
    transform: translate3d(-22px, -4px, 0) scaleX(-1);
  }
}

@keyframes demoStrike {
  0%,
  42%,
  100% {
    transform: rotate(-14deg);
  }
  58% {
    transform: rotate(-82deg) translateY(-4px);
  }
}

@keyframes demoWeaponStrike {
  0%,
  42%,
  100% {
    transform: rotate(0deg);
  }
  58% {
    transform: rotate(-24deg) translate(8px, -4px);
  }
}

@keyframes demoImpactPulse {
  0%,
  100% {
    transform: scale(0.72);
    opacity: 0.18;
  }
  52% {
    transform: scale(1.04);
    opacity: 0.5;
  }
}

@media (max-width: 1180px) {
  .game-header {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
  }

  .header-actions {
    grid-column: 1 / -1;
    justify-content: space-between;
  }

  .selection-layout {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .selection-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .battle-hud,
  .selection-layout {
    grid-template-columns: 1fr;
  }

  .hud-center {
    min-width: 0;
  }

  .selection-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-bottom: 0.4rem;
  }
}

@media (max-width: 540px) {
  .selection-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-height: 820px) {
  body.is-selection-screen .battle-panel {
    grid-template-rows: minmax(0, 1fr);
  }

  body.is-selection-screen .battle-hud {
    display: none;
  }

  .selection-screen,
  .match-overlay {
    padding: 0.7rem 0.85rem 1rem;
  }

  .selection-layout {
    gap: 0.68rem;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    grid-template-columns: minmax(252px, 0.68fr) minmax(0, 1.32fr);
  }

  .selection-preview-card,
  .selection-panel {
    padding: 0.9rem 0.76rem;
    gap: 0.56rem;
  }

  .selection-preview-stage {
    min-height: 210px;
    max-height: 258px;
  }

  .fighter-preview {
    width: 108px;
    height: 184px;
  }

  .fighter-preview .fighter-shadow {
    width: 84px;
    height: 18px;
  }

  .fighter-preview .fighter-head {
    top: 16px;
    left: 42px;
    width: 36px;
    height: 36px;
  }

  .fighter-preview .fighter-torso {
    top: 56px;
    left: 31px;
    width: 58px;
    height: 72px;
  }

  .fighter-preview .fighter-arm {
    top: 62px;
    height: 68px;
    width: 12px;
  }

  .fighter-preview .fighter-arm-left {
    left: 18px;
  }

  .fighter-preview .fighter-arm-right {
    right: 18px;
  }

  .fighter-preview .fighter-leg {
    top: 122px;
    height: 78px;
    width: 12px;
  }

  .fighter-preview .fighter-leg-left {
    left: 36px;
  }

  .fighter-preview .fighter-leg-right {
    right: 36px;
  }

  .selection-copy h2 {
    font-size: clamp(1.32rem, 2vw, 1.72rem);
  }

  .selection-role,
  .selection-special,
  .selection-stats {
    line-height: 1.3;
  }

  .selection-topbar h2 {
    font-size: clamp(1.2rem, 1.7vw, 1.58rem);
  }

  .selection-grid {
    gap: 0.52rem;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.14rem 0.2rem 0.48rem 0.08rem;
    scrollbar-width: thin;
  }

  .roster-card {
    gap: 0.3rem;
    flex-basis: 118px;
    min-width: 118px;
    min-height: 138px;
    padding: 0.55rem 0.42rem;
    border-radius: 16px;
  }

  .roster-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
  }

  .roster-icon img {
    width: 24px;
    height: 24px;
  }

  .roster-copy strong {
    font-size: 0.78rem;
  }

  .roster-copy span {
    font-size: 0.67rem;
  }

  .selection-actions .ghost-btn,
  .selection-actions .primary-btn {
    min-height: 38px;
    padding: 0.58rem 0.9rem;
  }
}

@media (max-width: 1024px), ((pointer: coarse) and (max-width: 1366px)) {
  .game-shell {
    display: none;
  }

  .mobile-fallback {
    display: block;
  }
}

@media (max-width: 640px) {
  .game-shell {
    padding: 8px;
    gap: 8px;
  }

  .game-header,
  .battle-panel {
    border-radius: 24px;
  }

  .game-header {
    padding: 0.75rem;
  }

  .control-strip span {
    font-size: 0.72rem;
  }

  .selection-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .arena-platform {
    display: none;
  }

  .overlay-actions,
  .selection-actions,
  .hud-actions {
    justify-content: stretch;
  }

  .overlay-actions .ghost-btn,
  .overlay-actions .primary-btn,
  .selection-actions .ghost-btn,
  .selection-actions .primary-btn,
  .hud-actions .ghost-btn {
    flex: 1 1 100%;
  }

  .mobile-fallback {
    padding: 10px;
  }

  .mobile-fallback-card {
    padding: 1.25rem;
  }

  .mobile-demo-stage {
    height: 240px;
  }
}
