/* THE DUEL — one screen, one cabinet.
   Fit rules: the page itself never scrolls (html/body are exactly one viewport tall,
   overflow hidden); everything that does not fit in the arena or the command menu
   lives in a floating window, opened from a button. The two fighters are sized by the
   height of the row that is left over, so shrinking the HUD makes them bigger. */

:root {
  --night: #02020a;
  --ink: #f4f0df;
  --muted: #b7b2cf;
  --cyan: #20e7ff;
  --magenta: #ff35bd;
  --violet: #8f52ff;
  --acid: #c8ff36;
  --line: rgba(214, 218, 255, .26);
  --panel: rgba(5, 6, 20, .9);
  --mono: "IBM Plex Mono", Consolas, monospace;
  --display: "Anton", "Black Ops One", Impact, sans-serif;
}

* { box-sizing: border-box; }
html, body.duel { height: 100%; overflow: hidden; }
body.duel {
  margin: 0; color: var(--ink); background: var(--night); overscroll-behavior: none;
  font: 700 clamp(.78rem, .4vw + .66rem, .98rem)/1.45 var(--mono);
}
img { max-width: 100%; display: block; }
a { color: var(--acid); }
:focus-visible { outline: 2px solid var(--acid); outline-offset: 2px; }
.skip {
  position: fixed; z-index: 90; top: .6rem; left: .6rem; padding: .6rem .9rem;
  color: var(--night); background: var(--acid); font: 700 .78rem/1 var(--mono);
  text-decoration: none; transform: translateY(-180%);
}
.skip:focus { transform: none; }

/* ---------------- cabinet: title, hud, arena, console ---------------- */
.cabinet {
  position: relative; isolation: isolate; overflow: hidden;
  height: 100svh; padding: .45rem clamp(.5rem, 1.4vw, 1.2rem) .5rem;
  display: grid; gap: .3rem;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}
.arena-bg {
  position: absolute; inset: 0; z-index: -3; width: 100%; height: 100%;
  /* the art has to read behind the console as well, so it stays brighter than before */
  object-fit: cover; filter: saturate(1) brightness(.86) contrast(1.08);
}
.vignette {
  position: absolute; inset: 0; z-index: -2; pointer-events: none;
  /* the bottom only darkens, it never goes opaque: the console sits down here, and the
     arena has to stay visible in the gaps around its frame */
  background:
    linear-gradient(180deg, rgba(2, 2, 10, .76), transparent 18%, transparent 56%, rgba(2, 2, 10, .42) 84%, rgba(2, 2, 10, .58)),
    radial-gradient(circle at 50% 44%, transparent 0 36%, rgba(2, 2, 12, .4) 80%);
}
.crt {
  position: absolute; inset: 0; z-index: 30; pointer-events: none; opacity: .12;
  background: repeating-linear-gradient(180deg, transparent 0 3px, rgba(0, 0, 0, .55) 4px);
}
.flash { position: absolute; inset: 0; z-index: 31; pointer-events: none; opacity: 0; background: #fff; mix-blend-mode: overlay; }
.cabinet.is-hit { animation: shake .24s steps(2, end); }
.cabinet.is-hit .flash { animation: flash .24s steps(2, end); }
@keyframes shake {
  0% { transform: translate(0); } 33% { transform: translate(-4px, 2px); }
  66% { transform: translate(4px, -2px); } 100% { transform: translate(0); }
}
@keyframes flash { 0%, 100% { opacity: 0; } 35% { opacity: .5; } 60% { opacity: .08; } }

/* ---------------- title: three tight lines, back link on the left ---------------- */
.titlebar { position: relative; z-index: 4; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0 .6rem; }
.back {
  grid-column: 1; grid-row: 1 / span 3; align-self: center;
  color: var(--acid); font-size: clamp(.5rem, .62vw, .68rem);
  font-weight: 700; letter-spacing: .14em; text-decoration: none;
}
.back:hover, .back:focus-visible { color: var(--night); background: var(--acid); }
.eyebrow, .tagline {
  grid-column: 2; margin: 0; justify-self: center; text-align: center;
  font-size: clamp(.44rem, .6vw, .62rem); font-weight: 700;
  letter-spacing: .26em; text-transform: uppercase; color: var(--acid);
}
.titlebar h1 {
  grid-column: 2; margin: .02rem 0; justify-self: center;
  font: 400 clamp(1.05rem, 2.7vw, 2.1rem)/.9 var(--display);
  letter-spacing: .02em; color: #f7f2e2; -webkit-text-stroke: 1px #14142e;
  transform: scaleY(1.12); transform-origin: center;
  filter: drop-shadow(3px 3px 0 rgba(255, 53, 189, .72));
}
.tagline { color: var(--muted); letter-spacing: .18em; }

/* ---------------- fighter HUD: small plaques (the arena wants the height) ---------------- */
.hud { position: relative; z-index: 4; display: grid; grid-template-columns: 1fr auto 1fr; gap: .5rem; align-items: center; }
.hud-card {
  position: relative; height: clamp(46px, 9svh, 92px); width: auto;
  aspect-ratio: 2172 / 724;
  padding: 0; border: 0; background: transparent; cursor: pointer;
  filter: saturate(.72) brightness(.74); transition: filter .12s, transform .12s;
  container-type: inline-size;
}
.hud-card--signal { justify-self: start; }
.hud-card--archive { justify-self: end; }
.hud-card > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.hud-card--archive > img { transform: scaleX(-1); }
.hud-copy {
  position: absolute; inset: 24% 20% 24% 29%;
  display: flex; flex-direction: column; justify-content: center; gap: .12em;
  color: var(--ink); text-shadow: 2px 2px 0 #07071a;
}
.hud-card--archive .hud-copy { inset: 24% 29% 24% 20%; }
.hud-copy b {
  display: block; font-family: var(--display); font-weight: 400;
  font-size: clamp(.52rem, 4.6cqw, 1rem); line-height: .95;
  letter-spacing: .01em; transform: scaleY(1.12); transform-origin: left center;
}
.hud-card--archive .hud-copy b { transform-origin: right center; }
.hud-copy small { font-size: clamp(.38rem, 2.7cqw, .64rem); font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.hud-copy i {
  display: block; height: .26em; margin: .08em 0;
  border: 1px solid rgba(255, 255, 255, .6);
  background: linear-gradient(90deg, var(--cyan), var(--violet), var(--magenta));
}
.hud-card--archive .hud-copy i { background: linear-gradient(90deg, var(--magenta), var(--violet), var(--cyan)); }
.hud-card.is-active, .hud-card:hover, .hud-card:focus-visible {
  outline: 0; filter: saturate(1.2) brightness(1.18) drop-shadow(0 0 14px rgba(32, 231, 255, .45));
  transform: translateY(-2px);
}
.hud-card--archive.is-active, .hud-card--archive:hover, .hud-card--archive:focus-visible {
  filter: saturate(1.2) brightness(1.18) drop-shadow(0 0 14px rgba(255, 53, 189, .45));
}
.vs {
  display: grid; place-items: center; width: clamp(1.5rem, 2.4vw, 2.2rem); aspect-ratio: 1;
  color: #0a0914; background: var(--acid); font: 400 clamp(.6rem, 1.1vw, .95rem)/1 var(--display);
  clip-path: polygon(50% 0, 62% 30%, 91% 9%, 76% 42%, 100% 51%, 72% 62%, 88% 94%, 57% 75%, 45% 100%, 38% 72%, 5% 91%, 25% 60%, 0 47%, 30% 38%, 13% 7%, 42% 27%);
}

/* ---------------- the arena: this row takes everything the HUD gives back ---------------- */
.battlefield { position: relative; z-index: 3; min-height: 0; overflow: hidden; }
.sprite {
  position: absolute; bottom: 0; height: 100%; max-width: 48%;
  padding: 0; border: 0; background: transparent; cursor: pointer;
  display: flex; align-items: flex-end; transition: filter .14s, transform .14s;
}
.sprite--signal { left: .5%; }
.sprite--archive { right: .5%; }
.sprite__body {
  position: relative; z-index: 2; height: 100%; width: auto; max-width: 100%;
  object-fit: contain; filter: drop-shadow(0 16px 14px rgba(0, 0, 12, .8));
}
.sprite__trail {
  position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%;
  object-fit: contain; opacity: .3; mix-blend-mode: screen;
}
.sprite--archive .sprite__trail { transform: scaleX(-1); opacity: .24; }
.sprite:hover, .sprite:focus-visible { filter: brightness(1.14); transform: translateY(-4px); }
.clash {
  position: absolute; left: 50%; top: 46%; z-index: 4; width: 15%;
  transform: translate(-50%, -50%); opacity: .7; mix-blend-mode: screen; pointer-events: none;
}
.cabinet[data-active="signal"] .sprite--archive,
.cabinet[data-active="archive"] .sprite--signal { opacity: .55; filter: saturate(.6); }
.cabinet.is-hit .clash { opacity: 1; filter: brightness(1.6); }
.field-hint {
  position: absolute; left: 50%; bottom: .1rem; z-index: 5; margin: 0; transform: translateX(-50%);
  color: rgba(183, 178, 207, .5); font-size: clamp(.44rem, .62vw, .6rem);
  letter-spacing: .18em; white-space: nowrap; pointer-events: none;
}

/* ---------------- console: same frame art, but short ---------------- */
.console { position: relative; z-index: 4; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: .25rem; }
.console-frame {
  position: relative; width: 100%; height: clamp(186px, 31svh, 330px);
  overflow: hidden; container-type: inline-size;
  /* The bezel art is cut to "top edge + the whole writing window". A plain height plus
     object-fit: fill means the frame is never cropped — a shorter box only squashes it
     vertically — so the top of the frame always shows. */
}
.console-frame__art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.console-inner {
  position: absolute; inset: 50% 9.5% 5.5% 23%;
  display: grid; grid-template-rows: auto minmax(0, 1fr); gap: .22rem; min-height: 0;
}
.turn { margin: 0; color: var(--acid); font-size: clamp(.4rem, .74cqw, .64rem); font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.turn span { color: var(--cyan); }

.console-body { display: grid; grid-template-columns: minmax(0, .3fr) minmax(0, 1fr); gap: .25rem .7rem; min-height: 0; }
.console-side { display: grid; align-content: start; gap: .12rem; min-width: 0; padding-right: .5rem; border-right: 1px solid var(--line); }
.kicker { margin: 0; color: var(--cyan); font-size: clamp(.4rem, .78cqw, .64rem); font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
#move-name {
  display: block; margin: 0; transform: scaleY(1.08); transform-origin: left center;
  font: 400 clamp(.72rem, 2.05cqw, 1.42rem)/.95 var(--display);
  letter-spacing: .01em; color: #f7f2e2; text-shadow: 2px 2px 0 rgba(255, 53, 189, .55);
}
#readout {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  color: var(--muted); font-size: clamp(.42rem, .74cqw, .6rem); font-weight: 600; line-height: 1.3;
}
.card-button {
  justify-self: start; margin-top: .1rem; padding: .16rem .42rem;
  border: 1px solid rgba(200, 255, 54, .5); background: rgba(6, 8, 24, .92);
  color: var(--acid); font: inherit; font-size: clamp(.38rem, .66cqw, .58rem);
  letter-spacing: .1em; text-transform: uppercase; cursor: pointer;
}
.card-button:hover, .card-button:focus-visible { color: var(--night); background: var(--acid); }

.console-lists { display: grid; grid-template-columns: 1fr 1fr; gap: .25rem .8rem; min-height: 0; }
.team { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; }
.team header { display: flex; align-items: baseline; gap: .3rem; padding-bottom: .06rem; border-bottom: 1px solid var(--cyan); }
.team--archive header { border-color: var(--magenta); }
.team header span { color: var(--violet); font-size: clamp(.38rem, .72cqw, .6rem); }
.team header h3 {
  margin: 0; font: 400 clamp(.5rem, 1.1cqw, .88rem)/1 var(--display);
  letter-spacing: .04em; transform: scaleY(1.08); transform-origin: left center;
}
.team ul {
  display: grid; grid-template-columns: 1fr 1fr; align-content: start; gap: .04rem .4rem;
  margin: .16rem 0 0; padding: 0; list-style: none; min-height: 0; overflow: hidden;
}
.team button {
  width: 100%; display: grid; grid-template-columns: 1.1rem minmax(0, 1fr); gap: .25rem; align-items: baseline;
  min-width: 0; padding: .05rem .2rem; border: 1px solid transparent; color: var(--muted);
  background: transparent; text-align: left; font: inherit; cursor: pointer;
}
.team button b { color: var(--violet); font-size: clamp(.36rem, .66cqw, .56rem); }
.team button span {
  display: block; min-width: 0; font-size: clamp(.44rem, .86cqw, .72rem); line-height: 1.15;
  font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.team button small { display: none; }
.team button:hover, .team button:focus-visible, .team button.is-selected {
  outline: 0; color: #fff; border-color: rgba(32, 231, 255, .55);
  background: linear-gradient(90deg, rgba(46, 231, 255, .24), transparent 88%);
}
.team--archive button:hover, .team--archive button:focus-visible, .team--archive button.is-selected {
  border-color: rgba(255, 53, 189, .55);
  background: linear-gradient(90deg, rgba(255, 53, 189, .24), transparent 88%);
}
.team button.is-playing { animation: hit .24s steps(2, end) 2; }
@keyframes hit { 50% { transform: translateX(4px); filter: brightness(1.4); } }

/* ---------------- help bar: keys, ticker, and the buttons that open the cards ---------------- */
.console-help {
  display: flex; flex-wrap: wrap; gap: .2rem .7rem; align-items: center;
  padding: .28rem .55rem; border: 1px solid rgba(143, 82, 255, .45); background: rgba(4, 5, 18, .88);
  font-size: clamp(.46rem, .64vw, .62rem); font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
}
.keys { color: #a9a4c4; }
.ticker { flex: 1 1 14rem; min-width: 0; color: var(--acid); letter-spacing: .06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.help-actions { display: flex; flex-wrap: wrap; gap: .18rem; }
.help-actions button {
  padding: .2rem .42rem; border: 1px solid rgba(32, 231, 255, .4); background: rgba(6, 8, 24, .92);
  color: var(--cyan); font: inherit; font-size: .6rem; letter-spacing: .1em; cursor: pointer;
}
.help-actions button:hover, .help-actions button:focus-visible { color: var(--night); background: var(--cyan); }

/* ---------------- floating windows ---------------- */
.floats { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: clamp(.5rem, 3vh, 2rem); }
.floats[hidden] { display: none; }
.floats__backdrop { position: absolute; inset: 0; background: rgba(2, 2, 10, .8); backdrop-filter: blur(3px); }
.float {
  position: relative; width: min(62rem, 94vw); max-height: 90svh;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  border: 1px solid rgba(143, 82, 255, .72);
  background: linear-gradient(180deg, rgba(9, 10, 28, .98), rgba(3, 4, 14, .99));
  box-shadow: 0 0 0 1px rgba(32, 231, 255, .18) inset, 0 24px 60px rgba(0, 0, 0, .72);
  animation: card-in .18s ease-out both;
}
@keyframes card-in { from { transform: translateY(10px) scale(.992); opacity: 0; } }
.float__bar {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .6rem;
  padding: .45rem .7rem; border-bottom: 1px solid var(--line);
}
.float__kicker { color: var(--violet); font-size: .6rem; letter-spacing: .18em; text-transform: uppercase; white-space: nowrap; }
.float__title {
  min-width: 0; font: 400 clamp(.85rem, 1.9vw, 1.45rem)/1 var(--display); color: #f7f2e2;
  transform: scaleY(1.08); transform-origin: left center; text-shadow: 2px 2px 0 rgba(255, 53, 189, .5);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.float__close {
  padding: .3rem .6rem; border: 1px solid var(--line); background: transparent; color: var(--acid);
  font: inherit; font-size: .6rem; letter-spacing: .12em; cursor: pointer; white-space: nowrap;
}
.float__close:hover, .float__close:focus-visible { color: var(--night); background: var(--acid); }
.float__body { overflow-y: auto; overscroll-behavior: contain; padding: .9rem; display: grid; gap: .8rem; align-content: start; }
.float__body img { width: 100%; max-height: 46svh; object-fit: contain; border: 1px solid var(--line); background: #04050f; }
.float__body p { margin: 0; color: var(--muted); font-weight: 600; }
.float__body p b { color: var(--ink); }
.float__body .flag { color: var(--acid); font-size: .68rem; letter-spacing: .16em; text-transform: uppercase; }
.float__body ol { margin: 0; padding-left: 1.3rem; display: grid; gap: .35rem; color: var(--muted); font-weight: 600; }
.float__body ol b { color: var(--ink); }
.float__body ol.log { list-style: none; padding: 0; }
.float__body ol.log li { position: relative; padding-left: 1.3rem; }
.float__body ol.log li::before { content: "▸"; position: absolute; left: 0; color: var(--violet); }
.float__body ol.log b { color: var(--cyan); }
.float__body ol.log .idle { color: #6f6a8c; font-style: italic; }
.float__body ol.log .idle::before { content: ""; }
.float__body .plate {
  display: grid; place-items: center; aspect-ratio: 16 / 7; color: #3a3760;
  border: 1px dashed var(--line);
  background: repeating-linear-gradient(135deg, transparent 0 12px, rgba(143, 82, 255, .08) 13px 14px);
  font: 400 2rem/1 var(--display);
}
.float__foot { display: flex; justify-content: space-between; gap: .6rem; padding: .32rem .7rem; border-top: 1px solid var(--line); color: #6f6a8c; font-size: .56rem; letter-spacing: .14em; text-transform: uppercase; }

/* ---------------- narrow screens: the bezel would shrink the text to nothing,
   so the console becomes a panel, and only the active fighter's moves are shown ---------------- */
@media (max-width: 1000px) {
  .console-frame { height: auto; overflow: visible; }
  .console-frame__art { display: none; }
  .console-inner {
    position: static; inset: auto; padding: .55rem .7rem .5rem;
    border: 1px solid rgba(143, 82, 255, .6); background: var(--panel);
    box-shadow: 0 0 0 1px rgba(32, 231, 255, .16) inset, 0 0 24px rgba(34, 9, 72, .8);
  }
  .console-body { grid-template-columns: 1fr; gap: .4rem; }
  .console-side { padding: 0 0 .35rem; border-right: 0; border-bottom: 1px solid var(--line); gap: .25rem; }
  .kicker, .turn { font-size: .6rem; }
  #move-name { font-size: clamp(1.1rem, 5.4vw, 1.7rem); }
  #readout { font-size: .74rem; }
  .team header h3 { font-size: .8rem; }
  .team button span { font-size: .68rem; }
  .team button b { font-size: .5rem; }
  .card-button { font-size: .56rem; }
  .crt { display: none; }
  .field-hint { display: none; }
  /* a phone shows one fighter's moves at a time, so the cabinet still fits one screen */
  .cabinet[data-active="signal"] .team--archive,
  .cabinet[data-active="archive"] .team--signal { display: none; }
  .console-lists { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .hud { gap: .3rem; }
  .hud-card { height: clamp(34px, 6svh, 54px); }
  .vs { width: 1.5rem; font-size: .6rem; }
  .sprite { max-width: 54%; }
  .clash { width: 24%; top: 42%; }
  .back { font-size: .54rem; }
  .console-help { gap: .18rem .5rem; }
  .ticker { flex-basis: 100%; }
  .float__title { font-size: 1rem; }
  .float__kicker { display: none; }
}
@media (max-height: 620px) {
  .titlebar h1 { font-size: clamp(.95rem, 2.2vw, 1.5rem); }
  .eyebrow { display: none; }
  .console-frame { height: clamp(150px, 30svh, 210px); }
  .team button { padding: 0 .18rem; }
  .team button b { display: none; }
  .team button span { font-size: .56rem; line-height: 1; }
  .team header { padding-bottom: 0; }
  .console-inner { gap: .1rem; }
  .card-button { display: none; }
  .console-side { gap: .06rem; }
  .console-side #readout { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .cabinet.is-hit, .cabinet.is-hit .flash, .team button.is-playing, .float { animation: none; }
}
