:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8eaf0;
  --text-dim: #8b93a3;
  --blue: #3b82f6;
  --red: #ef4444;
  --accent: #f1c40f;
}

:root[data-app-theme="light"] {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #eef0f3;
  --border: rgba(0, 0, 0, 0.1);
  --text: #1a1d23;
  --text-dim: #5b6472;
  --blue: #2563eb;
  --red: #dc2626;
  --accent: #b45309;
}

:root[data-app-theme="ocean"] {
  --bg: #071018;
  --panel: #0e1e2c;
  --panel-2: #142a3c;
  --border: rgba(94, 202, 255, 0.14);
  --text: #e4f4ff;
  --text-dim: #7fa8c2;
  --blue: #38bdf8;
  --red: #fb7185;
  --accent: #22d3ee;
}

:root[data-app-theme="forest"] {
  --bg: #0d140f;
  --panel: #16221a;
  --panel-2: #1e2f24;
  --border: rgba(134, 239, 172, 0.12);
  --text: #eaf4ec;
  --text-dim: #8fae97;
  --blue: #4ade80;
  --red: #f87171;
  --accent: #facc15;
}

/* ============================================================================
   Bridge: design-system.css -> this file's theme tokens.

   design-system.css ships a fixed dark ramp, but this page has four user
   themes driven by [data-app-theme]. Redefining the design-system names in
   terms of --bg/--panel/--text means the shared primitives (buttons, inputs,
   focus rings) re-resolve automatically whenever the theme changes, instead of
   staying stuck on the dark values. Only the tokens with no theme equivalent
   are derived, via color-mix against the theme's own surface and text.
   ========================================================================= */
:root {
  --surface-0: var(--bg);
  --surface-1: var(--panel);
  --surface-2: var(--panel-2);
  --surface-3: color-mix(in srgb, var(--panel-2) 88%, var(--text));
  --surface-4: color-mix(in srgb, var(--panel-2) 74%, var(--text));

  --line-subtle: color-mix(in srgb, var(--border) 55%, transparent);
  --line: var(--border);
  --line-strong: color-mix(in srgb, var(--border) 70%, var(--text));

  --ink: var(--text);
  --ink-2: var(--text-dim);
  --ink-3: color-mix(in srgb, var(--text-dim) 72%, var(--bg));

  --info: var(--blue);
  --info-dim: color-mix(in srgb, var(--blue) 16%, transparent);
  --danger: var(--red);
  --danger-dim: color-mix(in srgb, var(--red) 16%, transparent);
  --accent-dim: color-mix(in srgb, var(--accent) 16%, transparent);

  /* Text sitting on top of an --accent fill. Dark themes use a gold accent, so
     near-black reads; the light theme's accent is a dark amber, so it needs
     near-white instead. */
  --accent-ink: #1a1400;
}

:root[data-app-theme="light"] { --accent-ink: #fffaf0; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

/* ============================================================================
   App shell
   ========================================================================= */

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-subtle);
}

.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--sp-3) var(--sp-5);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.app-mark {
  display: block;
  width: 24px;
  height: 24px;
  border-radius: var(--r-md);
}

.app-brand-name {
  font-size: var(--fs-base);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 var(--sp-5) var(--sp-7);
}

/* ---- Hero ----------------------------------------------------------------
   The search is the page's one job, so it gets real vertical space and the
   only large type on the screen. */
.hero {
  padding: var(--sp-7) 0 var(--sp-6);
  text-align: center;
}

.hero h1 {
  margin: 0 0 var(--sp-2);
  font-size: var(--fs-xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: var(--lh-tight);
}

.hero-sub {
  margin: 0 auto var(--sp-5);
  max-width: 46ch;
  color: var(--ink-2);
  font-size: var(--fs-md);
}

/* Saved + Recent: shortcuts into the search above, so they share one row and
   stay visually quieter than the champion browser below. */
.shortcut-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}

.shortcut-grid .panel { margin: 0; }

.page > .panel {
  margin-bottom: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
}

#misc-menu {
  position: relative;
  display: flex;
  justify-content: flex-end;
}

#misc-menu-dropdown {
  display: none;
  position: absolute;
  top: 34px;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  min-width: 170px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  z-index: 20;
}

#misc-menu-dropdown.open { display: block; }

#misc-menu-dropdown a {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
}

#misc-menu-dropdown a:hover { background: rgba(255,255,255,0.06); }

.misc-menu-section {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 8px;
}

.misc-menu-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  padding: 0 10px 5px;
}

.misc-theme-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 0 6px 4px;
}

.misc-theme-group button {
  font-size: 11.5px;
  padding: 6px 4px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}

.misc-theme-group button:hover { background: rgba(255,255,255,0.06); }

.misc-theme-group button.selected {
  background: var(--accent);
  color: #1a1a1a;
  border-color: var(--accent);
  font-weight: 700;
}

/* The search bar reads as one control: region select and submit button sit
   flush inside a single bordered shell that lights up on focus-within, rather
   than as three separate boxes with gaps between them. */
#search-form {
  display: flex;
  align-items: center;
  gap: 0;
  max-width: 560px;
  margin: 0 auto;
  padding: var(--sp-1);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--surface-1);
  box-shadow: var(--shadow-2);
  transition: border-color var(--dur-2) var(--ease),
              box-shadow var(--dur-2) var(--ease);
}

#search-form:focus-within {
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  box-shadow: var(--shadow-2), 0 0 0 4px var(--accent-dim);
}

#search-form select,
#search-form input,
#search-form button {
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: var(--fs-md);
}

#search-form select {
  flex-shrink: 0;
  max-width: 132px;
  border-right: 1px solid var(--line-subtle);
  border-radius: 0;
  color: var(--ink-2);
  font-size: var(--fs-base);
}

#search-form select:hover { background: transparent; }

#search-form :focus-visible {
  box-shadow: none;
  outline: none;
}

/* Without this, Chrome/Edge on Windows renders a dropdown's OPEN option list
   with the OS default (white) background while still inheriting our light text
   color - unreadable until an option is hovered/highlighted. Covers every
   <select> in the app (search form, saved-summoner form, etc.). */
select option {
  background: var(--panel-2);
  color: var(--text);
}

/* Without this, Chrome/Edge on Windows renders a dropdown's OPEN option list
   with the OS default (white) background while still inheriting our light text
   color - unreadable until an option is hovered/highlighted. Covers every
   <select> in the app (search form, saved-summoner form, etc.). */
select option {
  background: var(--panel-2);
  color: var(--text);
}

#search-form input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0 var(--sp-4);
}

#search-form button {
  flex-shrink: 0;
  padding: 0 var(--sp-5);
  border-radius: var(--r-lg);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: var(--fs-base);
  font-weight: 600;
  cursor: pointer;
  transition: filter var(--dur-1) var(--ease);
}

#search-form button:hover { filter: brightness(1.08); }

#status {
  min-height: 20px;
  margin-top: var(--sp-3);
  color: var(--ink-2);
  font-size: var(--fs-base);
  text-align: center;
}

#status:empty { min-height: 0; margin-top: 0; }

#saved-panel {
  max-width: 640px;
  margin: 0 auto 8px;
  padding: 12px 24px;
}

#saved-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}

#saved-header h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  margin: 0;
  font-weight: 700;
}

#add-saved-btn {
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

#add-saved-btn:hover { background: rgba(255,255,255,0.06); }

#saved-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.saved-empty {
  color: var(--text-dim);
  font-size: 12.5px;
  text-align: center;
}

.saved-item {
  display: flex;
  align-items: stretch;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.saved-load {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12.5px;
}

.saved-load:hover { background: rgba(255,255,255,0.06); }

.saved-platform {
  font-size: 10px;
  font-weight: 700;
  color: #1a1a1a;
  background: var(--accent);
  border-radius: 4px;
  padding: 2px 5px;
}

.saved-edit,
.saved-remove {
  border: none;
  border-left: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 11px;
  padding: 6px 8px;
  cursor: pointer;
}

.saved-edit:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.saved-remove:hover { color: var(--red); background: rgba(239,68,68,0.1); }

#saved-form {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 10px;
  flex-wrap: wrap;
}

#saved-form[hidden] {
  display: none;
}

#saved-form select,
#saved-form input,
#saved-form button {
  font-size: 13px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
}

#saved-form-save {
  background: var(--accent);
  color: #1a1a1a;
  font-weight: 700;
  cursor: pointer;
  border: none;
}

#saved-form-cancel {
  cursor: pointer;
}

#history-panel {
  max-width: 640px;
  margin: 0 auto 8px;
  padding: 12px 24px;
}

#history-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}

#history-header h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  margin: 0;
  font-weight: 700;
}

#clear-history-btn {
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

#clear-history-btn:hover { color: var(--red); background: rgba(239,68,68,0.1); }

#history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.history-empty {
  color: var(--text-dim);
  font-size: 12.5px;
  text-align: center;
}

.history-item {
  display: flex;
  align-items: stretch;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.history-load {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12.5px;
}

.history-load:hover { background: rgba(255,255,255,0.06); }

.history-platform {
  font-size: 10px;
  font-weight: 700;
  color: #1a1a1a;
  background: var(--text-dim);
  border-radius: 4px;
  padding: 2px 5px;
}

.history-ago {
  font-size: 10.5px;
  color: var(--text-dim);
}

.history-save {
  border: none;
  border-left: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 11px;
  padding: 6px 8px;
  cursor: pointer;
}

.history-save:hover { color: var(--accent); background: rgba(255,255,255,0.06); }

/* ---- champion search + compare list ---- */

#champion-panel {
  max-width: 640px;
  margin: 0 auto 8px;
  padding: 12px 24px;
}

#champion-header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

#champion-header h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  margin: 0;
  font-weight: 700;
}

#champion-search-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
}

#champion-search-results {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 10px;
}

#champion-search-results:empty { margin-top: 0; }

.champion-search-empty {
  color: var(--text-dim);
  font-size: 12.5px;
  text-align: center;
}

/* Each result = a clickable chip (preview) + its own +/✓ compare toggle, so a
   champion can be added straight from the results without opening the detail. */
.champion-result {
  display: flex;
  align-items: stretch;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.champion-result:hover { border-color: var(--accent); }

.champion-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 4px 8px 4px 4px;
  cursor: pointer;
  font-size: 12.5px;
}

.champion-chip:hover { background: rgba(255,255,255,0.06); }

.champion-chip-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
}

.champion-add-btn {
  border: none;
  border-left: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  padding: 0 10px;
  cursor: pointer;
}

.champion-add-btn:hover { background: rgba(255,255,255,0.06); color: var(--accent); }

.champion-add-btn.added { color: #1a1a1a; background: var(--accent); }

#champion-preview:empty { display: none; }

#champion-preview {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.champion-preview-loading { color: var(--text-dim); font-size: 12.5px; text-align: center; }

#champion-preview-close {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1;
  border-radius: 6px;
  padding: 4px 9px;
  cursor: pointer;
}

#champion-preview-close:hover { color: var(--red); }

.champion-detail-view {
  max-width: 720px;
  margin: 0 auto;
}

.champion-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.champion-detail-header .champ-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
}

.champion-detail-header h2 { margin: 0; font-size: 20px; flex: 1; }

.compare-toggle-btn {
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.compare-toggle-btn:hover { background: rgba(241,196,15,0.12); }

.compare-toggle-btn.added {
  background: var(--accent);
  color: #1a1a1a;
}

#compare-panel {
  max-width: 1100px;
  margin: 0 auto 16px;
  padding: 12px 24px;
}

#compare-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}

#compare-header h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  margin: 0;
  font-weight: 700;
}

#compare-clear-btn {
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

#compare-clear-btn:hover { color: var(--red); background: rgba(239,68,68,0.1); }

/* The columns lay out side by side and scroll horizontally when there are more
   than fit - the "toggled side to side" comparison view. */
#compare-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  align-items: flex-start;
}

.compare-col {
  flex: 0 0 320px;
  max-width: 320px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.compare-col-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.compare-col-header .champ-icon-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.compare-col-name { flex: 1; font-weight: 700; font-size: 14px; }

.compare-remove {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.compare-remove:hover { color: var(--red); }

.compare-loading { color: var(--text-dim); font-size: 12.5px; padding: 8px; }

#winloss-widget {
  max-width: 480px;
  margin: 0 auto 16px;
  padding: 10px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}

#winloss-widget-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#winloss-widget-title {
  font-weight: 700;
  font-size: 13px;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#winloss-widget-timeframe {
  font-size: 11px;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
}

#copy-obs-link-btn {
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--accent);
  color: #1a1a1a;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

#copy-obs-link-btn:hover { filter: brightness(1.08); }

#winloss-widget-body {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-top: 8px;
  font-size: 14px;
}

#winloss-widget-score { font-weight: 700; font-size: 18px; }
#winloss-widget-wr,
#winloss-widget-streak { color: var(--text-dim); font-size: 12.5px; }

#winloss-widget-status {
  font-size: 11px;
  color: var(--red);
  margin-top: 4px;
}

#results {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 24px 60px;
}

/* Widen only when a pinned-abilities sidebar is actually present, so the
   match-history list etc. keep their normal, narrower reading width. */
#results:has(.match-view-layout) {
  max-width: 1440px;
}

/* flex-wrap (not a fixed max-width breakpoint) is what actually makes this
   adapt to any viewport: as long as both items fit at their basis widths they
   sit side by side; the instant they don't, the sidebar - being the one with
   the smaller flex-grow share - wraps onto its own full-width line below
   instead of squeezing (and overlapping) the team columns next to it. */
.match-view-layout {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 20px;
}

.match-main {
  flex: 999 1 640px;
  /* A real floor, not 0: the two-team grid's content (icon + name + 3 buttons
     per row) genuinely needs this much width - letting the flex box shrink it
     further doesn't reflow that content, it just overflows past the box edge
     and visually collides with the sidebar next to it. min-width is exactly
     what flex-wrap's own "does this fit on one line" math respects, so giving
     it the true minimum is what makes the wrap trigger at the right point
     instead of squeezing. */
  min-width: 640px;
}

.pinned-sidebar {
  flex: 1 1 300px;
  min-width: 260px;
  max-width: 340px;
  position: sticky;
  top: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  box-sizing: border-box;
}

/* Once the sidebar has wrapped onto its own line (see above), sticky
   positioning and a viewport-capped height stop making sense - it should
   just sit inline in the normal document flow like everything else. */
@media (max-width: 900px) {
  .pinned-sidebar {
    max-width: none;
    width: 100%;
    position: static;
    max-height: none;
  }
}

.pin-btn {
  font-size: 11px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}

.pin-btn:hover { background: rgba(255,255,255,0.06); }

.pin-btn.pinned {
  background: var(--accent);
  color: #1a1a1a;
  border-color: var(--accent);
  font-weight: 700;
}

.pinned-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.pinned-sidebar-header h3 {
  margin: 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
}

.sort-controls {
  display: flex;
  gap: 4px;
}

.sort-btn {
  font-size: 10.5px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}

.sort-btn:hover { background: rgba(255,255,255,0.06); }

.sort-btn.selected {
  background: var(--accent);
  color: #1a1a1a;
  border-color: var(--accent);
  font-weight: 700;
}

.pinned-sidebar-hint {
  font-size: 10.5px;
  color: var(--text-dim);
  font-style: italic;
  margin-bottom: 10px;
  line-height: 1.4;
}

.pinned-ability-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pinned-ability-row {
  display: flex;
  gap: 8px;
  padding: 6px;
  border-radius: 8px;
  background: var(--panel-2);
}

.pinned-ability-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  flex-shrink: 0;
  background: #000;
}

.pinned-ability-info { flex: 1; min-width: 0; }

.pinned-ability-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pinned-ability-title .slot {
  background: var(--accent);
  color: #1a1a1a;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

.pinned-champ-name {
  color: var(--text-dim);
  font-weight: 400;
}

.pinned-ability-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.pinned-ability-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 10.5px;
  color: var(--text-dim);
}

.cc-badge {
  background: rgba(239, 68, 68, 0.18);
  color: var(--red);
  border-radius: 4px;
  padding: 1px 6px;
  font-weight: 700;
}

.game-meta {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 16px;
}

.teams {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 760px) {
  .teams { grid-template-columns: 1fr; }
}

.team {
  border-radius: 12px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
}

.team-blue { border-top: 3px solid var(--blue); }
.team-red { border-top: 3px solid var(--red); }

.participant {
  background: var(--panel-2);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
}

.participant-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.champ-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #000;
  flex-shrink: 0;
}

.participant-info {
  flex: 1;
  min-width: 0;
}

.summoner-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.champion-name {
  color: var(--text-dim);
  font-size: 12px;
}

.opgg-link {
  font-size: 11px;
  font-weight: 700;
  color: #1a1a1a;
  background: var(--accent);
  padding: 5px 8px;
  border-radius: 6px;
  text-decoration: none;
  flex-shrink: 0;
}

.opgg-link:hover { filter: brightness(1.08); }

.expand-btn {
  font-size: 11px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}

.expand-btn:hover { background: rgba(255,255,255,0.06); }

.detail-panel {
  display: none;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.detail-panel.open { display: block; }

.champ-stats {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 10px;
  line-height: 1.6;
}

.ability {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.ability:last-child { border-bottom: none; }

.ability-icon {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  flex-shrink: 0;
  background: #000;
}

.ability-body { flex: 1; min-width: 0; }

.ability-name {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 3px;
}

.ability-name .slot {
  display: inline-block;
  background: var(--accent);
  color: #1a1a1a;
  border-radius: 4px;
  padding: 1px 6px;
  margin-right: 6px;
  font-size: 11px;
}

.ability-desc {
  font-size: 12.5px;
  color: var(--text);
  white-space: pre-line;
  line-height: 1.5;
  margin-bottom: 4px;
}

.ability-meta {
  font-size: 11.5px;
  color: var(--text-dim);
}

.ability-note {
  font-size: 11px;
  color: var(--text-dim);
  font-style: italic;
  margin-top: 4px;
}

.error-box {
  text-align: center;
  color: var(--red);
  padding: 20px;
}

/* ---- match history list ---- */

.history-header {
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
}

/* ---- match history overview: aggregate stats, form strip, trend chart, champ breakdown ---- */

.history-overview {
  max-width: 700px;
  margin: 0 auto 24px;
  padding: 14px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.overview-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  font-size: 13px;
  margin-bottom: 12px;
}

.overview-stats strong { font-size: 15px; }

.overview-section-title {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin: 14px 0 6px;
}

.form-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.form-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
}

.form-dot.win { background: var(--blue); }
.form-dot.loss { background: var(--red); }
.form-dot:hover { outline: 2px solid var(--accent); outline-offset: 1px; }

.trend-chart {
  width: 100%;
  height: auto;
  display: block;
}

.trend-point {
  cursor: pointer;
}

.trend-point:hover { r: 5; }

.champ-breakdown {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.champ-row {
  display: grid;
  grid-template-columns: 26px 1fr 50px 70px 70px;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  padding: 4px 0;
}

.champ-icon-sm {
  width: 26px;
  height: 26px;
  border-radius: 5px;
}

.champ-row .champ-games { color: var(--text-dim); text-align: right; }
.champ-row .champ-wr { text-align: right; font-weight: 700; }
.champ-row .champ-wr.good { color: var(--blue); }
.champ-row .champ-wr.bad { color: var(--red); }
.champ-row .champ-kda { color: var(--text-dim); text-align: right; }

.match-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.match-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--text-dim);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
}

.match-card:hover { background: var(--panel-2); }

.match-card.result-win { border-left-color: var(--blue); }
.match-card.result-loss { border-left-color: var(--red); }

.match-card .champ-icon {
  width: 44px;
  height: 44px;
  border-radius: 8px;
}

.match-card-info { flex: 1; min-width: 0; }

.match-card-top {
  display: flex;
  gap: 10px;
  font-size: 12px;
  margin-bottom: 3px;
}

.match-result { font-weight: 700; }
.result-win .match-result { color: var(--blue); }
.result-loss .match-result { color: var(--red); }

.match-queue,
.match-ago {
  color: var(--text-dim);
}

.match-card-bottom {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.load-more-row {
  text-align: center;
  margin-top: 14px;
}

.load-more-row button {
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}

.load-more-row button:hover { background: rgba(255,255,255,0.06); }

/* ---- match detail ---- */

.match-detail-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 14px;
  position: relative;
}

#back-to-list-btn {
  position: absolute;
  left: 0;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

#back-to-list-btn:hover { background: rgba(255,255,255,0.06); }

.match-detail-header .game-meta { margin: 0; }

.team-result {
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 4px;
  margin-bottom: 8px;
  border-radius: 6px;
}

.team-result.win { color: var(--blue); background: rgba(59, 130, 246, 0.12); }
.team-result.loss { color: var(--red); background: rgba(239, 68, 68, 0.12); }

.match-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  margin-top: 6px;
}

.stat-label {
  color: var(--text-dim);
  font-size: 10.5px;
}

.items-row {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

.item-icon {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  background: rgba(255,255,255,0.05);
}

.item-icon.item-empty {
  border: 1px dashed var(--border);
}

/* ---- graphs ---- */

.graphs-section,
.events-section {
  max-width: 700px;
  margin: 26px auto 0;
}

.graphs-section h2,
.events-section h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin: 20px 0 8px;
}

.diff-chart {
  width: 100%;
  height: auto;
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.chart-caption {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

.chart-empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  padding: 20px;
}

.dmg-bar-chart {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dmg-bar-row {
  display: grid;
  grid-template-columns: 90px 1fr 70px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.dmg-bar-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dmg-bar-track {
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  overflow: hidden;
  height: 14px;
}

.dmg-bar-fill {
  height: 100%;
  border-radius: 4px;
}

.dmg-bar-value {
  text-align: right;
  color: var(--text-dim);
}

/* ---- kills & objectives timeline ---- */

.events-list {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
}

.event-row {
  display: flex;
  gap: 10px;
  padding: 6px 12px;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
}

.event-row:last-child { border-bottom: none; }
.event-row.evt-blue { border-left-color: var(--blue); }
.event-row.evt-red { border-left-color: var(--red); }

.event-time {
  color: var(--text-dim);
  width: 40px;
  flex-shrink: 0;
}

.event-type {
  width: 76px;
  flex-shrink: 0;
  color: var(--text-dim);
  font-weight: 700;
  font-size: 10.5px;
  letter-spacing: 0.5px;
}

/* ============================================================================
   Layout reconciliation

   The section rules above each centred themselves with `max-width: 640px;
   margin: 0 auto`, which is why the page read as one narrow column of
   equal-weight blocks. Width and placement are now the .page grid's job, so
   these hand back that control. Appended rather than edited in place: same
   specificity, later wins, and the original rules stay legible as history.
   ========================================================================= */

#saved-panel,
#history-panel,
#champion-panel,
#compare-panel,
#winloss-widget {
  max-width: none;
  margin: 0 0 var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
}

.shortcut-grid #saved-panel,
.shortcut-grid #history-panel {
  margin: 0;
  padding: var(--sp-3) var(--sp-4);
}

/* Headers were centred, which left no consistent edge to scan down. Left-align
   the title and push the action to the far side. */
#saved-header,
#history-header,
#champion-header,
#compare-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}

#saved-header h2,
#history-header h2,
#champion-header h2,
#compare-header h2 {
  margin: 0;
  color: var(--ink-3);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Champion browser is the page's main content once a search is idle, so its
   title sits at body scale and the filter moves up onto the header row. */
#champion-header h2 {
  color: var(--ink);
  font-size: var(--fs-base);
  letter-spacing: -0.01em;
  text-transform: none;
}

#champion-header #champion-search-input {
  display: block;
  width: auto;
  flex: 0 1 280px;
  height: 30px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-md);
  font-size: var(--fs-base);
}

#results {
  max-width: none;
  padding: 0;
}

#results:empty { display: none; }

/* The action buttons in these headers are .btn now; drop the bespoke sizing
   the old rules gave them so they match every other button in the app. */
#add-saved-btn,
#clear-history-btn,
#compare-clear-btn,
#copy-obs-link-btn {
  font-size: var(--fs-xs);
  border-radius: var(--r-md);
}

#saved-form {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}

#saved-form[hidden] { display: none; }

@media (max-width: 640px) {
  .app-header-inner,
  .page { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .hero { padding: var(--sp-6) 0 var(--sp-5); }
  .hero h1 { font-size: var(--fs-lg); }
  #search-form { flex-wrap: wrap; }
  #search-form select { max-width: none; border-right: none; }
  #search-form input { flex-basis: 100%; order: -1; }
}
