: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;
  --gold: #e8a33d;
  --gold-dark: #6b4a1a;
  --gold-bg: #2a1f10;
}
* { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  padding: 3rem 1.5rem 4rem;
}
.wrap { max-width: 940px; margin: 0 auto; }
h1 { font-size: 24px; font-weight: 500; margin: 0 0 6px; letter-spacing: -0.015em; }
.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: #dcd0fb;
  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="date"] { color-scheme: dark; }

.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);
}
.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: 4px;
  flex-shrink: 0;
  /* Wiki icons are portrait (~347x410), so ~8% is trimmed top and bottom.
     If a face gets clipped, nudge this, e.g. object-position: center 35%; */
  object-fit: cover;
  object-position: center 45%;
  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;
}
.progress-track {
  width: 100%;
  height: 5px;
  background: color-mix(in srgb, var(--text) 12%, transparent);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
}
.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: #dcd0fb;
  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;
}
#date-warning {
  display: none;
  font-size: 12px;
  color: var(--text-secondary);
  margin: -1.25rem 0 1.75rem;
}
.status-line {
  display: none;
  font-size: 12px;
  color: var(--text-secondary);
  margin: 8px 0 0;
}
.status-line.is-error { color: #e88; }

.section-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.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;
}

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

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