:root {
  color-scheme: dark;
  --ink: #10130f;
  --surface: #191d18;
  --surface-2: #252b23;
  --cream: #f6edcf;
  --muted: #c9c3ad;
  --red: #c9362b;
  --red-bright: #ef4a3d;
  --gold: #f0b83f;
  --green: #426c49;
  --line: rgba(246, 237, 207, 0.22);
  --focus: #ffe65c;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: var(--ink);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--cream);
  background:
    linear-gradient(rgba(246, 237, 207, 0.025) 1px, transparent 1px) 0 0 / 100% 5px,
    linear-gradient(90deg, transparent 49.8%, rgba(240, 184, 63, 0.035) 50%, transparent 50.2%) 0 0 / 48px 48px,
    var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
button:focus-visible, a:focus-visible, canvas:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 50;
  min-height: 44px;
  padding: 0.7rem 1rem;
  color: var(--ink);
  background: var(--focus);
  font-weight: 900;
  text-decoration: none;
  transform: translateY(-180%);
}

.skip-link:focus { transform: translateY(0); }
.site-header, main, footer { width: min(1480px, calc(100% - 3rem)); margin-inline: auto; }

.site-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 78px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 0.75rem;
  min-height: 52px;
  color: var(--cream);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 2px solid var(--cream);
  color: var(--ink);
  background: var(--gold);
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 1.15rem;
  box-shadow: 4px 4px 0 var(--red);
  transform: rotate(-2deg);
}

.brand > span:last-child { display: grid; line-height: 1; }
.brand strong { color: var(--gold); font-size: 1rem; font-weight: 950; letter-spacing: 0.18em; }
.brand small { margin-top: 0.32rem; font-size: 0.55rem; font-weight: 900; letter-spacing: 0.18em; }
.line-label, .record { margin: 0; color: var(--muted); font-size: 0.64rem; font-weight: 850; letter-spacing: 0.13em; text-transform: uppercase; }
.line-label { display: flex; align-items: center; gap: 0.65rem; }
.line-label span { width: 26px; height: 2px; background: var(--red-bright); }
.record { display: grid; justify-self: end; text-align: right; }
.record strong { color: var(--cream); font-size: 0.9rem; }

main {
  display: grid;
  grid-template-columns: minmax(250px, 0.42fr) minmax(0, 1fr);
  gap: clamp(2rem, 4vw, 4.5rem);
  align-items: center;
  padding-block: clamp(2rem, 4vw, 4rem);
}

.intro { min-width: 0; }
.eyebrow { margin: 0 0 0.8rem; color: var(--gold); font-size: 0.68rem; font-weight: 950; letter-spacing: 0.17em; text-transform: uppercase; }

h1 {
  max-width: 8ch;
  margin: 0;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(4rem, 7vw, 7.2rem);
  font-weight: 900;
  letter-spacing: 0.02em;
  line-height: 0.82;
  text-transform: uppercase;
}

h1 span { display: block; color: var(--red-bright); font-size: 0.58em; letter-spacing: 0.055em; text-shadow: 3px 3px 0 var(--cream); }
.lead { max-width: 31rem; margin: 1.5rem 0 0; color: var(--muted); font-size: 0.95rem; line-height: 1.7; }
.campaign-map { display: grid; margin: 1.6rem 0 0; border-top: 1px solid var(--line); }
.campaign-map div { display: grid; grid-template-columns: 2.2rem 1fr; gap: 0.65rem; padding: 0.72rem 0; border-bottom: 1px solid var(--line); }
.campaign-map dt { color: var(--red-bright); font-family: Impact, sans-serif; font-size: 1.25rem; }
.campaign-map dd { display: grid; margin: 0; }
.campaign-map dd strong { font-size: 0.7rem; letter-spacing: 0.05em; text-transform: uppercase; }
.campaign-map dd span { margin-top: 0.15rem; color: var(--muted); font-size: 0.57rem; }

.arcade {
  min-width: 0;
  padding: 6px;
  border: 2px solid var(--cream);
  background: var(--surface);
  box-shadow: 11px 11px 0 var(--red);
}

.arcade-topbar { display: flex; justify-content: space-between; gap: 1rem; padding: 0.65rem 0.8rem; border-bottom: 1px solid var(--line); }
.arcade-topbar p { margin: 0; color: var(--muted); font-size: 0.56rem; font-weight: 900; letter-spacing: 0.11em; text-transform: uppercase; }
.signal { display: inline-block; width: 7px; height: 7px; margin-right: 0.4rem; border-radius: 50%; background: var(--red-bright); animation: pulse 1.5s ease-in-out infinite; }

.screen { position: relative; overflow: hidden; aspect-ratio: 16 / 9; background: #111712; isolation: isolate; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.hud {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px minmax(0, 1fr);
  gap: 0.65rem;
  align-items: start;
  padding: clamp(0.45rem, 1.3vw, 0.8rem);
  background: linear-gradient(rgba(8, 11, 8, 0.92), rgba(8, 11, 8, 0));
  pointer-events: none;
}

.fighter-hud { min-width: 0; }
.hud-copy { display: flex; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.25rem; text-shadow: 2px 2px #000; }
.hud-copy strong { overflow: hidden; font-size: clamp(0.58rem, 1.5vw, 0.88rem); letter-spacing: 0.05em; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.hud-copy span { color: var(--gold); font-size: clamp(0.65rem, 1.6vw, 0.9rem); }
.cpu-hud .hud-copy { flex-direction: row-reverse; }
.bar { height: clamp(8px, 1.3vw, 13px); border: 2px solid var(--cream); background: rgba(16, 19, 15, 0.9); }
.bar i { display: block; width: 100%; height: 100%; background: var(--red-bright); transform-origin: left; transition: transform 120ms linear; }
.cpu-hud .bar i { transform-origin: right; }
.bar.meter { height: clamp(5px, 0.8vw, 8px); margin-top: 0.18rem; border-width: 1px; }
.bar.meter i { width: 0; background: var(--gold); transform: none; }
.clock { display: grid; justify-items: center; text-shadow: 2px 2px #000; }
.clock > span, .clock small { color: var(--gold); font-size: clamp(0.46rem, 1vw, 0.62rem); font-weight: 950; letter-spacing: 0.08em; }
.clock strong { font-family: Impact, sans-serif; font-size: clamp(1.8rem, 4vw, 3rem); line-height: 0.95; }
.clock.is-urgent strong { color: var(--focus); animation: urgent 500ms steps(2) infinite; }

.overlay { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; overflow-y: auto; padding: clamp(0.5rem, 2vw, 1.25rem); background: rgba(10, 13, 10, 0.72); }
.panel { width: min(680px, 100%); padding: clamp(0.65rem, 1.8vw, 1.15rem); border: 2px solid var(--red-bright); background: rgba(25, 29, 24, 0.98); box-shadow: 6px 6px 0 var(--cream); }
.panel.compact { max-width: 400px; text-align: center; }
.kicker { margin: 0; color: var(--gold); font-size: clamp(0.48rem, 1vw, 0.62rem); font-weight: 950; letter-spacing: 0.16em; text-transform: uppercase; }
.panel h2 { margin: 0.25rem 0 0.65rem; font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif; font-size: clamp(1.55rem, 4vw, 2.7rem); font-weight: 900; letter-spacing: 0.04em; line-height: 0.95; text-transform: uppercase; }
.panel p:not(.kicker) { color: var(--muted); font-size: clamp(0.64rem, 1.2vw, 0.78rem); line-height: 1.5; }

.fighter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.45rem; margin-bottom: 0.65rem; }
.fighter-card { display: grid; grid-template-columns: clamp(42px, 6vw, 62px) minmax(0, 1fr); align-items: center; gap: 0.55rem; min-width: 0; min-height: 68px; padding: 0.35rem; border: 1px solid var(--line); color: var(--cream); background: var(--ink); text-align: left; cursor: pointer; }
.fighter-card:hover { border-color: var(--gold); }
.fighter-card.is-selected { border: 2px solid var(--gold); background: #332612; }
.fighter-card > span:last-child { display: grid; min-width: 0; }
.fighter-card strong { overflow: hidden; font-size: clamp(0.58rem, 1.15vw, 0.76rem); letter-spacing: 0.03em; text-overflow: ellipsis; white-space: nowrap; }
.fighter-card small { margin-top: 0.15rem; color: var(--muted); font-size: clamp(0.48rem, 0.9vw, 0.6rem); }
.fighter-card em { margin-top: 0.13rem; color: var(--gold); font-size: clamp(0.42rem, 0.78vw, 0.53rem); font-style: normal; }
.fighter-portrait { position: relative; display: block; align-self: stretch; min-height: 54px; overflow: hidden; border: 1px solid var(--cream); background: var(--green); }
.fighter-portrait::before { position: absolute; top: 8px; left: 50%; width: 24px; height: 26px; border-radius: 45% 45% 42% 42%; background: #b9784f; content: ""; transform: translateX(-50%); }
.fighter-portrait::after { position: absolute; right: 8px; bottom: -12px; left: 8px; height: 40px; border-radius: 44% 44% 0 0; background: var(--red); content: ""; }
.fighter-portrait i { position: absolute; top: 5px; left: 50%; z-index: 1; width: 28px; height: 10px; border-radius: 50% 50% 20% 20%; background: #28201d; transform: translateX(-50%); }
.fighter-portrait.centella { background: #3c6882; }
.fighter-portrait.centella::after { background: #e7b72f; }
.fighter-portrait.centella i { height: 16px; background: #151313; transform: translateX(-50%) rotate(-8deg); }
.fighter-portrait.martillo { background: #78442f; }
.fighter-portrait.martillo::before { background: #915b3d; }
.fighter-portrait.martillo::after { background: #3e5261; }
.fighter-portrait.martillo i { width: 31px; background: #202020; }
.fighter-portrait.marchanta { background: #7a3554; }
.fighter-portrait.marchanta::before { background: #c98655; }
.fighter-portrait.marchanta::after { background: #296553; }
.fighter-portrait.marchanta i { top: 2px; width: 34px; height: 20px; background: #38211c; }

.primary, .secondary { min-height: 44px; padding: 0.58rem 0.75rem; border: 0; font-size: 0.64rem; font-weight: 950; letter-spacing: 0.09em; text-transform: uppercase; cursor: pointer; }
.primary { display: flex; align-items: center; justify-content: space-between; width: 100%; border: 2px solid var(--cream); color: var(--cream); background: var(--red); }
.primary:hover { background: var(--red-bright); }
.secondary { width: 100%; border: 1px solid var(--line); color: var(--cream); background: var(--ink); }
.secondary:hover { border-color: var(--gold); }
.control-guide { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; margin: 0 0 0.6rem; background: var(--line); }
.control-guide div { display: flex; justify-content: space-between; gap: 0.5rem; padding: 0.55rem; background: var(--ink); font-size: clamp(0.52rem, 1vw, 0.66rem); }
.control-guide dt { color: var(--gold); font-weight: 950; }
.control-guide dd { margin: 0; color: var(--muted); }
.tip { margin: 0 0 0.65rem; }
.tip strong { color: var(--cream); }

.countdown, .message { background: rgba(8, 10, 8, 0.5); pointer-events: none; }
.countdown > div, .message > div { display: grid; justify-items: center; text-align: center; text-transform: uppercase; }
.countdown span, .message span { color: var(--cream); font-size: clamp(0.55rem, 1.4vw, 0.8rem); font-weight: 950; letter-spacing: 0.22em; }
.countdown strong { color: var(--focus); font-family: Impact, sans-serif; font-size: clamp(5rem, 16vw, 10rem); line-height: 0.9; text-shadow: 5px 5px 0 var(--red); animation: countdown 650ms ease-out infinite; }
.message strong { max-width: 12ch; color: var(--focus); font-family: Impact, sans-serif; font-size: clamp(2.8rem, 8vw, 5.5rem); line-height: 0.9; text-shadow: 4px 4px 0 var(--red); }
.result-panel { max-width: 520px; }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 0 0 0.7rem; background: var(--line); }
.result-stats div { display: grid; gap: 0.2rem; padding: 0.6rem; background: var(--ink); text-align: center; }
.result-stats dt { color: var(--muted); font-size: 0.52rem; letter-spacing: 0.1em; text-transform: uppercase; }
.result-stats dd { margin: 0; color: var(--gold); font-size: 1.05rem; font-weight: 950; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem; }

.controls { position: relative; z-index: 8; display: grid; grid-template-columns: 0.75fr 1fr auto; gap: 1px; border-top: 1px solid var(--red); background: var(--red); }
.move-controls, .fight-controls, .utility-controls { display: grid; gap: 1px; min-width: 0; background: var(--red); }
.move-controls { grid-template-columns: repeat(3, 1fr); }
.fight-controls { grid-template-columns: repeat(4, 1fr); }
.utility-controls { grid-template-columns: repeat(2, 48px); }
.controls button { display: flex; align-items: center; justify-content: center; gap: 0.3rem; min-width: 0; min-height: 54px; padding: 0.3rem; border: 0; color: var(--cream); background: var(--ink); font-size: clamp(0.48rem, 1vw, 0.62rem); font-weight: 900; text-transform: uppercase; touch-action: none; cursor: pointer; }
.controls button:hover:not(:disabled), .controls button.is-active { background: var(--surface-2); box-shadow: inset 0 -4px var(--gold); }
.controls button:disabled { color: #8f8b7d; cursor: not-allowed; }
.controls kbd { display: inline-grid; place-items: center; min-width: 24px; min-height: 24px; border: 1px solid var(--gold); color: var(--gold); background: transparent; font: inherit; }
.controls .special-control kbd { color: var(--red-bright); }

footer { display: flex; justify-content: space-between; padding-block: 1rem 1.5rem; border-top: 1px solid var(--line); }
footer p { margin: 0; color: var(--muted); font-size: 0.56rem; font-weight: 850; letter-spacing: 0.13em; text-transform: uppercase; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@keyframes pulse { 50% { opacity: 0.35; } }
@keyframes urgent { 50% { opacity: 0.35; } }
@keyframes countdown { from { opacity: 0; transform: scale(1.45); } to { opacity: 1; transform: scale(1); } }

@media (max-width: 1000px) {
  .site-header, main, footer { width: min(920px, calc(100% - 2rem)); }
  main { grid-template-columns: 1fr; gap: 2rem; }
  .intro { display: grid; grid-template-columns: 0.8fr 1.2fr; column-gap: 2rem; align-items: end; }
  .intro .eyebrow, .intro h1 { grid-column: 1; }
  .lead, .campaign-map { grid-column: 2; }
  .lead { grid-row: 1 / span 2; align-self: end; }
  .campaign-map { grid-row: 3; }
  .arcade { width: 100%; }
}

@media (max-width: 680px) {
  .site-header, main, footer { width: min(100% - 1rem, 620px); }
  .site-header { grid-template-columns: 1fr auto; min-height: 68px; }
  .line-label { display: none; }
  .brand-mark { width: 42px; height: 42px; }
  main { padding-block: 1.25rem 1.75rem; }
  .intro { display: block; }
  h1 { font-size: clamp(3.7rem, 19vw, 6rem); }
  .lead { margin-top: 1.2rem; }
  .campaign-map { display: none; }
  .arcade { padding: 3px; box-shadow: 6px 6px 0 var(--red); }
  .arcade-topbar { padding: 0.5rem; }
  .panel { box-shadow: 3px 3px 0 var(--cream); }
  .fighter-card { min-height: 55px; }
  .controls { grid-template-columns: 1fr auto; }
  .move-controls, .fight-controls { grid-column: 1; }
  .move-controls { grid-row: 1; }
  .fight-controls { grid-row: 2; }
  .utility-controls { grid-column: 2; grid-row: 1 / span 2; grid-template-columns: 44px; }
  .utility-controls button { min-height: 100%; }
  .controls button { min-height: 44px; }
  .controls button span { display: none; }
  footer { padding-top: 0.85rem; }
}

@media (max-width: 420px) {
  .brand small { display: none; }
  .record span { font-size: 0.5rem; }
  .arcade-topbar p:last-child { display: none; }
  .overlay { padding: 0.35rem; }
  .panel { padding: 0.3rem; }
  .select-panel > .kicker { display: none; }
  .select-panel h2 { margin-bottom: 0.25rem; font-size: 1.25rem; }
  .fighter-grid { gap: 0.25rem; margin-bottom: 0.35rem; }
  .fighter-card { grid-template-columns: 34px minmax(0, 1fr); gap: 0.3rem; min-height: 38px; padding: 0.15rem; }
  .fighter-portrait { min-height: 34px; }
  .fighter-portrait::before { top: 5px; width: 19px; height: 20px; }
  .fighter-portrait::after { right: 5px; bottom: -15px; left: 5px; height: 31px; }
  .fighter-portrait i { top: 3px; width: 22px; height: 7px; }
  .fighter-card strong { font-size: 0.47rem; }
  .fighter-card small { display: none; }
  .fighter-card em { font-size: 0.36rem; }
  .control-guide { margin-bottom: 0.35rem; }
  .control-guide div { padding: 0.35rem; }
  .tip { display: none; }
  .primary, .secondary { min-height: 32px; padding-block: 0.3rem; }
  .controls button { min-height: 42px; }
  .controls kbd { min-width: 22px; min-height: 22px; }
  footer p:last-child { display: none; }
}

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