@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Outfit:wght@500;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  --bg: hsl(222, 30%, 6%);
  --bg-elevated: hsl(222, 26%, 9%);
  --surface: hsl(221, 24%, 12%);
  --surface-2: hsl(221, 22%, 16%);
  --border: hsla(198, 70%, 60%, 0.16);
  --border-strong: hsla(198, 90%, 60%, 0.36);

  --c9-cyan: hsl(197, 96%, 54%);
  --c9-cyan-dim: hsla(197, 96%, 54%, 0.14);
  --c9-cyan-glow: hsla(197, 96%, 54%, 0.28);
  --jb-amber: hsl(29, 96%, 58%);
  --jb-magenta: hsl(331, 86%, 58%);
  --red-side: hsl(352, 84%, 60%);
  --red-dim: hsla(352, 84%, 60%, 0.14);
  --emerald: hsl(156, 74%, 46%);
  --emerald-dim: hsla(156, 74%, 46%, 0.15);
  --gold: hsl(43, 94%, 58%);

  --text: hsl(215, 32%, 95%);
  --text-muted: hsl(216, 16%, 64%);
  --text-faint: hsl(216, 14%, 45%);

  --font-display: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 15% -10%, hsla(197, 96%, 54%, 0.14), transparent 60%),
    radial-gradient(ellipse 65% 45% at 85% -10%, hsla(331, 86%, 58%, 0.10), transparent 60%),
    linear-gradient(to bottom, hsla(222, 30%, 6%, 0.96), hsl(222, 34%, 5%));
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Subtle tactical grid texture */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, hsla(197, 80%, 65%, 0.03) 1px, transparent 1px),
    linear-gradient(to bottom, hsla(197, 80%, 65%, 0.03) 1px, transparent 1px);
  background-size: 36px 36px;
  z-index: 0;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1520px;
  margin: 0 auto;
  padding: 14px 18px 40px;
}

/* Header */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: hsla(221, 24%, 11%, 0.86);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, hsla(197, 96%, 54%, 0.22), hsla(331, 86%, 58%, 0.18));
  border: 1px solid var(--border-strong);
  display: grid;
  place-items: center;
  box-shadow: 0 0 20px var(--c9-cyan-glow);
}

.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2.2vw, 1.42rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, hsla(29, 96%, 58%, 0.18), hsla(331, 86%, 58%, 0.22));
  border: 1px solid hsla(29, 96%, 58%, 0.4);
  color: hsl(34, 96%, 72%);
}

.brand-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.mode-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.tab-btn {
  min-height: 38px;
  padding: 6px 14px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 150ms ease;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  background: linear-gradient(135deg, hsl(197, 92%, 44%), hsl(208, 86%, 48%));
  color: hsl(220, 40%, 98%);
  box-shadow: 0 4px 16px var(--c9-cyan-glow);
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.btn {
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 140ms ease, border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  background: hsl(221, 22%, 20%);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, hsl(197, 94%, 46%), hsl(205, 92%, 40%));
  border-color: hsla(197, 96%, 68%, 0.5);
  color: #fff;
  box-shadow: 0 4px 16px hsla(197, 96%, 54%, 0.22);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, hsl(197, 96%, 52%), hsl(205, 92%, 46%));
  box-shadow: 0 6px 22px hsla(197, 96%, 54%, 0.34);
}

.btn-amber {
  background: linear-gradient(135deg, hsla(29, 92%, 52%, 0.22), hsla(331, 86%, 56%, 0.22));
  border-color: hsla(29, 96%, 58%, 0.45);
  color: hsl(34, 98%, 76%);
}

.btn-danger {
  border-color: hsla(352, 84%, 60%, 0.35);
  color: hsl(352, 92%, 75%);
}

/* Series & Fearless Control Bar */
.series-bar {
  margin-top: 12px;
  padding: 10px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.series-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.select-ctrl {
  min-height: 34px;
  padding: 4px 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
}

.fearless-vault {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.vault-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--jb-amber);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.lock-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: hsla(29, 96%, 58%, 0.14);
  border: 1px solid hsla(29, 96%, 58%, 0.32);
  color: hsl(34, 96%, 75%);
}

/* Momentum / Win Probability Banner */
.momentum-banner {
  margin-top: 12px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
  align-items: center;
}

.winbar-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.side-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.side-title.blue { color: var(--c9-cyan); }
.side-title.red { color: var(--red-side); }

.win-pct {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
}

.winbar-track {
  height: 12px;
  border-radius: 999px;
  background: var(--red-side);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
}

.winbar-blue {
  height: 100%;
  background: linear-gradient(90deg, hsl(204, 96%, 45%), var(--c9-cyan));
  transition: width 320ms cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 0 14px var(--c9-cyan-glow);
}

.turn-banner {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.turn-badge {
  padding: 3px 10px;
  border-radius: 6px;
  font-weight: 700;
  color: #fff;
  background: var(--c9-cyan);
}
.turn-badge.red { background: var(--red-side); }
.turn-badge.ban { background: hsl(28, 86%, 48%); }
.turn-badge.done { background: var(--emerald); }

.trajectory-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
}

.trajectory-title {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
}

/* Main 3-Column Draft War Room */
.war-room {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr) 330px;
  gap: 14px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25);
}

.panel-title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Ban slots */
.ban-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.ban-slot {
  height: 44px;
  border-radius: 8px;
  border: 1px dashed hsla(216, 20%, 50%, 0.35);
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  position: relative;
  overflow: hidden;
  padding: 2px;
  text-align: center;
}

.ban-slot.active-turn {
  border: 1.5px solid var(--jb-amber);
  box-shadow: 0 0 14px hsla(29, 96%, 58%, 0.3);
  color: var(--jb-amber);
}

.ban-slot.filled {
  border-style: solid;
  border-color: hsla(352, 84%, 60%, 0.45);
  background: hsla(352, 60%, 16%, 0.45);
  color: var(--text);
}

.ban-slot.filled::after {
  content: "✕";
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 9px;
  color: var(--red-side);
}

/* Pick slots */
.pick-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pick-slot {
  min-height: 56px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: border-color 150ms ease, transform 150ms ease;
}

.pick-slot.active-turn.blue {
  border-color: var(--c9-cyan);
  box-shadow: 0 0 18px var(--c9-cyan-glow);
}

.pick-slot.active-turn.red {
  border-color: var(--red-side);
  box-shadow: 0 0 18px var(--red-dim);
}

.pick-slot.filled.blue {
  border-left: 3px solid var(--c9-cyan);
  background: linear-gradient(90deg, hsla(197, 96%, 54%, 0.09), var(--bg-elevated));
}

.pick-slot.filled.red {
  border-left: 3px solid var(--red-side);
  background: linear-gradient(90deg, hsla(352, 84%, 60%, 0.09), var(--bg-elevated));
}

.slot-meta {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.sigil {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.slot-name {
  font-weight: 700;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.role-pill {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--c9-cyan);
  flex-shrink: 0;
}

/* Oracle Recommendations */
.oracle-card {
  background: linear-gradient(145deg, hsla(221, 28%, 14%, 0.96), hsla(222, 30%, 10%, 0.98));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 14px;
}

.oracle-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.rec-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rec-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background-color 140ms ease;
}

.rec-item:hover {
  transform: translateY(-2px);
  border-color: var(--c9-cyan);
  background: hsl(221, 26%, 15%);
}

.rec-item.top-rec {
  border-color: hsla(156, 74%, 46%, 0.5);
  background: linear-gradient(90deg, hsla(156, 74%, 46%, 0.09), var(--bg-elevated));
}

.rec-rank {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--c9-cyan);
}

.rec-item.top-rec .rec-rank {
  background: var(--emerald);
  color: #062115;
}

.rec-metrics {
  text-align: right;
  font-family: var(--font-mono);
}

.rec-wr {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.rec-delta {
  font-size: 11px;
  font-weight: 700;
}
.rec-delta.pos { color: var(--emerald); }
.rec-delta.neg { color: var(--red-side); }

/* Champion Pool Grid */
.pool-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.search-input {
  flex: 1;
  min-width: 160px;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: var(--font-body);
}

.role-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.role-chip {
  min-height: 36px;
  padding: 4px 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.role-chip.active {
  background: var(--c9-cyan-dim);
  border-color: var(--c9-cyan);
  color: var(--c9-cyan);
}

.champ-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 8px;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 4px;
}

.champ-card {
  padding: 8px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  position: relative;
  transition: transform 120ms ease, border-color 120ms ease;
}

.champ-card:hover:not(.disabled) {
  transform: translateY(-2px);
  border-color: var(--c9-cyan);
}

.champ-card.disabled {
  opacity: 0.34;
  cursor: not-allowed;
  filter: grayscale(0.8);
}

.champ-card.fearless {
  opacity: 0.45;
  border-color: hsla(29, 96%, 58%, 0.4);
  background: hsla(29, 40%, 10%, 0.45);
}

.champ-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.champ-card-name {
  font-weight: 700;
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.champ-card-roles {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

/* Telemetry Bars */
.telemetry-block {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.stat-row {
  margin-bottom: 8px;
}

.stat-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.dmg-bar {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  background: var(--bg);
}
.dmg-phys { background: hsl(24, 92%, 58%); }
.dmg-mag { background: hsl(204, 94%, 56%); }
.dmg-true { background: hsl(0, 0%, 92%); }

.meter-track {
  height: 7px;
  border-radius: 999px;
  background: var(--bg);
  overflow: hidden;
}
.meter-fill-blue { height: 100%; background: var(--c9-cyan); }
.meter-fill-red { height: 100%; background: var(--red-side); }

/* Minigame Mode */
.minigame-wrap {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1.4fr 0.9fr;
  gap: 16px;
}

.scenario-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.mg-hud {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.mg-stat {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.mg-choices {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.mg-choice {
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: all 140ms ease;
}

.mg-choice:hover:not(:disabled) {
  border-color: var(--c9-cyan);
  transform: translateY(-2px);
}

.mg-choice.correct {
  border-color: var(--emerald);
  background: var(--emerald-dim);
}

.mg-choice.wrong {
  border-color: var(--red-side);
  background: var(--red-dim);
}

.grade-badge {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
}

.grade-S { background: var(--gold); color: #1d1400; }
.grade-A { background: var(--emerald); color: #052214; }
.grade-B { background: var(--c9-cyan); color: #041d29; }
.grade-C { background: var(--red-side); color: #fff; }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 10, 20, 0.78);
  backdrop-filter: blur(6px);
  display: none;
  place-items: center;
  z-index: 50;
  padding: 16px;
}

.modal-backdrop.open {
  display: grid;
}

.modal {
  width: min(680px, 100%);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}

.modal textarea {
  width: 100%;
  min-height: 200px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 10px;
}

.hidden { display: none !important; }

@media (max-width: 1120px) {
  .war-room {
    grid-template-columns: 1fr;
  }
  .momentum-banner, .minigame-wrap {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .app-shell { padding: 10px 10px 30px; }
  .mg-choices { grid-template-columns: 1fr; }
}
