/* Kanto Circuit — FireRed vs LeafGreen scoreboard
   Palette is the two cartridges: warm red and leaf green, carried on a
   blue-slate neutral that sides with neither. */

:root {
  --bg: #EFF1F5;
  --surface: #FFFFFF;
  --surface-2: #F6F8FA;
  --ink: #1B2028;
  --ink-2: #59616F;
  --ink-3: #848D9C;
  --line: #DCE0E8;
  --line-2: #C8CEDA;

  --red: #C2372A;
  --red-vivid: #D8402F;
  --red-soft: rgba(216, 64, 47, .09);
  --green: #37792B;
  --green-vivid: #4E9B3D;
  --green-soft: rgba(78, 155, 61, .10);
  --gold: #9C6F16;
  --gold-vivid: #D9A441;

  --shadow: 0 1px 2px rgba(20, 24, 32, .05), 0 10px 28px rgba(20, 24, 32, .07);
  --shadow-sm: 0 1px 2px rgba(20, 24, 32, .06);

  /* A true silhouette: collapse the icon to a flat shape so an inherently
     grey badge (Boulder) still reads as clearly unearned next to a lit one. */
  --tico-off-filter: grayscale(1) brightness(0);
  --tico-off-opacity: .24;

  --r: 14px;
  --r-sm: 9px;

  --display: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Segoe UI", system-ui, sans-serif;
  --body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141820;
    --surface: #1C222C;
    --surface-2: #232B36;
    --ink: #E8ECF2;
    --ink-2: #9AA4B4;
    --ink-3: #707C8C;
    --line: #2B3440;
    --line-2: #3A4552;

    --red: #FF7A67;
    --red-vivid: #FF6F5C;
    --red-soft: rgba(255, 122, 103, .13);
    --green: #7FD463;
    --green-vivid: #74CF5A;
    --green-soft: rgba(127, 212, 99, .13);
    --gold: #EFC565;
    --gold-vivid: #EFC565;

    --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 10px 28px rgba(0, 0, 0, .32);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);

    /* On a dark ground the silhouette must lighten, not darken. */
    --tico-off-filter: grayscale(1) brightness(0) invert(1);
    --tico-off-opacity: .26;
  }
}

:root[data-theme="dark"] {
  --bg: #141820;
  --surface: #1C222C;
  --surface-2: #232B36;
  --ink: #E8ECF2;
  --ink-2: #9AA4B4;
  --ink-3: #707C8C;
  --line: #2B3440;
  --line-2: #3A4552;

  --red: #FF7A67;
  --red-vivid: #FF6F5C;
  --red-soft: rgba(255, 122, 103, .13);
  --green: #7FD463;
  --green-vivid: #74CF5A;
  --green-soft: rgba(127, 212, 99, .13);
  --gold: #EFC565;
  --gold-vivid: #EFC565;

  --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 10px 28px rgba(0, 0, 0, .32);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);

  --tico-off-filter: grayscale(1) brightness(0) invert(1);
  --tico-off-opacity: .26;
}

/* ---------- base ---------- */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 800;
  line-height: 1.15;
  text-wrap: balance;
  margin: 0;
}

p { margin: 0; }

a { color: inherit; }

:where(a, button, summary, [tabindex]):focus-visible {
  outline: 2.5px solid var(--gold-vivid);
  outline-offset: 3px;
  border-radius: 4px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--surface); color: var(--ink);
  padding: 10px 16px; z-index: 20; border-radius: 0 0 var(--r-sm) 0;
}
.skip:focus { left: 0; }

.wrap {
  max-width: 1080px;
  margin-inline: auto;
  padding-inline: clamp(16px, 4vw, 32px);
}

main > section { padding-block: clamp(32px, 5vw, 52px); }
main > section + section { border-top: 1px solid var(--line); }

.sec-head { margin-bottom: 22px; display: flex; flex-direction: column; gap: 6px; }
.sec-head h2 { font-size: clamp(1.35rem, 3vw, 1.75rem); letter-spacing: -.01em; }
.sec-note { color: var(--ink-2); font-size: .94rem; max-width: 64ch; }

/* ---------- masthead ---------- */

.masthead {
  padding-block: clamp(34px, 6vw, 62px) clamp(20px, 3vw, 30px);
  background:
    radial-gradient(120% 130% at 8% 0%, var(--red-soft), transparent 46%),
    radial-gradient(120% 130% at 92% 0%, var(--green-soft), transparent 46%);
}

.eyebrow {
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 10px;
}

.masthead h1 {
  font-size: clamp(2.3rem, 7.5vw, 4rem);
  letter-spacing: -.02em;
  background: linear-gradient(96deg, var(--red-vivid) 0%, var(--red-vivid) 38%, var(--green-vivid) 62%, var(--green-vivid) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lede {
  margin-top: 10px;
  color: var(--ink-2);
  font-size: clamp(1rem, 2.1vw, 1.1rem);
  max-width: 54ch;
}

.themetoggle {
  position: fixed; top: 12px; right: 12px; z-index: 15;
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink-2);
  font-size: 1rem; line-height: 1; cursor: pointer;
  box-shadow: var(--shadow-sm);
  display: grid; place-items: center;
}
.themetoggle:hover { color: var(--ink); border-color: var(--ink-3); }

/* ---------- scoreboard ---------- */

.board {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: clamp(10px, 2vw, 18px);
}

.side {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: clamp(16px, 3vw, 24px);
  display: flex; flex-direction: column; gap: 4px;
  position: relative; overflow: hidden;
}
.side::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
}
.side.red::before { background: var(--red-vivid); }
.side.green::before { background: var(--green-vivid); }

.side .who { font-family: var(--display); font-weight: 800; font-size: clamp(1.25rem, 3.4vw, 1.7rem); }
.side.red .who { color: var(--red); }
.side.green .who { color: var(--green); }

.side .cart {
  font-family: var(--mono); font-size: .76rem; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3);
}

.side .pts {
  font-family: var(--mono); font-weight: 600;
  font-size: clamp(2.6rem, 9vw, 3.9rem);
  line-height: 1; margin-top: 10px;
  font-variant-numeric: tabular-nums;
}
.side .ptslabel { font-size: .8rem; color: var(--ink-3); letter-spacing: .04em; }

.side .badges {
  margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line-2);
  font-size: .88rem; color: var(--ink-2);
}
.side .badges b { font-family: var(--mono); color: var(--ink); font-weight: 600; }

.vs {
  display: grid; place-items: center;
  font-family: var(--display); font-weight: 800;
  font-size: clamp(.85rem, 2.4vw, 1rem);
  letter-spacing: .1em; color: var(--ink-3);
  padding-inline: 2px;
}

.pips { display: flex; gap: 5px; margin-top: 12px; flex-wrap: wrap; }
.pip {
  width: 22px; height: 6px; border-radius: 99px;
  background: var(--line-2);
}
.pip.red { background: var(--red-vivid); }
.pip.green { background: var(--green-vivid); }
.pip.dbl { width: 40px; }

.nextup {
  margin-top: 18px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold-vivid);
  border-radius: var(--r-sm);
  padding: 14px 18px;
  font-size: .95rem; color: var(--ink-2);
}
.nextup b { color: var(--ink); font-weight: 600; }

/* ---------- cup ladder ---------- */

.ladder { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }

.cup {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.cup.won-red { border-color: color-mix(in srgb, var(--red-vivid) 45%, var(--line)); }
.cup.won-green { border-color: color-mix(in srgb, var(--green-vivid) 45%, var(--line)); }

.cup-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: clamp(12px, 2.4vw, 20px);
  align-items: center;
  padding: clamp(14px, 2.4vw, 20px);
}

.cup-n {
  font-family: var(--mono); font-weight: 600; font-size: 1rem;
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--ink-3);
  border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.cup.won-red .cup-n { background: var(--red-soft); color: var(--red); border-color: transparent; }
.cup.won-green .cup-n { background: var(--green-soft); color: var(--green); border-color: transparent; }

.cup-name { font-size: clamp(1.05rem, 2.6vw, 1.3rem); }

/* ---------- unlock track ---------- */

.svgdefs { position: absolute; width: 0; height: 0; overflow: hidden; }

.track {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 4px; margin-top: 7px;
}
.tico { width: 21px; height: 21px; display: block; flex: none; }
/* Silhouette for a requirement this cup does not need. Filter rather than a
   fill override, because the symbols are multi-coloured. */
.tico.off { filter: var(--tico-off-filter); opacity: var(--tico-off-opacity); }

.tsep {
  width: 1px; height: 15px; background: var(--line-2);
  margin-inline: 4px; flex: none;
}
.tnote {
  font-family: var(--mono); font-size: .7rem; color: var(--ink-3);
  margin-left: 6px; white-space: nowrap;
}

@media (max-width: 420px) {
  .tico { width: 18px; height: 18px; }
  .track { gap: 3px; }
}

.cup-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.chip {
  font-family: var(--mono); font-size: .74rem; font-weight: 500;
  padding: 3px 9px; border-radius: 99px;
  background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.chip.pts { color: var(--gold); border-color: color-mix(in srgb, var(--gold-vivid) 40%, var(--line)); background: transparent; }

.cup-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; min-width: 96px; }

.status {
  font-family: var(--mono); font-size: .72rem; font-weight: 600;
  letter-spacing: .07em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 99px;
  border: 1px solid var(--line-2); color: var(--ink-3);
  white-space: nowrap;
}
.status.red { color: var(--red); border-color: transparent; background: var(--red-soft); }
.status.green { color: var(--green); border-color: transparent; background: var(--green-soft); }
.status.live { color: var(--gold); border-color: transparent; background: color-mix(in srgb, var(--gold-vivid) 16%, transparent); }

/* level-cap ramp — width encodes the cap, so the ladder reads as a climb */
.ramp { width: 92px; height: 5px; border-radius: 99px; background: var(--line); overflow: hidden; }
.ramp i { display: block; height: 100%; border-radius: 99px; background: var(--ink-3); }
.cup.won-red .ramp i { background: var(--red-vivid); }
.cup.won-green .ramp i { background: var(--green-vivid); }
.ramp-l { font-family: var(--mono); font-size: .7rem; color: var(--ink-3); }

/* ---------- battle log ---------- */

.log { border-top: 1px solid var(--line); background: var(--surface-2); }

.brings {
  padding: 14px clamp(14px, 2.4vw, 20px);
  border-bottom: 1px dashed var(--line-2);
  display: grid; gap: 10px;
}
.brings .bl {
  font-family: var(--mono); font-size: .72rem; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: 5px;
}

.game { padding: 14px clamp(14px, 2.4vw, 20px); }
.game + .game { border-top: 1px dashed var(--line-2); }

.game-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 11px;
}
.game-n {
  font-family: var(--mono); font-size: .72rem; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3);
}
.game-win {
  font-size: .82rem; font-weight: 600;
  padding: 2px 9px; border-radius: 99px;
}
.game-win.red { color: var(--red); background: var(--red-soft); }
.game-win.green { color: var(--green); background: var(--green-soft); }
.game-note { font-size: .86rem; color: var(--ink-2); flex-basis: 100%; }

.lineups { display: grid; grid-template-columns: 1fr auto 1fr; gap: clamp(8px, 1.6vw, 16px); align-items: start; }
.lineup .ln {
  font-family: var(--mono); font-size: .72rem; font-weight: 600;
  letter-spacing: .05em; margin-bottom: 7px;
}
.lineup.red .ln { color: var(--red); }
.lineup.green .ln { color: var(--green); }
.lineup.right { text-align: right; }

.team { display: flex; flex-wrap: wrap; gap: 6px; }
.lineup.right .team { justify-content: flex-end; }

.mon {
  display: flex; flex-direction: column; align-items: center;
  width: 76px; padding: 5px 3px 6px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-width: 3px;
}
.mon img {
  /* FRLG sprites are natively 64x64 — render 1:1 so no scaling
     artifacts, and let pixelated keep the integer HiDPI upscale crisp. */
  width: 64px; height: 64px; display: block;
  image-rendering: pixelated;
}
.mon .nm {
  font-size: .63rem; line-height: 1.25; text-align: center;
  color: var(--ink-2); margin-top: 1px;
  overflow-wrap: anywhere;
}
.mon .ph {
  width: 64px; height: 64px; display: grid; place-items: center;
  font-family: var(--mono); font-size: 1.15rem; color: var(--ink-3);
}

.midvs {
  font-family: var(--display); font-weight: 800; font-size: .72rem;
  color: var(--ink-3); letter-spacing: .08em;
  align-self: center; padding-top: 18px;
}

.empty {
  padding: 16px clamp(14px, 2.4vw, 20px);
  font-size: .9rem; color: var(--ink-3);
  border-top: 1px solid var(--line); background: var(--surface-2);
}

/* ---------- rules / trading / setup ---------- */

.rules { display: grid; gap: 12px; }
@media (min-width: 720px) { .rules { grid-template-columns: 1fr 1fr; } }

.rule {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.rule h3 { font-size: 1rem; margin-bottom: 5px; }
.rule p { color: var(--ink-2); font-size: .92rem; }

.callout {
  margin-top: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--ink-3);
  border-radius: var(--r-sm);
  padding: 14px 18px;
  font-size: .92rem; color: var(--ink-2);
}
.callout h3 { font-size: .95rem; margin-bottom: 5px; color: var(--ink); }
.callout p + p { margin-top: 7px; }

.trade-grid { display: grid; gap: 12px; }
@media (min-width: 720px) { .trade-grid { grid-template-columns: 1fr 1fr; } }

.tcard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.tcard.red { border-top: 3px solid var(--red-vivid); }
.tcard.green { border-top: 3px solid var(--green-vivid); }
.tcard.full { grid-column: 1 / -1; border-top: 3px solid var(--line-2); }
.tcard h3 { font-size: 1rem; margin-bottom: 3px; }
.tcard.red h3 { color: var(--red); }
.tcard.green h3 { color: var(--green); }
.tcard .sub { font-size: .85rem; color: var(--ink-3); margin-bottom: 11px; }

.plainlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.plainlist li {
  color: var(--ink-2); font-size: .93rem;
  padding-left: 18px; position: relative;
}
.plainlist li::before {
  content: ""; position: absolute; left: 0; top: .62em;
  width: 6px; height: 6px; border-radius: 50%; background: var(--line-2);
}

/* ---------- footer ---------- */

.foot {
  padding-block: 28px 40px;
  border-top: 1px solid var(--line);
  color: var(--ink-3); font-size: .86rem;
  display: flex; flex-direction: column; gap: 8px;
}
.foot .fine { font-size: .78rem; max-width: 70ch; }
.foot span { font-family: var(--mono); }

/* ---------- narrow ---------- */

@media (max-width: 640px) {
  .board { grid-template-columns: 1fr; }
  .vs { padding-block: 2px; }
  .cup-head { grid-template-columns: auto 1fr; }
  .cup-right { grid-column: 1 / -1; flex-direction: row; align-items: center;
               justify-content: space-between; min-width: 0; }
  .lineups { grid-template-columns: 1fr; gap: 12px; }
  .lineup.right { text-align: left; }
  .lineup.right .team { justify-content: flex-start; }
  .midvs { padding-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}
