/* ==========================================================================
   NERD FIGHT REFEREE — CYBERNETIC COMBAT ARBITRATION STYLESHEET
   ========================================================================== */

:root {
  --bg-core: #070a12;
  --bg-surface: rgba(15, 23, 42, 0.78);
  --bg-surface-solid: #0f172a;
  --bg-surface-elevated: rgba(30, 41, 59, 0.75);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-active: rgba(255, 255, 255, 0.2);

  --crimson-core: #ef4444;
  --crimson-glow: rgba(239, 68, 68, 0.4);
  --crimson-surface: rgba(239, 68, 68, 0.08);

  --cyan-core: #06b6d4;
  --cyan-glow: rgba(6, 182, 212, 0.4);
  --cyan-surface: rgba(6, 182, 212, 0.08);

  --emerald-core: #10b981;
  --amber-core: #f59e0b;
  --purple-core: #a855f7;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
}

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

body {
  background-color: var(--bg-core);
  color: var(--text-primary);
  font-family: var(--font-main);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Ambient Cyber Glow Spheres */
.glow-sphere {
  position: fixed;
  border-radius: 50%;
  filter: blur(140px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.22;
}

.sphere-crimson {
  top: -100px;
  left: -100px;
  width: 550px;
  height: 550px;
  background: radial-gradient(circle, var(--crimson-core) 0%, transparent 70%);
}

.sphere-cyan {
  top: -100px;
  right: -100px;
  width: 550px;
  height: 550px;
  background: radial-gradient(circle, var(--cyan-core) 0%, transparent 70%);
}

.cyber-grid-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* Main Container */
.app-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 20px;
  position: relative;
  z-index: 1;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 32px;
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-badge {
  font-size: 28px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.brand-name {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 1.5px;
  background: linear-gradient(135deg, #ffffff 30%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-tagline {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 1.2px;
  margin-top: 2px;
}

.status-cluster {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-subtle);
  padding: 6px 14px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot-emerald {
  background-color: var(--emerald-core);
  box-shadow: 0 0 8px var(--emerald-core);
}

.btn-discord-invite {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #5865f2;
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(88, 101, 242, 0.35);
}

.btn-discord-invite:hover {
  background: #4752c4;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(88, 101, 242, 0.5);
}

/* Combat Stage Layout */
.combat-stage {
  margin-bottom: 40px;
}

.duel-grid {
  display: grid;
  grid-template-columns: 1fr 340px 1fr;
  gap: 24px;
  align-items: stretch;
}

@media (max-width: 1100px) {
  .duel-grid {
    grid-template-columns: 1fr;
  }
}

/* Corner Cards (Contender A & B) */
.corner-card {
  background: var(--bg-surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-subtle);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.corner-crimson {
  border-top: 3px solid var(--crimson-core);
}

.corner-crimson:hover {
  box-shadow: 0 10px 30px rgba(239, 68, 68, 0.12);
}

.corner-cyan {
  border-top: 3px solid var(--cyan-core);
}

.corner-cyan:hover {
  box-shadow: 0 10px 30px rgba(6, 182, 212, 0.12);
}

.corner-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.corner-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.corner-crimson .corner-tag { color: var(--crimson-core); }
.corner-cyan .corner-tag { color: var(--cyan-core); }

.ready-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}

.ready-badge.is-ready {
  background: rgba(16, 185, 129, 0.15);
  color: var(--emerald-core);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Search Box & Autocomplete */
.search-box-wrap {
  position: relative;
}

.search-input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  font-size: 14px;
  pointer-events: none;
  opacity: 0.6;
}

.search-input {
  width: 100%;
  padding: 12px 38px 12px 42px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
}

.corner-crimson .search-input:focus {
  border-color: var(--crimson-core);
  box-shadow: 0 0 12px var(--crimson-glow);
}

.corner-cyan .search-input:focus {
  border-color: var(--cyan-core);
  box-shadow: 0 0 12px var(--cyan-glow);
}

.btn-clear {
  position: absolute;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
}

.btn-clear:hover { color: #fff; }

.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #0f172a;
  border: 1px solid var(--border-active);
  border-radius: var(--radius-md);
  max-height: 280px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.7);
  display: none;
}

.autocomplete-dropdown.active {
  display: block;
}

.suggestion-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.15s ease;
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item:hover, .suggestion-item.selected {
  background: rgba(255, 255, 255, 0.06);
}

.sugg-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.sugg-franchise {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.sugg-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
}

/* Portrait Viewport */
.portrait-viewport {
  position: relative;
  width: 100%;
  height: 380px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #090e17;
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
}

.portrait-viewport img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform 0.4s ease;
}

.portrait-viewport:hover img {
  transform: scale(1.03);
}

.portrait-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px 18px;
  background: linear-gradient(to top, rgba(7, 10, 18, 0.95) 0%, rgba(7, 10, 18, 0.6) 60%, transparent 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.fighter-display-name {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}

.fighter-meta-tags {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.meta-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-subtle);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--text-secondary);
}

.image-search-bar {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.img-search-input {
  flex: 1;
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
}

.img-search-input:focus {
  border-color: var(--border-active);
}

.btn-subtle {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-subtle:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* Form Selector */
.form-selector-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.form-select {
  width: 100%;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

/* Center Nexus */
.nexus-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  justify-content: center;
}

.vs-emblem-wrap {
  position: relative;
  width: 76px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vs-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, 0.15);
  animation: spin 20s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.vs-text {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 1px;
  background: linear-gradient(135deg, var(--crimson-core), var(--cyan-core));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
}

/* Options Glass Card */
.options-glass-card {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.options-heading {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 700;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 6px;
}

.option-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.option-info {
  display: flex;
  flex-direction: column;
}

.option-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.option-desc {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.mini-select {
  padding: 6px 10px;
  background: #090e17;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 11px;
  outline: none;
  max-width: 160px;
}

/* Switch Toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: .3s;
  border-radius: 22px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--emerald-core);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

input:checked + .slider:before {
  transform: translateX(18px);
}

/* Master CTA Button */
.btn-simulate-duel {
  position: relative;
  width: 100%;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  border: none;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  font-family: var(--font-main);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1.5px;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(16, 185, 129, 0.4);
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn-simulate-duel:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 32px rgba(16, 185, 129, 0.6);
  background: linear-gradient(135deg, #34d399 0%, #059669 100%);
}

.btn-simulate-duel:active {
  transform: translateY(1px);
}

.btn-simulate-duel.is-loading {
  pointer-events: none;
  opacity: 0.85;
  background: #1e293b;
  box-shadow: none;
}

/* Progress bar */
.progress-bar-wrap {
  width: 100%;
  background: rgba(15, 23, 42, 0.9);
  border-radius: var(--radius-sm);
  padding: 4px;
  display: none;
}

.progress-bar-wrap.active {
  display: block;
}

.progress-bar-fill {
  height: 6px;
  background: linear-gradient(90deg, var(--crimson-core), var(--cyan-core));
  border-radius: 3px;
  width: 10%;
  transition: width 0.3s ease;
  animation: pulse-glow 1.5s infinite alternate;
}

@keyframes pulse-glow {
  from { filter: brightness(1); }
  to { filter: brightness(1.4); }
}

.progress-status-text {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 6px;
}

/* Results Section */
.results-section {
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-active);
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-top: 24px;
  animation: slideUp 0.4s ease forwards;
}

.results-section.hidden {
  display: none;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.results-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 14px;
  flex-wrap: wrap;
  gap: 12px;
}

.results-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 1px;
}

.btn-re-dispatch {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-re-dispatch:hover {
  background: rgba(88, 101, 242, 0.25);
  border-color: #5865f2;
}

/* Verdict Banner */
.verdict-banner {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(6, 182, 212, 0.05) 100%);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.trophy-badge {
  font-size: 42px;
}

.verdict-lead {
  flex: 1;
}

.winner-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.winner-headline {
  font-size: 24px;
  font-weight: 800;
  color: #fff;
}

.diff-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(245, 158, 11, 0.2);
  color: var(--amber-core);
  border: 1px solid var(--amber-core);
}

.odds-bar-container {
  margin-top: 12px;
}

.odds-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.odds-track {
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  overflow: hidden;
  display: flex;
}

.odds-fill-a {
  background: var(--crimson-core);
  transition: width 0.4s ease;
}

.odds-fill-b {
  background: var(--cyan-core);
  transition: width 0.4s ease;
}

/* Dual Fight Cards */
.cards-dual-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 768px) {
  .cards-dual-grid {
    grid-template-columns: 1fr;
  }
}

.result-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.result-card-header {
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  border-bottom: 1px solid var(--border-subtle);
}

.result-card-a .result-card-header {
  background: var(--crimson-surface);
  color: var(--crimson-core);
}

.result-card-b .result-card-header {
  background: var(--cyan-surface);
  color: var(--cyan-core);
}

.result-card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
}

.card-detail-item strong {
  color: var(--text-secondary);
}

/* Analysis Panel */
.analysis-panel, .narrative-panel, .discord-preview-panel {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
}

.panel-heading {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.panel-prose {
  font-size: 15px;
  line-height: 1.7;
  color: #e2e8f0;
}

/* Play-by-Play Grid */
.play-by-play-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 900px) {
  .play-by-play-grid {
    grid-template-columns: 1fr;
  }
}

.phase-card {
  background: rgba(7, 10, 18, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.phase-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
  align-self: flex-start;
  color: var(--text-muted);
}

.phase-title {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.phase-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Discord Webhook Preview */
.discord-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 12px;
}

.delivery-status {
  color: var(--emerald-core);
}

.discord-embed-card {
  background: #2b2d31;
  border-radius: 6px;
  display: flex;
  overflow: hidden;
  max-width: 600px;
}

.discord-embed-pill {
  width: 4px;
  background: #10b981;
}

.discord-embed-inner {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.discord-embed-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.discord-embed-desc {
  font-size: 13px;
  color: #dbdee1;
}

.discord-embed-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  color: #dbdee1;
}

.discord-embed-footer {
  font-size: 10px;
  color: #949ba4;
  margin-top: 4px;
}

/* Toast Container */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: #1e293b;
  border: 1px solid var(--border-active);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.25s ease forwards;
}

.toast.toast-success { border-left: 4px solid var(--emerald-core); }
.toast.toast-error { border-left: 4px solid var(--crimson-core); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.app-footer {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  padding: 24px 0;
}
