:root {
  --bg: #f6f5f1;
  --panel: #ffffff;
  --ink: #1d2320;
  --muted: #5d6762;
  --line: #e2e0d8;
  --accent: #2f6f5e;
  --accent-ink: #ffffff;
  --lost: #a8432f;
  --won: #2f6f5e;
  --soft: #eef3f0;
  --warn-bg: #fff6e0;
  --warn-ink: #6b4d00;
  --radius: 12px;
  /* splinters */
  --Red: #c8462f; --Blue: #2f6db5; --Green: #3d8a3b; --White: #b89a3a; --Black: #6a4a8c; --Gold: #c79416; --Gray: #7b8580;
  color-scheme: light;
}
/* Dark colors: used when the device prefers dark (theme "Auto"), or when the player picks Dark.
   theme.js sets data-theme="light" / "dark" on <html> from the saved choice. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141816; --panel: #1c211f; --ink: #e7ece9; --muted: #9aa5a0; --line: #2d3431;
    --accent: #5cb89c; --accent-ink: #0d1411; --lost: #e2846f; --won: #5cb89c; --soft: #222a27;
    --warn-bg: #3a3118; --warn-ink: #f0d38a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141816; --panel: #1c211f; --ink: #e7ece9; --muted: #9aa5a0; --line: #2d3431;
  --accent: #5cb89c; --accent-ink: #0d1411; --lost: #e2846f; --won: #5cb89c; --soft: #222a27;
  --warn-bg: #3a3118; --warn-ink: #f0d38a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main, .top, footer.site { max-width: 860px; margin: 0 auto; padding: 0 16px; }
a { color: var(--accent); }
h1 { font-size: 1.7rem; line-height: 1.2; margin: 0.4em 0 0.3em; }
h2 { font-size: 1.15rem; margin: 0 0 0.6em; }
h3 { font-size: 1rem; margin: 0 0 0.4em; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

.top { display: flex; align-items: center; gap: 12px; padding-top: 14px; padding-bottom: 6px; }
.brand { font-weight: 800; letter-spacing: 0.02em; text-decoration: none; color: var(--ink); font-size: 1.1rem; padding: 8px 0; }
.tag { font-size: 0.75rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }

.lead { color: var(--muted); margin: 0 0 1em; max-width: 46em; }
.paste { display: flex; gap: 8px; }
.paste input {
  flex: 1; min-width: 0; font: inherit; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink);
}
.paste input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button, .button {
  font: inherit; font-weight: 600; cursor: pointer; border: 0; border-radius: var(--radius);
  padding: 12px 18px; background: var(--accent); color: var(--accent-ink);
}
button.secondary { background: var(--soft); color: var(--ink); border: 1px solid var(--line); }
button:disabled { opacity: 0.6; cursor: default; }
.hint { font-size: 0.875rem; color: var(--muted); margin: 6px 0 0; }
.status { min-height: 1.5em; color: var(--muted); margin: 14px 0; }
.status.error { color: var(--lost); }

.who { margin: 8px 0 20px; }
.who-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.who-buttons button { min-width: 140px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 16px; }
.summary h2 { font-size: 1.35rem; margin: 0 0 4px; }
.summary .lost { color: var(--lost); }
.summary .won { color: var(--won); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; }
.chips li { font-size: 0.8rem; background: var(--soft); border-radius: 999px; padding: 2px 10px; }
details { margin-top: 10px; }
details summary { cursor: pointer; color: var(--accent); font-size: 0.9rem; }
details ul { margin: 6px 0 0; padding-left: 1.2em; }

.factors { margin: 0; padding-left: 1.3em; }
.factors li { margin: 0 0 8px; }
.factors li::marker { font-weight: 700; color: var(--accent); }
.coach-text { white-space: pre-line; margin: 0 0 12px; }
.coach-text:empty { display: none; }

.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .teams { grid-template-columns: 1fr; } }
.team h3 { display: flex; align-items: center; gap: 8px; }
.unit { display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: start; padding: 8px 0; border-top: 1px solid var(--line); }
.unit:first-of-type { border-top: 0; }
.thumb { width: 44px; height: 60px; border-radius: 6px; background: var(--soft); object-fit: cover; object-position: top; }
.thumb.blank { display: grid; place-items: center; font-size: 0.7rem; color: var(--muted); }
.unit .name { font-weight: 600; }
.unit .meta { font-size: 0.8rem; color: var(--muted); }
.unit .fate { font-size: 0.8rem; }
.unit .fate.dead { color: var(--lost); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.pos { display: inline-grid; place-items: center; min-width: 1.5em; height: 1.5em; padding: 0 0.3em; margin-right: 6px; border-radius: 999px;
  background: var(--soft); border: 1px solid var(--line); font-size: 0.72rem; font-weight: 700; color: var(--muted); vertical-align: 0.1em; }
.badge { font-size: 0.7rem; font-weight: 600; border-radius: 999px; padding: 1px 7px; background: var(--warn-bg); color: var(--warn-ink); white-space: nowrap; }
.badge.owned { background: var(--soft); color: var(--muted); }

.timeline { margin: 0; padding: 0; list-style: none; }
.timeline li { padding: 4px 0; border-top: 1px solid var(--line); font-size: 0.92rem; }
.timeline li:first-child { border-top: 0; }
.timeline .r { display: inline-block; min-width: 4.5em; font-weight: 700; color: var(--muted); }

.swap { display: grid; grid-template-columns: auto 1fr; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.swap:first-of-type { border-top: 0; }
.swap .cards { display: flex; align-items: center; gap: 6px; }
.swap .arrow { color: var(--muted); font-size: 1.1rem; }
.swap ul { margin: 4px 0 0; padding-left: 1.1em; font-size: 0.92rem; }
.swap .title { font-weight: 600; }
.price { font-weight: 700; }
.lineup { margin: 0; padding: 0; list-style: none; }
.note { background: var(--soft); border-radius: 8px; padding: 10px 12px; font-size: 0.92rem; margin: 10px 0 0; }
.note.warn { background: var(--warn-bg); color: var(--warn-ink); }
.glossary dt { font-weight: 600; }
.glossary dd { margin: 0 0 8px; color: var(--muted); }
.share { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

footer.site { color: var(--muted); font-size: 0.8rem; padding-top: 12px; padding-bottom: 32px; border-top: 1px solid var(--line); margin-top: 24px; }
footer.site p { margin: 6px 0; }
.buy-warning { margin: 0 0 12px; line-height: 1.45; }

/* Small links and toggles: keep a comfortable tap area on phones without changing the layout. */
.summary a[data-switch] { display: inline-block; padding: 10px 4px; margin: -10px -4px; }
details summary { padding: 9px 0; margin: -9px 0; }
details[open] summary { margin-bottom: 0; }

/* PC and large tablets: wider page, bigger card art, suggested team in two columns. */
@media (min-width: 900px) {
  main, .top, footer.site { max-width: 1040px; }
  h1 { font-size: 2.1rem; }
  .panel { padding: 20px 22px; }
  .unit { grid-template-columns: 56px 1fr; gap: 12px; }
  .thumb { width: 56px; height: 76px; }
  /* Two columns that read top to bottom, like a lineup. */
  .lineup-grid { column-count: 2; column-gap: 28px; }
  .lineup-grid .unit { break-inside: avoid; }
}
/* Summoners show their whole card (portrait frame), not a cropped battle image. */
.thumb.card { object-fit: contain; background: transparent; }

/* Header theme switch */
.top .spacer { flex: 1; }
.theme-toggle {
  font-size: 0.85rem; font-weight: 600; padding: 8px 12px; min-height: 40px;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 999px;
}
.theme-toggle:hover { border-color: var(--accent); }
@media (max-width: 360px) { .top .tag { display: none; } }
