:root {
  color-scheme: dark;
  --bg: #0a0a14;
  --panel: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8e6f0;
  --muted: #8a849f;
  --accent: #5bc8e7;
  --green: #5be77c;
  --yellow: #e0c54a;
  --red: #ff8b9c;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(circle at 20% 0%, #1f1633, #0a0a14 60%) fixed;
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
code { font-family: "SF Mono", Consolas, Monaco, monospace; font-size: 0.9em;
       background: rgba(255,255,255,0.06); padding: 1px 6px; border-radius: 4px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; backdrop-filter: blur(10px); z-index: 5;
  background: rgba(10, 10, 20, 0.7);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: var(--muted); flex-shrink: 0;
}
.dot-cyan   { background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.dot-green  { background: var(--green);  box-shadow: 0 0 12px var(--green); }
.dot-yellow { background: var(--yellow); box-shadow: 0 0 12px var(--yellow); }
.dot-red    { background: var(--red);    box-shadow: 0 0 12px var(--red); }
.dot-grey   { background: var(--muted); }

main { max-width: 880px; margin: 0 auto; padding: 24px; display: grid; gap: 18px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.card-header h2 {
  margin: 0; font-size: 16px; font-weight: 600;
  display: flex; align-items: center; gap: 10px;
}
.card-actions { display: flex; gap: 8px; }

.kv {
  display: grid; grid-template-columns: 180px 1fr; gap: 6px 16px;
  margin: 0; font-size: 14px;
}
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.btn-sm {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity .15s, background .15s;
}
.btn-sm:hover:not(:disabled) { background: rgba(255, 255, 255, 0.10); }
.btn-sm:disabled { opacity: 0.4; cursor: not-allowed; }

.badge {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
}
.badge.muted { color: var(--muted); }
.badge.ok    { color: var(--green); }

.muted { color: var(--muted); }
.small { font-size: 12px; }

/* The HTML `hidden` attribute defaults to `display: none`, but author CSS
   like `.setup-card { display: grid }` wins by specificity. Force the
   attribute to actually hide things. */
[hidden] { display: none !important; }

.setup-card {
  margin-top: 16px;
  padding: 16px 18px;
  border: 1px dashed rgba(224, 197, 74, 0.35);
  border-radius: 10px;
  background: rgba(224, 197, 74, 0.04);
  display: grid; gap: 14px;
}
.setup-card.warn {
  border-color: rgba(255, 139, 156, 0.45);
  background: rgba(255, 139, 156, 0.06);
}
.setup-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.setup-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.setup-row { font-size: 13px; }
.setup-row summary { cursor: pointer; font-weight: 500; padding: 4px 0; }
.setup-row summary:hover { color: var(--accent); }
.setup-steps { padding-left: 20px; margin: 8px 0 0; display: grid; gap: 10px; }
.setup-steps li { line-height: 1.5; }

.cmd-row {
  margin-top: 6px;
  display: flex; gap: 8px; align-items: center;
}
.cmd-row code {
  flex: 1; padding: 8px 10px; font-size: 12.5px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border); border-radius: 6px;
  white-space: nowrap; overflow-x: auto;
}
.copy-btn { white-space: nowrap; }
.copy-btn.copied { color: var(--green); }

.btn-primary {
  background: var(--accent); color: #0a0a14;
  border: 0; padding: 8px 16px;
  font-size: 13px; font-weight: 600;
  border-radius: 6px; cursor: pointer;
  transition: opacity .15s;
}
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary:hover:not(:disabled) { opacity: 0.9; }

.event-log {
  list-style: none; padding: 0; margin: 0;
  font-family: "SF Mono", Consolas, Monaco, monospace;
  font-size: 12px; max-height: 220px; overflow-y: auto;
}
.event-log li {
  padding: 4px 8px; border-bottom: 1px dashed var(--border);
}
.event-log li:last-child { border-bottom: none; }
.event-log .ev-game  { color: var(--green); }
.event-log .ev-state { color: var(--yellow); }
.event-log .ev-warn  { color: var(--red); }

/* Decks panel — list view */
.decks-list { display: grid; gap: 10px; }
.deck-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,0.02);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.deck-row:hover { background: rgba(91,200,231,0.05); border-color: rgba(91,200,231,0.3); }
.deck-row .deck-name { font-weight: 600; }
.deck-row .deck-meta { color: var(--muted); font-size: 12px; }
.deck-row .deck-stat { font-size: 12px; color: var(--muted); white-space: nowrap; }
.deck-row .deck-wr { font-weight: 600; font-size: 13px; min-width: 50px; text-align: right; }
.deck-row .deck-wr.good { color: var(--green); }
.deck-row .deck-wr.bad  { color: var(--red); }

/* Decks panel — review view */
.deck-review { display: grid; gap: 16px; }
.deck-review h3 { margin: 0 0 8px; font-size: 14px; font-weight: 600; }
.deck-review h4 { margin: 14px 0 6px; font-size: 12px; font-weight: 600;
                   color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.deck-review .panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.deck-review .stat-tile {
  padding: 12px 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.stat-label { font-size: 11px; color: var(--muted);
              text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 22px; font-weight: 600; margin-top: 4px; }
.stat-sub   { font-size: 11px; color: var(--muted); margin-top: 2px; }

.curve-bar { display: grid; grid-template-columns: 30px 1fr 32px;
             gap: 8px; align-items: center; padding: 2px 0; font-size: 12px; }
.curve-bar .label { color: var(--muted); text-align: right; }
.curve-bar .bar { background: rgba(91,200,231,0.15); border-radius: 3px;
                  height: 14px; min-width: 1px; }
.curve-bar .bar > div { background: var(--accent); height: 100%; border-radius: 3px; }
.curve-bar .count { font-variant-numeric: tabular-nums; text-align: right; color: var(--muted); }

.color-pip { display: inline-block; width: 18px; height: 18px;
             border-radius: 50%; line-height: 18px; text-align: center;
             font-size: 11px; font-weight: 700; margin-right: 4px; }
.color-pip.W { background: #f5f0d6; color: #5a4a14; }
.color-pip.U { background: #b3ddf2; color: #14315a; }
.color-pip.B { background: #444;    color: #ddd; }
.color-pip.R { background: #f4a08a; color: #5a1f14; }
.color-pip.G { background: #a3d4a6; color: #1f5a2f; }
.color-pip.C { background: #888;    color: #fff; }

.lineage-list { display: grid; gap: 4px; font-size: 12px; }
.lineage-list .v { display: flex; gap: 8px; align-items: center; }
.lineage-list .v .v-num { color: var(--muted); min-width: 30px; }
.lineage-list .v .v-current { color: var(--accent); font-weight: 600; }

.matchup-row, .archetype-row {
  display: grid; grid-template-columns: 1fr 60px 60px 60px;
  gap: 8px; padding: 4px 0; font-size: 12px;
  border-bottom: 1px dashed var(--border);
}
.matchup-row:last-child, .archetype-row:last-child { border-bottom: 0; }
.matchup-row .num, .archetype-row .num {
  text-align: right; font-variant-numeric: tabular-nums;
}

.ban-warning {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(255,139,156,0.4);
  background: rgba(255,139,156,0.06);
  border-radius: 6px;
  font-size: 12px;
}
.ban-warning .ban-card { font-weight: 600; color: var(--red); }

/* Ask the coach */
.ask-form { display: grid; gap: 8px; }
.ask-form textarea {
  background: rgba(255,255,255,0.04); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; font-family: inherit; font-size: 14px;
  resize: vertical;
}
.ask-form textarea:focus { outline: none; border-color: var(--accent); }
.ask-controls {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.ask-controls select, .ask-controls input {
  background: rgba(255,255,255,0.06); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; font-size: 13px;
}
.coach-response {
  margin-top: 14px; padding: 12px 14px;
  background: rgba(255,255,255,0.03); border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; line-height: 1.55;
  white-space: pre-wrap;
}
.coach-response.thinking { color: var(--accent); }
.coach-response.error    { color: var(--red); border-color: rgba(255,139,156,0.4); }

/* Draft retrospective rows */
.pick-row {
  display: grid; grid-template-columns: 60px 1fr 1fr 60px;
  gap: 10px; padding: 6px 0;
  border-bottom: 1px dashed var(--border); font-size: 13px;
}
.pick-row:last-child { border-bottom: 0; }
.pick-row .pp-coord { color: var(--muted); font-variant-numeric: tabular-nums; }
.pick-row .pp-took { font-weight: 500; }
.pick-row .pp-engine { color: var(--muted); font-style: italic; }
.pick-row .pp-engine.agreed { color: var(--green); font-style: normal; }
.pick-row .pp-engine.disagreed { color: var(--yellow); }
.pick-row .pp-confidence { text-align: right; color: var(--muted); font-size: 11px; }

.table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.table th, .table td {
  padding: 8px 10px; text-align: left;
  border-bottom: 1px solid var(--border);
}
.table th { color: var(--muted); font-weight: 500; }
.table tr:last-child td { border-bottom: none; }
