/* Patent Fighter — retro arcade styling.
   Phase 0: layout + start/matchup placeholders. Real art/theme in Phase 3. */

:root {
  --pf-bg: #0a0a12;
  --pf-panel: #14142a;
  --pf-ink: #f4f4ff;
  --pf-accent: #ffd23f;      /* arcade yellow */
  --pf-accent-2: #ff3b3b;    /* reject red */
  --pf-granted: #36e36b;     /* grant green */
  --pf-muted: #8a8ab0;
  --pf-display: 'Press Start 2P', 'Courier New', monospace;  /* blocky arcade headings/VS */
  --pf-body: 'VT323', 'Courier New', monospace;              /* readable retro body */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #000;
  color: var(--pf-ink);
  font-family: var(--pf-body);
  -webkit-font-smoothing: none;
  image-rendering: pixelated;
  overflow: hidden;
}

#cabinet {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;   /* dynamic vh — avoids mobile URL-bar cropping */
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, #1a1a3a 0%, #05050a 70%);
}

/* Maintain a stable 960:600 (16:10) arcade stage that scales to fit the viewport.
   NOTE: aspect-ratio + calc division need UNITLESS numbers — never use px here. */
#stage {
  position: relative;
  width: min(100vw, 160vh);   /* 160vh = 100vh * (960/600) */
  height: min(62.5vw, 100vh); /* 62.5vw = 100vw * (600/960); fallback if aspect-ratio unsupported */
  aspect-ratio: 960 / 600;
  background: var(--pf-bg);
  border: 3px solid var(--pf-accent);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  user-select: none;
}

/* On phones / portrait, fill the whole screen (no letterbox bands) and use dvh. */
@media (orientation: portrait), (max-width: 760px) {
  #stage {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    aspect-ratio: auto;
    border: none;
  }
  /* Stack the two fighters vertically to use the tall space. */
  .arena {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto 1fr;
  }
}

/* (Start-screen splash styling lives in the "Splash / Start screen" block below.) */

#fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  width: 100%;
  height: 100%;
}

#mute-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 5;
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid var(--pf-accent);
  color: var(--pf-ink);
  font-size: 1.1rem;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
}
#mute-btn:hover { background: rgba(0, 0, 0, 0.7); }

/* Scanline overlay for CRT feel */
#stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.18) 3px
  );
  mix-blend-mode: multiply;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(0.8rem, 2.5vmin, 2rem);
  padding: clamp(1rem, 3vmin, 2.5rem);
}

/* ---- Splash / Start screen (also the top-level mode-select landing) ---- */
#screen-start,
#screen-mode-select {
  background-image: url('../assets/splash_landscape.webp');
  background-position: center;
  background-size: cover;
  justify-content: flex-end;
  gap: 0;
  padding-bottom: clamp(2.1rem, 7vmin, 4.4rem);
}

@media (orientation: portrait) {
  #screen-start,
  #screen-mode-select {
    background-image: url('../assets/splash_portrait.webp');
  }
}

#screen-mode-select .subtitle {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.mode-select-buttons {
  position: relative;
  z-index: 1;
  display: flex;
  gap: clamp(0.6rem, 2vmin, 1.2rem);
  flex-wrap: wrap;
  justify-content: center;
}
.mode-select-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3em;
  min-width: clamp(180px, 34vmin, 300px);
  padding: 0.7em 1em;
  background: rgba(10, 10, 26, 0.55);
  border: 3px solid var(--pf-accent);
  border-radius: 6px;
  cursor: pointer;
}
.mode-select-btn:hover, .mode-select-btn:focus-visible {
  border-color: var(--pf-ink);
  background: rgba(10, 10, 26, 0.75);
}
.mode-select-title {
  font-family: var(--pf-display);
  font-size: clamp(1rem, 3vmin, 1.6rem);
  color: var(--pf-accent);
  text-shadow: 3px 3px 0 #b3000f, 0 0 12px rgba(255, 210, 63, 0.8), 0 0 28px rgba(255, 59, 59, 0.55);
  animation: blink 1s steps(2, start) infinite;
}
.mode-select-sub {
  font-family: var(--pf-body);
  font-size: clamp(0.85rem, 2vmin, 1.1rem);
  color: var(--pf-ink);
}
@media (prefers-reduced-motion: reduce) { .mode-select-title { animation: none; } }

/* The splash art bakes in the game logo. Keep this copy for screen readers only. */
#screen-start .title,
#screen-start .subtitle,
#screen-start .explainer {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

#screen-start #insert-coin {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 0.55em 0.8em;
  color: var(--pf-accent);
  text-shadow:
    3px 3px 0 #b3000f,
    0 0 12px rgba(255, 210, 63, 0.8),
    0 0 28px rgba(255, 59, 59, 0.55);
}

/* ---- Typography ---- */
.title {
  font-family: var(--pf-display);
  font-size: clamp(1.3rem, 5.5vmin, 3.4rem);
  line-height: 1.25;
  color: var(--pf-accent);
  text-shadow: 3px 3px 0 #b3000f, 6px 6px 0 rgba(0,0,0,0.45);
  margin: 0;
}
.subtitle { font-size: clamp(1.1rem, 2.8vmin, 1.7rem); color: var(--pf-ink); margin: 0; letter-spacing: 0.04em; }
.explainer { font-size: clamp(0.95rem, 2.2vmin, 1.35rem); color: var(--pf-muted); }
.blink {
  font-family: var(--pf-display); font-size: clamp(0.85rem, 2.8vmin, 1.4rem);
  animation: blink 1s steps(2, start) infinite; color: var(--pf-accent); letter-spacing: 0.05em;
}
@keyframes blink { to { visibility: hidden; } }

.boot-msg { color: var(--pf-muted); letter-spacing: 0.3em; }
.loading {
  font-family: var(--pf-display); color: var(--pf-accent);
  font-size: clamp(0.8rem, 2.6vmin, 1.3rem); letter-spacing: 0.18em;
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---- Matchup ---- */
.prompt {
  font-size: clamp(1.2rem, 3.6vmin, 2.3rem);
  color: var(--pf-accent);
  letter-spacing: 0.04em;
  margin: 0 0 0.3rem;
  max-width: 90%;
}
.arena {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: 100%;
  flex: 1 1 auto;          /* let the arena claim the vertical space */
  gap: 2%;
}
.fighter {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.4rem, 1.5vmin, 1rem);
  cursor: pointer;
  padding: 1.2vmin 0.5vmin;
  border: 2px solid transparent;
  border-radius: 6px;
  transition: transform 0.08s ease, border-color 0.1s ease, background 0.1s ease;
}
.fighter:hover, .fighter:focus { border-color: var(--pf-accent); background: rgba(255,210,63,0.06); transform: translateY(-4px); outline: none; }
.fighter .portrait {
  width: clamp(150px, 34vmin, 540px);
  height: clamp(150px, 34vmin, 540px);
  image-rendering: pixelated;
  object-fit: contain;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.5));
}
/* Placeholder portrait (before real art lands) */
.portrait.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2a2a55, #1a1a3a);
  border: 2px dashed var(--pf-muted);
  color: var(--pf-muted);
  font-size: clamp(0.9rem, 2.4vmin, 1.4rem);
  text-align: center;
  padding: 0.5rem;
}
/* Fighters are drawn in a 3/4 FRONT pose facing the viewer and are NOT mirrored, so
   logos, wordmarks, and asymmetric state shapes always read correctly on both sides. */
.fighter .name {
  font-size: clamp(1rem, 2.8vmin, 1.8rem); font-weight: 700;
  letter-spacing: 0.08em; color: var(--pf-ink); text-shadow: 2px 2px 0 rgba(0,0,0,0.6);
}
.vs {
  font-family: var(--pf-display);
  font-size: clamp(1.3rem, 5vmin, 3rem);
  color: var(--pf-accent);
  text-shadow: 3px 3px 0 var(--pf-accent-2), -2px -2px 0 #b3000f, 0 0 14px rgba(255,59,59,0.5);
  transform: rotate(-6deg);
  padding: 0 1vmin;
}

.hint { color: var(--pf-muted); font-size: clamp(0.9rem, 2vmin, 1.2rem); margin-top: 0.5rem; }

.backlink {
  font-family: var(--pf-body);
  color: var(--pf-muted); text-decoration: none;
  font-size: clamp(0.85rem, 2vmin, 1.15rem); letter-spacing: 0.03em;
  margin-top: 0.4rem;
}
.backlink:hover { color: var(--pf-accent); text-decoration: underline; }

/* ---- HUD ---- */
/* In normal flow at the top of the screen column (was absolute — overlapped the prompt). */
.hud { display: flex; justify-content: center; margin-bottom: 0.2rem; }
.round-badge {
  font-family: var(--pf-display);
  letter-spacing: 0.06em; color: var(--pf-bg);
  background: var(--pf-accent); padding: 0.45em 0.7em; border-radius: 3px;
  font-size: clamp(0.5rem, 1.7vmin, 0.85rem);
  box-shadow: 0 2px 0 #b38600;
}

/* ---- Round intro announce ---- */
.announce {
  font-family: var(--pf-display);
  font-size: clamp(1.4rem, 6.5vmin, 3.8rem); color: var(--pf-ink);
  line-height: 1.2; text-shadow: 4px 4px 0 #b3000f;
  animation: announce-in 0.25s ease-out;
}
.announce.faceoff {
  font-size: clamp(1.1rem, 5vmin, 2.8rem); color: var(--pf-accent);
  text-shadow: 3px 3px 0 #b3000f; animation: announce-in 0.25s ease-out;
}
.announce.fight { color: var(--pf-accent-2); animation: fight-in 0.2s ease-out; }
@keyframes announce-in { from { transform: scale(2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fight-in { from { transform: scale(0.3) rotate(-8deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }

/* ---- Reveal metric numbers ---- */
.metric {
  font-family: var(--pf-display);
  font-size: clamp(0.85rem, 2.8vmin, 1.7rem); color: var(--pf-accent);
  margin-top: 0.3rem; animation: pop 0.25s ease-out;
}
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }

/* ---- Feedback ---- */
.fighter.winner { animation: lunge 0.35s ease-out; }
.fighter.winner .portrait, .fighter.winner .placeholder { filter: drop-shadow(0 0 12px var(--pf-granted)); }
.fighter.loser { animation: shakeback 0.35s ease-out; opacity: 0.75; }
.fighter.hit .portrait, .fighter.hit .placeholder { filter: drop-shadow(0 0 12px var(--pf-accent-2)); }
@keyframes lunge { 0% { transform: translateX(0); } 50% { transform: translateX(12px) scale(1.06); } 100% { transform: translateX(0); } }
.fighter.right.winner { animation: lunge-r 0.35s ease-out; }
@keyframes lunge-r { 0% { transform: translateX(0); } 50% { transform: translateX(-12px) scale(1.06); } 100% { transform: translateX(0); } }
@keyframes shakeback { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* ---- Stamp ---- */
.stamp {
  position: absolute; top: 42%; left: 50%;
  transform: translate(-50%, -50%) rotate(-12deg) scale(0.2);
  font-family: var(--pf-display);
  font-size: clamp(1rem, 4.5vmin, 2.6rem); line-height: 1.3;
  padding: 0.5em 0.7em; border: 5px solid currentColor; border-radius: 6px;
  background: rgba(10,10,18,0.72);
  opacity: 0; animation: stamp-slam 0.3s ease-out forwards; text-transform: uppercase;
  pointer-events: none; white-space: nowrap;
}
.stamp.granted { color: var(--pf-granted); }
.stamp.rejected { color: var(--pf-accent-2); }
@keyframes stamp-slam {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(-12deg) scale(1.8); }
  60% { opacity: 1; transform: translate(-50%, -50%) rotate(-12deg) scale(0.92); }
  100% { opacity: 1; transform: translate(-50%, -50%) rotate(-12deg) scale(1); }
}

/* ---- Screen shake ---- */
#stage.shake { animation: stage-shake 0.4s ease-in-out; }
@keyframes stage-shake {
  0%,100% { transform: translate(0, 0); }
  20% { transform: translate(-6px, 4px); }
  40% { transform: translate(6px, -4px); }
  60% { transform: translate(-5px, -3px); }
  80% { transform: translate(5px, 3px); }
}

/* ---- End screen ---- */
.end-over { font-family: var(--pf-display); font-size: clamp(0.8rem, 2.8vmin, 1.4rem); letter-spacing: 0.12em; color: var(--pf-muted); margin: 0; }
.score-line { font-family: var(--pf-display); font-size: clamp(1.8rem, 7vmin, 4rem); margin: 0.3rem 0; color: var(--pf-ink); text-shadow: 3px 3px 0 rgba(0,0,0,0.4); }
.rank-label { font-family: var(--pf-display); font-size: clamp(0.55rem, 1.8vmin, 0.9rem); letter-spacing: 0.18em; color: var(--pf-muted); margin: 0.4rem 0 0; }
.rank-headline {
  font-family: var(--pf-display);
  font-size: clamp(1.2rem, 5vmin, 3rem); line-height: 1.25; margin: 0; color: var(--pf-accent);
  text-shadow: 3px 3px 0 #b3000f; animation: pop 0.3s ease-out;
}
/* Rank tier coloring (0 worst -> 5 best) */
.rank-headline.tier-0 { color: #ff5b5b; text-shadow: 3px 3px 0 #5a0000; }
.rank-headline.tier-1 { color: #ff9d4d; text-shadow: 3px 3px 0 #5a2a00; }
.rank-headline.tier-2 { color: #ffd23f; text-shadow: 3px 3px 0 #5a4400; }
.rank-headline.tier-3 { color: #c9e84f; text-shadow: 3px 3px 0 #2f4400; }
.rank-headline.tier-4 { color: #6fe39a; text-shadow: 3px 3px 0 #00402080; }
.rank-headline.tier-5 { color: var(--pf-granted); text-shadow: 3px 3px 0 #004020, 0 0 16px var(--pf-granted); }
.result-grid { display: flex; gap: clamp(0.3rem, 1.2vmin, 0.6rem); margin: 0.2rem 0; }
.result-grid .cell {
  font-size: clamp(1.1rem, 3.4vmin, 2rem); font-weight: 900; line-height: 1;
}
.result-grid .cell.hit { color: var(--pf-granted); }
.result-grid .cell.miss { color: var(--pf-accent-2); }
.end-buttons { display: flex; gap: 0.8rem; margin-top: 1rem; flex-wrap: wrap; justify-content: center; align-items: center; }
.btn-x { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.arcade-btn {
  font-family: var(--pf-display); letter-spacing: 0.04em;
  color: var(--pf-bg); background: var(--pf-accent); border: none; cursor: pointer;
  padding: 0.9em 1.1em; font-size: clamp(0.6rem, 1.9vmin, 1rem); border-radius: 3px;
  box-shadow: 0 4px 0 #b38600; transition: transform 0.05s ease;
}
.arcade-btn:hover { filter: brightness(1.08); }
.arcade-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #b38600; }
.share-status { font-family: var(--pf-body); color: var(--pf-granted); font-size: clamp(1rem, 2.2vmin, 1.3rem); min-height: 1.2rem; }

/* ==================== Arena Mode (v0, tasks B4/B5) ====================
   Persistent combat screen: header (bars/meters/pips) -> stage (portraits,
   never mirrored — same non-mirror rule as the guessing game) -> controls.
   Reuses .fighter/.portrait/.vs/.stamp-adjacent tokens; new classes are all
   `arena-`/`vbar-`/`dmg-` prefixed so nothing here can collide upstream. */

.arena-combat.screen {
  justify-content: space-between;
  gap: clamp(0.4rem, 1.5vmin, 1rem);
}

.arena-hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  width: 100%;
  gap: 2%;
}
.vbar-block { display: flex; flex-direction: column; gap: 0.2rem; }
.vbar-block.b { align-items: flex-end; text-align: right; }
.vbar-name {
  font-family: var(--pf-display); font-size: clamp(0.55rem, 1.6vmin, 0.85rem);
  letter-spacing: 0.04em; color: var(--pf-ink);
}
.vbar-track {
  width: clamp(90px, 22vmin, 260px); height: 12px;
  background: rgba(0,0,0,0.5); border: 2px solid var(--pf-muted); border-radius: 3px;
  overflow: hidden;
}
.vbar-block.b .vbar-track { align-self: flex-end; }
.vbar-fill {
  height: 100%; width: 100%;
  background: var(--pf-granted);
  transition: width 0.25s ease-out, background-color 0.2s ease-out;
}
.vbar-fill.mid { background: var(--pf-accent); }
.vbar-fill.low { background: var(--pf-accent-2); }
.vbar-fill.zero { background: #4a0000; }
.vbar-pct { font-family: var(--pf-body); font-size: clamp(0.7rem, 1.8vmin, 1rem); color: var(--pf-muted); }
.meter-row { font-size: clamp(0.75rem, 2vmin, 1.1rem); color: var(--pf-muted); letter-spacing: 0.1em; }
.meter-row.full { color: var(--pf-accent); text-shadow: 0 0 8px rgba(255,210,63,0.7); }

.arena-center { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; }
.round-pips { font-size: clamp(0.8rem, 2vmin, 1.1rem); letter-spacing: 0.2em; color: var(--pf-accent); }
.exchange-counter {
  font-family: var(--pf-display); font-size: clamp(0.5rem, 1.4vmin, 0.75rem);
  color: var(--pf-muted); letter-spacing: 0.05em;
}

.arena-stagefloor {
  position: relative;
  flex: 1 1 auto; min-height: 0; width: 100%;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  border-radius: 4px; overflow: hidden;
  background-size: cover; background-position: center bottom;
}
/* Fallback look until stage art (task D5/D6) lands. */
.arena-stagefloor.no-art {
  background-image: radial-gradient(circle at 50% 20%, #22224a 0%, #0a0a12 75%);
}
.arena-stagefloor::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to bottom, rgba(10,10,18,0.15) 0%, rgba(10,10,18,0.55) 100%);
}
.arena-fighter { position: relative; z-index: 1; }
.arena-fighter.arena-hit .portrait, .arena-fighter.arena-hit .placeholder {
  animation: shakeback 0.3s ease-out, arena-hitflash 0.35s ease-out;
}
@keyframes arena-hitflash {
  0% { filter: brightness(1.9) saturate(1.5) drop-shadow(0 0 14px var(--pf-accent-2)); }
  100% { filter: none; }
}
/* Block brace (B6): defender hunkers down for a beat. */
.arena-fighter.arena-brace .portrait, .arena-fighter.arena-brace .placeholder {
  animation: arena-brace 0.28s ease-out;
}
@keyframes arena-brace {
  0% { transform: scale(1); }
  40% { transform: scale(0.94) translateY(2%); filter: brightness(0.7); }
  100% { transform: scale(1); filter: none; }
}
/* KO fall (B6): topple + drain color; cleared at the next roundStart. */
.arena-fighter.arena-ko .portrait, .arena-fighter.arena-ko .placeholder {
  transform: rotate(78deg) translateY(8%);
  filter: grayscale(0.85) brightness(0.7);
  transition: transform 0.55s cubic-bezier(0.34, 1.3, 0.64, 1), filter 0.4s ease-out;
}
.ko-dust {
  position: absolute; bottom: 8%; left: 50%; z-index: 3;
  color: var(--pf-muted); font-size: clamp(1rem, 3.4vmin, 2rem);
  letter-spacing: 0.3em; white-space: nowrap; pointer-events: none;
  animation: dust-pop 0.8s ease-out forwards;
}
@keyframes dust-pop {
  0% { opacity: 0; transform: translateX(-50%) scale(0.4); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) scale(1.7) translateY(-40%); }
}
.arena-tell {
  position: absolute; top: -1.6em; left: 50%; transform: translateX(-50%);
  font-family: var(--pf-display); font-size: clamp(0.5rem, 1.4vmin, 0.75rem);
  color: var(--pf-accent); white-space: nowrap; text-shadow: 2px 2px 0 rgba(0,0,0,0.6);
  min-height: 1.2em;
}
.arena-stagefloor.stunned-lock .fighter.left { opacity: 0.6; filter: grayscale(0.6); }

.arena-banner {
  position: absolute; top: 50%; left: 50%; z-index: 2;
  transform: translate(-50%, -50%) scale(0.3);
  font-family: var(--pf-display);
  font-size: clamp(1rem, 4.5vmin, 2.4rem);
  color: var(--pf-ink); text-shadow: 3px 3px 0 #b3000f;
  padding: 0.4em 0.6em; text-align: center;
  opacity: 0; pointer-events: none; white-space: nowrap;
  transition: opacity 0.15s ease-out, transform 0.15s ease-out;
}
.arena-banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.arena-banner.tone-a { color: var(--pf-granted); }
.arena-banner.tone-b { color: var(--pf-accent-2); }

.dmg-float {
  position: absolute; top: 30%; left: 50%; z-index: 3;
  font-family: var(--pf-display); font-size: clamp(0.9rem, 2.6vmin, 1.5rem);
  color: var(--pf-accent-2); text-shadow: 2px 2px 0 rgba(0,0,0,0.6);
  animation: dmg-rise 0.9s ease-out forwards; pointer-events: none;
}
.dmg-float.chip { color: var(--pf-muted); font-size: clamp(0.7rem, 2vmin, 1.1rem); }
@keyframes dmg-rise {
  0% { transform: translate(-50%, 0); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translate(-50%, -3em); opacity: 0; }
}

.arena-below-stage { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 0.15rem; }
.arena-clock-track {
  width: min(90%, 420px); height: 6px;
  background: rgba(0,0,0,0.5); border-radius: 3px; overflow: hidden;
}
.arena-clock-fill { height: 100%; width: 100%; background: var(--pf-accent); }
.arena-warning {
  font-family: var(--pf-display); font-size: clamp(0.55rem, 1.5vmin, 0.8rem);
  color: var(--pf-accent-2); letter-spacing: 0.04em; min-height: 1.2em;
}

/* Prototype picker (B7 — placeholder screen until C2 squad select) */
.arena-picker-row { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; justify-content: center; }
.arena-picker-label {
  font-family: var(--pf-display); font-size: clamp(0.5rem, 1.5vmin, 0.8rem);
  color: var(--pf-muted); letter-spacing: 0.08em;
}
.arena-picker-select {
  font-family: var(--pf-body); font-size: clamp(1rem, 2.4vmin, 1.4rem);
  color: var(--pf-ink); background: var(--pf-panel);
  border: 2px solid var(--pf-accent); border-radius: 4px;
  padding: 0.4em 0.6em; min-height: 48px; cursor: pointer;
}

.arena-controls {
  display: flex; align-items: center; justify-content: center;
  gap: clamp(0.4rem, 1.5vmin, 1rem); width: 100%; flex-wrap: wrap;
}
.arena-stance-btn, .arena-action-btn, .arena-special-btn {
  font-family: var(--pf-display); letter-spacing: 0.03em;
  color: var(--pf-bg); background: var(--pf-ink); border: none; cursor: pointer;
  min-width: 48px; min-height: 48px; padding: 0.6em 0.8em;
  font-size: clamp(0.55rem, 1.6vmin, 0.8rem); border-radius: 4px;
  box-shadow: 0 3px 0 rgba(0,0,0,0.35); transition: transform 0.05s ease;
}
.arena-stance-btn:active, .arena-action-btn:active, .arena-special-btn:active {
  transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,0.35);
}
.arena-stance-btn { background: var(--pf-accent); }
.arena-stance-btn.low { background: #ff9d4d; }
.arena-actions { display: flex; gap: clamp(0.3rem, 1vmin, 0.6rem); }
.arena-action-btn { background: var(--pf-ink); }
.arena-special-btn { background: var(--pf-muted); color: var(--pf-bg); opacity: 0.55; }
.arena-special-btn.ready {
  background: var(--pf-accent-2); color: var(--pf-ink); opacity: 1;
  box-shadow: 0 3px 0 #7a0000, 0 0 12px rgba(255,59,59,0.6);
}
.arena-special-btn:disabled { cursor: not-allowed; }

@media (orientation: portrait), (max-width: 760px) {
  .arena-stagefloor { grid-template-rows: 1fr auto 1fr; grid-template-columns: 1fr; }
  .vbar-track { width: clamp(70px, 30vmin, 200px); }
}
@media (prefers-reduced-motion: reduce) {
  .arena-fighter.arena-hit .portrait, .arena-fighter.arena-hit .placeholder { animation: none; }
  .arena-fighter.arena-brace .portrait, .arena-fighter.arena-brace .placeholder { animation: none; }
  .ko-dust { animation: none; opacity: 0.7; }
  /* Keep the KO state readable (grayscale) but skip the topple motion. */
  .arena-fighter.arena-ko .portrait, .arena-fighter.arena-ko .placeholder {
    transition: none; transform: none; filter: grayscale(0.85) brightness(0.7);
  }
  .dmg-float { animation: none; opacity: 1; }
}

/* ===================== ARENA v3 — real-time fight (js/fight/) ============= */

.fight-wrap {
  position: relative;
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  background: #101425;
}
.fight-hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 2;
  padding: 0.8rem 1rem;
}
.fight-hud-center { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; }
.fight-timer {
  font-family: var(--pf-display);
  font-size: clamp(1.2rem, 4vmin, 2.2rem);
  color: var(--pf-ink);
}
.fight-timer.low {
  color: var(--pf-accent-2);
  animation: meter-pulse 0.6s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) { .fight-timer.low { animation: none; } }

/* Mode links (Classic start screen + arena menu) */
.mode-link {
  font-family: var(--pf-display);
  font-size: clamp(0.5rem, 1.6vmin, 0.8rem);
  color: var(--pf-accent);
  background: rgba(10, 10, 26, 0.75);
  border: 2px solid var(--pf-accent);
  border-radius: 4px;
  padding: 0.6em 1em;
  cursor: pointer;
  min-height: 44px;
  letter-spacing: 0.05em;
}
.mode-link:hover { color: var(--pf-ink); border-color: var(--pf-ink); }

/* How-to-fight card (first-run overlay in arena) */
.howto-veil {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5, 5, 12, 0.82);
}
.howto-card {
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
  background: var(--pf-panel);
  border: 3px solid var(--pf-accent);
  border-radius: 8px;
  padding: clamp(1rem, 3vmin, 2rem);
  width: min(92%, 640px);
}
.fight-rounds {
  font-size: clamp(0.9rem, 2.4vmin, 1.3rem);
  color: var(--pf-accent);
  letter-spacing: 0.2em; white-space: pre;
}
.fight-meter {
  font-size: clamp(0.9rem, 2.6vmin, 1.4rem);
  color: var(--pf-muted);
  letter-spacing: 0.25em;
}
.fight-meter.full {
  color: var(--pf-accent-2);
  text-shadow: 0 0 8px var(--pf-accent-2);
  animation: meter-pulse 0.8s ease-in-out infinite;
}
@keyframes meter-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) { .fight-meter.full { animation: none; } }
.fight-canvas {
  flex: 1; width: 100%; height: 100%;
  display: block; object-fit: contain;
  image-rendering: pixelated;
}
.fight-banner {
  position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%) scale(0.7);
  z-index: 3; pointer-events: none;
  font-family: var(--pf-display);
  font-size: clamp(1.4rem, 6vmin, 3.2rem);
  color: var(--pf-accent);
  text-shadow: 4px 4px 0 #000, -2px -2px 0 var(--pf-accent-2);
  opacity: 0; transition: opacity 0.12s ease-out, transform 0.12s ease-out;
  white-space: nowrap;
}
.fight-banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.fight-vs-line {
  font-family: var(--pf-display);
  font-size: clamp(0.9rem, 3vmin, 1.6rem);
  color: var(--pf-ink);
}
.fight-vs-line span { color: var(--pf-accent-2); }
.fight-legend {
  font-size: clamp(1rem, 2.4vmin, 1.3rem);
  color: var(--pf-ink); text-align: center; line-height: 1.5;
}
.fight-legend p { margin: 0.15em 0; }
.fight-legend-dim { color: var(--pf-muted); }

@media (prefers-reduced-motion: reduce) {
  .fight-banner { transition: none; }
}

/* Squad select / ladder flow (task C4) */
.title-sm {
  font-family: var(--pf-display);
  font-size: clamp(0.9rem, 3.2vmin, 1.8rem);
  color: var(--pf-accent);
  text-shadow: 3px 3px 0 #000;
  margin: 0.2em 0;
  text-align: center;
}
.squad-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.7rem;
  width: min(92%, 1000px);
}
.squad-card {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
  padding: 0.6rem 0.4rem;
  background: var(--pf-panel);
  border: 3px solid var(--pf-muted);
  border-radius: 6px;
  color: var(--pf-ink);
  font-family: var(--pf-body);
  cursor: pointer;
  min-height: 48px;
}
.squad-card:hover { border-color: var(--pf-ink); }
.squad-card.picked { border-color: var(--pf-accent); box-shadow: 0 0 12px var(--pf-accent); }
.squad-card.benched { opacity: 0.35; cursor: not-allowed; filter: grayscale(1); }
.squad-portrait {
  width: clamp(64px, 11vmin, 110px);
  height: clamp(64px, 11vmin, 110px);
  object-fit: contain;
  image-rendering: pixelated;
}
.squad-portrait.missing { visibility: hidden; }
.squad-name {
  font-family: var(--pf-display);
  font-size: clamp(0.45rem, 1.3vmin, 0.7rem);
  letter-spacing: 0.05em;
}
.squad-stats {
  display: flex; flex-direction: column; align-items: flex-start;
  font-size: clamp(0.75rem, 1.8vmin, 1rem);
  color: var(--pf-muted); line-height: 1.25;
}
.squad-stats .pip-on { color: var(--pf-accent); }
.squad-special {
  font-size: clamp(0.7rem, 1.7vmin, 0.95rem);
  color: var(--pf-accent-2);
  text-align: center;
}
.squad-tag {
  position: absolute; top: 6px; right: 6px;
  font-family: var(--pf-display);
  font-size: clamp(0.4rem, 1vmin, 0.55rem);
  color: var(--pf-accent-2);
}

/* SF2-style PLAYER SELECT (free fight + squad select).
 * #stage scales up to fill the viewport (see the aspect-ratio rule near the
 * top of this file) - on a big desktop it can be 2000px+ wide. Every size
 * below is bounded by vh/vw (tracks the STAGE, which is what actually holds
 * this screen) with a generous max, not a tiny fixed cap, and .sf-select
 * spreads its rows across the full height instead of bunching in the middle
 * — the previous small fixed caps were the "lot of blank space" bug. */
.sf-select {
  justify-content: space-evenly;
  gap: clamp(0.4rem, 1.6vh, 1rem);
  overflow-y: auto;   /* safety net on extreme aspect ratios; shouldn't kick in normally */
}
.sf-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: clamp(0.6rem, 2vw, 1.5rem);
  width: min(94%, 1300px);
}
.sf-big {
  display: flex; align-items: center; gap: clamp(0.6rem, 1.8vw, 1.4rem);
  background: linear-gradient(180deg, #1b2148, #10142a);
  border: 3px solid var(--pf-accent);
  border-radius: 6px;
  padding: clamp(0.4rem, 1.3vh, 1rem) clamp(0.7rem, 1.8vw, 1.6rem);
  min-height: clamp(100px, 19vh, 200px);
}
.sf-big.p2 { border-color: var(--pf-accent-2); flex-direction: row-reverse; text-align: right; }
.sf-big-img {
  width: clamp(72px, 16vh, 170px);
  height: clamp(72px, 16vh, 170px);
  object-fit: contain;
  image-rendering: pixelated;
  flex: none;
}
.sf-big-plate { display: flex; flex-direction: column; gap: clamp(0.15rem, 0.6vh, 0.4rem); min-width: 0; }
.sf-big.p2 .sf-big-plate { align-items: flex-end; }
.sf-big-name {
  font-family: var(--pf-display);
  font-size: clamp(0.7rem, 2.8vh, 1.6rem);
  color: var(--pf-ink);
  text-shadow: 2px 2px 0 #000;
}
.sf-big-sub {
  font-size: clamp(0.9rem, 2.4vh, 1.4rem);
  color: var(--pf-accent-2);
}
.sf-big.p2 .sf-big-sub { color: var(--pf-accent); }
.sf-big-stats {
  display: flex; flex-direction: column;
  font-size: clamp(0.8rem, 2.1vh, 1.2rem);
  color: var(--pf-muted); line-height: 1.3;
}
.sf-big-stats .pip-on { color: var(--pf-accent); }
.sf-vs {
  font-family: var(--pf-display);
  font-size: clamp(1.2rem, 5.5vh, 3rem);
  color: var(--pf-accent-2);
  text-shadow: 3px 3px 0 #000, -2px -2px 0 var(--pf-accent);
  transform: rotate(-6deg);
}
.sf-rows {
  display: flex; flex-direction: column;
  gap: clamp(0.4rem, 1.4vh, 1rem);
  width: 100%; align-items: center;
}
.sf-row { display: flex; flex-direction: column; align-items: center; gap: clamp(0.15rem, 0.6vh, 0.4rem); width: 100%; }
.sf-row-label {
  font-family: var(--pf-display);
  font-size: clamp(0.5rem, 1.5vh, 0.7rem);
  color: var(--pf-muted);
  letter-spacing: 0.15em;
}
.sf-row.boss .sf-row-label { color: var(--pf-accent-2); }
.sf-grid {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: clamp(5px, 0.9vh, 12px);
  width: min(96%, 1150px);
}
.sf-tile {
  position: relative;
  width: clamp(56px, 10.5vh, 96px);
  height: clamp(56px, 10.5vh, 96px);
  padding: 0;
  background: #0d1024;
  border: 3px solid var(--pf-muted);
  border-radius: 4px;
  cursor: pointer;
  overflow: hidden;
}
.sf-tile img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 50% 10%;   /* crop toward the head, SF2-portrait style */
  image-rendering: pixelated;
}
.sf-tile:hover { border-color: var(--pf-ink); }
.sf-tile.selected { border-color: var(--pf-accent); box-shadow: 0 0 10px var(--pf-accent); }
.sf-grid.boss .sf-tile.selected { border-color: var(--pf-accent-2); box-shadow: 0 0 10px var(--pf-accent-2); }
.sf-tile.picked { border-color: var(--pf-accent); box-shadow: 0 0 10px var(--pf-accent); }
.sf-tile.picked::after {
  content: attr(data-pick);
  position: absolute; top: 1px; right: 3px;
  font-family: var(--pf-display);
  font-size: clamp(0.5rem, 1.6vh, 0.85rem);
  color: var(--pf-accent);
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000;
}
.sf-fight-btn {
  font-size: clamp(0.8rem, 2.3vh, 1.2rem);
  padding: 0.85em 2.4em;
}

/* Mystery opponent card (the gauntlet is hidden by design) */
.sf-big.mystery { justify-content: center; }
.sf-mystery-mark {
  font-family: var(--pf-display);
  font-size: clamp(2.2rem, 12vh, 6rem);
  color: var(--pf-accent-2);
  text-shadow: 4px 4px 0 #000;
  animation: blink 1.6s steps(2, start) infinite;
  flex: none;
}
@media (prefers-reduced-motion: reduce) { .sf-mystery-mark { animation: none; } }

/* VS splash between gauntlet bouts ("ROUND 1 … X VS Y" + hero shots) */
.vs-splash { justify-content: space-evenly; cursor: pointer; }
.vs-splash-round {
  font-family: var(--pf-display);
  font-size: clamp(1.1rem, 5vh, 2.6rem);
  color: var(--pf-accent);
  text-shadow: 3px 3px 0 #b3000f, 6px 6px 0 rgba(0,0,0,0.45);
  margin: 0;
}
.vs-splash-round.final {
  color: var(--pf-accent-2);
  text-shadow: 3px 3px 0 #000, 0 0 18px rgba(255, 59, 59, 0.8);
  animation: blink 1s steps(2, start) infinite;
}
@media (prefers-reduced-motion: reduce) { .vs-splash-round.final { animation: none; } }
.vs-splash-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: clamp(0.6rem, 2.5vw, 2rem);
  width: min(96%, 1300px);
}
.vs-hero {
  display: flex; flex-direction: column; align-items: center;
  gap: clamp(0.3rem, 1vh, 0.8rem);
}
.vs-hero img {
  width: clamp(140px, 42vh, 420px);
  height: clamp(140px, 42vh, 420px);
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 22px rgba(255, 210, 63, 0.25));
}
.vs-hero.p2 img { filter: drop-shadow(0 0 22px rgba(255, 59, 59, 0.3)); }
.vs-hero-name {
  font-family: var(--pf-display);
  font-size: clamp(0.75rem, 2.8vh, 1.5rem);
  color: var(--pf-ink);
  text-shadow: 2px 2px 0 #000;
}
.vs-hero.p2 .vs-hero-name { color: var(--pf-accent-2); }
.vs-splash-vs {
  font-family: var(--pf-display);
  font-size: clamp(1.6rem, 9vh, 4.5rem);
  color: var(--pf-accent-2);
  text-shadow: 4px 4px 0 #000, -3px -3px 0 var(--pf-accent);
  transform: rotate(-6deg);
}
.vs-skip {
  font-size: clamp(0.85rem, 2vh, 1.1rem);
  color: var(--pf-muted);
  margin: 0;
}
