:root {
  --ink: #fff8f2;
  --muted: #c9b7a4;
  --red: #e23b2f;
  --gold: #e6b34a;
  --panel: #161018;
  --line: rgba(255, 248, 242, 0.16);
  --bg: #07060a;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: #050308;
  color: var(--ink);
  font-family: "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
}
a { color: inherit; text-decoration: none; }
.kicker {
  margin: 0;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--gold);
}
.mark {
  width: 14px;
  height: 14px;
  background: var(--red);
  box-shadow: 5px 5px 0 var(--gold);
  flex: 0 0 auto;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: var(--red);
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
}
button.ghost {
  background: transparent;
  border: 1px solid var(--line);
}
button:hover { filter: brightness(1.08); }

.fight-app {
  height: 100%;
  position: relative;
}
.mm-brand {
  position: absolute;
  top: 18px;
  left: 24px;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 12px;
}
.mm-brand a { display: flex; align-items: center; gap: 12px; color: inherit; }
.mm-brand strong { display: block; font-size: 18px; letter-spacing: 0.04em; }
.mm-title {
  position: absolute;
  top: 14px;
  right: 28px;
  z-index: 6;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: clamp(42px, 7vw, 88px);
  letter-spacing: -0.03em;
  text-shadow: 0 8px 0 rgba(0, 0, 0, 0.35);
}
.mm-nav {
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  gap: 18px;
}
.mm-nav a {
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 13px;
}
.mm-nav a:hover { color: var(--ink); }

.fight-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: #07060a;
}
.fight-top h1 {
  margin: 0;
  font-family: Georgia, serif;
  font-size: 22px;
}
.fight-top p { margin: 2px 0 0; color: var(--muted); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.fight-top a { color: var(--gold); }
.top-links { display: flex; align-items: center; gap: 12px; }
.top-links .ghost.on { background: #141414; color: #fff; border-color: #141414; }

body.hako {
  background: #f4f5f7;
  color: #1a1c20;
  --ink: #1a1c20;
  --muted: #6b7280;
  --panel: #fff;
  --line: #d5d8de;
}
body.hako .fight-top {
  background: #fff;
  border-bottom: 2px solid #141414;
}
body.hako .fight-top p { color: #6b7280; }
body.hako .fight-top a { color: #141414; }
body.hako .stage-wrap { background: #f4f5f7; }
body.hako .bar-col,
body.hako .vs,
body.hako .train-panel {
  background: #fff;
  border: 2px solid #141414;
  box-shadow: 4px 4px 0 #141414;
  backdrop-filter: none;
}
body.hako .bar-col h2,
body.hako .vs { color: #141414; text-shadow: none; }
body.hako .moves { color: #4b5563; text-shadow: none; }
body.hako .hp { border-color: #141414; background: #f3f4f6; box-shadow: none; }
body.hako .meter { background: #eef0f3; border-color: #141414; box-shadow: none; }
body.hako .help { background: #fff; border-top: 2px solid #141414; color: #374151; }
body.hako .select { color: #1a1c20; background: #f4f5f7; }
body.hako .select-tools input,
body.hako .from-filters button,
body.hako .stage-picks button,
body.hako .pick,
body.hako .train-panel select {
  background: #fff;
  border: 2px solid #141414;
  color: #1a1c20;
}
body.hako .pick canvas { background: linear-gradient(#f7f8fa, #e6e8ee); }
body.hako .select-actions { background: linear-gradient(rgba(244, 245, 247, 0), #f4f5f7 14px); }
body.hako button.ghost { border: 2px solid #141414; color: #141414; }
body.hako .combo, body.hako .move-call { color: #141414; text-shadow: none; -webkit-text-stroke: 0; }

.stage-wrap {
  position: relative;
  height: 100%;
  min-height: 0;
  background: #050308;
}
#arena {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* display on the class below would otherwise beat the hidden attribute, so
   both panels stayed laid out behind the select screen. */
.hud[hidden], .train-panel[hidden] { display: none; }
.hud {
  pointer-events: none;
  position: absolute;
  inset: 16px 20px auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 18px;
  align-items: start;
}
.bar-col {
  padding: 10px 12px 12px;
  background: linear-gradient(180deg, rgba(8, 6, 8, 0.62), rgba(8, 6, 8, 0.28));
  border: 1px solid rgba(244, 234, 216, 0.14);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
}
.bar-col h2 {
  margin: 0 0 2px;
  font-size: 17px;
  font-family: Georgia, serif;
  text-shadow: 0 2px 0 #0a0806, 0 0 16px rgba(0, 0, 0, 0.55);
}
.moves {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 0 #0a0806;
}
.bar-col.p2 { text-align: right; }
.hp {
  height: 18px;
  border: 2px solid #f4ead8;
  background: #1a0c0a;
  overflow: hidden;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.45), 0 0 0 1px #120c08;
}
.hp > i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(180deg, #ffd56a 0%, #e23b2f 58%, #8a1810 100%);
  transform-origin: left center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.bar-col.p2 .hp > i { transform-origin: right center; margin-left: auto; }
.meter {
  margin-top: 7px;
  height: 8px;
  background: #101820;
  border: 1px solid #4a6e92;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.4);
}
.meter > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #1e5ec8, #7ed0ff);
  width: 0;
  box-shadow: 0 0 10px rgba(80, 170, 255, 0.45);
}
.guard {
  margin-top: 5px;
  height: 5px;
  background: #16120e;
  border: 1px solid #6a5a3c;
  opacity: 0;
  transition: opacity 0.2s;
}
.guard.on { opacity: 1; }
.guard > i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #f0e0a8, #d8a23c);
  transform: scaleX(1);
  transform-origin: left center;
}
.bar-col.p2 .guard > i { transform-origin: right center; }
.guard.low > i { background: linear-gradient(90deg, #ffb46a, #e2402c); }
.vs {
  text-align: center;
  font-family: Georgia, serif;
  color: var(--gold);
  font-size: 28px;
  padding: 8px 14px 10px;
  text-shadow: 0 3px 0 #1a1008, 0 0 22px rgba(230, 179, 74, 0.4);
  background: linear-gradient(180deg, rgba(8, 6, 8, 0.5), rgba(8, 6, 8, 0.18));
  border: 1px solid rgba(230, 179, 74, 0.2);
  border-radius: 12px;
}
.vs small {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.stage-picks {
  display: none;
}
.stage-picks button {
  background: #1b1814;
  border: 1px solid var(--line);
  padding: 4px 10px;
  font-size: 12px;
}
.stage-picks button.on { background: var(--red); border-color: transparent; }
/* The HUD bar owns the top ~128px of the stage. Percentages alone put these
   three on top of it whenever the stage is short, so they get a pixel floor. */
.combo {
  position: absolute;
  left: 50%;
  top: max(14%, 124px);
  transform: translateX(-50%) skewX(-8deg);
  font-size: 42px;
  font-weight: 800;
  font-family: Georgia, serif;
  color: #fff8ee;
  -webkit-text-stroke: 2px #1a0c08;
  text-shadow: 4px 4px 0 #8a2018, 0 0 28px #e23b2f;
  pointer-events: none;
  letter-spacing: 0.08em;
}
.move-call {
  position: absolute;
  left: 50%;
  top: max(26%, 178px);
  transform: translateX(-50%);
  pointer-events: none;
  font-family: Georgia, serif;
  font-size: clamp(22px, 4vw, 42px);
  letter-spacing: 0.08em;
  color: #fff8ee;
  text-shadow: 0 3px 0 #8a2018, 0 0 18px rgba(226, 59, 47, 0.45);
  text-transform: uppercase;
}
.banner {
  position: absolute;
  left: 50%;
  top: max(18%, 138px);
  transform: translateX(-50%);
  pointer-events: none;
  font-family: Georgia, serif;
  font-size: clamp(28px, 5vw, 58px);
  letter-spacing: 0.16em;
  color: #fff8ee;
  text-shadow: 0 3px 0 #8a2018, 0 0 28px rgba(226, 59, 47, 0.45);
}

.fight-app:has(#select:not(.hidden)) .help { display: none; }
.help { display: none; }
.fight-app:has(#hud:not([hidden])) .help {
  display: flex;
  padding: 8px 16px 12px;
  border-top: 1px solid var(--line);
  background: #100e0c;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.help kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: #1b1814;
}

.css-plates {
  position: absolute;
  top: 92px;
  left: 24px;
  right: 24px;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
}
.stage-wrap:has(#select.hidden) .css-plates { display: none; }
.css-plate {
  min-width: 180px;
  padding: 8px 14px;
  background: linear-gradient(90deg, rgba(8, 4, 8, 0.82), transparent);
}
.css-plate.p2 { text-align: right; background: linear-gradient(270deg, rgba(8, 4, 8, 0.82), transparent); }
.css-plate h2 { margin: 2px 0 0; font-family: Georgia, serif; font-size: 22px; }
.css-plate p { margin: 0; color: var(--muted); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; }
.css-plate.p1 h2 { color: #7eb6ff; }
.css-plate.p2 h2 { color: #ff8a7a; }
.css-vs {
  margin: 18px 0 0;
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 42px;
  color: #fff;
  text-shadow: 0 0 20px rgba(226, 59, 47, 0.6);
}

body.match-on .mm-brand,
body.match-on .mm-nav,
body.match-on .mm-title { display: none; }

/* Safety net that needs no class toggle: the page chrome shares the top strip
   with the fight HUD, so whenever the HUD is up, the chrome is gone. */
body:has(.hud:not([hidden])) .mm-brand,
body:has(.hud:not([hidden])) .mm-nav,
body:has(.hud:not([hidden])) .mm-title { display: none; }

/* Arcade and Training field a single fighter, so the P2 half of the select
   screen has nothing to say. */
body.solo-mode .css-plate.p2,
body.solo-mode .css-vs,
body.solo-mode .vs-only { display: none; }
body.solo-mode .css-plates { justify-content: flex-start; }

.score-pill {
  position: absolute;
  bottom: 18px;
  left: 20px;
  z-index: 6;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(14, 10, 14, 0.82);
  border: 1px solid var(--line);
  font-family: Georgia, serif;
  letter-spacing: 0.08em;
}
.fight-toast {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9;
  padding: 14px 26px;
  background: rgba(8, 4, 8, 0.88);
  border: 1px solid var(--gold);
  font-family: Georgia, serif;
  font-size: 22px;
  letter-spacing: 0.06em;
}
.score-pill[hidden], .fight-toast[hidden] { display: none; }
.select {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: 58%;
  background: linear-gradient(180deg, transparent, #050308 40px);
  overflow: auto;
  padding: 18px 20px 0;
  z-index: 4;
}
.select.hidden { display: none; }
.select h2 { margin: 0 0 8px; font-family: Georgia, serif; }
.select .lead { color: var(--muted); margin: 0 0 12px; }
.select-tools {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px 0 12px;
  background: #050308;
}
.select-tools select,
.select-tools input[type="search"] {
  font: inherit;
  color: inherit;
  background: #16130f;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  min-width: 200px;
}
.from-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.from-filters button {
  background: #1b1814;
  border: 1px solid var(--line);
  padding: 4px 10px;
  font-size: 12px;
}
.from-filters button.on { background: var(--red); border-color: transparent; }
.roster-count { margin: 0; color: var(--muted); font-size: 12px; }
.roster {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 8px;
}
.pick[hidden] { display: none; }
.pick {
  background: #140f16;
  border: 2px solid transparent;
  border-radius: 4px;
  padding: 4px;
  cursor: pointer;
  text-align: center;
  color: inherit;
  width: 100%;
}
.pick canvas { width: 100%; height: 88px; display: block; background: #1a1218; border-radius: 2px; }
/* One line per name keeps the roster rows even. */
.pick span {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pick .kit { display: none; }
.pick.p1 { border-color: #3d8cff; }
.pick.p2 { border-color: #e23b2f; }
.pick.both { border-color: var(--gold); }
.select-actions {
  position: sticky;
  bottom: 0;
  margin-top: 18px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  /* Cards scroll underneath this sticky bar, so the backdrop must be opaque by
     the time the buttons start, and it has to reach into the container's own
     padding — cards kept showing through below the bar otherwise. */
  margin: 18px -20px 0;
  padding: 14px 20px 20px;
  background: linear-gradient(rgba(5, 3, 8, 0), #050308 14px);
}
.select-actions label { color: var(--muted); font-size: 14px; }
.hold-chip {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.train-panel {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  background: linear-gradient(180deg, rgba(16, 13, 12, 0.82), rgba(16, 13, 12, 0.58));
  border: 1px solid rgba(244, 234, 216, 0.16);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
  pointer-events: auto;
  min-width: 180px;
}
.train-panel[hidden] { display: none; }
.train-panel p {
  margin: 0;
  color: var(--gold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 11px;
}
.train-panel label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
}
.train-panel select {
  font: inherit;
  color: inherit;
  background: #100e0c;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 6px;
}
.train-panel button { width: 100%; }

@media (max-width: 800px) {
  .roster { grid-template-columns: repeat(2, 1fr); }
  .help { font-size: 12px; }
}
