:root {
  --bg: #14121e;
  --surface: #1f1b2e;
  --surface-2: #29243a;
  --surface-3: #332c46;
  --border: #3d3552;
  --border-strong: #524669;
  --text: #f2eefb;
  --text-secondary: #ada2c9;
  --text-muted: #786c94;
  --accent: #a48af2;
  --accent-dark: #3a2c66;
  --accent-text: #dcd0fb;
  --gold: #e8a33d;
  --gold-dark: #6b4a1a;
  --gold-bg: #2a1f10;
}
[data-theme="light"] {
  --bg: #ece6f7;
  --surface: #ffffff;
  --surface-2: #f3eefb;
  --surface-3: #e7dbf5;
  --border: #d2c2ea;
  --border-strong: #b39cdb;
  --text: #221d33;
  --text-secondary: #5c5372;
  --text-muted: #6f6584;
  --accent: #6b46e0;
  --accent-dark: #e8ddfb;
  --accent-text: #3c2570;
  --gold: #a3670a;
  --gold-dark: #e8c184;
  --gold-bg: #fdf1de;
}
* { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  /* Extra top padding so content doesn't sit under the fixed brand/theme/changelog bar.
     .wrap only gets natural side clearance from it once the viewport's wide enough to
     center a 940px .wrap, so this actually matters below ~988px, not just on phones */
  padding: 5rem 1.5rem 4rem;
  transition: background 0.3s ease, color 0.3s ease;
}

/* Circular reveal animation for the theme toggle */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}
::view-transition-new(root) {
  clip-path: circle(0 at var(--reveal-x) var(--reveal-y));
  animation: themeReveal 700ms cubic-bezier(.65,0,.35,1) forwards;
}
@keyframes themeReveal {
  to { clip-path: circle(150vmax at var(--reveal-x) var(--reveal-y)); }
}
.wrap { max-width: 940px; margin: 0 auto; }
h1 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 24px;
  font-weight: 500;
  margin: 0 0 6px;
  letter-spacing: -0.015em;
}
.title-icon { width: 32px; height: 32px; object-fit: contain; flex-shrink: 0; margin-top: 4px; }
.subtitle { color: var(--text-secondary); font-size: 14px; margin: 0 0 2rem; line-height: 1.6; }
.section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 2.25rem 0 0.85rem;
}
.section-label:first-of-type { margin-top: 0; }

.mode-toggle {
  display: inline-flex;
  border: 0.5px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}
.mode-toggle button {
  background: var(--surface-2);
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.mode-toggle button:not(:last-child) {
  border-right: 0.5px solid var(--border);
}
.mode-toggle button:hover { background: var(--surface-3); }
.mode-toggle button.active {
  background: var(--accent-dark);
  color: var(--accent-text);
  font-weight: 500;
}

.global-panel {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.75rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}
.field.hidden { display: none; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
input[type="number"], input[type="date"], select {
  width: 100%;
  background: var(--surface-2);
  border: 0.5px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s ease;
}
input[type="number"]:hover, input[type="date"]:hover, select:hover {
  border-color: var(--border-strong);
}
input[type="number"]:focus, input[type="date"]:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}
input[type="number"], input[type="date"] { color-scheme: dark; }
[data-theme="light"] input[type="number"], [data-theme="light"] input[type="date"] { color-scheme: light; }

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 1.75rem;
}
.action-btn {
  background: var(--surface-2);
  border: 0.5px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.action-btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-3);
}
[data-theme="light"] .action-btn {
  background: #ddd0f0;
  border-color: #bfa8e0;
}
[data-theme="light"] .action-btn:hover {
  background: #cbb6e8;
  border-color: #9d7fd0;
}
.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 1.75rem;
}
.summary .card, .totals-panel .card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
}
.summary .card p:first-child, .totals-panel .card p:first-child {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 6px;
  line-height: 1.4;
}
.summary .card p:last-child {
  font-size: 22px;
  font-weight: 500;
  margin: 0;
}
.totals-panel .card p.big {
  font-size: 20px;
  font-weight: 500;
  margin: 0;
}

.sinner-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 12px;
}
.sinner-card {
  background: color-mix(in srgb, var(--sinner-color, var(--surface)) 7%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--sinner-color, var(--border)) 55%, var(--border));
  border-radius: 14px;
  padding: 1.1rem 1.2rem;
  transition: border-color 0.15s ease, background 0.15s ease;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
}
.sinner-card.complete {
  background: color-mix(in srgb, var(--sinner-color, var(--surface)) 12%, var(--surface));
}
.sinner-card.empty {
  background: var(--surface);
  border-style: dashed;
  border-width: 2px;
  padding: calc(1.1rem - 1px) calc(1.2rem - 1px);
}
.sinner-card.empty .sinner-name-text {
  opacity: 0.55;
}
.sinner-grid.hide-empty .sinner-card.empty {
  display: none;
}
.sinner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.reset-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 4px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.sinner-card:hover .reset-btn { opacity: 1; }
.reset-btn:hover { color: var(--text); }
.sinner-name {
  font-weight: 500;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}
.sinner-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.sinner-icon {
  width: auto;
  height: 35px;
  border-radius: 0;
  flex-shrink: 0;
  /* Contain instead of cover so the icon never gets cropped at the edges */
  object-fit: contain;
  object-position: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sinner-monogram {
  background: color-mix(in srgb, var(--sinner-color, var(--surface-2)) 22%, var(--surface-2));
  color: var(--sinner-color, var(--text-secondary));
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
}
.sinner-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
  align-items: end;
}
.sinner-inputs label {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  min-height: 20px;
  margin-bottom: 5px;
  line-height: 1.35;
  white-space: nowrap;
}
.rank-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-secondary);
  min-height: 20px;
  margin-bottom: 5px;
  line-height: 1.35;
  white-space: nowrap;
}
.rank-badge {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  background: var(--gold-bg);
  border: 1px solid var(--gold-dark);
  border-radius: 4px;
  padding: 3px 4px;
  line-height: 0;
  color: var(--gold);
}
.progress-track {
  width: 100%;
  height: 5px;
  background: color-mix(in srgb, var(--text) 12%, transparent);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
}
[data-theme="light"] .progress-track {
  background: color-mix(in srgb, var(--text) 20%, transparent);
}
.progress-fill {
  height: 100%;
  background: var(--sinner-color, var(--accent));
  border-radius: 999px;
  transition: width 0.2s ease;
}
.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  gap: 8px;
}
.status-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-dark);
  color: var(--accent-text);
  white-space: nowrap;
}
.sinner-card.complete .status-badge {
  background: color-mix(in srgb, var(--sinner-color, var(--accent)) 30%, var(--surface-2));
  color: var(--text);
}
.needed { color: var(--text-secondary); }
.pct-label { color: var(--text-muted); font-variant-numeric: tabular-nums; }

.totals-panel {
  margin-top: 1.75rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1.75rem;
  line-height: 1.7;
}

/* ---- moved out of inline HTML styles ---- */
#storage-warning {
  display: none;
  font-size: 13px;
  color: #f0c674;
  background: #3a2f14;
  border: 1px solid #6b5a1a;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 0 0 1.5rem;
}
[data-theme="light"] #storage-warning {
  color: #8a5a00;
  background: #fff6e0;
  border-color: #e8c184;
}
.field-note {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: -1.25rem 0 1.75rem;
}
/* #count-note and #mode-note sit right after .mode-toggle (one at a time,
   swapped based on the selected mode), not .global-panel, so neither wants
   the pull-up margin below */
#count-note,
#mode-note {
  margin: 0 0 1.75rem;
}
/* #date-warning and #xp-note both use the same pull-up as .field-note so
   they sit snug under whatever's directly above them (the panel, or each
   other in date mode) instead of leaving a big gap */
#date-warning,
#xp-note {
  margin: -1.25rem 0 1.75rem;
}
#date-warning {
  display: none;
  font-size: 12px;
  color: var(--text-secondary);
}
.status-line {
  display: none;
  font-size: 12px;
  color: var(--text-secondary);
  margin: 8px 0 0;
}
.status-line.is-error { color: #e88; }
[data-theme="light"] .status-line.is-error { color: #c0392b; }

.section-label-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
}
.inline-check {
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: none;
  letter-spacing: normal;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 400;
}
.inline-check input[type="checkbox"] {
  width: auto;
  margin: 0;
}
.battlepass-check {
  margin-bottom: 1rem;
}

#share-code-input {
  flex: 1;
  min-width: 220px;
}

.overall-track { margin: 8px 0 0; }
#overall-fill {
  background: var(--accent);
  width: 0%;
}

/* ---- theme toggle + changelog button + modal ---- */
.theme-toggle {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top));
  right: max(1rem, env(safe-area-inset-right));
  z-index: 998;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.25s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.theme-toggle:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
  transform: rotate(15deg);
}
.theme-toggle img {
  width: 18px;
  height: 18px;
  display: block;
}

.changelog-btn {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top));
  right: calc(max(1rem, env(safe-area-inset-right)) + 44px);
  z-index: 998;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 999px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.changelog-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--surface-2);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 8, 16, 0.65);
  padding: 1.5rem;
}
.modal-overlay[hidden] { display: none; }

.modal-panel {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 560px;
  max-height: min(80vh, 720px);
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.modal-header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 1.1rem 1.25rem;
  background: var(--surface);
  border-bottom: 0.5px solid var(--border);
}
.modal-header h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 16px;
  font-weight: 500;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  padding: 2px 6px;
  cursor: pointer;
  border-radius: 6px;
  transition: color 0.15s ease, background 0.15s ease;
}
.modal-close:hover {
  color: var(--text);
  background: var(--surface-2);
}
.modal-body {
  padding: 1.1rem 1.25rem 1.4rem;
}

.cl-version { margin-bottom: 1.5rem; }
.cl-version:last-child { margin-bottom: 0; }
.cl-version-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0.6rem;
}
.cl-version-date {
  font-size: 12px;
  color: var(--text-muted);
}
.cl-tag {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.cl-tag--new {
  color: #8ee0b3;
  background: rgba(94, 200, 143, 0.12);
  border-color: rgba(94, 200, 143, 0.3);
}
[data-theme="light"] .cl-tag--new {
  color: #1f7a4d;
  background: rgba(31, 122, 77, 0.1);
  border-color: rgba(31, 122, 77, 0.25);
}
.cl-tag--initial {
  color: var(--gold);
  background: var(--gold-bg);
  border-color: var(--gold-dark);
}
.cl-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.6;
}
.cl-list li { margin-bottom: 6px; }
.cl-list li:last-child { margin-bottom: 0; }
.cl-list b { color: var(--text); font-weight: 600; }

/* ---- site branding ----
   Fully shared with home/card via brand.css now - no local override, so
   the color (and its hover state) stays identical across every page. */

/* ---- mobile ----
   Breakpoints (600px / 480px) and how the corner buttons/brand behave here
   match home's style.css - tap targets grow on mobile instead of shrinking,
   and the brand text stays visible no matter how small the screen gets. */
@media (max-width: 600px) {
  body {
    padding: 4.5rem 1rem 3rem;
  }
  .subtitle { margin-bottom: 1.5rem; }

  .theme-toggle,
  .changelog-btn {
    top: 0.75rem;
    width: 44px;
    height: 44px;
  }
  .theme-toggle {
    right: 0.75rem;
  }
  .theme-toggle img {
    width: 26px;
    height: 26px;
    margin: auto;
  }
  .changelog-btn {
    right: calc(0.75rem + 52px);
  }
  .changelog-btn svg {
    width: 20px;
    height: 20px;
  }

  .global-panel {
    grid-template-columns: 1fr;
    padding: 1rem;
    gap: 0.85rem;
  }
  .summary,
  .totals-panel {
    grid-template-columns: repeat(2, 1fr);
  }
  .sinner-grid {
    grid-template-columns: 1fr;
  }
  .sinner-inputs {
    gap: 6px;
  }

  .btn-row {
    flex-direction: column;
    align-items: stretch;
  }
  .btn-row .action-btn {
    width: 100%;
  }
  #share-code-input {
    min-width: 0;
    width: 100%;
  }

  .modal-overlay { padding: 0.75rem; }
  .modal-panel { max-height: 85vh; }
}

@media (max-width: 480px) {
  h1 { font-size: 20px; }
  /* .site-brand shrink comes from brand.css */
}
