:root {
  --bg: #fbfbfa;
  --surface: #ffffff;
  --text: #1b1b1b;
  --muted: #6b6b68;
  --border: #e6e4df;
  --accent: #1f6f4a;
  --accent-text: #ffffff;
  --accent-soft: #e6f1eb;
  --gold: #85661a;
  --gold-soft: #f5edd6;
  --error: #b3261e;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141414;
    --surface: #1c1c1c;
    --text: #ececea;
    --muted: #9b9b97;
    --border: #2d2d2b;
    --accent: #5cc493;
    --accent-text: #0c1f15;
    --accent-soft: #1b2e24;
    --gold: #e2c46d;
    --gold-soft: #393120;
    --error: #f2b8b5;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 680px;
  margin: 0 auto;
  padding: 56px 16px 24px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Intro */

.intro { text-align: center; }

h1 {
  margin: 0 0 4px;
  font-size: 2.4rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.lead { margin: 0 0 24px; color: var(--muted); font-size: 1.1rem; }

.music {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 28px;
}
.music audio { width: 100%; max-width: 320px; }
.music p { margin: 0; font-size: 0.9rem; color: var(--muted); text-align: center; }

/* Form */

form, .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

form { padding: 20px; }

.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 500;
}

/* 16px keeps iOS Safari from zooming the page when an input is tapped. */
input {
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  font-size: 16px;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
input::placeholder { color: var(--muted); opacity: 0.7; }
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[aria-invalid="true"] { border-color: var(--error); }
input:disabled { cursor: not-allowed; opacity: 0.55; }
label.soon { color: var(--muted); }

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 28px;
  margin-top: 16px;
}

label.check, label.move { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
label.check { cursor: pointer; }
.check input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.move input { width: 6em; padding: 6px 9px; }

.actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
}

button {
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
button:hover:not(:disabled) { filter: brightness(1.08); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.hint { margin: 0; font-size: 0.85rem; color: var(--muted); text-align: center; }
.hint:empty { display: none; }
.hint.error { color: var(--error); }

/* Results */

.total {
  margin: 40px 0 20px;
  text-align: center;
  color: var(--muted);
}
.total strong {
  display: block;
  font-size: 3.5rem;
  line-height: 1.05;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.card { padding: 16px 20px; margin-bottom: 14px; }

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.card h2 { margin: 0; font-size: 1.05rem; }
.card h2 .who { margin-left: 6px; font-weight: 400; color: var(--muted); }
.card .count {
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.status { margin: 2px 0 0; font-size: 0.875rem; color: var(--muted); }
.status.error { color: var(--error); }

.bar {
  height: 4px;
  margin-top: 10px;
  overflow: hidden;
  background: var(--border);
  border-radius: 2px;
}
.bar > span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}
.bar.indeterminate > span { width: 30%; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide {
  from { transform: translateX(-100%); }
  to { transform: translateX(340%); }
}

table {
  width: 100%;
  margin-top: 12px;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th {
  padding: 6px 10px 6px 0;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
td {
  padding: 7px 10px 7px 0;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
tbody tr:last-child td { border-bottom: 0; }
th:last-child, td:last-child { padding-right: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td small { display: block; color: var(--muted); font-size: 0.8rem; }

.title {
  display: inline-block;
  min-width: 2.8em;
  padding: 1px 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 4px;
}
.title.GM { color: var(--gold); background: var(--gold-soft); }

.more {
  margin-top: 8px;
  padding: 6px 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--accent);
  background: none;
}

/* Summary card, shown once every source is done */

.summary { margin: 40px 0 20px; padding: 22px 24px 18px; scroll-margin-top: 16px; }
.summary p { margin: 0; }
.summary figure { margin: 0; }

.brand {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.summary-who { font-size: 1.05rem; font-weight: 600; overflow-wrap: anywhere; }
.summary-who .site { font-weight: 400; color: var(--muted); }
.summary .hero { margin-top: 14px; color: var(--muted); }
.hero strong {
  display: block;
  font-size: 3.5rem;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--text);
}
.summary .by-source { margin-top: 6px; font-size: 0.875rem; color: var(--muted); }

.breakdowns, .summary .section, .summary-foot {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.breakdowns { display: grid; grid-template-columns: 1fr 1fr; gap: 22px 32px; }
.summary figcaption, .summary .label {
  margin-bottom: 10px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
}

.hbars {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 12px;
  align-items: center;
  font-size: 0.875rem;
}
.hbar { display: flex; align-items: center; gap: 6px; min-width: 0; font-variant-numeric: tabular-nums; }
.hbar .fill {
  flex: none;
  width: calc((100% - 3.5em) * var(--share));
  min-width: 2px;
  height: 10px;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
}

.chart { position: relative; height: 200px; touch-action: pan-y; }
.chart svg { display: block; overflow: visible; font-size: 11px; }
.chart svg:focus { outline: none; }
.chart svg:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }
.chart .grid { stroke: var(--border); }
.chart .tick { fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent); fill-opacity: 0.1; }
.chart .gm-dot { fill: var(--gold); stroke: var(--surface); stroke-width: 2; }
.gm-key { margin-left: 14px; white-space: nowrap; }
.gm-key::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  background: var(--gold);
  border-radius: 50%;
}
.chart .cross { stroke: var(--muted); }
.chart .hover-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }

.tip {
  position: absolute;
  top: 0;
  z-index: 1;
  padding: 6px 10px;
  font-size: 0.8rem;
  line-height: 1.4;
  white-space: nowrap;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.08);
}
.tip strong { display: block; font-size: 0.95rem; }
.tip span { display: block; color: var(--muted); }

.best-who { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; font-weight: 600; }
.best-who .rating { font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.summary .best-meta { margin-top: 4px; font-size: 0.85rem; color: var(--muted); }

.summary-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  font-size: 0.8rem;
  color: var(--muted);
}
.share { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.share button { padding: 7px 16px; font-size: 0.875rem; }
.share-hint { overflow-wrap: anywhere; }

.confetti { position: absolute; z-index: 10; width: 0; height: 0; pointer-events: none; }
.confetti i { position: absolute; left: -3px; top: -2px; width: 6px; height: 4px; border-radius: 1px; }

footer {
  max-width: 680px;
  margin: 0 auto;
  padding: 8px 16px 40px;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 520px) {
  main { padding-top: 28px; }
  h1 { font-size: 1.7rem; }
  .lead { margin-bottom: 18px; font-size: 1rem; }
  .music { margin-bottom: 20px; }
  .music p { font-size: 0.82rem; }
  .fields { grid-template-columns: 1fr; gap: 12px; }
  form, .card { padding: 14px; }
  .total { margin: 28px 0 16px; }
  .total strong { font-size: 2.6rem; }
  .summary { margin: 28px 0 16px; padding: 18px 16px 14px; }
  .hero strong { font-size: 2.8rem; }
  .breakdowns { grid-template-columns: 1fr; }
  .card .count { font-size: 1.35rem; }
  table { font-size: 0.85rem; }
  .wins-col { display: none; }
}
