:root {
  --bg: #050008;
  --panel: #100816;
  --green: #4dff73;
  --red: #ff314f;
  --purple: #9a5cff;
  --gold: #ffd84d;
  --cyan: #4deeff;
  --ink: #f7fff8;
  --muted: rgba(247, 255, 248, 0.72);
  --line: rgba(255, 255, 255, 0.14);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.46);
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "DM Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 8%, rgba(77, 255, 115, 0.18), transparent 26%),
    radial-gradient(circle at 86% 16%, rgba(255, 49, 79, 0.16), transparent 24%),
    radial-gradient(circle at 50% 92%, rgba(154, 92, 255, 0.18), transparent 34%),
    linear-gradient(145deg, #040005 0%, #120615 46%, #030106 100%);
  overflow-x: hidden;
}
button, a, select { font: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }

/* ---- CRT + header (shared arcade chrome) ------------------------------- */
.crt-overlay {
  position: fixed; inset: 0; z-index: 30; pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 50%, rgba(0, 0, 0, 0.08) 50%),
    linear-gradient(90deg, rgba(255, 49, 79, 0.035), rgba(77, 255, 115, 0.025), rgba(77, 238, 255, 0.035));
  background-size: 100% 4px, 6px 100%;
  mix-blend-mode: screen; opacity: 0.5;
}
.site-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(5, 0, 8, 0.78); backdrop-filter: blur(14px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  display: grid; place-items: center; width: 58px; height: 38px;
  border: 1px solid rgba(77, 255, 115, 0.55); color: var(--green);
  background: rgba(77, 255, 115, 0.08);
  box-shadow: 0 0 18px rgba(77, 255, 115, 0.25), inset 0 0 18px rgba(77, 255, 115, 0.1);
  font-family: var(--mono); font-size: 12px; font-weight: 800;
}
.brand-copy { display: grid; line-height: 1; }
.brand-copy span { font-weight: 900; text-transform: uppercase; }
.brand-copy small { margin-top: 4px; color: var(--muted); font-family: var(--mono); font-size: 11px; text-transform: uppercase; }
.site-nav { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.site-nav a {
  min-height: 36px; padding: 9px 12px; border: 1px solid transparent;
  color: var(--muted); font-size: 13px; font-weight: 800; text-transform: uppercase;
}
.site-nav a:hover, .site-nav a:focus-visible {
  border-color: rgba(154, 92, 255, 0.45); color: var(--ink);
  background: rgba(154, 92, 255, 0.12); outline: none;
}

.arcade-shell { width: min(1440px, 100%); margin: 0 auto; padding: clamp(12px, 2.2vw, 28px); }

/* ---- Hero copy --------------------------------------------------------- */
.fight-hero {
  display: grid;
  grid-template-columns: minmax(260px, 0.58fr) minmax(360px, 1.42fr);
  gap: clamp(18px, 3vw, 34px); align-items: center;
  min-height: calc(100svh - 78px); padding-bottom: clamp(14px, 2vw, 24px);
}
.game-copy { min-width: 0; display: grid; gap: 16px; align-content: center; }
.eyebrow {
  color: var(--green); font-family: var(--mono); font-size: 12px; font-weight: 900;
  text-transform: uppercase; text-shadow: 0 0 16px rgba(77, 255, 115, 0.56);
}
h1 {
  max-width: 9ch; font-size: clamp(42px, 5.7vw, 82px); line-height: 0.88; text-transform: uppercase;
  text-shadow: 4px 0 0 rgba(255, 49, 79, 0.54), -4px 0 0 rgba(77, 238, 255, 0.38), 0 0 30px rgba(154, 92, 255, 0.42);
}
.tagline { max-width: 30ch; color: rgba(247, 255, 248, 0.86); font-size: clamp(17px, 1.8vw, 24px); font-weight: 900; line-height: 1.18; }
.copy-note { max-width: 42ch; color: var(--muted); font-size: 14px; line-height: 1.5; }
.hero-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(108px, 1fr)); gap: 10px; width: min(100%, 460px); }
.hero-stats span {
  display: flex; align-items: baseline; gap: 7px; min-height: 38px; padding: 8px 11px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06);
  color: var(--muted); font-family: var(--mono); font-size: 12px; text-transform: uppercase;
}
.hero-stats strong { color: var(--gold); font-size: 18px; }

/* ---- Cabinet ----------------------------------------------------------- */
.fight-cabinet {
  position: relative; min-width: 0; overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 16%),
    linear-gradient(145deg, rgba(255, 49, 79, 0.18), rgba(154, 92, 255, 0.12) 40%, rgba(77, 255, 115, 0.1)),
    var(--panel);
  box-shadow: var(--shadow), 0 0 55px rgba(255, 49, 79, 0.16);
}
.fight-cabinet::before { content: ""; position: absolute; inset: 8px; border: 1px solid rgba(255, 49, 79, 0.22); pointer-events: none; }
.cabinet-marquee {
  position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 18px; border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  background: linear-gradient(90deg, rgba(255, 49, 79, 0.2), rgba(154, 92, 255, 0.16), rgba(77, 255, 115, 0.14)), rgba(0, 0, 0, 0.26);
  font-family: var(--mono); font-size: 14px; font-weight: 900; text-transform: uppercase;
}
.marquee-blink { color: var(--red); animation: blink 0.9s steps(2) infinite; }

/* ---- Fight HUD: health bars + meter + round pips ----------------------- */
.fight-hud {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: start;
  padding: 12px 14px 6px;
}
.hud-fighter { min-width: 0; display: grid; gap: 5px; }
.health-track {
  position: relative; height: 22px; overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.3); border-radius: 4px;
  background: rgba(0, 0, 0, 0.45); transform: skewX(-14deg);
}
.health-chip, .health-fill {
  position: absolute; inset: 0; width: 100%; transform-origin: left;
  border-radius: 2px;
}
.health-chip { background: rgba(255, 255, 255, 0.55); transition: width 480ms ease 120ms; }
.health-fill {
  background: linear-gradient(90deg, var(--red), var(--gold) 65%, var(--green));
  box-shadow: 0 0 14px rgba(255, 216, 77, 0.5); transition: width 120ms linear;
}
.health-track.is-right { transform: skewX(14deg); }
.health-track.is-right .health-fill, .health-track.is-right .health-chip {
  left: auto; right: 0; transform-origin: right;
  background: linear-gradient(270deg, var(--red), var(--gold) 65%, var(--green));
}
.health-track.is-right .health-chip { background: rgba(255, 255, 255, 0.55); }
.hud-meta { display: flex; align-items: center; gap: 8px; }
.hud-meta.is-right { justify-content: flex-end; }
.hud-meta strong { font-size: clamp(13px, 2vw, 17px); text-transform: uppercase; letter-spacing: 0.02em; }
.round-pips { display: inline-flex; gap: 4px; }
.pip { width: 11px; height: 11px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.4); background: rgba(0, 0, 0, 0.4); }
.pip.is-won { background: radial-gradient(circle at 35% 30%, #fff, var(--gold) 70%); box-shadow: 0 0 10px rgba(255, 216, 77, 0.7); border-color: var(--gold); }
.special-track { height: 6px; overflow: hidden; border: 1px solid rgba(77, 238, 255, 0.35); border-radius: 999px; background: rgba(0, 0, 0, 0.4); }
.special-fill { display: block; width: 0%; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--purple)); box-shadow: 0 0 10px rgba(77, 238, 255, 0.6); transition: width 140ms linear; }
.special-track.is-right { direction: rtl; }
.special-track.is-right .special-fill { background: linear-gradient(270deg, var(--cyan), var(--purple)); }
.hud-center { display: grid; place-items: center; gap: 2px; padding: 0 6px; }
.hud-center strong {
  font-family: var(--mono); font-size: clamp(26px, 4vw, 38px); line-height: 1; color: var(--ink);
  text-shadow: 0 0 18px rgba(255, 49, 79, 0.5);
}
.hud-center span { font-family: var(--mono); font-size: 10px; color: var(--muted); text-transform: uppercase; }
.icon-btn {
  position: absolute; top: 10px; right: 14px; z-index: 2;
  display: grid; place-items: center; width: 44px; min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.22); border-radius: 8px;
  background: rgba(255, 255, 255, 0.07); color: var(--ink); cursor: pointer; font-size: 17px;
}
.icon-btn .sfx-off { display: inline; } .icon-btn .sfx-on { display: none; }
.icon-btn.is-on .sfx-off { display: none; } .icon-btn.is-on .sfx-on { display: inline; }

/* ---- Screen + canvas --------------------------------------------------- */
.screen-wrap {
  position: relative; z-index: 1;
  width: min(calc(100% - 24px), calc(min(60svh, 660px) * 16 / 9));
  margin: 0 auto; overflow: hidden; aspect-ratio: 16 / 9; max-height: min(60svh, 660px);
  border: 1px solid rgba(255, 49, 79, 0.34); background: #050008;
  box-shadow: inset 0 0 34px rgba(255, 49, 79, 0.12);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
#tk-canvas { display: block; width: 100%; height: 100%; background: #0a0510; }

/* ---- Announce banner (ROUND 1 / FIGHT / K.O. / FINISH) ----------------- */
.tk-announce {
  position: absolute; inset: 0; z-index: 5; display: grid; place-items: center;
  font-family: var(--font); font-weight: 900; text-transform: uppercase;
  font-size: clamp(38px, 9vw, 96px); line-height: 0.9; text-align: center;
  color: var(--ink); pointer-events: none; opacity: 0; transform: scale(0.6);
  text-shadow: 5px 0 0 rgba(255, 49, 79, 0.7), -5px 0 0 rgba(77, 238, 255, 0.5), 0 0 40px rgba(154, 92, 255, 0.6);
}
.tk-announce.is-show { animation: announcePop 0.9s cubic-bezier(0.18, 1.4, 0.4, 1) both; }
.tk-announce.is-big.is-show { animation: announceSlam 1.3s cubic-bezier(0.18, 1.4, 0.4, 1) both; color: var(--red); }
@keyframes announcePop {
  0% { opacity: 0; transform: scale(0.5) rotate(-6deg); }
  20%, 70% { opacity: 1; transform: scale(1) rotate(0deg); }
  100% { opacity: 0; transform: scale(1.2); }
}
@keyframes announceSlam {
  0% { opacity: 0; transform: scale(2.4) rotate(4deg); }
  16%, 78% { opacity: 1; transform: scale(1) rotate(-2deg); }
  100% { opacity: 0; transform: scale(0.9); }
}

/* ---- Overlays ---------------------------------------------------------- */
.game-overlay {
  position: absolute; inset: 0; z-index: 8; display: grid; place-items: center; padding: 18px; overflow: auto;
  background: radial-gradient(circle at 50% 42%, rgba(154, 92, 255, 0.26), transparent 36%), rgba(3, 0, 6, 0.82);
  opacity: 0; pointer-events: none; transition: opacity 200ms ease;
}
.game-overlay.is-visible { opacity: 1; pointer-events: auto; }
.overlay-card {
  width: min(620px, 100%); max-height: 100%; overflow: auto; padding: clamp(16px, 2.6vw, 24px);
  border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03)), rgba(14, 5, 18, 0.94);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.62);
}
.overlay-kicker { color: var(--green); font-family: var(--mono); font-size: 12px; font-weight: 900; text-transform: uppercase; }
.overlay-card h2 { margin-top: 5px; font-size: clamp(28px, 4.6vw, 46px); line-height: 0.92; text-transform: uppercase; }
.select-sub { margin-top: 8px; color: var(--muted); font-size: 14px; }

/* roster picks */
.roster-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 16px 0;
}
.roster-pick {
  --accent: var(--green);
  display: grid; justify-items: center; gap: 4px; padding: 12px 8px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 10px; color: var(--ink);
  background: rgba(255, 255, 255, 0.05); transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}
.roster-pick:hover, .roster-pick:focus-visible {
  transform: translateY(-3px); border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent); outline: none;
}
.roster-pick.is-active {
  border-color: var(--accent); background: color-mix(in srgb, var(--accent) 22%, transparent);
  box-shadow: 0 0 24px color-mix(in srgb, var(--accent) 40%, transparent);
}
.roster-pick .portrait { width: 84px; height: 84px; object-fit: contain; }
.roster-pick strong { font-size: 14px; text-transform: uppercase; }
.pick-tag { color: var(--muted); font-family: var(--mono); font-size: 10px; text-transform: uppercase; }

.select-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 6px; }
.select-readout { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 13px; }
.select-readout strong { color: var(--gold); }
.vs-dot { color: var(--red); font-weight: 900; }
.select-actions { display: flex; align-items: center; gap: 12px; }
.cpu-diff { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-family: var(--mono); font-size: 11px; text-transform: uppercase; }
.cpu-diff select {
  padding: 7px 8px; border: 1px solid var(--line); border-radius: 7px;
  background: rgba(0, 0, 0, 0.5); color: var(--ink); font-family: var(--mono); font-size: 12px;
}

/* buttons */
.primary-btn, .secondary-btn {
  position: relative; min-height: 46px; padding: 12px 18px; border-radius: 10px;
  border: 1px solid rgba(77, 255, 115, 0.62); color: #08020a; cursor: pointer;
  font-weight: 900; text-transform: uppercase;
  background: linear-gradient(135deg, rgba(77, 255, 115, 0.92), rgba(255, 216, 77, 0.94));
  box-shadow: 0 0 26px rgba(77, 255, 115, 0.26);
  transition: transform 120ms ease, box-shadow 160ms ease, filter 160ms ease;
}
.secondary-btn { border-color: var(--line); color: var(--ink); background: rgba(255, 255, 255, 0.08); box-shadow: none; }
.primary-btn:hover, .primary-btn:focus-visible, .secondary-btn:hover, .secondary-btn:focus-visible {
  transform: translateY(-2px); outline: 2px solid rgba(77, 238, 255, 0.34); outline-offset: 2px;
}
.primary-btn:active, .secondary-btn:active { transform: translateY(1px) scale(0.985); }
.primary-btn:disabled { cursor: not-allowed; filter: grayscale(0.7); opacity: 0.55; transform: none; }
.pulse-btn:not(:disabled) { animation: btnPulse 1.8s ease-in-out infinite; }
@keyframes btnPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(77, 255, 115, 0.5); } 50% { box-shadow: 0 0 0 10px rgba(77, 255, 115, 0); } }

/* result overlay */
.result-card { position: relative; text-align: center; }
.result-card h2 { color: var(--green); text-shadow: 3px 0 0 rgba(77, 238, 255, 0.32), 0 0 28px rgba(77, 255, 115, 0.52); }
.result-overlay.is-loss .result-card h2 { color: var(--red); text-shadow: 3px 0 0 rgba(77, 238, 255, 0.32), 0 0 28px rgba(255, 49, 79, 0.52); }
.result-card p { margin-top: 10px; color: var(--muted); line-height: 1.45; }
.finish-badge {
  display: inline-block; margin-bottom: 8px; padding: 6px 12px;
  border: 1px solid var(--red); border-radius: 6px; color: var(--red); background: rgba(255, 49, 79, 0.12);
  font-family: var(--mono); font-weight: 900; letter-spacing: 0.14em; text-transform: uppercase;
  animation: blink 0.7s steps(2) infinite;
}
.overlay-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 18px; }
.link-back { display: inline-block; margin-top: 14px; color: var(--green); font-family: var(--mono); font-size: 12px; }
.link-back:hover { text-decoration: underline; }

/* ---- Touch controls ---------------------------------------------------- */
.touch-controls {
  position: relative; z-index: 1; display: none; align-items: center; justify-content: space-between;
  gap: 14px; padding: 12px 14px;
}
.touch-pad { display: grid; grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(2, 52px); gap: 6px; }
.touch-pad .tbtn[data-key="left"]   { grid-area: 1 / 1 / 3 / 2; height: auto; }
.touch-pad .tbtn[data-key="up"]     { grid-area: 1 / 2 / 2 / 3; }
.touch-pad .tbtn[data-key="crouch"] { grid-area: 2 / 2 / 3 / 3; }
.touch-pad .tbtn[data-key="right"]  { grid-area: 1 / 3 / 3 / 4; height: auto; }
.touch-acts { display: grid; grid-template-columns: repeat(2, 56px); gap: 8px; }
.tbtn {
  display: grid; place-items: center; min-height: 52px;
  border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, 0.08);
  color: var(--ink); font-size: 20px; cursor: pointer; user-select: none; -webkit-user-select: none;
  touch-action: none;
}
.tbtn.is-down { background: rgba(77, 255, 115, 0.22); border-color: var(--green); transform: scale(0.94); }
.tbtn.is-punch { background: rgba(255, 216, 77, 0.14); }
.tbtn.is-kick { background: rgba(255, 49, 79, 0.14); }
.tbtn.is-special { background: rgba(77, 238, 255, 0.14); }
.tbtn.is-block { background: rgba(154, 92, 255, 0.14); }

.cabinet-footer {
  position: relative; z-index: 1; display: flex; justify-content: space-between; gap: 12px;
  padding: 12px 14px 16px; color: var(--muted); font-family: var(--mono); font-size: 11px; line-height: 1.35;
}

/* ---- Roster section (page) -------------------------------------------- */
.arcade-rack { padding: clamp(12px, 3vw, 32px) 0 24px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.section-heading h2 { font-size: clamp(28px, 4vw, 48px); line-height: 1; text-transform: uppercase; }
.game-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.roster-card {
  --accent: var(--green); position: relative; overflow: hidden; min-height: 180px; padding: 18px;
  border: 1px solid var(--line); border-radius: 8px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 16%, transparent), rgba(255, 255, 255, 0.04)), rgba(255, 255, 255, 0.05);
}
.roster-card > * { position: relative; z-index: 1; }
.roster-card-art {
  position: absolute !important; right: -14px; top: -8px; z-index: 0 !important;
  width: 96px; height: 96px; object-fit: contain; opacity: 0.5; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.4));
  transition: transform 240ms ease, opacity 240ms ease;
}
.roster-card:hover .roster-card-art { transform: scale(1.08) rotate(-4deg); opacity: 0.7; }
.roster-card span { color: var(--red); font-family: var(--mono); font-size: 12px; font-weight: 900; }
.roster-card h3 { margin-top: 22px; font-size: 22px; line-height: 1.05; text-transform: uppercase; }
.roster-card p { margin-top: 9px; color: var(--muted); line-height: 1.42; font-size: 14px; }
.special-line { font-family: var(--mono); font-size: 12px; }
.special-line strong { color: var(--gold); }

@keyframes blink { 50% { opacity: 0.25; } }

/* ---- Responsive -------------------------------------------------------- */
@media (max-width: 980px) {
  .fight-hero { min-height: 0; grid-template-columns: 1fr; align-items: start; }
  h1 { max-width: 14ch; }
  .roster-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .site-header { position: static; align-items: flex-start; flex-direction: column; }
  .site-nav { justify-content: flex-start; }
  .arcade-shell { padding: 10px; }
  .fight-hero { display: flex; flex-direction: column; gap: 14px; }
  .fight-cabinet { order: -1; }
  .game-copy { order: 1; }
  .touch-controls { display: flex; }   /* show on-screen pad on touch layouts */
  .screen-wrap { width: 100%; max-height: 46svh; }
  .hero-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .roster-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cabinet-footer { flex-direction: column; }
  .select-footer { flex-direction: column; align-items: stretch; }
  .select-actions { justify-content: space-between; }
}
@media (max-width: 430px) {
  .roster-pick .portrait { width: 64px; height: 64px; }
  .touch-pad { grid-template-columns: repeat(3, 46px); grid-template-rows: repeat(2, 46px); }
  .touch-acts { grid-template-columns: repeat(2, 50px); }
}

/* Pointer (desktop) layouts hide the touch pad */
@media (hover: hover) and (pointer: fine) {
  .touch-controls { display: none; }
}
