:root {
  --bg-primary: #0b0f19;
  --bg-card: #151d30;
  --bg-card-hover: #1c2740;
  --bg-card-subtle: #111827;
  --border-color: #24324f;
  --border-accent: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent-red: #e11d48;
  --accent-red-hover: #be123c;
  --accent-red-glow: rgba(225, 29, 72, 0.25);
  --badge-green: #10b981;
  --badge-green-bg: rgba(16, 185, 129, 0.15);
  --badge-yellow: #f59e0b;
  --badge-yellow-bg: rgba(245, 158, 11, 0.15);
  --badge-red: #ef4444;
  --badge-red-bg: rgba(239, 68, 68, 0.15);
  --badge-neutral: #64748b;
  --badge-neutral-bg: rgba(100, 116, 139, 0.15);
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: 60px;
}

/* Header */
.app-header {
  background: linear-gradient(180deg, #182238 0%, #0e1526 100%);
  border-bottom: 1px solid var(--border-color);
  padding: 14px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent-red);
}

.header-title-box h1 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  gap: 10px;
}

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-red);
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px;
}

/* Step Pipeline Navigation */
.steps-nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.step-indicator {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.step-indicator.active {
  border-color: var(--accent-red);
  box-shadow: 0 0 15px var(--accent-red-glow);
  background: #19243d;
}

.step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--border-color);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
}

.step-indicator.active .step-num {
  background: var(--accent-red);
}

.step-text .step-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 700;
}

.step-text .step-desc {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Team Selection Grid */
.team-select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-select, .form-input {
  width: 100%;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.form-select:focus, .form-input:focus {
  border-color: var(--accent-red);
}

/* Missing Players Checklist */
.lineup-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.lineup-item {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
}

.lineup-item:hover {
  background: var(--bg-card-hover);
}

.lineup-item.missing {
  border-color: var(--accent-red);
  background: rgba(225, 29, 72, 0.12);
}

.lineup-pos-tag {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-dim);
  margin-right: 8px;
}

.lineup-name {
  font-size: 0.88rem;
  font-weight: 600;
  flex: 1;
}

.lineup-ttr {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-left: 6px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.status-badge.green {
  background: var(--badge-green-bg);
  color: var(--badge-green);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.yellow {
  background: var(--badge-yellow-bg);
  color: var(--badge-yellow);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-badge.red {
  background: var(--badge-red-bg);
  color: var(--badge-red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-badge.neutral {
  background: var(--badge-neutral-bg);
  color: var(--badge-neutral);
  border: 1px solid rgba(100, 116, 139, 0.3);
}

/* Opponent Lineup Table / Cards */
.opp-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

.opp-table th {
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
}

.opp-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(36, 50, 79, 0.5);
  font-size: 0.9rem;
}

.opp-table tr:hover td {
  background: rgba(28, 39, 64, 0.4);
}

.opp-pos-badge {
  font-weight: 800;
  color: #fff;
  background: var(--border-color);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
}

.target-badge {
  background: rgba(225, 29, 72, 0.2);
  color: #fb7185;
  border: 1px solid rgba(225, 29, 72, 0.4);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
}

/* Candidates Grid */
.candidate-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 14px;
  transition: all 0.2s ease;
  position: relative;
}

.candidate-card:hover {
  border-color: var(--border-accent);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.candidate-card.advantage {
  border-left: 4px solid var(--badge-green);
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.05) 0%, var(--bg-card) 50%);
}

.candidate-card.balanced {
  border-left: 4px solid var(--badge-yellow);
}

.candidate-card.disadvantage {
  border-left: 4px solid var(--badge-red);
}

.candidate-card.neutral {
  border-left: 4px solid var(--text-dim);
}

.candidate-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}

.cand-name-box h3 {
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cand-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Head to Head Duel Box */
.h2h-duels-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.h2h-box {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.h2h-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
}

.h2h-score-line {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.h2h-history-list {
  margin-top: 8px;
  font-size: 0.78rem;
  border-top: 1px solid var(--border-color);
  padding-top: 6px;
}

.h2h-history-item {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  color: var(--text-muted);
}

.h2h-history-item.win {
  color: #34d399;
}

.h2h-history-item.loss {
  color: #f87171;
}

/* Action Buttons */
.btn-primary {
  background: var(--accent-red);
  color: #fff;
  border: none;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary:hover {
  background: var(--accent-red-hover);
  box-shadow: 0 0 15px var(--accent-red-glow);
}

.btn-secondary {
  background: #1e293b;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: #334155;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 16px;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: #fff;
  border: 1px solid var(--accent-red);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  z-index: 1000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* Responsive */
@media (max-width: 768px) {
  .steps-nav {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .app-header {
    padding: 10px 14px;
  }
  .container {
    padding: 12px 10px;
  }
}
