/* ============================================================
   base.css — Reset, Variables, Typography, Screen Management
   ============================================================ */

/* Google Fonts — Bebas Neue for display, Barlow for body */
@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Barlow:wght@400;500;600;700&display=swap');

/* ── CSS Variables ────────────────────────────────────────── */
:root {
  /* Background & Surface */
  --bg-deep:           #07070c;
  --bg-body:           #0a0a0f;
  --bg-surface:        #12121e;
  --bg-surface-raised: #1a1a2e;
  --bg-surface-hover:  #222240;

  /* Court wood tones */
  --court-dark:        #1a1510;
  --court-mid:         #2a2218;
  --court-line:        rgba(245, 166, 35, 0.12);

  /* Primary accent — warm court-wood amber */
  --amber:             #f5a623;
  --amber-dim:         #b37a18;
  --amber-glow:        rgba(245, 166, 35, 0.35);
  --amber-pulse:       rgba(245, 166, 35, 0.18);

  /* Cool accent — defense blue */
  --blue:              #38bdf8;
  --blue-dim:          #2390c0;
  --blue-glow:         rgba(56, 189, 248, 0.35);

  /* Score / text */
  --white:             #f0f0f5;
  --white-dim:         #a0a0b0;
  --white-muted:       #606078;

  /* Card category colors */
  --cat-perimeter:     #f59e42;   /* warm orange — perimeter offense */
  --cat-inside:        #e05555;   /* warm red — inside offense */
  --cat-defense:       #2dd4bf;   /* teal — defense */
  --cat-utility:       #a78bfa;   /* purple — rebound/utility */
  --cat-perimeter-bg:  rgba(245, 158, 66, 0.08);
  --cat-inside-bg:     rgba(224, 85, 85, 0.08);
  --cat-defense-bg:    rgba(45, 212, 191, 0.08);
  --cat-utility-bg:    rgba(167, 139, 250, 0.08);

  /* Identity colors — player vs opponent */
  --player:            #2dd4bf;
  --player-dim:        #1a9e8f;
  --player-glow:       rgba(45, 212, 191, 0.35);
  --opponent:          #dc2626;
  --opponent-dim:      #b91c1c;
  --opponent-glow:     rgba(220, 38, 38, 0.35);
  --score-made:        #f97316;
  --score-miss:        #6b7280;
  --foul:              #ec4899;

  /* Rarity palette — THE primary card identity color */
  --rarity-common:     #d1d5db;
  --rarity-uncommon:   #4ade80;
  --rarity-rare:       #60a5fa;
  --rarity-epic:       #c084fc;
  --rarity-legendary:  #fbbf24;

  /* Rarity glow (for box-shadow) */
  --glow-common:       rgba(209, 213, 219, 0.20);
  --glow-uncommon:     rgba(74, 222, 128, 0.35);
  --glow-rare:         rgba(96, 165, 250, 0.40);
  --glow-epic:         rgba(192, 132, 252, 0.45);
  --glow-legendary:    rgba(251, 191, 36, 0.55);

  /* Rarity background tints (subtle gradient bottoms) */
  --rarity-common-bg:  rgba(209, 213, 219, 0.04);
  --rarity-uncommon-bg: rgba(74, 222, 128, 0.08);
  --rarity-rare-bg:    rgba(96, 165, 250, 0.08);
  --rarity-epic-bg:    rgba(192, 132, 252, 0.10);
  --rarity-legendary-bg: rgba(251, 191, 36, 0.12);

  /* State colors */
  --success:           #22c55e;
  --danger:            #ef4444;
  --warning:           #eab308;

  /* Spacing scale */
  --sp-xs:  4px;
  --sp-sm:  8px;
  --sp-md:  16px;
  --sp-lg:  24px;
  --sp-xl:  32px;
  --sp-2xl: 48px;

  /* Typography */
  --font-display: 'Bebas Neue', 'Impact', sans-serif;
  --font-body:    'Barlow', 'Segoe UI', system-ui, sans-serif;

  /* Borders & Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Tier color system — minerals → gems */
  --tier-iron-accent:      #8a9bae;
  --tier-iron-dim:         rgba(138,155,174,0.12);
  --tier-iron-glow:        rgba(138,155,174,0.35);

  --tier-bronze-accent:    #cd7f52;
  --tier-bronze-dim:       rgba(205,127,82,0.12);
  --tier-bronze-glow:      rgba(205,127,82,0.35);

  --tier-silver-accent:    #b8c5d4;
  --tier-silver-dim:       rgba(184,197,212,0.12);
  --tier-silver-glow:      rgba(184,197,212,0.35);

  --tier-gold-accent:      #d4a843;
  --tier-gold-dim:         rgba(212,168,67,0.12);
  --tier-gold-glow:        rgba(212,168,67,0.35);

  --tier-emerald-accent:   #2ecc71;
  --tier-emerald-dim:      rgba(46,204,113,0.12);
  --tier-emerald-glow:     rgba(46,204,113,0.35);

  --tier-sapphire-accent:  #2e86de;
  --tier-sapphire-dim:     rgba(46,134,222,0.12);
  --tier-sapphire-glow:    rgba(46,134,222,0.35);

  --tier-ruby-accent:      #e74c3c;
  --tier-ruby-dim:         rgba(231,76,60,0.12);
  --tier-ruby-glow:        rgba(231,76,60,0.35);

  --tier-diamond-accent:   #e8e8f0;
  --tier-diamond-dim:      rgba(232,232,240,0.12);
  --tier-diamond-glow:     rgba(232,232,240,0.35);

  /* Transitions */
  --ease-out:   cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --transition: 200ms var(--ease-out);
  --transition-slow: 400ms var(--ease-out);
}


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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--white);
  background: var(--bg-body);
  min-height: 100vh;
  overflow-x: hidden;
}

ul, ol {
  list-style: none;
}

button {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  outline: none;
  background: none;
  color: inherit;
}

button:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}


/* ── Display Typography ───────────────────────────────────── */
.display-font {
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}


/* ── Screen Management ────────────────────────────────────── */
.screen {
  display: none;
  width: 100%;
  min-height: 100vh;
}

.screen.active {
  display: flex;
  flex-direction: column;
  animation: screen-fade-in 300ms var(--ease-out);
}

@keyframes screen-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}


/* ── Back to Ballin' Suite Link ───────────────────────────── */
.back-to-suite {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.5rem 1rem;
  margin-top: 1.5rem;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--white-muted);
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 200ms var(--ease-out);
}

.back-to-suite:hover {
  color: var(--amber);
  border-color: var(--amber-dim);
  transform: translateX(-2px);
}

/* ── Back Navigation Button (in-game) ────────────────────── */
.back-nav-btn {
  position: absolute;
  top: var(--sp-md);
  left: var(--sp-md);
  padding: 0.4rem 0.75rem;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--white-dim);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 200ms var(--ease-out);
  z-index: 10;
}

.back-nav-btn:hover {
  color: var(--amber);
  border-color: var(--amber-dim);
  transform: translateX(-2px);
}

/* ── Utility ──────────────────────────────────────────────── */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}


/* ── QP Progress Bar ──────────────────────────────────── */
.qp-progress-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
}
.qp-match-label {
  font-weight: 700;
  font-size: 1.1rem;
}
.qp-progress-dots {
  display: flex;
  gap: 0.5rem;
}
.qp-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg-tertiary, #333);
  border: 2px solid var(--border-color, #555);
  transition: background 0.3s;
}
.qp-dot.won { background: var(--green, #4caf50); border-color: var(--green, #4caf50); }
.qp-dot.current { border-color: var(--accent, #ffc107); background: var(--accent, #ffc107); }
.qp-dot.upcoming { opacity: 0.4; }

/* ── QP Opponent Preview ──────────────────────────────── */
.qp-opponent-preview {
  text-align: center;
  font-size: 1rem;
  color: var(--text-secondary, #aaa);
  margin-bottom: 0.75rem;
}

/* ── QP Deck Info ─────────────────────────────────────── */
.qp-deck-info {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-secondary, #aaa);
  margin-bottom: 0.5rem;
  font-weight: 600;
}
.qp-deck-tips {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--white-muted, #777);
  margin-top: 0.25rem;
  line-height: 1.4;
}

/* Deck/Bench vertical layout */
.qp-deck-bench {
  flex: 1;
  overflow-y: auto;
  padding: 0 0.5rem;
}
.qp-deck-panel {
  background: var(--bg-surface-raised, #1a1f2e);
  border-radius: var(--radius-lg, 12px);
  padding: 0.75rem;
  margin-bottom: 0.5rem;
}
.qp-bench-panel {
  background: rgba(255,255,255,0.02);
  border: 1px dashed rgba(255,255,255,0.1);
  border-radius: var(--radius-lg, 12px);
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}
.qp-panel-heading {
  font-family: var(--font-display, sans-serif);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--amber, #d4a028);
  margin-bottom: 0.5rem;
  text-align: center;
}
.qp-bench-heading {
  color: var(--white-muted, #666);
}
.qp-cat-setup .qp-cat-label {
  color: var(--cat-utility, #a78bfa);
  border-color: rgba(167, 139, 250, 0.2);
}

/* ── QP Category Rows ────────────────────────────────── */
.qp-category-rows {
  flex: 1;
  overflow-y: auto;
  padding: 0 0.5rem;
}
.qp-cat-section {
  margin-bottom: 0.75rem;
}
.qp-cat-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 0.4rem 0;
  text-align: center;
}
.qp-cat-perimeter .qp-cat-label { color: var(--cat-perimeter, #f59e42); }
.qp-cat-inside .qp-cat-label    { color: var(--cat-inside, #e05555); }
.qp-cat-defense .qp-cat-label   { color: var(--cat-defense, #38bdf8); }

.qp-card-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
}

.qp-inside-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-start;
  justify-content: center;
}

/* Benched cards are dimmed */
.qp-card-row .card-mini.qp-benched {
  opacity: 0.35;
  filter: grayscale(0.4);
}
.qp-card-row .card-mini.qp-benched:hover {
  opacity: 0.7;
  filter: none;
}

/* Interactive counter highlight — when a defense card is hovered */
.qp-card-row .card-mini.qp-highlight {
  outline: 3px solid var(--amber);
  box-shadow: 0 0 18px rgba(245, 166, 35, 0.6), inset 0 0 8px rgba(245, 166, 35, 0.15);
  transform: scale(1.1);
  opacity: 1 !important;
  filter: none !important;
  transition: all 0.15s ease;
}
.qp-card-row .card-mini.qp-dim {
  opacity: 0.12 !important;
  filter: grayscale(0.8) brightness(0.5);
  transform: scale(0.95);
  transition: all 0.15s ease;
}
.qp-card-row .card-mini.qp-explaining {
  outline: 3px solid var(--cat-defense);
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.5);
  transform: scale(1.08);
}

/* Counter hints on defense mini-cards */
.qp-counter-hint {
  font-size: 0.45rem;
  color: var(--cat-defense, #38bdf8);
  opacity: 0.7;
  letter-spacing: 0.03em;
  margin-top: 1px;
  text-align: center;
}

/* ── Counter Matrix Reference Grid ───────────────────── */
.qp-counter-grid {
  margin: 0.75rem 0.5rem 0;
  font-size: 0.6rem;
  font-family: var(--font-body);
}
.qp-counter-grid table {
  border-collapse: collapse;
  width: auto;
  margin: 0 auto;
}
.qp-counter-grid th {
  font-weight: 600;
  padding: 2px 6px;
  text-align: center;
  color: var(--white-dim);
  font-size: 0.55rem;
  letter-spacing: 0.03em;
}
.qp-counter-grid th.qp-grid-offense {
  color: var(--cat-perimeter);
}
.qp-counter-grid th.qp-grid-offense-inside {
  color: var(--cat-inside);
}
.qp-counter-grid th.qp-grid-offense-utility {
  color: var(--cat-utility);
}
.qp-counter-grid td {
  padding: 2px 6px;
  text-align: center;
}
.qp-counter-grid td.qp-grid-def-label {
  font-weight: 700;
  color: var(--cat-defense);
  text-align: right;
  padding-right: 8px;
  font-size: 0.55rem;
}
.qp-counter-grid .qp-grid-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.qp-counter-grid .qp-grid-dot.hit-perimeter {
  background: var(--cat-perimeter);
}
.qp-counter-grid .qp-grid-dot.hit-inside {
  background: var(--cat-inside);
}
.qp-counter-grid .qp-grid-dot.hit-utility {
  background: var(--cat-utility);
}

/* ── QP Inside Pass Widget ───────────────────────────── */
.qp-ip-widget {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}
.qp-ip-widget .qp-ip-card {
  position: relative;
  pointer-events: none;
}
.qp-ip-badge {
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.4rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--cat-inside, #e05555);
  background: rgba(224, 85, 85, 0.15);
  padding: 1px 6px;
  border-radius: 3px;
}
.qp-ip-stepper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.qp-ip-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border-color, #555);
  background: var(--bg-surface-raised, #2a2a2a);
  color: var(--white, #fff);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  padding: 0;
}
.qp-ip-btn:hover {
  background: var(--cat-inside, #e05555);
  border-color: var(--cat-inside, #e05555);
}
.qp-ip-count {
  font-family: var(--font-display);
  font-size: 1.1rem;
  min-width: 1.5rem;
  text-align: center;
}

/* ── QP Confirm Button ───────────────────────────────── */
#qp-confirm-deck-btn {
  margin: 0.75rem auto;
  display: block;
}
#qp-confirm-deck-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── QP Victory Screen ───────────────────────────────── */
.qp-victory-banner {
  font-size: 2.5rem;
  font-weight: 900;
  text-align: center;
  color: var(--accent, #ffc107);
  margin: 2rem 0 1rem;
  text-shadow: 0 0 20px rgba(255, 193, 7, 0.5);
}
.qp-victory-stats {
  text-align: center;
  font-size: 1.1rem;
  color: var(--text-secondary, #aaa);
  margin-bottom: 2rem;
}
#qp-play-again-btn, #qp-back-to-menu-btn {
  display: block;
  margin: 0.5rem auto;
  min-width: 200px;
}

/* ── Card Stacks (deck build) ────────────────────────────── */
.qp-card-stack {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.qp-stack-cards {
  position: relative;
  width: 80px;
}

.qp-stack-cards .card-mini {
  position: absolute;
  top: 0;
  left: 0;
}

.qp-stack-cards .card-mini:first-child {
  position: relative;
}

.qp-stack-cards .card-mini:nth-child(2) { top: 4px; }
.qp-stack-cards .card-mini:nth-child(3) { top: 8px; }
.qp-stack-cards .card-mini:nth-child(4) { top: 12px; }
.qp-stack-cards .card-mini:nth-child(5) { top: 16px; }

.qp-stack-cards .card-mini.stack-inactive {
  opacity: 0.25;
  filter: grayscale(0.5);
}

.qp-stack-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--white-dim);
}

.qp-stack-stepper button {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: var(--white);
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
}

.qp-stack-stepper button:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Opponent deck preview */
.qp-opponent-deck-preview {
  font-size: 0.75rem;
  color: var(--white-muted);
  margin-top: 4px;
  text-align: center;
}

/* ── Active Game Conflict Modal ───────────────────────────── */
.active-game-modal {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.active-game-modal-content {
  background: var(--bg-surface-raised, #1a1a2e);
  border: 1px solid rgba(245, 166, 35, 0.3);
  border-radius: 12px;
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  text-align: center;
  animation: modal-pop 0.3s ease-out;
}

@keyframes modal-pop {
  0% { opacity: 0; transform: scale(0.9); }
  100% { opacity: 1; transform: scale(1); }
}

.active-game-modal-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.6rem;
  color: var(--amber, #f5a623);
  letter-spacing: 0.08em;
  margin: 0 0 0.75rem 0;
}

#active-game-msg {
  font-family: 'Barlow', sans-serif;
  font-size: 0.95rem;
  color: var(--white-dim, #a0a0b0);
  line-height: 1.5;
  margin: 0 0 1.5rem 0;
}

.active-game-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

