:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #5f6b7a;
  --accent: #2f6fde;
  --accent-text: #ffffff;
  --border: #d8dde5;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171d;
    --card: #1d222b;
    --text: #e6e9ef;
    --muted: #9aa5b4;
    --accent: #5b8ff0;
    --border: #2e3541;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.brand { font-weight: 600; color: var(--text); text-decoration: none; }
main { max-width: 960px; margin: 24px auto; padding: 0 16px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px;
}
h1 { font-size: 1.3rem; margin: 0 0 12px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
label { display: block; margin-bottom: 4px; color: var(--muted); }
input {
  width: 100%;
  max-width: 320px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  letter-spacing: 0.05em;
}
button {
  margin-top: 12px;
  padding: 8px 16px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  cursor: pointer;
}
button.secondary { background: transparent; color: var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
form.inline { display: inline; }

/* Admin pages */
:root { --good: #1f8a4c; --bad: #c0392b; --warn: #b9770e; }
@media (prefers-color-scheme: dark) { :root { --good: #4cc27f; --bad: #ff7b6b; --warn: #f0b04a; } }
header { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
nav { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; flex: 1; }
nav a { color: var(--text); text-decoration: none; }
nav a:hover { color: var(--accent); }
nav .who { margin-left: auto; color: var(--muted); }
main { max-width: 1200px; }
main > section, .grid { margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 0.8rem; font-weight: normal; border: 1px solid var(--border); color: var(--muted); vertical-align: middle; }
.badge.good { border-color: var(--good); color: var(--good); }
.badge.bad { border-color: var(--bad); color: var(--bad); }
.badge.warn { border-color: var(--warn); color: var(--warn); }
table { border-collapse: collapse; width: 100%; }
table.facts th { text-align: left; font-weight: normal; color: var(--muted); padding: 3px 12px 3px 0; white-space: nowrap; vertical-align: top; }
table.list th { text-align: left; font-weight: 600; border-bottom: 1px solid var(--border); padding: 6px 8px; }
table.list td { border-bottom: 1px solid var(--border); padding: 5px 8px; vertical-align: top; overflow-wrap: anywhere; }
.box { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin: 8px 0 12px; }
.slot { min-height: 52px; padding: 5px 7px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); font-size: 0.85rem; display: flex; flex-direction: column; overflow: hidden; }
.slot a { font-weight: 600; text-decoration: none; }
.slot .nick { font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 700px) { .box { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
details summary { cursor: pointer; margin: 6px 0; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.8rem; max-height: 480px; overflow: auto; background: var(--bg); padding: 10px; border-radius: 6px; }
form.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
form.row input:not([type=checkbox]) { flex: 1; min-width: 180px; max-width: none; }
form.row button { margin-top: 0; }
label.check { display: inline-flex; align-items: center; gap: 4px; margin: 0; color: var(--text); }
label.check input { width: auto; }
button.small { margin-top: 0; padding: 3px 10px; font-size: 0.85rem; }
ul.names { columns: 2; padding-left: 18px; margin: 0; }

/* Sprites of PokeAPI, 96 px pixel art scaled without blur */
.sprite { image-rendering: pixelated; vertical-align: middle; }
.slot .sprite { align-self: center; margin: -4px 0 -2px; }
td .sprite { margin: -6px 4px -6px 0; }
/* The header of a Pokémon: text on the left, the sprite inside the card on the right. Its transparent edges may use the padding. */
.card.head { display: flex; align-items: center; gap: 16px; }
.card.head .grow { flex: 1; min-width: 0; }
.sprite.big { flex: none; margin: -20px -8px; }

/* Actions of part 4: links that look like buttons lead to a page that asks first */
a.button { display: inline-block; padding: 6px 14px; border: 1px solid var(--accent); border-radius: 6px; background: var(--accent); color: var(--accent-text); text-decoration: none; }
a.button.secondary { background: transparent; color: var(--accent); }
.actions { align-items: center; }
.actions form.row { flex: 1; min-width: 280px; }
form .actions { margin-top: 14px; }
form .actions button { margin-top: 0; }
.choices { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.choices input[disabled] + * { opacity: 0.6; }

/* The edit form of part 5 */
select { padding: 7px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font: inherit; max-width: 320px; width: 100%; }
form.edit table.facts td { padding: 3px 0; }
form.edit table.stats input { width: 5.5em; padding: 4px 6px; }
form.edit .moves { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
form.edit .moves input { max-width: none; }
form.edit input[type=checkbox] { width: auto; }

/* The audit list: short columns stay on one line and only the message wraps. A narrow screen scrolls the table instead. */
.scroll { overflow-x: auto; }
table.audit td { white-space: nowrap; overflow-wrap: normal; }
table.audit td.detail { white-space: normal; overflow-wrap: break-word; min-width: 260px; width: 100%; }

/* The form of a new Pokémon: the properties need the whole width */
input.wide { max-width: none; }
form.stack label { margin-top: 10px; }

/* The trainer card, part 8.3a */
.card.trainer { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 24px; }
.card.trainer .grow { flex: 1; min-width: 260px; }
.card.trainer .skin { flex: none; width: 128px; height: 256px; image-rendering: pixelated; image-rendering: crisp-edges; }
.card.trainer .title { margin: -6px 0 8px; font-style: italic; }
.badge.rank { border-color: var(--accent); color: var(--accent); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 14px; }
.tile { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.tile strong { display: block; font-size: 1.3rem; }
.tile span { color: var(--muted); font-size: 0.85rem; }
.tracks { display: grid; gap: 8px; }
.track { display: grid; grid-template-columns: 90px 1fr auto; align-items: center; gap: 12px; }
.track progress { width: 100%; }

/* The account: a section inside a card that follows a button or a form */
.card h2.next { margin-top: 26px; }
.card .aside { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--border); }

/* Suggestions under an input, see panel.js */
ul.suggest { position: absolute; z-index: 10; margin: 0; padding: 4px 0; list-style: none; background: var(--card); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25); max-height: 340px; overflow-y: auto; }
ul.suggest li { display: flex; justify-content: space-between; gap: 16px; padding: 5px 12px; cursor: pointer; white-space: nowrap; }
ul.suggest li.active { background: var(--bg); color: var(--accent); }

/* Login through Discord under the code */
form.discord { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--border); }
nav .who a { color: inherit; }

/* Pages of players, part 7 */
nav.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
nav.tabs a { padding: 6px 14px; border: 1px solid var(--border); border-radius: 6px; background: var(--card); color: var(--text); text-decoration: none; }
nav.tabs a.active { border-color: var(--accent); color: var(--accent); }
p.tracks { display: flex; flex-wrap: wrap; gap: 8px; }
progress { width: 100%; height: 14px; margin-top: 8px; accent-color: var(--accent); }
.box.dex .slot { align-items: center; text-align: center; }
tr.own td { font-weight: 600; color: var(--accent); }

/* Leaderboards, part 8.3b */
table.board td:first-child { width: 3.5em; white-space: nowrap; }
table.board th:last-child, table.board td:last-child { text-align: right; white-space: nowrap; }
table.board .head, table.hall .head, dl.firsts .head { width: 24px; height: 24px; margin: -4px 8px -4px 0; border-radius: 4px; image-rendering: pixelated; image-rendering: crisp-edges; vertical-align: middle; }
tr.gap td { text-align: center; color: var(--muted); }
table.board a, table.hall a, dl.firsts a { color: inherit; text-decoration: none; }
table.board a:hover, table.hall a:hover, dl.firsts a:hover { color: var(--accent); text-decoration: underline; }

/* The hall of fame, part 8.4a */
table.hall td:first-child { white-space: nowrap; color: var(--muted); }
table.hall th:last-child, table.hall td:last-child { text-align: right; }
.button .count { opacity: 0.7; font-weight: normal; margin-left: 2px; }
dl.firsts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 20px; margin: 0; }
dl.firsts dt { font-weight: 600; }
dl.firsts dd { margin: 0; overflow-wrap: anywhere; }
dl.firsts .head { margin: -4px 8px -4px 0; }
/* On a phone four columns break every nick in the middle: a catch becomes two lines, who and when over what and its level. */
@media (max-width: 700px) {
  table.hall, table.hall tbody { display: block; }
  table.hall tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
  table.hall tr:first-child { display: none; }
  table.hall td { border: 0; padding: 0; }
  table.hall td:nth-child(1) { grid-area: 1 / 2; font-size: 0.85rem; }
  table.hall td:nth-child(2) { grid-area: 1 / 1; }
  table.hall td:nth-child(3) { grid-area: 2 / 1; }
  table.hall td:nth-child(4) { grid-area: 2 / 2; }
  table.hall td:nth-child(4)::before { content: "Lv. "; color: var(--muted); font-weight: normal; }
  table.hall .head { margin: 0 8px 0 0; }
  dl.firsts { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  dl.firsts dd { margin-bottom: 10px; }
}

/* The login: one centred card with the logo inside, without the header. Purple after the logo, only on this page. */
body.login {
  --accent: #6a52c2;
  --button: #6a52c2;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(900px 520px at 50% -8%, rgba(106, 82, 194, 0.30), transparent 65%),
    radial-gradient(700px 420px at 100% 108%, rgba(226, 54, 70, 0.12), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
@media (prefers-color-scheme: dark) { body.login { --accent: #a999f2; } }
body.login main { width: 100%; max-width: 380px; margin: 0; padding: 0; }
.login-card { padding: 24px 28px 26px; border-radius: 16px; text-align: center; box-shadow: 0 18px 48px rgba(20, 12, 50, 0.18); }
.login-card .logo { display: block; width: 128px; height: 128px; margin: 0 auto 10px; filter: drop-shadow(0 8px 14px rgba(20, 12, 50, 0.35)); }
.login-card h1 { font-size: 1.45rem; margin-bottom: 6px; }
.login-card > p { margin: 0 0 20px; }
.login-card label { text-align: left; font-size: 0.85rem; }
.login-card input + label { margin-top: 12px; }
.login-card input { max-width: none; padding: 11px 12px; border-radius: 10px; font-size: 1rem; letter-spacing: normal; }
.login-card .error { margin: -6px 0 16px; padding: 9px 12px; border: 1px solid var(--bad); border-radius: 10px; color: var(--bad); font-size: 0.9rem; }
.login-card input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.login-card button { width: 100%; margin-top: 18px; padding: 11px 16px; border-radius: 10px; border-color: var(--button); background: var(--button); font-weight: 600; transition: filter 0.15s; }
.login-card button:hover { filter: brightness(1.1); }
.login-card button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.login-card button.secondary { margin-top: 0; border-color: var(--border); background: transparent; color: var(--text); }
.login-card button.secondary:hover { border-color: var(--accent); color: var(--accent); filter: none; }
.login-card form.discord { margin-top: 18px; padding-top: 0; border-top: 0; }
.login-card .or { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; color: var(--muted); font-size: 0.85rem; }
.login-card .or::before, .login-card .or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.login-card .hint { margin: 10px 0 0; font-size: 0.85rem; }
.login-card p.after { margin-top: 24px; }
