/* SNES / 16-bit visual style — all palette values defined here as variables */

:root {
  --snes-black:        #0d0d1a;
  --snes-panel:        #1c1c3c;
  --snes-panel-dark:   #12122a;
  --snes-border:       #5050b8;
  --snes-border-light: #8888d8;
  --snes-text:         #f8f8f8;
  --snes-yellow:       #f8d020;
  --snes-green:        #20d060;
  --snes-red:          #e03030;
  --snes-blue:         #3878f8;
  --snes-purple:       #9030c8;
  --snes-shadow:       #000000;

  /* ── Z-index scale — all layers reference these variables ── */
  --z-hud:       100;
  --z-overlay:   200;
  --z-popup:     300;
  --z-scanlines: 400;

  /* ── Readable font for long-form text (skill/powerup descriptions, Jessie) ── */
  --font-readable: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* ── Reset ────────────────────────────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Base ─────────────────────────────────────────────────────────────────── */

body {
  background: var(--snes-black);
  color: var(--snes-text);
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  line-height: 2;
  min-height: 100dvh;
  overflow-x: hidden;
  image-rendering: pixelated;
  -webkit-font-smoothing: none;
  font-smooth: never;
}

/* Scanline overlay — pointer-events: none so it never blocks clicks */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 3px,
    rgba(0, 0, 0, 0.07) 3px,
    rgba(0, 0, 0, 0.07) 4px
  );
  z-index: var(--z-scanlines);
}

/* ── Screen fade transition ── */
#app {
  transition: opacity 0.15s ease;
}
#app.fading {
  opacity: 0;
  pointer-events: none;
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── HUD (persistent player widget + feedback button) ────────────────────── */

#hud {
  position: fixed;
  top: 8px;
  left: 0;
  right: 0;
  z-index: var(--z-hud);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0 8px;
  pointer-events: none; /* let clicks pass through the gap between buttons */
}

#hud > * {
  pointer-events: auto;
}

#hud-feedback {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: var(--snes-text);
  background: var(--snes-panel);
  border: 2px solid var(--snes-border-light);
  box-shadow:
    inset 0 0 0 1px var(--snes-border),
    3px 3px 0 var(--snes-shadow);
  padding: 8px 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0s;
  white-space: nowrap;
}

#hud-feedback:hover {
  background: var(--snes-border);
  color: var(--snes-yellow);
}

#hud-feedback:active {
  transform: translate(1px, 1px);
  box-shadow:
    inset 0 0 0 1px var(--snes-border),
    1px 1px 0 var(--snes-shadow);
}

#hud-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--snes-panel);
  border: 2px solid var(--snes-border-light);
  box-shadow:
    inset 0 0 0 1px var(--snes-border),
    3px 3px 0 var(--snes-shadow);
  padding: 4px 10px 4px 4px;
  cursor: pointer;
  font-family: 'Press Start 2P', monospace;
  color: var(--snes-text);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0s;
}

#hud-chip:hover {
  background: var(--snes-border);
  color: var(--snes-yellow);
}

#hud-chip:active {
  transform: translate(1px, 1px);
  box-shadow:
    inset 0 0 0 1px var(--snes-border),
    1px 1px 0 var(--snes-shadow);
}

.hud-chip-name {
  font-size: 12px;
  line-height: 1;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── HUD stats overlay ────────────────────────────────────────────────────── */

#hud-overlay {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-hud) + 10);
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
}

#hud-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

#hud-overlay-panel {
  position: relative;
  z-index: 1;
  width: min(480px, 94vw);
  max-height: 90dvh;
  overflow-y: auto;
  margin: 8px 8px 0 0;
  background: var(--snes-panel-dark);
  border: 3px solid var(--snes-border-light);
  box-shadow:
    inset 0 0 0 2px var(--snes-panel-dark),
    inset 0 0 0 4px var(--snes-border),
    6px 6px 0 var(--snes-shadow);
  padding: 16px;
}

/* ── Screen container ─────────────────────────────────────────────────────── */

.screen {
  width: 100%;
  min-height: 100dvh;
  /* 52px top padding clears the fixed HUD chip on every screen */
  padding: 52px clamp(16px, 4vw, 64px) 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Centered narrow card — for login, summary, intro */
.content-card {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Wider centered card — for character select */
.content-card--lg {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 2-column slot grid for character select on desktop */
.char-slots-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (min-width: 640px) {
  .char-slots-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}

/* Spacer that clears the fixed HUD chip on mobile so portraits never overlap */
.match-hud-spacer {
  display: none;
}
@media (max-width: 767px) {
  .match-hud-spacer {
    display: block;
    /* HUD chip: top:8px + 4px padding + 64px portrait + 4px padding + 2px border = 82px bottom edge.
       Screen already has 16px top padding, so 68px spacer puts content at 84px. */
    height: 68px;
    flex-shrink: 0;
  }
}

/* Match screen 2-column layout on desktop */
.match-layout {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.match-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (min-width: 768px) {
  .match-layout {
    flex-direction: row;
    align-items: flex-start;
    gap: 24px;
    max-width: 1080px;
    margin: 0 auto;
  }

  .match-panel {
    flex: 1;
    min-width: 0;
    max-width: 520px;
  }
}

/* ── SNES panel (FF6-style menu box) ──────────────────────────────────────── */

.snes-panel {
  background: var(--snes-panel);
  border: 3px solid var(--snes-border-light);
  /* Double-border inset creates the classic SNES menu look */
  box-shadow:
    inset 0 0 0 2px var(--snes-panel-dark),
    inset 0 0 0 4px var(--snes-border),
    4px 4px 0 var(--snes-shadow);
  padding: 16px;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.snes-btn {
  display: inline-block;
  background: var(--snes-panel);
  color: var(--snes-text);
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  line-height: 1;
  border: 3px solid var(--snes-border-light);
  box-shadow:
    inset 0 0 0 2px var(--snes-border),
    3px 3px 0 var(--snes-shadow);
  padding: 12px 16px;
  min-height: 44px;
  cursor: pointer;
  letter-spacing: 1px;
  user-select: none;
  transition: background 0s, color 0s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.snes-btn:hover {
  background: var(--snes-border);
  color: var(--snes-yellow);
}

.snes-btn:active {
  transform: translate(2px, 2px);
  box-shadow:
    inset 0 0 0 2px var(--snes-border),
    1px 1px 0 var(--snes-shadow);
}

.snes-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.snes-btn-yellow {
  color: var(--snes-yellow);
  border-color: var(--snes-yellow);
  box-shadow:
    inset 0 0 0 2px var(--snes-border),
    3px 3px 0 var(--snes-shadow);
}

.snes-btn-yellow:hover {
  background: var(--snes-yellow);
  color: var(--snes-black);
}

/* ── Inputs ───────────────────────────────────────────────────────────────── */

.snes-input {
  background: var(--snes-black);
  color: var(--snes-text);
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  line-height: 2;
  border: 3px solid var(--snes-border-light);
  box-shadow: inset 0 0 0 2px var(--snes-border);
  padding: 10px 12px;
  min-height: 44px;
  outline: none;
  width: 100%;
  caret-color: var(--snes-yellow);
  touch-action: manipulation;
}

.snes-input:focus {
  border-color: var(--snes-yellow);
  box-shadow: inset 0 0 0 2px var(--snes-yellow);
}

.snes-input::placeholder {
  color: var(--snes-border);
  opacity: 1;
}

/* ── Portrait frame ───────────────────────────────────────────────────────── */

.portrait-frame {
  border: 3px solid var(--snes-border-light);
  box-shadow:
    inset 0 0 0 2px var(--snes-border),
    3px 3px 0 var(--snes-shadow);
  background: var(--snes-black);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.portrait-frame img {
  image-rendering: pixelated;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.portrait-frame--sm  { width: 64px;  height: 64px; }
.portrait-frame--md  { width: 96px;  height: 96px; }
.portrait-frame--lg  { width: 128px; height: 128px; }
.portrait-frame--xl  { width: 160px; height: 160px; }

/* Selected state for portrait gallery */
.portrait-frame--selected {
  border-color: var(--snes-yellow);
  box-shadow:
    inset 0 0 0 2px var(--snes-yellow),
    3px 3px 0 var(--snes-shadow);
}

/* ── Typography ───────────────────────────────────────────────────────────── */

.snes-title {
  font-size: 16px;
  color: var(--snes-yellow);
  text-shadow: 3px 3px 0 var(--snes-shadow);
  letter-spacing: 2px;
  line-height: 1.6;
}

.snes-subtitle {
  font-size: 10px;
  color: var(--snes-border-light);
  text-shadow: 2px 2px 0 var(--snes-shadow);
  line-height: 1.8;
}

.snes-label {
  font-size: 8px;
  color: var(--snes-text);
  text-shadow: 1px 1px 0 var(--snes-shadow);
  line-height: 2;
}

.snes-small {
  font-size: 6px;
  color: var(--snes-border-light);
  line-height: 2;
}

.snes-highlight { color: var(--snes-yellow); }
.snes-success   { color: var(--snes-green);  }
.snes-error     { color: var(--snes-red);    }
.snes-muted     { color: var(--snes-border); }

/* ── Selection cursor ─────────────────────────────────────────────────────── */

.snes-cursor::before {
  content: '▶ ';
  color: var(--snes-yellow);
}

/* ── Divider ──────────────────────────────────────────────────────────────── */

.snes-divider {
  border: none;
  border-top: 2px solid var(--snes-border);
  margin: 4px 0;
}

/* ── Animations ───────────────────────────────────────────────────────────── */

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.cursor-blink {
  display: inline-block;
  animation: blink 0.8s step-end infinite;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.fade-in {
  animation: fadeIn 0.3s ease-in;
}

/* ── Bracket visualization ────────────────────────────────────────────────── */

.bracket-round-headers {
  display: flex;
  margin-bottom: 6px;
}

.bracket-round-header {
  flex: 1;
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  color: var(--snes-yellow);
  text-align: center;
  letter-spacing: 1px;
}

.bracket-conn-gap {
  width: 24px;
  flex-shrink: 0;
}

.bracket-body {
  display: flex;
  align-items: stretch;
  min-height: 180px;
}

.bracket-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.bracket-col--final {
  justify-content: center;
}

.bracket-match {
  background: var(--snes-panel-dark);
  border: 2px solid var(--snes-border);
  box-shadow: 3px 3px 0 var(--snes-shadow);
}

.bracket-match--active {
  border-color: var(--snes-yellow);
  box-shadow: 0 0 0 1px var(--snes-yellow), 3px 3px 0 var(--snes-shadow);
}

.bracket-match--complete {
  opacity: 0.75;
}

.bracket-slot {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 6px;
  min-height: 38px;
  overflow: hidden;
}

.bracket-slot + .bracket-slot {
  border-top: 1px solid var(--snes-border);
}

.bracket-slot--winner {
  background: rgba(32, 208, 96, 0.1);
}

.bracket-slot--loser {
  opacity: 0.35;
}

.bracket-portrait {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border: 1px solid var(--snes-border);
  background: var(--snes-black);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.bracket-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
  display: block;
}

.bracket-name {
  flex: 1;
  min-width: 0;
  font-family: var(--font-readable);
  font-size: 10px;
  color: var(--snes-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.6;
}

.bracket-name--player {
  color: var(--snes-yellow);
}

.bracket-score {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  flex-shrink: 0;
  min-width: 12px;
  text-align: right;
  color: var(--snes-border);
}

.bracket-score--win  { color: var(--snes-green); }
.bracket-score--loss { color: var(--snes-red);   }

/* Fork connector between rounds */
.bracket-conn {
  width: 24px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.bracket-conn-top {
  flex: 1;
  border-right: 2px solid var(--snes-border-light);
  border-bottom: 2px solid var(--snes-border-light);
}

.bracket-conn-bot {
  flex: 1;
  border-right: 2px solid var(--snes-border-light);
  border-top: 2px solid var(--snes-border-light);
}

/* ── Throw choice buttons ─────────────────────────────────────────────────── */

.throw-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--snes-panel);
  border: 3px solid var(--snes-border-light);
  box-shadow:
    inset 0 0 0 2px var(--snes-border),
    3px 3px 0 var(--snes-shadow);
  padding: 10px 4px;
  cursor: pointer;
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  color: var(--snes-text);
  min-height: 44px;
  width: 100%;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.throw-btn:hover {
  background: var(--snes-border);
  color: var(--snes-yellow);
}

.throw-btn:active {
  transform: translate(2px, 2px);
  box-shadow:
    inset 0 0 0 2px var(--snes-border),
    1px 1px 0 var(--snes-shadow);
}

.throw-btn img {
  width: 72px;
  height: 72px;
  image-rendering: pixelated;
  display: block;
  pointer-events: none;
}

/* ── Throw reveal (both hands facing each other) ──────────────────────────── */

.throw-reveal {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 8px;
}

.throw-reveal-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  flex: 1;
}

.throw-reveal-side img {
  width: 96px;
  height: 96px;
  image-rendering: pixelated;
  display: block;
}

.throw-reveal-side--flip img {
  transform: scaleX(-1);
}

/* Portrait grid for character creation */
.portrait-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.portrait-grid-scroll {
  max-height: 220px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}

/* ── Skill tree screen ─────────────────────────────────────────────────────── */

.tree-card-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (min-width: 768px) {
  .tree-card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }
}

.tree-card {
  background: var(--snes-panel);
  border: 3px solid var(--snes-border-light);
  box-shadow:
    inset 0 0 0 2px var(--snes-panel-dark),
    inset 0 0 0 4px var(--snes-border),
    4px 4px 0 var(--snes-shadow);
  display: flex;
  flex-direction: column;
}

.tree-card--purchased {
  border-color: var(--snes-yellow);
  box-shadow:
    inset 0 0 0 2px var(--snes-panel-dark),
    inset 0 0 0 4px var(--snes-yellow),
    4px 4px 0 var(--snes-shadow);
}

.tree-card--locked {
  opacity: 0.45;
}

.tree-card-header {
  padding: 10px 12px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

/* ── Skill tree panel ────────────────────────────────────────────────────── */

.st-panel {
  display: flex;
  flex-direction: column;
  background: var(--snes-panel-dark);
}

/* Navigator bar */
.st-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--snes-panel);
  border-bottom: 2px solid var(--snes-border);
}

.st-nav-btn {
  font-size: 7px !important;
  padding: 8px 12px !important;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Scrollable canvas wrapper */
.st-canvas-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0;
  background: var(--snes-black);
  scrollbar-width: thin;
  scrollbar-color: var(--snes-border) var(--snes-panel-dark);
  /* Allow vertical page-scroll through this element on touch devices.
     Without this, iOS intercepts all touch gestures that start here. */
  touch-action: pan-y;
}

/* Mobile: detail panel slides up as a fixed bottom sheet so Buy/Refund
   is always visible without needing to scroll past the tree canvas.
   bottom:96px keeps it above the ~90px sticky Lock In footer.
   Max height capped at 40vh to keep the tree canvas visible above. */
.st-detail--mobile-sheet {
  position: fixed;
  bottom: 96px;
  left: 0;
  right: 0;
  z-index: var(--z-overlay);
  max-height: calc(40vh - 96px);
  overflow-y: auto;
}

/* Semi-transparent scrim behind the mobile detail sheet.
   Stops at bottom:96px so the Lock In footer remains visible and tappable. */
.st-detail-scrim {
  display: none;
}
@media (max-width: 767px) {
  .st-detail-scrim {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 96px;
    z-index: calc(var(--z-overlay) - 1);
    background: rgba(0, 0, 0, 0.55);
  }
}

/* Node boxes */
.st-node {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 2px solid var(--snes-border);
  background: var(--snes-panel-dark);
  box-sizing: border-box;
  padding: 6px 6px;
  cursor: default;
  text-align: center;
  transition: border-color 0.1s, box-shadow 0.1s;
}

.st-node--available {
  cursor: pointer;
  border-color: var(--snes-border-light);
}

.st-node--available:hover {
  border-color: var(--snes-yellow);
  box-shadow: 0 0 6px var(--snes-yellow)66;
}

/* "available" pulse — fires 3 times then stops, drawing the eye without looping forever */
@keyframes st-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--snes-yellow)00; }
  50%       { box-shadow: 0 0 0 3px var(--snes-yellow)44; }
}
.st-node--available {
  animation: st-pulse 2s ease-in-out 3;
  animation-fill-mode: forwards;
}
.st-node--available:hover {
  animation: none;
}

.st-node--purchased {
  cursor: pointer;
  /* border-color and glow set inline per tree color */
}

.st-node--locked {
  opacity: 0.5;
  cursor: pointer;
}

.st-node--future {
  opacity: 0.18;
  border-style: dashed;
  cursor: default;
}

.st-node--selected {
  animation: none !important;
}

.st-node-name {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: var(--snes-text);
  line-height: 1.5;
  word-break: break-word;
  hyphens: auto;
  text-align: center;
}

.st-node-cost {
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  color: var(--snes-border-light);
  text-align: center;
}

.st-cost--owned  { color: var(--snes-green); }
.st-cost--broke  { color: var(--snes-red); }

/* Detail panel */
.st-detail {
  padding: 12px;
  background: var(--snes-panel);
  /* Ensure scrollIntoView leaves clearance for the sticky Lock In footer below */
  scroll-margin-bottom: 100px;
}

/* Full-screen overlay (from HUD "VIEW SKILL TREES" button) */
.st-fs-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--snes-black);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Powerup tray ────────────────────────────────────────────────────────── */

.pu-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pu-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 56px;
  cursor: default;
}

.pu-slot--filled {
  cursor: pointer;
}

.pu-slot--filled:hover .pu-slot-icon {
  border-color: var(--snes-yellow);
  box-shadow:
    inset 0 0 0 1px var(--snes-border),
    2px 2px 0 var(--snes-shadow),
    0 0 0 1px var(--snes-yellow);
}

.pu-slot-icon {
  width: 48px;
  height: 48px;
  background: var(--snes-panel-dark);
  border: 2px solid var(--snes-border);
  box-shadow: inset 0 0 0 1px var(--snes-border), 2px 2px 0 var(--snes-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0s;
}

.pu-slot--empty .pu-slot-icon {
  border-color: var(--snes-border);
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--snes-border), 2px 2px 0 var(--snes-shadow);
}

.pu-slot--active-now .pu-slot-icon {
  border-color: var(--snes-green);
  box-shadow: inset 0 0 0 1px var(--snes-border), 2px 2px 0 var(--snes-shadow), 0 0 4px var(--snes-green);
}

.pu-slot--gutcheck-only .pu-slot-icon {
  border-color: var(--snes-yellow);
  box-shadow: inset 0 0 0 1px var(--snes-border), 2px 2px 0 var(--snes-shadow);
}

.pu-slot-icon img {
  width: 36px;
  height: 36px;
  image-rendering: pixelated;
  object-fit: contain;
}

.pu-slot-name {
  font-family: var(--font-readable);
  font-size: 9px;
  line-height: 1.3;
  color: var(--snes-text);
  text-align: center;
  word-break: break-word;
  max-width: 60px;
}

.pu-slot-scope {
  font-family: var(--font-readable);
  font-size: 9px;
  line-height: 1.2;
  color: var(--snes-border-light);
  text-align: center;
}

/* ── Powerup detail popup ─────────────────────────────────────────────────── */

#pu-popup-layer {
  position: fixed;
  inset: 0;
  z-index: var(--z-popup);
  display: flex;
  align-items: center;
  justify-content: center;
}

#pu-popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

#pu-popup {
  position: relative;
  z-index: 1;
  width: min(340px, 90vw);
  background: var(--snes-panel-dark);
  border: 3px solid var(--snes-border-light);
  box-shadow:
    inset 0 0 0 2px var(--snes-panel-dark),
    inset 0 0 0 4px var(--snes-border),
    6px 6px 0 var(--snes-shadow);
  padding: 18px;
}

/* Responsive portrait frame for match screen */
.portrait-frame--match {
  width: 96px;
  height: 96px;
}

/* ── Jessie dialogue panel — gold border distinguishes coach from player ── */

.jessie-panel {
  border-color: var(--snes-yellow) !important;
  box-shadow:
    inset 0 0 0 2px var(--snes-panel-dark),
    inset 0 0 0 4px var(--snes-yellow),
    4px 4px 0 var(--snes-shadow) !important;
}

/* ── Readable body text — system font for descriptions, effect text, Jessie ── */
/* Applied to long-form descriptive text where pixel font would be too small. */

.readable-text {
  font-family: var(--font-readable);
  font-size: 13px;
  line-height: 1.6;
  -webkit-font-smoothing: auto;
  font-smooth: auto;
}

@media (min-width: 768px) {
  .readable-text { font-size: 14px; }
}

/* ── Horizontal scroll container with right-edge fade affordance ── */

.h-scroll {
  overflow-x: auto;
  padding-bottom: 4px;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: var(--snes-border) var(--snes-panel-dark);
}

/* Pseudo-element fade on the wrapper requires a separate overlay approach;
   use .h-scroll-wrap to apply the gradient as a sibling */
.h-scroll-wrap {
  position: relative;
  overflow: hidden;
}

.h-scroll-wrap::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 4px;
  width: 40px;
  background: linear-gradient(to right, transparent, var(--snes-black));
  pointer-events: none;
  z-index: 1;
}

/* ── Collapsible section (match screen panels) ── */

.collapsible-section {
  display: flex;
  flex-direction: column;
}

.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  cursor: pointer;
  background: var(--snes-panel-dark);
  border-bottom: 2px solid var(--snes-border);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: 36px;
}

.collapsible-header:hover {
  background: var(--snes-border);
}

.collapsible-header-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: var(--snes-border-light);
  letter-spacing: 1px;
}

.collapsible-badge {
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  background: var(--snes-border);
  color: var(--snes-text);
  border-radius: 2px;
  padding: 2px 6px;
  margin-right: 6px;
}

.collapsible-arrow {
  font-size: 8px;
  color: var(--snes-border-light);
  transition: transform 0.15s;
  flex-shrink: 0;
}

.collapsible-arrow--open {
  transform: rotate(90deg);
}

.collapsible-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Skill button cooldown fill (replaces dark gradient) ── */

.skill-btn-wrap {
  position: relative;
  overflow: hidden;
}

.skill-btn-cooldown-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  background: rgba(32, 208, 96, 0.15);
  pointer-events: none;
  transition: width 0.3s ease;
}

.skill-btn-ready-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  color: var(--snes-green);
  letter-spacing: 1px;
}

/* ── NPR progress bar ── */

.npr-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.npr-bar-track {
  height: 8px;
  background: var(--snes-panel-dark);
  border: 1px solid var(--snes-border);
  position: relative;
  overflow: hidden;
}

.npr-bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  background: linear-gradient(to right, var(--snes-blue), var(--snes-purple));
  transition: width 0.4s ease;
}

.npr-bar-fill--near {
  background: linear-gradient(to right, var(--snes-purple), var(--snes-yellow));
  animation: npr-glow 0.8s ease-in-out infinite alternate;
}

@keyframes npr-glow {
  from { box-shadow: none; }
  to   { box-shadow: 0 0 6px var(--snes-yellow); }
}

.npr-bar-threshold {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--snes-yellow);
  opacity: 0.7;
}

/* ── Overflow prompt — new drop vs existing inventory distinction ── */

.overflow-new-drop {
  border: 2px solid var(--snes-yellow);
  padding: 10px;
  margin-bottom: 8px;
}

.overflow-new-drop-header {
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  color: var(--snes-yellow);
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.overflow-inventory-header {
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  color: var(--snes-border-light);
  letter-spacing: 1px;
  padding: 4px 0;
  border-top: 1px solid var(--snes-border);
  margin: 6px 0;
}

/* ── Gut check intel section ── */

.gutcheck-action-panel {
  border: 2px solid var(--snes-yellow);
  padding: 8px 10px;
}

.gutcheck-intel-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px 0;
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  color: var(--snes-border-light);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.gutcheck-intel-toggle:hover { color: var(--snes-text); }

/* ── Powerup popup type badge ── */

.pu-popup-type-badge {
  display: inline-block;
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  padding: 2px 8px;
  border-radius: 2px;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.pu-popup-type-badge--powerup {
  background: rgba(248, 208, 32, 0.15);
  border: 1px solid var(--snes-yellow);
  color: var(--snes-yellow);
}

.pu-popup-type-badge--skill {
  background: rgba(56, 120, 248, 0.15);
  border: 1px solid var(--snes-blue);
  color: var(--snes-blue);
}

/* ── Powerup usability indicator dot ── */

.pu-status-dot {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin: 0 auto 2px;
  flex-shrink: 0;
}

.pu-status-dot--ready      { background: var(--snes-green); box-shadow: 0 0 4px var(--snes-green); }
.pu-status-dot--gutcheck   { background: var(--snes-yellow); }
.pu-status-dot--unavailable{ background: var(--snes-red); opacity: 0.7; }

/* ── ELO delta display ── */

.elo-delta-up   { color: var(--snes-green); font-size: 8px; }
.elo-delta-down { color: var(--snes-red);   font-size: 8px; }
.elo-delta-same { color: var(--snes-border-light); font-size: 8px; }

/* ── Round history tie indicator ── */

.round-tie { color: var(--snes-border-light); }

/* ── Shake animation for disabled Lock In button taps ── */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-4px); }
  40%       { transform: translateX(4px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}
.shake {
  animation: shake 0.3s ease;
}

/* ── Responsive breakpoints ───────────────────────────────────────────────── */

@media (min-width: 640px) {
  .portrait-grid {
    grid-template-columns: repeat(8, 1fr);
  }

  .portrait-grid-scroll {
    max-height: 360px;
  }
}

@media (min-width: 1024px) {
  .portrait-grid {
    grid-template-columns: repeat(10, 1fr);
  }
}

@media (min-width: 768px) {
  /* Typography scales up on desktop */
  body        { font-size: 10px; }
  .snes-title    { font-size: 22px; }
  .snes-subtitle { font-size: 13px; }
  .snes-label    { font-size: 11px; }
  .snes-small    { font-size: 8px; }
  .snes-btn      { font-size: 10px; }
  .snes-input    { font-size: 10px; }

  /* Powerup slot labels scale up on desktop */
  .pu-slot-name  { font-size: 5px; }
  .pu-slot-scope { font-size: 5px; }
  .pu-slot-icon  { width: 56px; height: 56px; }
  .pu-slot       { width: 64px; }
  .pu-slot-icon img { width: 44px; height: 44px; }

  /* Bracket scales up on desktop */
  .bracket-body {
    min-height: 280px;
  }

  .bracket-slot {
    min-height: 56px;
    padding: 8px 12px;
  }

  .bracket-portrait {
    width: 44px;
    height: 44px;
  }

  .bracket-name {
    font-size: 12px;
  }

  .bracket-score {
    font-size: 8px;
    min-width: 16px;
  }

  .bracket-conn {
    width: 48px;
  }

  .bracket-conn-gap {
    width: 48px;
  }

  /* Match portraits scale up on desktop */
  .portrait-frame--match {
    width: 128px;
    height: 128px;
  }

  /* Hand images scale up on desktop */
  .throw-btn img {
    width: 110px;
    height: 110px;
  }

  .throw-reveal-side img {
    width: 140px;
    height: 140px;
  }
}
