:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --text: #1d1c1a;
  --muted: #6b6860;
  --border: #dedbd2;
  --accent: #2f6fd6;
  --warn-bg: #fdecc8;
  --warn-text: #5c3b00;
  --mild-bg: #e3edfb;
  --mild-text: #173a6b;
  /* The five mana colours, as on the card symbols. Used only for the small
     dots beside deck names. */
  --mana-w: #f8f6d8;
  --mana-u: #0e68ab;
  --mana-b: #150b00;
  --mana-r: #d3202a;
  --mana-g: #00733e;
  --mana-none: #9a978f;
  --pip-ring: rgba(0, 0, 0, 0.45); /* outline so white and black dots stay visible */
  /* One colour for every chart bar: the bar shows time, the dots show colour. */
  --bar: #5b8def;
  /* The title's gradient keeps its own softer colours. */
  --title-1: #c9a227;
  --title-2: #3d8fe0;
  --title-3: #7d3c8c;
  --title-4: #d9482f;
  --title-5: #12a08a;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17161a;
    --surface: #211f25;
    --text: #ebe8e1;
    --muted: #a09c93;
    --border: #38353d;
    --accent: #6ea8ff;
    --warn-bg: #4a3608;
    --warn-text: #ffe2a3;
    --mild-bg: #1c2f4d;
    --mild-text: #cfe0fb;
    --pip-ring: rgba(255, 255, 255, 0.55);
    --bar: #6f9cf5;
    --title-3: #a05bb0;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0 auto;
  padding: 16px;
  max-width: 1000px;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, sans-serif;
}

h1 { margin: 0; font-size: 1.6rem; }
h2 { margin: 2rem 0 0.25rem; font-size: 1.15rem; }
p { margin: 0.25rem 0; }
a { color: var(--accent); }

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-top: 8px;
}

.meta, .hint, footer { color: var(--muted); font-size: 0.9rem; }
footer { margin: 2.5rem 0 1rem; }

.banner {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--warn-bg);
  color: var(--warn-text);
}
.banner code { font-size: 0.85rem; overflow-wrap: anywhere; }
.banner ul { margin: 0; padding-left: 1.2rem; }
.banner.mild { background: var(--mild-bg); color: var(--mild-text); }
.banner + .banner { margin-top: 8px; }

h1 {
  background: linear-gradient(90deg, var(--title-1), var(--title-2), var(--title-3), var(--title-4), var(--title-5));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* A small dot in one mana colour. The data-c attribute picks which. */
.pip {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid var(--pip-ring);
  background: var(--mana-none);
}
.pip[data-c="W"] { background: var(--mana-w); }
.pip[data-c="U"] { background: var(--mana-u); }
.pip[data-c="B"] { background: var(--mana-b); }
.pip[data-c="R"] { background: var(--mana-r); }
.pip[data-c="G"] { background: var(--mana-g); }
.pips { display: inline-flex; gap: 2px; margin-right: 6px; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.85rem;
}
.legend li { display: inline-flex; align-items: center; gap: 6px; }

/* Deck-name links laid over the left edge of the ranking chart. app.js sets
   each link's top to its bar's centre. */
#ranking-links { position: absolute; inset: 8px; pointer-events: none; }
#ranking-links a {
  position: absolute;
  left: 0;
  width: 180px;
  transform: translateY(-50%);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
  font-size: 0.8rem;
  color: var(--text);
  text-decoration: none;
  pointer-events: auto;
}
#ranking-links a:hover { color: var(--accent); text-decoration: underline; }
td a { color: inherit; text-decoration: none; }
td a:hover { color: var(--accent); text-decoration: underline; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  margin: 1.25rem 0 0;
  padding: 8px 14px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.filters legend { padding: 0 6px; color: var(--muted); font-size: 0.9rem; }

.chart {
  position: relative;
  margin-top: 8px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.chart.short { height: 260px; }

.table-wrap {
  margin-top: 8px;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { padding: 8px 12px; text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
tbody tr { border-top: 1px solid var(--border); cursor: pointer; }
tbody tr:hover { background: var(--bg); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.unreliable { color: var(--muted); cursor: default; }
tr.unreliable td[colspan] { text-align: center; font-style: italic; }

button {
  padding: 8px 16px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}
button.quiet {
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
}

body.login {
  display: grid;
  place-items: center;
  min-height: 100vh;
}
body.login form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(100%, 320px);
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
body.login input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
