:root {
  --primary: #c0392b;
  --accent: #f1c40f;
  --bg: #0e1a14;
  --surface: color-mix(in srgb, var(--bg) 90%, #fff);
  --surface-2: color-mix(in srgb, var(--bg) 80%, #fff);
  --line: color-mix(in srgb, var(--bg) 70%, #fff);
  --text: #f3f1ea;
  --muted: #a9b4ab;
  --good: #3ecf8e;
  --radius: 14px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0; min-height: 100vh; color: var(--text); line-height: 1.45;
  background:
    radial-gradient(1100px 500px at 85% -10%, color-mix(in srgb, var(--primary) 28%, transparent), transparent 70%),
    radial-gradient(900px 480px at 0% 0%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 65%),
    var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 24px 16px 64px; }
.loading, .empty { color: var(--muted); text-align: center; padding: 32px 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; font-size: 14px; color: var(--muted); }
.brand { font-weight: 700; letter-spacing: .02em; color: var(--text); }
.brand span { color: var(--accent); }

.hero { padding: 28px; border-radius: 20px; border: 1px solid var(--line);
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 30%, var(--surface)), var(--surface) 70%); }
.hero h1 { margin: 6px 0 4px; font-size: clamp(26px, 5vw, 42px); line-height: 1.1; letter-spacing: -.01em; }
.hero p { margin: 0; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--line); }
.pill.live { color: #fff; background: color-mix(in srgb, var(--good) 28%, var(--surface)); border-color: var(--good); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 0 var(--good); animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 70%, transparent); } 100% { box-shadow: 0 0 0 10px transparent; } }

.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 16px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat .n { font-size: clamp(26px, 4vw, 34px); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stat.key .n { color: var(--accent); }

.grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 860px) { .grid.two { grid-template-columns: 3fr 2fr; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card h2 { margin: 0 0 12px; font-size: 16px; letter-spacing: .01em; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.stack { display: grid; gap: 16px; align-content: start; }

.ms { margin: 0 0 14px; }
.ms-top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; margin-bottom: 6px; }
.ms-top .v { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .8s cubic-bezier(.2, .8, .2, 1); }
.ms.done .bar > i { background: var(--good); }
.ms.done .ms-top b::after { content: " ✓"; color: var(--good); }

.tabs { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.tabs button { background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 8px; cursor: pointer; }
.tabs button[aria-pressed=true] { background: var(--bg); color: var(--text); }
select, button, input, textarea { font: inherit; }
select { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 13px; max-width: 100%; }
button:focus-visible, select:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

table.lb { width: 100%; border-collapse: collapse; font-size: 14px; }
table.lb td { padding: 9px 6px; border-top: 1px solid var(--line); vertical-align: middle; }
table.lb tr:first-child td { border-top: 0; }
.rank { width: 34px; color: var(--muted); font-variant-numeric: tabular-nums; }
.name { font-weight: 600; overflow-wrap: anywhere; }
.tier { display: inline-block; font-size: 11px; color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent); border-radius: 999px; padding: 1px 8px; margin-left: 6px; font-weight: 600; white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sub { color: var(--muted); font-size: 12px; }

.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 520px; overflow: auto; }
.feed li { padding: 10px 4px; border-top: 1px solid var(--line); font-size: 14px; }
.feed li:first-child { border-top: 0; }
.feed li.new { animation: flash 2.4s ease-out; }
@keyframes flash { from { background: color-mix(in srgb, var(--accent) 22%, transparent); } to { background: transparent; } }
.feed .who { font-weight: 600; }

.types { display: grid; gap: 10px; }
.type-row { display: grid; grid-template-columns: minmax(150px, 1.6fr) 2fr 44px; gap: 10px; align-items: center; font-size: 14px; }
.type-row .bar { height: 8px; }
.type-row b { text-align: right; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 6px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; color: var(--text); }
.chip:hover { border-color: var(--accent); text-decoration: none; }

.events { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.ev { display: block; color: var(--text); padding: 20px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); transition: transform .15s, border-color .15s; }
.ev:hover { transform: translateY(-2px); border-color: var(--accent); text-decoration: none; }
.ev h3 { margin: 10px 0 4px; font-size: 18px; }
.ev .em { font-size: 28px; }
.ev .mini { display: flex; gap: 16px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.ev .mini b { color: var(--text); font-variant-numeric: tabular-nums; }
h2.section { font-size: 14px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 28px 0 12px; }
.back { display: inline-block; margin-bottom: 14px; font-size: 14px; }
footer { margin-top: 36px; text-align: center; color: var(--muted); font-size: 12px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: 92vw; padding: 14px 20px; border-radius: 14px;
  background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 50%, var(--accent))); color: #fff; font-weight: 700;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .5); z-index: 10; text-align: center; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (max-width: 520px) { .hero { padding: 20px; } .type-row { grid-template-columns: 1fr auto; } .type-row .bar { grid-column: 1 / -1; order: 3; } }

/* ---------- Festive mode (html[data-festive="1"]) ---------- */
canvas.snow { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 5; }
.xmas-count { margin-left: 8px; color: #fff; background: color-mix(in srgb, var(--primary) 55%, var(--surface)); border-color: color-mix(in srgb, var(--primary) 70%, #fff); }
html[data-festive="1"] { --fest-red: #e0443a; --fest-green: #2fb36d; --fest-gold: #f6cf4a; --fest-blue: #4fa3ff; }
html[data-festive="1"] body::before { content: ""; position: fixed; top: 0; left: 0; right: 0; height: 6px; z-index: 20;
  background: repeating-linear-gradient(135deg, #c0392b 0 10px, #fff 10px 20px); }
html[data-festive="1"] body {
  background:
    radial-gradient(1100px 520px at 85% -10%, color-mix(in srgb, var(--primary) 34%, transparent), transparent 70%),
    radial-gradient(900px 520px at 0% 0%, color-mix(in srgb, #2fb36d 16%, transparent), transparent 65%),
    radial-gradient(700px 380px at 50% 110%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%),
    var(--bg);
}
/* string lights along the top of the hero */
html[data-festive="1"] .hero { position: relative; padding-top: 38px; border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
html[data-festive="1"] .hero::before, html[data-festive="1"] .hero::after {
  content: ""; position: absolute; left: 14px; right: 14px; top: 8px; height: 16px; pointer-events: none; background-size: 120px 16px; background-repeat: repeat-x;
}
html[data-festive="1"] .hero::before {
  background-image:
    radial-gradient(circle at 15px 9px, var(--fest-red) 0 4px, transparent 5.5px),
    radial-gradient(circle at 75px 9px, var(--fest-green) 0 4px, transparent 5.5px),
    linear-gradient(to bottom, transparent 3px, rgba(255, 255, 255, .22) 3px 4px, transparent 4px);
  filter: drop-shadow(0 0 4px var(--fest-red)); animation: twinkle 2.4s ease-in-out infinite;
}
html[data-festive="1"] .hero::after {
  background-image:
    radial-gradient(circle at 45px 9px, var(--fest-gold) 0 4px, transparent 5.5px),
    radial-gradient(circle at 105px 9px, var(--fest-blue) 0 4px, transparent 5.5px);
  filter: drop-shadow(0 0 4px var(--fest-gold)); animation: twinkle 2.4s ease-in-out -1.2s infinite;
}
@keyframes twinkle { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
html[data-festive="1"] .hero h1 { font-family: Georgia, "Times New Roman", serif; font-style: italic; text-shadow: 0 0 24px color-mix(in srgb, var(--accent) 35%, transparent); }
html[data-festive="1"] .stat.key .n { background: linear-gradient(180deg, #fff3b0, var(--accent) 60%, #d89b00); -webkit-background-clip: text; background-clip: text; color: transparent; }
html[data-festive="1"] .stat { border-top: 3px solid var(--primary); }
html[data-festive="1"] .stat:nth-child(even) { border-top-color: var(--fest-green); }
html[data-festive="1"] .card h2::before { content: "❄"; color: color-mix(in srgb, #fff 70%, var(--accent)); font-size: 13px; margin-right: 2px; opacity: .85; }
html[data-festive="1"] .card h2 { justify-content: flex-start; }
html[data-festive="1"] .card h2 .tabs, html[data-festive="1"] .card h2 select { margin-left: auto; }
/* candy-cane progress bars */
html[data-festive="1"] .bar > i { background: repeating-linear-gradient(135deg, #d6382b 0 9px, #fff 9px 18px); background-size: 25.5px 25.5px; animation: candy 1.2s linear infinite; }
html[data-festive="1"] .ms.done .bar > i { background: repeating-linear-gradient(135deg, #1f9d5a 0 9px, #e9f7ef 9px 18px); background-size: 25.5px 25.5px; }
@keyframes candy { to { background-position: 25.5px 0; } }
html[data-festive="1"] .tier { color: var(--fest-gold); }
html[data-festive="1"] .toast { background: linear-gradient(90deg, #b3261e, #1f9d5a); }
.wrap, .toast { position: relative; z-index: 6; }
.toast { position: fixed; }

/* Event banner (Sarge's artwork) */
.event-banner { display: block; width: 100%; height: auto; border-radius: 14px; margin: 0 0 16px; border: 1px solid rgba(255,255,255,.12); box-shadow: 0 8px 28px rgba(0,0,0,.45); }
