/* Arena AI — UI minimale */

:root {
  color-scheme: dark;
  --bg: #07090d;
  --panel: #11151e;
  --line: #232a3c;
  --text: #eef2f6;
  --muted: #7c8499;
  --gold: #f5c042;
  --side-a: #ff5560;
  --side-b: #4f9bff;
  --hp-high: #2dd47b;
  --hp-mid: #f5c042;
  --hp-low: #ff5560;
  --font-sans: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(245, 192, 66, 0.06), transparent 60%),
    radial-gradient(900px 500px at 50% 110%, rgba(79, 155, 255, 0.04), transparent 60%),
    var(--bg);
}

.app {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

/* Topbar : juste le bouton FIGHT centré */

.topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 20px;
  flex: 0 0 auto;
  position: relative;
}

.credits {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(245, 192, 66, 0.08);
  border: 1px solid rgba(245, 192, 66, 0.35);
  border-radius: 6px;
  padding: 8px 14px;
  font-weight: 800;
  font-size: 1rem;
  color: var(--gold);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  transition: transform 220ms ease, box-shadow 220ms ease;
}

.credits.is-bumping {
  transform: translateY(-50%) scale(1.18);
  box-shadow: 0 0 22px rgba(245, 192, 66, 0.6);
}

.credits-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.btn {
  appearance: none;
  border: none;
  font: 800 1rem/1 var(--font-sans);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #1a1305;
  background: linear-gradient(180deg, #ffd25a 0%, #d6a02d 100%);
  border-radius: 6px;
  padding: 14px 36px;
  min-width: 180px;
  min-height: 48px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(245, 192, 66, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: transform 80ms, box-shadow 120ms;
}

.btn:hover { box-shadow: 0 8px 24px rgba(245, 192, 66, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.4); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: default; }

/* Layout : juste l'arène */

.layout {
  display: flex;
  flex-direction: column;
  padding: 0 28px 28px;
  min-height: 0;
  overflow: hidden;
}

.stage {
  flex: 1 1 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 18px;
  min-height: 0;
  overflow: hidden;
}

/* VS bar : portrait + nom + ability + HP, deux côtés */

.versus {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

.vs-side {
  display: grid;
  grid-template-columns: 52px 1fr;
  grid-template-areas:
    "portrait info"
    "hp hp";
  column-gap: 12px;
  row-gap: 8px;
  min-width: 0;
  align-items: center;
}

.vs-portrait {
  grid-area: portrait;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #11151e;
  position: relative;
}

.vs-info {
  grid-area: info;
  display: grid;
  gap: 2px;
  min-width: 0;
}

.vs-name {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vs-ability {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-2, #c7cdda);
  line-height: 1.32;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Étiquette Mêlée / Distance */

.vs-range, .pick-range {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  width: fit-content;
  border: 1px solid currentColor;
  opacity: 0.9;
}

.vs-range { font-size: 0.6rem; padding: 1px 7px; }

.vs-range.is-melee, .pick-range.is-melee {
  background: rgba(255, 90, 100, 0.12);
  color: #ff7080;
  border-color: rgba(255, 90, 100, 0.4);
}
.vs-range.is-ranged, .pick-range.is-ranged {
  background: rgba(79, 155, 255, 0.12);
  color: #7eb5ff;
  border-color: rgba(79, 155, 255, 0.4);
}
.vs-range:empty, .pick-range:empty { display: none; }

.vs-right .vs-range { margin-left: auto; }

.vs-right {
  grid-template-columns: 1fr 52px;
  grid-template-areas:
    "info portrait"
    "hp hp";
}

.vs-left  .vs-name { color: var(--side-a); text-shadow: 0 0 22px rgba(255, 85, 96, 0.35); text-align: left; }
.vs-right .vs-name { color: var(--side-b); text-shadow: 0 0 22px rgba(79, 155, 255, 0.35); text-align: right; }
.vs-right .vs-ability { text-align: right; }
.vs-right .vs-info { justify-items: end; }

/* Sort 1 (base) vs Sort 2 (secondaire) */
.vs-ability .ab1 { color: var(--text-2, #c7cdda); }
.vs-ability .ab2 { color: var(--gold, #f5c042); font-size: 0.84em; opacity: 0.95; }

/* Couronne sur le champion verrouillé (streak) */
.vs-name.is-locked::before {
  content: "♛ ";
  color: var(--gold);
  text-shadow: 0 0 12px rgba(245, 192, 66, 0.6);
}

.hp-track {
  grid-area: hp;
}

.hp-track {
  height: 14px;
  border: 1px solid #2f3851;
  border-radius: 3px;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.02) 0 6px, transparent 6px 12px),
    #050709;
  overflow: hidden;
  position: relative;
}

.hp-fill {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--hp-high) 0%, var(--hp-mid) 65%, var(--hp-low) 100%);
  transition: width 160ms ease;
}

.hp-track.right .hp-fill {
  background: linear-gradient(270deg, var(--hp-high) 0%, var(--hp-mid) 65%, var(--hp-low) 100%);
  margin-left: auto;
}

/* Arena */

.canvas-frame {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background:
    radial-gradient(60% 80% at 50% 50%, #1a2030 0%, #0d1119 100%);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  min-height: 0;
  min-width: 0;
  /* la frame ne grossit JAMAIS au-delà de la zone allouée par le parent */
  width: 100%;
  height: 100%;
}

#arena {
  display: block;
  /* taille pilotée par JS via style.width/height (résolution interne via canvas.width/height) */
  background: #0a0d13;
  border-radius: 4px;
  transform-origin: 50% 50%;
  will-change: transform;
}

/* Winner overlay */

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: radial-gradient(50% 60% at 50% 50%, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.85));
  animation: fadeIn 240ms ease;
}
.overlay[hidden] { display: none; }

.overlay-inner {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 22px 38px;
  border-radius: 8px;
  background: rgba(10, 13, 19, 0.85);
  backdrop-filter: blur(6px);
  text-align: center;
}

.overlay-title {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--c, #f5c042);
  text-shadow: 0 0 28px color-mix(in oklab, var(--c, #f5c042) 60%, transparent);
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to   { opacity: 1; transform: scale(1); }
}

/* Card overlay (choix d'augment entre rounds) */

.card-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 5, 8, 0.94);
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 24px;
  z-index: 1100;
  backdrop-filter: blur(10px);
  animation: fadeIn 220ms ease;
  gap: 22px;
}
.card-overlay[hidden] { display: none; }

.card-header {
  display: grid;
  justify-items: center;
  gap: 6px;
}

.card-kicker {
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
}

.card-round {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  max-width: 920px;
  width: 100%;
}

.card {
  appearance: none;
  border: 1px solid #2f3851;
  background: linear-gradient(180deg, #161b27 0%, #0a0d13 100%);
  padding: 18px 16px;
  border-radius: 12px;
  cursor: pointer;
  display: grid;
  gap: 10px;
  font-family: inherit;
  color: var(--text);
  text-align: left;
  position: relative;
  transition: transform 120ms, border-color 140ms, box-shadow 140ms;
}

.card:hover, .card:focus-visible {
  transform: translateY(-3px);
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 14px 32px rgba(245, 192, 66, 0.25);
}

.card-tier {
  font-family: ui-monospace, monospace;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.7;
}

.card-name {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.005em;
}

.card-effect {
  font-size: 0.82rem;
  color: #b3ed7a;
  line-height: 1.35;
}

.card-drawback {
  font-size: 0.78rem;
  color: #ff9a8c;
  line-height: 1.35;
  font-style: italic;
}

.card-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.card-tag {
  font-size: 0.55rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 7px;
}

.card-enemy {
  margin-top: 4px;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: #ff9a8c;
  text-align: center;
  max-width: 540px;
}

/* Inventaire augments (chips sous le HP du joueur) */
.aug-chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
  min-height: 14px;
}
.aug-chip {
  font-size: 0.55rem;
  letter-spacing: 0.06em;
  background: rgba(245, 192, 66, 0.12);
  border: 1px solid rgba(245, 192, 66, 0.4);
  color: var(--gold);
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 600;
}
.vs-right .aug-chips { justify-content: flex-end; }

/* ─── Mode selector + select overlay ─── */

.btn-mode {
  background: rgba(245, 192, 66, 0.08);
  border: 1px solid rgba(245, 192, 66, 0.35);
  color: var(--gold);
  padding: 6px 14px;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-mode:hover { background: rgba(245, 192, 66, 0.18); }
.btn-mode[data-mode="choice"] {
  background: rgba(122, 200, 130, 0.15);
  border-color: rgba(122, 200, 130, 0.5);
  color: #7ac882;
}

.btn-link {
  background: none; border: none;
  color: var(--muted); cursor: pointer;
  font-family: inherit; font-size: 0.75rem;
  letter-spacing: 0.06em;
}
.btn-link:hover { color: var(--text); }

.select-overlay {
  position: fixed; inset: 0;
  background: rgba(8, 10, 18, 0.95);
  display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start;
  padding: 32px 24px; gap: 20px;
  z-index: 120; overflow-y: auto;
}
.select-overlay[hidden] { display: none; }
.select-header {
  display: flex; justify-content: space-between;
  align-items: center; width: 100%; max-width: 920px;
}
.select-kicker {
  font-size: 0.82rem; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--gold);
}
.select-columns {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 24px; max-width: 920px; width: 100%;
}
.select-col-title {
  font-size: 0.72rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 8px;
}
.select-actions { margin-bottom: 8px; }
.select-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(82px, 1fr));
  gap: 6px;
}
.select-tile {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; padding: 8px 4px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  cursor: pointer; transition: all 0.12s;
  font-family: inherit; color: var(--text);
}
.select-tile:hover { background: rgba(255, 255, 255, 0.06); border-color: var(--muted); }
.select-tile[data-selected="true"] {
  border-color: var(--gold);
  background: rgba(245, 192, 66, 0.12);
  box-shadow: 0 0 0 1px rgba(245, 192, 66, 0.3);
}
.select-tile .tile-portrait {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--c, #888);
}
.select-tile .tile-name {
  font-size: 0.62rem; line-height: 1.1;
  text-align: center; word-break: break-word;
}

#selectGoBtn:disabled {
  opacity: 0.35; cursor: not-allowed;
}

@media (max-width: 640px) {
  .select-columns { grid-template-columns: 1fr; }
  .select-grid { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
  .select-tile { padding: 6px 2px; }
  .select-tile .tile-portrait { width: 26px; height: 26px; }
}

.aug-chip-enemy {
  background: rgba(255, 154, 140, 0.10);
  border-color: rgba(255, 154, 140, 0.35);
  color: #ff9a8c;
}

.card-effect-mini {
  display: inline;
  margin-left: 6px;
  opacity: 0.85;
  font-size: 0.66rem;
  color: var(--muted);
}

@media (max-width: 640px) {
  .card-grid { grid-template-columns: 1fr; gap: 10px; max-width: 360px; }
  .card { padding: 12px; gap: 6px; }
  .card-name { font-size: 0.95rem; }
  .card-effect { font-size: 0.74rem; }
  .card-drawback { font-size: 0.7rem; }
}

/* Pick overlay (choisis ton champion) */

.pick-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 5, 8, 0.94);
  display: grid;
  align-items: center;
  justify-items: center;
  padding: 24px;
  z-index: 1100;
  backdrop-filter: blur(10px);
  animation: fadeIn 220ms ease;
}
.pick-overlay[hidden] { display: none; }

.pick-kicker {
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 22px;
  text-align: center;
}

.pick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  max-width: 760px;
  width: 100%;
}

.pick-card {
  appearance: none;
  border: 2px solid var(--c, var(--line));
  background: linear-gradient(180deg, var(--panel) 0%, #0a0d13 100%);
  padding: 28px 22px;
  border-radius: 14px;
  cursor: pointer;
  display: grid;
  gap: 12px;
  justify-items: center;
  transition: transform 120ms, box-shadow 140ms, border-color 140ms;
  font-family: inherit;
  color: var(--text);
}

.pick-card:hover, .pick-card:focus-visible {
  transform: translateY(-3px);
  outline: none;
  box-shadow: 0 16px 38px color-mix(in oklab, var(--c, var(--gold)) 35%, transparent);
}

.pick-portrait {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--c, var(--gold)), 0 0 28px color-mix(in oklab, var(--c, var(--gold)) 55%, transparent);
}

.pick-name {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--c, var(--text));
  letter-spacing: 0.005em;
}

.pick-ability {
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.4;
  max-width: 280px;
}

.pick-hint {
  margin-top: 22px;
  font-size: 0.74rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-align: center;
  max-width: 460px;
}

@media (max-width: 640px) {
  .pick-overlay { padding: 16px; }
  .pick-kicker { font-size: 0.75rem; margin-bottom: 14px; }
  .pick-grid { gap: 12px; }
  .pick-card { padding: 16px 10px; gap: 6px; }
  .pick-portrait { width: 64px; height: 64px; }
  .pick-name { font-size: 1.05rem; }
  .pick-ability {
    font-size: 0.7rem;
    max-width: none;
    line-height: 1.3;
  }
  .pick-hint { margin-top: 12px; font-size: 0.62rem; }
  .pick-range { font-size: 0.55rem; padding: 1px 6px; }
}

/* Roulette pré-fight (slot-machine) */

.reel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 5, 8, 0.94);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  justify-items: center;
  gap: 24px;
  padding: 24px;
  z-index: 1000;
  backdrop-filter: blur(10px);
  animation: fadeIn 220ms ease;
}
.reel-overlay[hidden] { display: none; }

.reel {
  width: 280px;
  height: 216px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--panel) 0%, #0a0d13 100%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0, black 22%, black 78%, transparent 100%);
          mask-image: linear-gradient(180deg, transparent 0, black 22%, black 78%, transparent 100%);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
}

.reel-strip {
  display: flex;
  flex-direction: column;
  will-change: transform;
}

.reel-card {
  flex: 0 0 72px;
  height: 72px;
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.reel-card-portrait {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--c, var(--gold)), inset 0 -3px 5px rgba(0, 0, 0, 0.4);
}

.reel-card-info {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.reel-card-name {
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reel-card-role {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.reel-vs {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--gold);
  text-shadow: 0 0 32px rgba(245, 192, 66, 0.6);
}

@media (max-width: 640px) {
  .reel-overlay { grid-template-columns: 1fr; grid-template-rows: 1fr auto 1fr; gap: 12px; padding: 16px; }
  .reel { width: 100%; max-width: 320px; height: 160px; }
  .reel-card { flex-basis: 56px; height: 56px; grid-template-columns: 36px 1fr; padding: 0 12px; gap: 10px; }
  .reel-card-portrait { width: 36px; height: 36px; }
  .reel-card-name { font-size: 0.92rem; }
  .reel-vs { font-size: 1.8rem; }
}

/* Mobile */

@media (max-width: 640px) {
  .topbar { padding: 12px 14px; }
  .btn { padding: 12px 24px; min-width: 140px; font-size: 0.9rem; letter-spacing: 0.12em; }
  .layout { padding: 0 14px 14px; }
  .stage { gap: 10px; }
  .versus { gap: 10px; }
  .vs-side { grid-template-columns: 40px 1fr; column-gap: 8px; }
  .vs-right { grid-template-columns: 1fr 40px; }
  .vs-portrait { width: 40px; height: 40px; }
  .vs-name { font-size: 0.92rem; }
  .vs-ability {
    font-size: 0.62rem;
    -webkit-line-clamp: 5;
    line-height: 1.25;
    letter-spacing: 0.005em;
  }
  .vs-range { display: none; }  /* on garde le chip uniquement sur le pick screen en mobile */
  .hp-track { height: 9px; }
  .canvas-frame { padding: 8px; }
  .overlay-title { font-size: 1.6rem; }
}

@media (max-height: 480px) and (orientation: landscape) {
  .topbar { padding: 8px 12px; }
  .btn { padding: 8px 18px; min-height: 36px; }
  .layout { padding: 0 12px 12px; }
  .stage { gap: 6px; }
  .canvas-frame { padding: 6px; }
}

/* ============================================================
   Arena AI UI v2 - adapted from auditU/refined pixel design
   Vanilla DOM port: keeps existing IDs and gameplay wiring.
   ============================================================ */

:root {
  color-scheme: dark;
  --bg-void: #08090f;
  --bg-deep: #0d1018;
  --bg-panel: #141826;
  --bg-panel-2: #1c2133;
  --bg-panel-3: #262d43;
  --bg-elev: #323a55;
  --ink-white: #e8ecf5;
  --ink-soft: #b6bcd3;
  --ink-dim: #7e84a0;
  --ink-mute: #4e546e;
  --line-1: #1f2538;
  --line-2: #2a3148;
  --line-3: #404868;
  --player: #5dd6ff;
  --player-bg: #0f2330;
  --enemy: #ff5e72;
  --enemy-bg: #2d101a;
  --gold: #f4c14a;
  --lime: #a8e44c;
  --violet: #b794ff;
  --magenta: #ff6cc1;
  --hp-good: #a8e44c;
  --hp-mid: #f4c14a;
  --hp-low: #ff5e72;
  --r-common: #a0a6bd;
  --r-rare: #5dd6ff;
  --r-epic: #b794ff;
  --r-legend: #f4c14a;
  --font-pixel: "Silkscreen", ui-monospace, monospace;
  --font-title: "Pixelify Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

html,
body {
  background: var(--bg-void);
  color: var(--ink-white);
  font-family: var(--font-pixel);
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background:
    radial-gradient(ellipse 80% 60% at 50% 18%, rgba(93, 214, 255, 0.045), transparent 60%),
    radial-gradient(ellipse 80% 60% at 50% 100%, rgba(244, 193, 74, 0.04), transparent 60%),
    linear-gradient(rgba(126, 132, 160, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(126, 132, 160, 0.045) 1px, transparent 1px),
    var(--bg-void);
  background-size: auto, auto, 24px 24px, 24px 24px, auto;
}

img,
svg,
canvas,
.vs-portrait,
.pick-portrait,
.reel-card-portrait,
.tile-portrait {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.app {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.topbar {
  position: relative;
  display: grid;
  grid-template-columns: auto auto auto minmax(160px, 210px) auto 1fr;
  align-items: center;
  justify-content: stretch;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-2);
  background:
    linear-gradient(180deg, rgba(20, 24, 38, 0.96), rgba(13, 16, 24, 0.96));
  box-shadow:
    inset 0 -1px 0 rgba(255, 255, 255, 0.025),
    0 0 0 1px #000;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 142px;
}

.brand-mark {
  width: 22px;
  height: 22px;
  display: inline-block;
  background:
    linear-gradient(var(--player), var(--player)) 9px 0 / 4px 22px no-repeat,
    linear-gradient(var(--enemy), var(--enemy)) 0 9px / 22px 4px no-repeat,
    linear-gradient(var(--gold), var(--gold)) 9px 9px / 4px 4px no-repeat,
    var(--bg-deep);
  border: 1px solid var(--line-3);
  box-shadow: 0 0 12px rgba(93, 214, 255, 0.18);
}

.brand-copy {
  display: grid;
  line-height: 1;
  gap: 2px;
}

.brand-title {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.5px;
}

.brand-sub {
  font-size: 7px;
  color: var(--ink-dim);
  letter-spacing: 0.8px;
}

.credits {
  position: static;
  transform: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 10px 4px 8px;
  border-radius: 0;
  background: var(--bg-deep);
  border: 1px solid var(--line-2);
  color: var(--gold);
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.5px;
  box-shadow: inset 0 0 12px rgba(244, 193, 74, 0.08);
}

.credits.is-bumping {
  transform: scale(1.12);
  box-shadow: inset 0 0 12px rgba(244, 193, 74, 0.15), 0 0 18px rgba(244, 193, 74, 0.42);
}

.credits-icon {
  width: 14px;
  height: 14px;
  display: inline-block;
  font-size: 0;
  line-height: 0;
  background:
    linear-gradient(#fff4d0, #fff4d0) 2px 1px / 8px 2px no-repeat,
    linear-gradient(#fff4d0, #fff4d0) 1px 3px / 2px 7px no-repeat,
    linear-gradient(#7a5e0e, #7a5e0e) 9px 3px / 2px 7px no-repeat,
    linear-gradient(#7a5e0e, #7a5e0e) 4px 10px / 6px 2px no-repeat,
    #f4c14a;
  clip-path: polygon(28% 0, 72% 0, 72% 14%, 100% 14%, 100% 86%, 72% 86%, 72% 100%, 28% 100%, 28% 86%, 0 86%, 0 14%, 28% 14%);
}

.match-strip {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 6px 8px;
  background: var(--bg-deep);
  border: 1px solid var(--line-2);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.018);
}

.meta-block {
  display: grid;
  gap: 2px;
  min-width: 70px;
  line-height: 1;
}

.meta-label,
.score-line,
.result-chip {
  font-size: 7px;
  color: var(--ink-dim);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.meta-value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-white);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

#matchState[data-state="live"] { color: var(--lime); }
#matchState[data-state="paused"] { color: var(--gold); }
#matchState[data-state="done"] { color: var(--enemy); }

.score-line {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-white);
}

.score-sep { color: var(--ink-mute); }

.result-chip {
  padding: 4px 7px;
  border: 1px solid var(--line-2);
  background: var(--bg-panel);
}

.result-chip[data-state="done"] {
  color: var(--gold);
  border-color: rgba(244, 193, 74, 0.45);
}

.top-actions {
  display: contents;
}

.btn {
  appearance: none;
  border-radius: 0;
  border: 1px solid var(--line-3);
  min-width: 0;
  min-height: 32px;
  padding: 8px 12px;
  cursor: pointer;
  font-family: var(--font-pixel);
  font-size: 10px;
  line-height: 1;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--ink-white);
  background: var(--bg-panel-2);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.4),
    0 1px 0 #000;
  transition: transform 40ms linear, border-color 80ms, background 80ms, box-shadow 80ms;
}

.btn:hover {
  background: var(--bg-panel-3);
  border-color: var(--ink-dim);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  padding: 10px 18px;
  color: #fff;
  background: linear-gradient(180deg, #c44150 0%, #8a2030 100%);
  border-color: #ff7a8a;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 -1px 0 rgba(0, 0, 0, 0.4),
    0 0 0 1px #000,
    0 0 16px rgba(255, 94, 114, 0.35);
}

.btn-mode {
  color: var(--gold);
  background: var(--bg-deep);
  border-color: rgba(244, 193, 74, 0.45);
  padding: 8px 10px;
  border-radius: 0;
}

.btn-mode[data-mode="choice"] {
  color: var(--lime);
  border-color: rgba(168, 228, 76, 0.45);
  background: #142312;
}

.speed-control {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 5px 8px;
  background: var(--bg-deep);
  border: 1px solid var(--line-2);
  color: var(--ink-dim);
  font-size: 7px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.speed-control input {
  width: 72px;
  accent-color: var(--gold);
}

.speed-control output {
  min-width: 42px;
  color: var(--ink-white);
  font-family: var(--font-mono);
  font-size: 10px;
  text-align: right;
}

.layout {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 10px 16px 16px;
}

.stage {
  flex: 1 1 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  min-height: 0;
}

.versus {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
}

.versus::before {
  content: "VS";
  grid-column: 2;
  grid-row: 1;
  place-self: center;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  color: var(--gold);
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 700;
  background: var(--bg-panel);
  border: 1px solid var(--gold);
  box-shadow:
    inset 0 0 0 1px rgba(244, 193, 74, 0.22),
    0 0 24px rgba(244, 193, 74, 0.18);
}

.vs-side {
  position: relative;
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) auto;
  grid-template-areas:
    "portrait info readouts"
    "hp hp hp"
    "cd cd cd";
  gap: 6px 10px;
  align-items: center;
  min-width: 0;
  padding: 8px;
  background: var(--bg-panel);
  border: 1px solid var(--player);
  box-shadow:
    inset 0 0 0 1px rgba(93, 214, 255, 0.18),
    inset 0 0 0 2px var(--bg-panel),
    0 0 0 1px #000,
    0 0 24px rgba(93, 214, 255, 0.12);
}

.vs-side::before,
.vs-side::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  pointer-events: none;
  color: currentColor;
}

.vs-side::before {
  top: -1px;
  left: -1px;
  border-top: 2px solid currentColor;
  border-left: 2px solid currentColor;
}

.vs-side::after {
  right: -1px;
  bottom: -1px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

.vs-right {
  grid-column: 3;
  grid-template-columns: auto minmax(0, 1fr) 62px;
  grid-template-areas:
    "readouts info portrait"
    "hp hp hp"
    "cd cd cd";
  border-color: var(--enemy);
  box-shadow:
    inset 0 0 0 1px rgba(255, 94, 114, 0.18),
    inset 0 0 0 2px var(--bg-panel),
    0 0 0 1px #000,
    0 0 24px rgba(255, 94, 114, 0.12);
}

.vs-portrait {
  grid-area: portrait;
  width: 56px;
  height: 56px;
  border-radius: 0;
  background-color: var(--bg-deep);
  border: 1px solid var(--line-2);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.vs-info {
  grid-area: info;
  display: grid;
  gap: 3px;
  min-width: 0;
}

.vs-right .vs-info {
  justify-items: end;
  text-align: right;
}

.vs-tags {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 14px;
}

.team-tag,
.vs-range,
.pick-range,
.vs-role {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
  padding: 3px 5px 4px;
  border-radius: 0;
  font-family: var(--font-pixel);
  font-size: 7px;
  line-height: 1;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: var(--bg-deep);
  border: 1px solid var(--line-2);
  opacity: 1;
}

.team-tag {
  color: var(--player);
  border-color: rgba(93, 214, 255, 0.45);
  background: var(--player-bg);
}

.vs-right .team-tag {
  color: var(--enemy);
  border-color: rgba(255, 94, 114, 0.45);
  background: var(--enemy-bg);
}

.vs-role:empty { display: none; }

.vs-range.is-melee,
.pick-range.is-melee {
  color: var(--enemy);
  border-color: rgba(255, 94, 114, 0.45);
  background: var(--enemy-bg);
}

.vs-range.is-ranged,
.pick-range.is-ranged {
  color: var(--player);
  border-color: rgba(93, 214, 255, 0.45);
  background: var(--player-bg);
}

.vs-name {
  font-family: var(--font-title);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink-white);
  letter-spacing: 0.3px;
  line-height: 1.05;
  text-shadow: none;
}

.vs-left .vs-name { color: var(--ink-white); text-align: left; }
.vs-right .vs-name { color: var(--ink-white); text-align: right; }

.vs-name.is-locked::before {
  content: "* ";
  color: var(--gold);
  text-shadow: 0 0 10px rgba(244, 193, 74, 0.55);
}

.vs-ability {
  max-width: 100%;
  color: var(--ink-soft);
  font-size: 8px;
  line-height: 1.35;
  font-weight: 400;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.vs-ability .ab2 {
  color: var(--gold);
  font-size: 0.95em;
}

.vs-readouts {
  grid-area: readouts;
  display: grid;
  gap: 4px;
  justify-items: end;
  min-width: 60px;
}

.vs-right .vs-readouts {
  justify-items: start;
}

.hp-num,
.cd-num {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-white);
  font-variant-numeric: tabular-nums;
}

.cd-num {
  color: var(--ink-dim);
}

.hp-track,
.cd-track {
  grid-area: hp;
  position: relative;
  height: 12px;
  padding: 1px;
  overflow: hidden;
  border-radius: 0;
  background: var(--bg-void);
  border: 1px solid var(--line-2);
}

.cd-track {
  grid-area: cd;
  height: 6px;
}

.hp-fill,
.cd-fill {
  display: block;
  height: 100%;
  width: 0;
  transition: width 160ms linear;
}

.hp-fill {
  background:
    repeating-linear-gradient(90deg, transparent 0 10px, rgba(0, 0, 0, 0.38) 10px 11px),
    linear-gradient(90deg, var(--hp-good) 0%, var(--hp-mid) 62%, var(--hp-low) 100%);
}

.hp-track.right .hp-fill {
  margin-left: auto;
  background:
    repeating-linear-gradient(270deg, transparent 0 10px, rgba(0, 0, 0, 0.38) 10px 11px),
    linear-gradient(270deg, var(--hp-good) 0%, var(--hp-mid) 62%, var(--hp-low) 100%);
}

.cd-fill {
  background: linear-gradient(90deg, var(--player), var(--gold));
}

.cd-track.right .cd-fill {
  margin-left: auto;
  background: linear-gradient(270deg, var(--enemy), var(--gold));
}

.status-row,
.aug-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  min-height: 12px;
}

.vs-right .status-row,
.vs-right .aug-chips {
  justify-content: flex-end;
}

.status-chip,
.aug-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 5px;
  border-radius: 0;
  font-family: var(--font-pixel);
  font-size: 7px;
  line-height: 1;
  color: var(--sc, var(--gold));
  background: var(--bg-deep);
  border: 1px solid color-mix(in srgb, var(--sc, var(--gold)) 50%, transparent);
}

.aug-chip {
  color: var(--gold);
  border-color: rgba(244, 193, 74, 0.45);
}

.aug-chip-enemy {
  color: var(--enemy);
  border-color: rgba(255, 94, 114, 0.35);
  background: var(--enemy-bg);
}

.canvas-frame {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  padding: 5px;
  overflow: hidden;
  border-radius: 0;
  background: var(--bg-panel);
  border: 1px solid var(--line-2);
  box-shadow:
    inset 0 0 0 1px var(--bg-panel),
    inset 0 0 0 2px var(--line-1),
    0 0 0 1px #000;
}

.canvas-frame::before,
.canvas-frame::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  height: 1px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(244, 193, 74, 0.34), transparent);
  z-index: 1;
}

.canvas-frame::before { top: 10px; }
.canvas-frame::after { bottom: 10px; }

#arena {
  display: block;
  background: #080a12;
  border-radius: 0;
  image-rendering: pixelated;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse at center, rgba(244, 193, 74, 0.12), transparent 48%),
    rgba(3, 4, 8, 0.78);
  pointer-events: none;
}

.overlay[hidden] { display: none; }

.overlay-inner {
  display: grid;
  justify-items: center;
  gap: 8px;
  min-width: 420px;
  padding: 16px 20px;
  border-radius: 0;
  background: var(--bg-panel);
  border: 1px solid var(--gold);
  box-shadow:
    inset 0 0 0 1px rgba(244, 193, 74, 0.22),
    0 0 40px rgba(244, 193, 74, 0.28),
    4px 4px 0 #000;
}

.overlay-kicker {
  order: 1;
  font-size: 8px;
  color: var(--gold);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.overlay-title {
  order: 2;
  font-family: var(--font-title);
  font-size: 58px;
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: 2px;
  color: var(--c, var(--gold));
  text-shadow: 0 0 28px color-mix(in srgb, var(--c, var(--gold)) 60%, transparent), 3px 3px 0 #000;
}

.overlay-sub {
  order: 3;
  min-height: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
}

.pick-overlay,
.reel-overlay,
.select-overlay,
.card-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background:
    radial-gradient(ellipse 80% 60% at 50% 20%, rgba(93, 214, 255, 0.04), transparent 60%),
    radial-gradient(ellipse 80% 60% at 50% 100%, rgba(244, 193, 74, 0.06), transparent 60%),
    rgba(8, 9, 15, 0.96);
  backdrop-filter: blur(8px);
}

.pick-overlay[hidden],
.reel-overlay[hidden],
.select-overlay[hidden],
.card-overlay[hidden] {
  display: none;
}

.pick-overlay {
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: center;
  justify-items: center;
  gap: 18px;
  padding: 24px;
}

.pick-kicker,
.select-kicker,
.card-kicker {
  color: var(--gold);
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  text-align: center;
}

.pick-kicker::before,
.pick-kicker::after,
.select-kicker::before,
.card-kicker::before {
  color: var(--gold);
}

.pick-kicker::before,
.select-kicker::before,
.card-kicker::before { content: "> "; }
.pick-kicker::after { content: " <"; }

.pick-grid {
  display: grid;
  grid-template-columns: 1fr 90px 1fr;
  gap: 22px;
  max-width: 720px;
  width: 100%;
  align-items: center;
}

.pick-grid::before {
  content: "VS";
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
  color: var(--gold);
  font-family: var(--font-title);
  font-size: 36px;
  font-weight: 700;
  text-shadow: 0 0 16px rgba(244, 193, 74, 0.45);
}

.pick-card {
  position: relative;
  appearance: none;
  display: grid;
  justify-items: center;
  gap: 10px;
  min-height: 300px;
  padding: 16px 14px;
  border-radius: 0;
  border: 1px solid var(--c, var(--line-3));
  background: var(--bg-panel);
  color: var(--ink-white);
  font-family: inherit;
  cursor: pointer;
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--c, var(--gold)) 22%, transparent),
    0 0 0 1px #000,
    0 0 24px color-mix(in srgb, var(--c, var(--gold)) 18%, transparent);
}

.pick-card:first-child { grid-column: 1; }
.pick-card:last-child { grid-column: 3; }

.pick-card:hover,
.pick-card:focus-visible {
  outline: none;
  transform: translateY(-3px);
  box-shadow:
    inset 0 0 0 1px var(--c, var(--gold)),
    0 0 0 1px #000,
    0 0 34px color-mix(in srgb, var(--c, var(--gold)) 38%, transparent);
}

.pick-portrait {
  width: 96px;
  height: 96px;
  border-radius: 0;
  border: 1px solid var(--line-2);
  background-color: var(--bg-deep);
  box-shadow: inset 0 0 0 1px var(--c, var(--gold)), 0 0 18px color-mix(in srgb, var(--c, var(--gold)) 42%, transparent);
}

.pick-name {
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink-white);
  text-align: center;
}

.pick-ability {
  color: var(--ink-soft);
  font-size: 9px;
  line-height: 1.45;
  text-align: center;
  max-width: 250px;
}

.pick-hint {
  max-width: 520px;
  margin: 0;
  padding: 7px 10px;
  color: var(--ink-dim);
  font-size: 8px;
  letter-spacing: 0.6px;
  text-align: center;
  background: var(--bg-deep);
  border: 1px solid var(--line-2);
}

.reel-overlay {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  justify-items: center;
  gap: 24px;
  padding: 24px;
}

.reel {
  width: 340px;
  height: 270px;
  overflow: hidden;
  position: relative;
  border-radius: 0;
  border: 1px solid var(--line-2);
  background: var(--bg-panel);
  box-shadow: inset 0 0 0 1px var(--bg-panel), 0 0 0 1px #000, 0 18px 50px rgba(0, 0, 0, 0.58);
  -webkit-mask-image: linear-gradient(180deg, transparent 0, black 20%, black 80%, transparent 100%);
          mask-image: linear-gradient(180deg, transparent 0, black 20%, black 80%, transparent 100%);
}

.reel::after {
  content: "";
  position: absolute;
  left: -1px;
  right: -1px;
  top: 50%;
  height: 90px;
  transform: translateY(-50%);
  border: 1px solid var(--gold);
  pointer-events: none;
  box-shadow: inset 0 0 12px rgba(244, 193, 74, 0.18);
}

.reel-card {
  flex: 0 0 90px;
  height: 90px;
  display: grid;
  grid-template-columns: 64px 1fr;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.045);
}

.reel-card-portrait {
  width: 64px;
  height: 64px;
  border-radius: 0;
  border: 1px solid var(--line-2);
  display: grid;
  place-items: center;
  overflow: hidden;
  background-color: var(--bg-deep);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--c, var(--gold)) 45%, transparent),
    0 0 16px color-mix(in srgb, var(--c, var(--gold)) 36%, transparent);
}

.reel-card-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.reel-card-name {
  font-family: var(--font-title);
  font-size: 17px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reel-card-role {
  margin-top: 2px;
  color: var(--ink-dim);
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.reel-vs {
  color: var(--gold);
  font-family: var(--font-title);
  font-size: 42px;
  font-weight: 700;
  letter-spacing: 1px;
  text-shadow: 0 0 18px rgba(244, 193, 74, 0.5);
}

.select-overlay {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  justify-content: flex-start;
  overflow-y: auto;
  padding: 18px;
  z-index: 1200;
}

.select-header,
.select-columns {
  width: 100%;
  max-width: 1100px;
}

.select-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-link {
  color: var(--ink-dim);
  background: transparent;
  border: 1px solid var(--line-2);
  padding: 6px 9px;
  font-family: var(--font-pixel);
  font-size: 8px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.select-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.select-col {
  padding: 12px;
  background: var(--bg-panel);
  border: 1px solid var(--line-2);
  box-shadow: inset 0 0 0 1px var(--bg-panel), inset 0 0 0 2px var(--line-1);
}

.select-col:first-child {
  border-color: var(--player);
}

.select-col:last-child {
  border-color: var(--enemy);
}

.select-col-title {
  margin-bottom: 10px;
  color: var(--ink-dim);
  font-family: var(--font-title);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.select-actions { margin-bottom: 8px; }

.select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 5px;
}

.select-tile {
  display: grid;
  justify-items: center;
  gap: 4px;
  min-height: 72px;
  padding: 6px 4px;
  border-radius: 0;
  border: 1px solid var(--line-2);
  background: var(--bg-panel);
  color: var(--ink-soft);
  font-family: var(--font-pixel);
  cursor: pointer;
}

.select-tile:hover {
  background: var(--bg-panel-2);
  border-color: var(--line-3);
}

.select-tile[data-selected="true"] {
  color: var(--ink-white);
  background: color-mix(in srgb, var(--c, var(--gold)) 16%, var(--bg-panel));
  border-color: var(--c, var(--gold));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c, var(--gold)) 35%, transparent);
}

.select-tile .tile-portrait {
  width: 42px;
  height: 42px;
  border-radius: 0;
  border: 1px solid var(--line-2);
  background: var(--bg-deep);
}

.select-tile .tile-name {
  max-width: 100%;
  font-size: 7px;
  line-height: 1.15;
  text-align: center;
  overflow-wrap: anywhere;
}

#selectGoBtn {
  width: min(260px, 100%);
}

.card-overlay {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 18px;
  padding: 24px;
}

.card-header {
  display: grid;
  justify-items: center;
  gap: 6px;
}

.card-round {
  color: var(--gold);
  font-family: var(--font-title);
  font-size: 24px;
  font-weight: 700;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 220px));
  gap: 20px;
  justify-content: center;
  width: 100%;
  max-width: 760px;
}

.card {
  position: relative;
  display: grid;
  gap: 8px;
  min-height: 220px;
  padding: 0 0 12px;
  border-radius: 0;
  border: 1px solid var(--line-3);
  background: var(--bg-panel);
  color: var(--ink-white);
  font-family: inherit;
  text-align: center;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.025), 0 0 0 1px #000;
}

.card:hover,
.card:focus-visible {
  outline: none;
  transform: translateY(-6px);
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(244, 193, 74, 0.22), 0 0 24px rgba(244, 193, 74, 0.28);
}

.card-tier {
  display: block;
  padding: 7px 10px;
  color: var(--gold);
  background: var(--bg-deep);
  border-bottom: 1px solid rgba(244, 193, 74, 0.24);
  font-size: 7px;
  letter-spacing: 1px;
}

.card-name {
  padding: 8px 12px 0;
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 700;
}

.card-effect,
.card-drawback {
  padding: 0 14px;
  font-size: 9px;
  line-height: 1.45;
}

.card-effect { color: var(--ink-soft); }
.card-drawback { color: var(--enemy); font-style: normal; }

.card-enemy {
  max-width: 720px;
  color: var(--enemy);
  font-size: 8px;
  text-align: center;
}

.card-effect-mini {
  color: var(--ink-soft);
  font-size: 8px;
}

@media (max-width: 860px) {
  .topbar {
    grid-template-columns: 1fr auto auto;
  }

  .brand-lockup {
    min-width: 0;
  }

  .credits,
  .speed-control {
    display: none;
  }

  .match-strip {
    overflow-x: auto;
    scrollbar-width: none;
  }

  .versus {
    grid-template-columns: 1fr 1fr;
  }

  .versus::before {
    display: none;
  }

  .vs-right {
    grid-column: auto;
  }

  .vs-side,
  .vs-right {
    grid-template-columns: 46px minmax(0, 1fr);
    grid-template-areas:
      "portrait info"
      "readouts readouts"
      "hp hp"
      "cd cd";
    padding: 6px;
    gap: 5px 7px;
  }

  .vs-right .vs-info,
  .vs-right .vs-readouts {
    justify-items: start;
    text-align: left;
  }

  .vs-portrait {
    width: 42px;
    height: 42px;
  }

  .vs-name {
    font-size: 13px;
  }

  .vs-ability {
    font-size: 7px;
    -webkit-line-clamp: 2;
  }

  .vs-role,
  .vs-range {
    display: none;
  }

  .card-grid,
  .pick-grid,
  .select-columns {
    grid-template-columns: 1fr;
  }

  .pick-grid::before {
    grid-column: 1;
    grid-row: 2;
    font-size: 24px;
  }

  .pick-card:first-child,
  .pick-card:last-child {
    grid-column: 1;
  }

  .pick-card:first-child { grid-row: 1; }
  .pick-card:last-child { grid-row: 3; }
}

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

  .brand-title {
    font-size: 13px;
  }

  .brand-sub,
  .meta-label,
  .result-chip {
    display: none;
  }

  .btn {
    min-height: 30px;
    padding: 7px 9px;
    font-size: 8px;
  }

  .layout {
    padding: 8px;
  }

  .stage {
    gap: 8px;
  }

  .hp-track { height: 9px; }

  .canvas-frame { padding: 4px; }

  .overlay-inner {
    min-width: 0;
    width: calc(100% - 36px);
  }

  .overlay-title {
    font-size: 42px;
  }

  .reel-overlay {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto 1fr;
    gap: 12px;
    padding: 16px;
  }

  .reel {
    width: 100%;
    max-width: 320px;
    height: 160px;
  }

  .reel::after {
    height: 56px;
  }

  .reel-card {
    flex-basis: 56px;
    height: 56px;
    grid-template-columns: 36px 1fr;
  }

  .reel-card-portrait {
    width: 36px;
    height: 36px;
  }
}

/* ============================================================
   auditU structural fidelity pass
   Makes the live app match the proposed artboards, not just the
   color tokens: floating top panel, compact match strip, smaller
   versus cards, centered arena, and stronger overlay composition.
   ============================================================ */

body {
  min-height: 100%;
  background:
    radial-gradient(ellipse 80% 56% at 50% 10%, rgba(93, 214, 255, 0.045) 0%, transparent 62%),
    radial-gradient(ellipse 74% 50% at 50% 104%, rgba(244, 193, 74, 0.055) 0%, transparent 64%),
    radial-gradient(ellipse at center, #11141f 0%, var(--bg-void) 82%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(126, 132, 160, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(126, 132, 160, 0.045) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: radial-gradient(ellipse at center, #000 0%, transparent 86%);
}

.app {
  position: relative;
  grid-template-rows: auto minmax(0, 1fr);
  background: transparent;
}

.topbar {
  width: min(1500px, calc(100% - 40px));
  min-height: 68px;
  margin: 14px auto 12px;
  padding: 10px 14px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 1px solid var(--line-2);
  background: rgba(20, 24, 38, 0.96);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.025),
    inset 0 0 0 1px var(--bg-panel),
    inset 0 0 0 2px var(--line-1),
    0 0 0 1px #000,
    0 18px 46px rgba(0, 0, 0, 0.28);
}

.brand-lockup {
  order: 1;
  flex: 0 0 auto;
  min-width: 158px;
  padding-right: 14px;
  border-right: 1px solid var(--line-2);
}

.brand-mark {
  width: 24px;
  height: 24px;
}

.brand-title {
  font-size: 18px;
}

.brand-sub {
  font-size: 8px;
}

.match-strip {
  order: 2;
  flex: 1 1 360px;
  grid-column: auto;
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 360px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.meta-block {
  min-width: auto;
  gap: 3px;
}

.meta-label {
  font-size: 8px;
  color: var(--ink-dim);
}

.meta-value {
  font-size: 14px;
}

.score-line {
  margin-left: auto;
  padding-left: 10px;
  color: var(--ink-white);
  font-size: 15px;
}

.result-chip {
  padding: 6px 9px;
  color: var(--ink-dim);
  background: transparent;
}

.credits {
  order: 3;
  flex: 0 0 auto;
  min-height: 36px;
  padding: 5px 12px 5px 9px;
  font-size: 20px;
}

.mode-segment {
  order: 4;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  padding: 1px;
  background: var(--bg-deep);
  border: 1px solid var(--line-2);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.018);
}

.mode-segment-btn {
  appearance: none;
  min-height: 34px;
  padding: 8px 13px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink-dim);
  font-family: var(--font-pixel);
  font-size: 10px;
  line-height: 1;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  white-space: nowrap;
}

button.mode-segment-btn {
  cursor: pointer;
}

.mode-segment-btn.is-active,
.mode-segment-btn[data-mode="random"] {
  color: var(--gold);
  background: var(--bg-elev);
}

.mode-segment-btn[data-mode="choice"] {
  color: var(--lime);
  background: var(--bg-elev);
}

.mode-segment-ghost {
  pointer-events: none;
}

.speed-control {
  order: 5;
  flex: 0 0 auto;
  width: 162px;
  min-height: 36px;
  height: 36px;
  grid-template-columns: auto 72px auto;
  gap: 8px;
  padding: 5px 9px;
  font-size: 8px;
}

.speed-control input {
  grid-column: auto;
  width: 72px;
}

.speed-control output {
  min-width: 0;
  font-size: 12px;
}

#startBtn {
  order: 6;
  flex: 0 0 auto;
  min-width: 112px;
  min-height: 42px;
  padding: 12px 20px;
  font-size: 13px;
}

.layout {
  width: min(1500px, calc(100% - 40px));
  margin: 0 auto 16px;
  padding: 0;
}

.stage {
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

.versus {
  grid-template-columns: minmax(0, 1fr) 118px minmax(0, 1fr);
  gap: 14px;
  height: 170px;
  min-height: 170px;
}

.versus::before {
  width: 78px;
  height: 78px;
  font-size: 24px;
  place-self: center;
  box-shadow:
    inset 0 0 0 1px rgba(244, 193, 74, 0.22),
    0 0 0 1px #000,
    0 0 28px rgba(244, 193, 74, 0.20);
}

.versus::after {
  content: "LIVE DUEL";
  grid-column: 2;
  grid-row: 1;
  align-self: end;
  justify-self: center;
  margin-bottom: 13px;
  color: var(--ink-dim);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.vs-side {
  height: 170px;
  min-height: 170px;
  padding: 10px;
  grid-template-columns: 82px minmax(0, 1fr) auto;
  grid-template-rows: auto 6px;
  grid-template-areas:
    "portrait info readouts"
    "cd cd cd";
  gap: 7px 12px;
  overflow: hidden;
}

.vs-right {
  grid-template-columns: auto minmax(0, 1fr) 82px;
  grid-template-areas:
    "readouts info portrait"
    "cd cd cd";
}

.vs-portrait {
  width: 80px;
  height: 80px;
}

.vs-info {
  gap: 5px;
  align-self: stretch;
  align-content: start;
  min-height: 0;
}

.team-tag,
.vs-range,
.pick-range,
.vs-role {
  padding: 4px 6px;
  font-size: 8px;
}

.vs-name {
  display: block;
  font-size: 21px;
  line-height: 1;
  min-height: 22px;
  color: var(--ink-white);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vs-ability {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 4px;
  width: min(100%, 520px);
  min-height: 62px;
  max-height: 68px;
  padding: 6px 7px;
  color: var(--ink-soft);
  font-size: 9px;
  line-height: 1.18;
  background: rgba(8, 9, 15, 0.42);
  border: 1px solid var(--line-2);
  overflow: hidden;
}

.vs-right .vs-ability {
  justify-self: end;
  text-align: right;
}

.vs-ability .spell-row {
  display: grid;
  grid-template-columns: auto minmax(72px, auto) minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.vs-right .vs-ability .spell-row {
  grid-template-columns: minmax(0, 1fr) minmax(72px, auto) auto;
}

.vs-right .vs-ability .spell-row b {
  grid-column: 3;
  grid-row: 1;
}

.vs-right .vs-ability .spell-row .ab1,
.vs-right .vs-ability .spell-row .ab2 {
  grid-column: 2;
  grid-row: 1;
}

.vs-right .vs-ability .spell-row .ab-desc {
  grid-column: 1;
  grid-row: 1;
}

.vs-ability .spell-row b {
  padding: 2px 4px;
  color: var(--ink-dim);
  background: var(--bg-deep);
  border: 1px solid var(--line-2);
  font-family: var(--font-pixel);
  font-size: 7px;
  line-height: 1;
}

.vs-ability .ab1 {
  color: var(--gold);
  font-family: var(--font-title);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.5px;
}

.vs-ability .ab2 {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 4px;
  color: var(--violet);
  background: #1c1530;
  border: 1px solid rgba(183, 148, 255, 0.36);
  font-family: var(--font-title);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.vs-ability .ab-desc {
  display: -webkit-box;
  color: var(--ink-soft);
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-width: 0;
}

.vs-readouts {
  align-self: center;
}

.hp-num,
.cd-num {
  font-size: 13px;
}

.status-row,
.aug-chips {
  min-height: 0;
  max-height: 15px;
  overflow: hidden;
}

.hp-track {
  height: 13px;
}

.vs-info .hp-track-main {
  grid-area: auto;
  width: min(100%, 440px);
  height: 17px;
  margin: 1px 0 2px;
  padding: 2px;
  border-color: color-mix(in srgb, var(--player) 45%, var(--line-2));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.025),
    0 0 12px rgba(93, 214, 255, 0.14);
}

.vs-right .vs-info .hp-track-main {
  justify-self: end;
  border-color: color-mix(in srgb, var(--enemy) 45%, var(--line-2));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.025),
    0 0 12px rgba(255, 94, 114, 0.14);
}

.cd-track {
  height: 6px;
}

.canvas-frame {
  --arena-max-h: calc(100dvh - 294px);
  align-self: start;
  justify-self: center;
  width: min(100%, 1420px, calc(var(--arena-max-h) * 1.785714));
  height: auto;
  aspect-ratio: 1000 / 560;
  max-height: var(--arena-max-h);
  padding: 4px;
  background: var(--bg-panel);
}

.canvas-frame::before,
.canvas-frame::after {
  left: 10px;
  right: 10px;
}

.pick-overlay,
.reel-overlay,
.select-overlay,
.card-overlay {
  background:
    radial-gradient(ellipse 80% 60% at 50% 20%, rgba(93, 214, 255, 0.055) 0%, transparent 60%),
    radial-gradient(ellipse 80% 60% at 50% 100%, rgba(244, 193, 74, 0.055) 0%, transparent 60%),
    rgba(8, 9, 15, 0.97);
}

.pick-overlay {
  align-content: center;
  gap: 18px;
}

.pick-kicker {
  margin: 0;
  color: var(--gold);
}

.pick-kicker::before {
  content: "MISE EN JEU · ";
}

.pick-grid {
  grid-template-columns: minmax(240px, 340px) 86px minmax(240px, 340px);
  gap: 20px;
  max-width: 820px;
  align-items: center;
}

.pick-grid::before {
  content: "VS";
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
  align-self: center;
  color: var(--gold);
  font-family: var(--font-title);
  font-size: 36px;
  text-shadow: 0 0 14px rgba(244, 193, 74, 0.42);
}

.pick-card:first-child { grid-column: 1; }
.pick-card:last-child { grid-column: 3; }

.pick-card {
  min-height: 250px;
  padding: 12px;
  border-width: 1px;
  border-radius: 0;
  background: var(--bg-panel);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.025),
    inset 0 0 0 2px var(--line-1),
    0 0 0 1px #000;
}

.pick-portrait {
  width: 76px;
  height: 76px;
  border-radius: 0;
}

.pick-name {
  font-family: var(--font-title);
  font-size: 22px;
}

.pick-hint {
  margin: 0;
  padding: 6px 10px;
  max-width: none;
  color: var(--ink-soft);
  background: var(--bg-panel);
  border: 1px solid var(--line-2);
}

.card-grid {
  max-width: 820px;
  grid-template-columns: repeat(3, minmax(0, 240px));
}

.card {
  min-height: 220px;
  border-radius: 0;
}

@media (max-width: 980px) {
  .topbar {
    flex-wrap: wrap;
  }

  .match-strip {
    order: 7;
    flex-basis: 100%;
  }

  .versus {
    grid-template-columns: 1fr 1fr;
  }

  .versus::before,
  .versus::after {
    display: none;
  }

  .vs-right {
    grid-column: auto;
  }
}
