:root {
  --bg: #0a0d1c;
  --bg-deep: #05070f;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-strong: rgba(255, 255, 255, 0.07);
  --line: rgba(255, 255, 255, 0.09);
  --text: #eaedff;
  --muted: #9ba3c9;
  --faint: #6b7399;
  --gold: #f3c76b;
  --gold-soft: rgba(243, 199, 107, 0.16);
  --violet: #b590ff;
  --violet-soft: rgba(181, 144, 255, 0.16);
  --good: #7ee0b0;
  --warn: #f3c76b;
  --bad: #ff8a8a;
  --stale: #ffaa73;
  --stale-soft: rgba(255, 170, 115, 0.13);
  --radius: 18px;
  --font-head: 'Sora', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--bg-deep); }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(120, 90, 255, 0.22), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(60, 140, 255, 0.14), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

/* A faint field of stars behind everything. */
.sky {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.55;
  background-image:
    radial-gradient(1px 1px at 12% 18%, #fff, transparent),
    radial-gradient(1px 1px at 68% 8%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 40% 32%, #cfd6ff, transparent),
    radial-gradient(1px 1px at 88% 44%, #fff, transparent),
    radial-gradient(1px 1px at 22% 66%, #dfe3ff, transparent),
    radial-gradient(1.5px 1.5px at 76% 72%, #fff, transparent),
    radial-gradient(1px 1px at 52% 88%, #cfd6ff, transparent),
    radial-gradient(1px 1px at 6% 92%, #fff, transparent);
  background-size: 520px 520px;
}

.top, main, .credits {
  position: relative;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

/* Header */
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 28px;
  padding-bottom: 20px;
}
.switches { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; margin-left: auto; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 34px;
  height: 34px;
  fill: var(--gold);
  filter: drop-shadow(0 0 12px rgba(243, 199, 107, 0.55));
}
.brand h1 {
  margin: 0;
  font-family: var(--font-head);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 0.875rem; }
.game-switch, .view-switch {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
}
.game-switch button, .view-switch button {
  padding: 7px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: 500 0.8125rem var(--font-body);
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.game-switch button:hover, .view-switch button:hover { color: var(--text); }
.game-switch button[aria-pressed='true'] {
  background: var(--gold-soft);
  color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(243, 199, 107, 0.35);
}
/* Which page you're on is violet, so it doesn't read as a fourth game. */
.view-switch button[aria-pressed='true'] {
  background: var(--violet-soft);
  color: var(--violet);
  box-shadow: inset 0 0 0 1px rgba(181, 144, 255, 0.4);
}
.game-switch button:focus-visible, .view-switch button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Sign-in. Until it's known whether you're signed in, neither the gate nor the app shows. */
.auth-pending main, .auth-pending .switches, .auth-pending .gate,
.signed-out main, .signed-out .switches { display: none; }
body:not(.signed-out) .gate { display: none; }
.gate { position: relative; display: grid; place-items: center; padding: 6vh 16px 2vh; }
.gate-card {
  width: min(420px, 100%);
  padding: 32px 28px 26px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background:
    radial-gradient(320px 180px at 50% 0%, var(--gold-soft), transparent 70%),
    var(--panel);
  backdrop-filter: blur(10px);
  text-align: center;
}
.gate-mark { width: 44px; height: 44px; fill: var(--gold); filter: drop-shadow(0 0 16px rgba(243, 199, 107, 0.6)); }
.gate-card h2 { margin: 12px 0 6px; font-family: var(--font-head); font-size: 1.4rem; font-weight: 600; }
.gate-text { margin: 0 0 22px; color: var(--muted); font-size: 0.9375rem; line-height: 1.5; }
.gate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 12px 18px;
  border: 0;
  border-radius: 12px;
  background: #fff;
  color: #1f1f1f;
  font: 600 0.9375rem var(--font-body);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.gate-btn:hover { box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.12); }
.gate-btn:active { transform: translateY(1px); }
.gate-btn:disabled { opacity: 0.6; cursor: progress; }
.gate-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.gate-btn svg { width: 20px; height: 20px; flex: none; }
.gate-error { margin: 14px 0 0; color: var(--bad); font-size: 0.8125rem; line-height: 1.5; }
.gate-error:empty { display: none; }
.account { margin: 0 0 10px; color: var(--muted); }
.account button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

/* Status panel */
.status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(10px);
}
.status-rows { display: flex; flex-direction: column; gap: 8px; min-width: 0; flex: 1 1 420px; }
.pill {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--text);
}
.pill::before {
  content: '';
  flex: none;
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--faint);
}
.pill-good::before { background: var(--good); box-shadow: 0 0 10px var(--good); }
.pill-warn::before { background: var(--warn); box-shadow: 0 0 10px var(--warn); }
.pill-bad::before { background: var(--bad); box-shadow: 0 0 10px var(--bad); }
.pill-loading::before { animation: pulse 1.2s ease-in-out infinite; }
.pill strong { font-weight: 600; }

.refresh {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid rgba(243, 199, 107, 0.45);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(243, 199, 107, 0.2), rgba(243, 199, 107, 0.08));
  color: var(--gold);
  font: 600 0.875rem var(--font-body);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}
.refresh:hover { background: linear-gradient(180deg, rgba(243, 199, 107, 0.3), rgba(243, 199, 107, 0.12)); }
.refresh:active { transform: translateY(1px); }
.refresh:disabled { opacity: 0.6; cursor: progress; }
.refresh svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.refresh.busy svg { animation: spin 0.9s linear infinite; }
.refresh[data-mode='edit'] .icon-refresh, .refresh:not([data-mode='edit']) .icon-edit { display: none; }
.refresh[data-mode='edit'].busy svg { animation: none; }

.summary { margin: 22px 2px 6px; color: var(--muted); font-size: 0.9375rem; }
.summary strong { color: var(--text); font-weight: 600; }

/* Roster sections */
.group { margin-top: 26px; }
.group-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 2px 14px;
  font-family: var(--font-head);
  font-size: 1.05rem;
  font-weight: 600;
}
.group-title .count { color: var(--faint); font-family: var(--font-body); font-size: 0.875rem; font-weight: 500; }
.group-note { margin: -8px 2px 14px; color: var(--faint); font-size: 0.8125rem; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
  gap: 14px;
}

/* Character card */
.card {
  --rarity: var(--gold);
  --rarity-soft: var(--gold-soft);
  --el: #9ba3c9;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(240px 140px at 0% 0%, var(--rarity-soft), transparent 70%),
    var(--panel);
  overflow: hidden;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.card.r4 { --rarity: var(--violet); --rarity-soft: var(--violet-soft); }
.card:hover { border-color: color-mix(in srgb, var(--rarity) 45%, transparent); transform: translateY(-2px); }

.card-head { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; }

.portrait {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  padding: 2px;
  background: conic-gradient(from 210deg, var(--rarity), transparent 40%, var(--rarity) 80%);
}
.portrait img, .portrait .initials {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: #161a33;
}
.initials {
  display: grid !important;
  place-items: center;
  font-family: var(--font-head);
  font-weight: 600;
  color: var(--muted);
}

.who { min-width: 0; }
.who h3 {
  margin: 0;
  font-family: var(--font-head);
  font-size: 1.0625rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
}
.meta .tag { display: inline-flex; align-items: center; gap: 5px; }
.meta img { width: 16px; height: 16px; }
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--el);
  box-shadow: 0 0 8px var(--el);
  /* Keeps dark element colours (Quantum) visible on the dark card. */
  outline: 1px solid rgba(255, 255, 255, 0.35);
  outline-offset: 1px;
}

/* Copy counters */
.copies { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.badge {
  min-width: 46px;
  padding: 4px 10px;
  border-radius: 10px;
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  color: var(--faint);
  background: rgba(255, 255, 255, 0.05);
}
.badge.has { color: #1a1406; background: linear-gradient(180deg, #ffe1a1, var(--gold)); box-shadow: 0 0 18px rgba(243, 199, 107, 0.35); }
.badge.max { background: linear-gradient(135deg, #ffe9b8, var(--gold) 45%, #ff9e6b); }

.pips { display: flex; gap: 4px; }
.pip {
  width: 8px;
  height: 8px;
  transform: rotate(45deg);
  border-radius: 1.5px;
  background: rgba(255, 255, 255, 0.12);
}
.pip.on { background: var(--gold); box-shadow: 0 0 6px rgba(243, 199, 107, 0.7); }
.pips.round .pip { transform: none; border-radius: 50%; width: 7px; height: 7px; }

/* Light cone row */
.lc {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.lc img, .lc .lc-blank { width: 40px; height: 40px; border-radius: 8px; object-fit: contain; background: rgba(255, 255, 255, 0.04); }
.lc-name { min-width: 0; }
.lc-name p {
  display: -webkit-box;
  margin: 0;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.3;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.lc-name span { color: var(--faint); font-size: 0.75rem; }
.lc .copies { flex-direction: row; align-items: center; gap: 8px; }
.lc .badge { min-width: 38px; padding: 3px 8px; font-size: 0.875rem; }
.lc-none { grid-template-columns: 1fr; color: var(--faint); font-size: 0.8125rem; }

.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: -4px; }
.source { margin: 0; color: var(--faint); font-size: 0.75rem; }
.source.enka::before { content: '● '; color: var(--good); }

/* Cards that open build advice */
.card.has-advice { cursor: pointer; }
.card.has-advice:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.advice-chip {
  flex: none;
  padding: 4px 10px;
  border: 1px solid rgba(243, 199, 107, 0.4);
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold);
  font-size: 0.75rem;
  font-weight: 600;
}
/* Advice written for other copies than the ones you have now */
.advice-chip.outdated {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-color: rgba(255, 170, 115, 0.45);
  background: var(--stale-soft);
  color: var(--stale);
}
.advice-chip.outdated::before,
.advice-outdated strong::before {
  content: '';
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--stale);
  box-shadow: 0 0 8px var(--stale);
}

/* Build advice panel */
body:has(.advice[open]) { overflow: hidden; }
.advice {
  width: min(780px, calc(100% - 32px));
  max-height: min(92vh, 100%);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(180deg, #11163a 0%, #0b0e1f 240px);
  color: var(--text);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
  overflow: auto;
  overscroll-behavior: contain;
}
.advice::backdrop { background: rgba(3, 5, 12, 0.72); backdrop-filter: blur(4px); }
.advice-inner { padding: 0 22px 22px; }

.advice-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 -22px;
  padding: 16px 22px;
  background: rgba(15, 19, 48, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.advice-head h2 { margin: 0; font-family: var(--font-head); font-size: 1.2rem; font-weight: 600; }
.advice-head .meta { margin-top: 3px; }
.advice-title { flex: 1; min-width: 0; }
.advice-close {
  margin-left: auto;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.advice-close:hover { color: var(--text); background: var(--panel-strong); }

.mini .portrait { width: 44px; height: 44px; }

.advice-summary {
  margin: 18px 0 0;
  padding: 14px 16px;
  border-left: 3px solid var(--gold);
  border-radius: 0 12px 12px 0;
  background: var(--gold-soft);
  font-size: 0.9375rem;
  line-height: 1.55;
}

.advice-outdated {
  margin: 18px 0 0;
  padding: 12px 16px;
  border-left: 3px solid var(--stale);
  border-radius: 0 12px 12px 0;
  background: var(--stale-soft);
  font-size: 0.875rem;
  line-height: 1.5;
}
.advice-outdated p { margin: 0; color: var(--muted); }
.advice-outdated p + p { margin-top: 4px; }
.advice-outdated strong { display: inline-flex; align-items: center; gap: 8px; color: var(--stale); font-weight: 600; }
.advice-outdated + .advice-summary { margin-top: 10px; }

/* Weapons the advice covers, listed when nothing is equipped */
.lc-option { padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.lc-option + .lc-option { margin-top: 8px; }
.lc-option-name { margin: 0; font-weight: 600; font-size: 0.9375rem; }
.lc-option .advice-text { margin-top: 4px; color: var(--muted); }

.advice-section { margin-top: 26px; }
.advice-section h3 { margin: 0; font-family: var(--font-head); font-size: 1.05rem; font-weight: 600; }
.advice-lead { margin: 4px 0 12px; color: var(--muted); font-size: 0.8125rem; line-height: 1.5; }
.advice-text { margin: 10px 0 0; font-size: 0.875rem; line-height: 1.55; }
.advice-error { margin: 18px 0; color: var(--bad); }

.eidolon-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
}
.eidolon-row + .eidolon-row { margin-top: 8px; }
.eidolon-row.off { opacity: 0.6; }
.eidolon-row.on { border-color: rgba(243, 199, 107, 0.25); }
.e-title { margin: 2px 0 0; font-weight: 600; font-size: 0.875rem; }
.e-title .locked { color: var(--faint); font-weight: 500; }
.e-what, .e-foryou { margin: 6px 0 0; font-size: 0.8125rem; line-height: 1.5; color: var(--muted); }
.e-foryou { color: var(--text); }
.e-foryou strong { color: var(--gold); }

.build-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px 16px;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  font-size: 0.875rem;
  line-height: 1.5;
}
.build-list dt { color: var(--muted); font-weight: 500; }
.build-list dd { margin: 0; }

.copy-note { margin: 8px 0 0; font-size: 0.8125rem; line-height: 1.5; }
.copy-note.have strong { color: var(--gold); }
.copy-note.next { color: var(--muted); }
.copy-note.next strong { color: var(--violet); }

.team {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}
.team + .team { margin-top: 12px; }
.team-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.team-head h4 { margin: 0; font-family: var(--font-head); font-size: 1rem; font-weight: 600; }
.team-tag {
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 138, 138, 0.12);
  color: var(--bad);
  font-size: 0.75rem;
  font-weight: 600;
}
.team-tag.ok { background: rgba(126, 224, 176, 0.12); color: var(--good); }
.team-source { margin: 4px 0 0; color: var(--faint); font-size: 0.75rem; }

.slot { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.slot-role {
  margin: 0 0 8px;
  color: var(--faint);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.slot-pick { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; }
.slot-name { margin: 2px 0 0; font-weight: 600; font-size: 0.9375rem; }
.slot-copies { color: var(--muted); font-weight: 500; font-size: 0.8125rem; }
.slot-note { margin: 6px 0 0; color: var(--muted); font-size: 0.8125rem; line-height: 1.5; }
.slot-empty { margin: 0; color: var(--bad); font-size: 0.8125rem; }
.slot-alts, .slot-missing { margin: 10px 0 0; font-size: 0.75rem; color: var(--muted); }
.slot-missing { color: var(--faint); }

.advice-sources { margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--faint); font-size: 0.75rem; line-height: 1.6; }
.advice-sources a { color: var(--accent, #8fb3ff); }

/* Wuthering Waves roster form (shares the advice panel's frame) */
.editor { width: min(680px, calc(100% - 32px)); }
.editor-inner { padding-bottom: 0; }
.editor-loading { margin: 18px 0 22px; }
.editor-tools { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 14px; }
.editor-tools .ed-input { flex: 1 1 220px; }

.ed-input, .ed-select {
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(8, 11, 28, 0.8);
  color: var(--text);
  font: 500 0.875rem var(--font-body);
}
.ed-select {
  padding-right: 32px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ba3c9' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  cursor: pointer;
}
.ed-select:disabled { opacity: 0.45; cursor: default; }
.ed-input:focus-visible, .ed-select:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.ed-select option { background: #0f1330; color: var(--text); }

.ed-list { display: grid; gap: 8px; }
.ed-row {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  transition: border-color 0.15s, background 0.15s;
}
.ed-row.owned {
  --el-c: var(--el, var(--gold));
  border-color: color-mix(in srgb, var(--el-c) 38%, transparent);
  background: linear-gradient(100deg, color-mix(in srgb, var(--el-c) 12%, transparent), var(--panel) 55%);
}
.ed-main { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 10px 12px; cursor: pointer; }
.ed-main .portrait { width: 44px; height: 44px; }
.ed-row:not(.owned) .portrait img { filter: saturate(0.35); opacity: 0.7; }
.ed-who { min-width: 0; }
.ed-name { display: block; overflow: hidden; font-weight: 600; font-size: 0.9375rem; white-space: nowrap; text-overflow: ellipsis; }
.ed-meta { display: flex; align-items: center; gap: 6px; margin-top: 2px; color: var(--muted); font-size: 0.75rem; }
.ed-meta .dot { background: var(--el, var(--faint)); }

/* The "I own this" switch */
.ed-switch {
  position: relative;
  flex: none;
  width: 44px;
  height: 26px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  appearance: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.ed-switch::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s, background 0.15s;
}
.ed-switch:checked { border-color: transparent; background: linear-gradient(180deg, #ffe1a1, var(--gold)); }
.ed-switch:checked::before { background: #1a1406; transform: translateX(18px); }
.ed-switch:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.ed-details { display: grid; gap: 12px; padding: 2px 12px 14px; }
.ed-details[hidden] { display: none; }
.ed-label { margin: 0 0 6px; color: var(--faint); font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.seq { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.seq button {
  padding: 7px 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font: 600 0.8125rem var(--font-body);
  cursor: pointer;
}
.seq button:hover { color: var(--text); border-color: rgba(243, 199, 107, 0.35); }
.seq button[aria-pressed='true'] { border-color: transparent; background: linear-gradient(180deg, #ffe1a1, var(--gold)); color: #1a1406; }
.seq button:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.ed-weapon { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.ed-refine { width: 78px; }

.ed-error { margin: 12px 0 0; color: var(--bad); font-size: 0.8125rem; }
.ed-error:empty { display: none; }
.editor-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 16px -22px 0;
  padding: 12px 22px max(12px, env(safe-area-inset-bottom));
  background: rgba(15, 19, 48, 0.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.ed-count { margin-right: auto; color: var(--muted); font-size: 0.8125rem; }
.btn-ghost {
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font: 600 0.875rem var(--font-body);
  cursor: pointer;
}
.btn-ghost:hover { background: var(--panel-strong); }
.btn-ghost.danger { border-color: rgba(255, 138, 138, 0.4); color: var(--bad); }
.btn-ghost:disabled { opacity: 0.6; cursor: progress; }
.btn-ghost.with-icon { display: inline-flex; align-items: center; gap: 8px; }
.btn-ghost svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* Pity page */
.pity-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.pity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 14px;
  margin-top: 16px;
}
.pity-card {
  --glow: var(--violet-soft);
  --accent: var(--violet);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(280px 160px at 100% 0%, var(--glow), transparent 70%),
    var(--panel);
}
.pity-card.sure { --glow: var(--gold-soft); --accent: var(--gold); border-color: rgba(243, 199, 107, 0.3); }
.pity-card.soft { --glow: rgba(255, 170, 115, 0.2); --accent: var(--stale); border-color: rgba(255, 170, 115, 0.4); }
.pity-name { margin: 0; font-family: var(--font-head); font-size: 1.0625rem; font-weight: 600; }

.pity-count { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.pity-num {
  font-family: var(--font-head);
  font-size: 3.25rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.pity-card.sure .pity-num { color: var(--gold); text-shadow: 0 0 26px rgba(243, 199, 107, 0.35); }
.pity-card.soft .pity-num { color: var(--stale); text-shadow: 0 0 26px rgba(255, 170, 115, 0.45); }
.pity-card.unknown .pity-num { color: var(--faint); }
.pity-unit { color: var(--muted); font-size: 0.875rem; }

/* The bar: how far to hard pity, with the soft-pity stretch hatched at the end */
.pity-meter { position: relative; height: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); overflow: hidden; }
.pity-soft {
  position: absolute;
  inset: 0 0 0 var(--soft);
  border-left: 2px solid rgba(255, 170, 115, 0.75);
  background: repeating-linear-gradient(135deg, rgba(255, 170, 115, 0.24) 0 4px, transparent 4px 8px);
}
.pity-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--fill);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--violet), var(--accent));
  box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 55%, transparent);
  transition: width 0.4s ease;
}
.pity-card.sure .pity-fill { background: linear-gradient(90deg, var(--violet), var(--gold)); }
.pity-card.soft .pity-fill { background: linear-gradient(90deg, var(--gold), var(--stale)); }
.pity-next { margin: -2px 0 0; color: var(--muted); font-size: 0.8125rem; line-height: 1.5; }
.pity-next strong { color: var(--text); font-weight: 600; }

.pity-guarantee {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.45;
}
.pity-guarantee::before {
  content: '';
  flex: none;
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--faint);
}
.pity-guarantee strong { color: var(--text); font-weight: 600; }
.pity-guarantee.sure { border-color: rgba(243, 199, 107, 0.4); background: var(--gold-soft); }
.pity-guarantee.sure strong { color: var(--gold); }
.pity-guarantee.sure::before { background: var(--gold); box-shadow: 0 0 10px var(--gold); }
.pity-guarantee.open::before { background: var(--violet); box-shadow: 0 0 10px var(--violet); }
.pity-four { margin: 0; color: var(--muted); font-size: 0.8125rem; }
.pity-four strong { color: var(--text); font-weight: 600; }

.pity-label { margin: 0 0 8px; color: var(--faint); font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.pity-label span { letter-spacing: normal; text-transform: none; font-weight: 500; }
.pity-tops ul { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.pity-top {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.75rem;
}
.pity-top-name { font-weight: 500; }
.pity-top-pulls {
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--muted);
  font-family: var(--font-head);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.pity-top-tag { padding-right: 6px; font-size: 0.6875rem; font-weight: 600; }
.pity-top.won { border-color: rgba(126, 224, 176, 0.35); }
.pity-top.won .pity-top-tag { color: var(--good); }
.pity-top.guaranteed, .pity-top.featured { border-color: rgba(243, 199, 107, 0.35); }
.pity-top.guaranteed .pity-top-tag, .pity-top.featured .pity-top-tag { color: var(--gold); }
.pity-top.lost { border-color: rgba(255, 138, 138, 0.35); }
.pity-top.lost .pity-top-tag { color: var(--bad); }

.pity-note { margin: 0; color: var(--faint); font-size: 0.75rem; line-height: 1.5; }
.pity-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.pity-card-foot[hidden] { display: none; }
.pity-source { margin: 0; color: var(--faint); font-size: 0.75rem; line-height: 1.45; }
.pity-edit { flex: none; padding: 6px 12px; border-radius: 10px; font-size: 0.75rem; }

/* Typing your own numbers in */
.pity-form {
  display: grid;
  gap: 12px;
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.24);
}
.pity-field { display: grid; }
.pity-input { width: 120px; font-variant-numeric: tabular-nums; }
.pity-choice { grid-template-columns: repeat(3, 1fr); }
.pity-form-note { margin: 0; color: var(--faint); font-size: 0.75rem; line-height: 1.5; }
.pity-form .ed-error { margin: 0; }
.pity-form-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.pity-form-foot .btn-ghost.danger { margin-right: auto; }
.pity-form-foot .refresh, .pity-form-foot .btn-ghost { padding: 8px 14px; }
.pity-foot { margin: 18px 2px 0; color: var(--faint); font-size: 0.75rem; line-height: 1.5; }

/* Import dialog */
.pity-import-lead { margin-top: 16px; }
.pity-steps { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.pity-steps li {
  position: relative;
  padding: 12px 14px 12px 52px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  font-size: 0.875rem;
  line-height: 1.5;
}
.pity-steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  top: 11px;
  left: 14px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--gold-soft);
  color: var(--gold);
  font: 700 0.8125rem var(--font-head);
}
.pity-steps p { margin: 0; }
.pity-steps p + p, .pity-steps p + details, .pity-steps p + .pity-link { margin-top: 8px; }
.pity-steps .step-extra { color: var(--muted); font-size: 0.8125rem; }
kbd {
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  font: 600 0.75rem var(--font-body);
}
.pity-steps code { font-family: ui-monospace, Consolas, monospace; font-size: 0.75rem; color: var(--text); }
.pity-command { margin-top: 10px; }
.pity-command summary { color: var(--muted); font-size: 0.8125rem; cursor: pointer; }
.pity-command[open] summary { margin-bottom: 8px; }
.pity-command p { color: var(--muted); font-size: 0.8125rem; }
.pity-command pre {
  max-height: 180px;
  margin: 8px 0 0;
  padding: 10px 12px;
  overflow: auto;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.4);
  color: var(--muted);
  font-size: 0.6875rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
}
.pity-file { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.pity-file .step-extra { flex: 1 1 260px; }
.pity-srs {
  display: grid;
  justify-items: start;
  gap: 8px;
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  font-size: 0.875rem;
}
.pity-srs .pity-label { margin: 0; }
.pity-srs .step-extra { margin: 0; color: var(--muted); font-size: 0.8125rem; line-height: 1.5; }
.pity-link { display: block; width: 100%; resize: vertical; font: 500 0.75rem ui-monospace, Consolas, monospace; }
.pity-import-safety { margin: 14px 0 0; color: var(--faint); font-size: 0.75rem; line-height: 1.5; }
.pity-import-done { margin: 12px 0 0; color: var(--gold); font-size: 0.8125rem; line-height: 1.5; }
.pity-import-done:empty { display: none; }

/* Empty / error */
.empty {
  margin-top: 26px;
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}
.empty p { margin: 0 0 16px; }

.credits {
  padding-top: 40px;
  padding-bottom: 40px;
  color: var(--faint);
  font-size: 0.75rem;
  line-height: 1.6;
  text-align: center;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: 0.3; } }

@media (max-width: 560px) {
  /* Three games don't fit beside the title, so the switch takes its own full-width row. */
  .top { flex-wrap: wrap; padding-top: 20px; gap: 12px; }
  .switches { flex: 1 1 100%; flex-direction: column; align-items: stretch; }
  .game-switch button, .view-switch button { flex: 1; padding: 8px 6px; }
  .editor { width: 100%; }
  .editor-foot { margin: 16px -16px 0; padding-left: 16px; padding-right: 16px; }
  .editor-foot .ed-save, .editor-foot .refresh, .pity-form-foot .refresh { width: auto; }
  .pity-actions { flex: 1 1 100%; }
  .pity-actions > * { flex: 1; justify-content: center; }
  .pity-num { font-size: 2.75rem; }
  .pity-steps li { padding-left: 46px; }
  .pity-steps li::before { left: 11px; }
  .brand h1 { font-size: 1.25rem; }
  .tagline { display: none; }
  .refresh { width: 100%; justify-content: center; }
  .portrait { width: 54px; height: 54px; }
  .lc .pips { display: none; }
  .advice { width: 100%; max-width: 100%; height: 100%; max-height: 100%; margin: 0; border: 0; border-radius: 0; }
  .advice-inner { padding: 0 16px 20px; }
  .advice-head { margin: 0 -16px; padding: 12px 16px; }
  .build-list { grid-template-columns: 1fr; gap: 2px; }
  .build-list dd + dt { margin-top: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}
