:root {
  --bg: #07162a;
  --bg-2: #0c2240;
  --card: #102a4d;
  --line: #22426d;
  --text: #eaf2fb;
  --muted: #9fb4cd;
  --green: #3ddc97;
  --green-dark: #22b578;
  --gold: #ffc857;
  --radius: 18px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
* { box-sizing: border-box; }
html { overflow-x: clip; }
body {
  margin: 0; min-height: 100vh; color: var(--text); line-height: 1.45;
  background:
    radial-gradient(900px 500px at 90% -10%, rgba(61, 220, 151, .15), transparent 60%),
    radial-gradient(700px 500px at -10% 110%, rgba(255, 200, 87, .08), transparent 60%),
    var(--bg);
}
a { color: var(--green); }
.cad { font-weight: inherit; }
.usd { font-size: .55em; font-weight: 600; color: var(--muted); white-space: nowrap; }

.tracker { max-width: 1280px; margin: 0 auto; padding: 1.25rem; display: flex; flex-direction: column; gap: 1.25rem; min-height: 100vh; }

/* Header */
.t-header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.t-brand { display: flex; align-items: center; gap: .8rem; color: var(--text); text-decoration: none; }
.t-brand img { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; border: 2px solid var(--green); background: var(--card); }
.t-brand strong { display: block; font-size: 1.2rem; }
.t-brand span { font-size: .85rem; color: var(--muted); }
.t-controls { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.t-btn { font: inherit; font-size: .85rem; font-weight: 700; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: .45rem .9rem; cursor: pointer; }
.t-btn:hover { border-color: var(--green); }
.t-btn[aria-pressed="true"] { background: var(--green); color: #05211a; border-color: var(--green); }
.t-select { appearance: none; -webkit-appearance: none; max-width: 15rem; padding-right: 2rem; text-overflow: ellipsis;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.t-select option, .t-select optgroup { background: var(--bg-2); color: var(--text); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.live { display: inline-flex; align-items: center; gap: .45rem; font-size: .8rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.live .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.live.on { color: var(--green); }
.live.on .dot { background: var(--green); animation: pulse 1.6s infinite; }
.live.err { color: var(--gold); }
.live.err .dot { background: var(--gold); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(61, 220, 151, .7); } 70% { box-shadow: 0 0 0 10px rgba(61, 220, 151, 0); } 100% { box-shadow: 0 0 0 0 rgba(61, 220, 151, 0); } }

/* Grid */
.t-grid { flex: 1; display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; }
.t-left { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }
.t-feed-card { position: sticky; top: 1.25rem; max-height: calc(100vh - 2.5rem); overflow-y: auto; }
.t-card { background: linear-gradient(160deg, #143259, var(--card)); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.4rem 1.5rem; }
.t-label { margin: 0 0 .6rem; font-size: .78rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); }
.t-empty { color: var(--muted); margin: 0; }

/* Total */
.t-raised { font-size: clamp(2.8rem, 7vw, 5rem); font-weight: 900; line-height: 1; letter-spacing: -.02em; }
.t-raised .usd { display: block; font-size: 1.1rem; margin-top: .4rem; letter-spacing: 0; }
.t-raised.bump { animation: bump .8s ease; }
@keyframes bump { 30% { transform: scale(1.06); color: var(--green); } }
.t-bar { height: 20px; margin: 1.2rem 0 .7rem; background: var(--bg); border-radius: 999px; overflow: hidden; }
.t-bar-fill { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--green-dark), var(--green)); transition: width 1.2s cubic-bezier(.2, .8, .2, 1); }
.t-goal-row { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; color: var(--muted); }
.t-goal-row strong { color: var(--text); }

/* Latest */
.latest-amt { font-size: 2rem; font-weight: 900; color: var(--green); }
.latest-amt .usd { margin-left: .3rem; }
.latest-who { font-size: 1.15rem; font-weight: 700; margin: .2rem 0 0; }
.latest-to { color: var(--muted); margin: .1rem 0 0; font-size: .9rem; }
.latest-msg { margin: .6rem 0 0; font-style: italic; color: var(--text); }

/* Leaderboard */
.board { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.board li { display: grid; grid-template-columns: 1.5rem 40px minmax(0, 1fr) auto; align-items: center; gap: .7rem; }
.board .rank { font-weight: 900; color: var(--muted); text-align: center; }
.board li:first-child .rank { color: var(--gold); }
.board img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--bg-2); }
.board .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .mini-bar { height: 6px; background: var(--bg); border-radius: 999px; overflow: hidden; margin-top: .3rem; }
.board .mini-bar div { height: 100%; background: var(--green-dark); border-radius: 999px; }
.board .amt { font-weight: 800; text-align: right; white-space: nowrap; }
.board .amt .usd { display: block; font-size: .72rem; }

/* Feed */
.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.feed li { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; background: rgba(7, 22, 42, .55); border: 1px solid var(--line); border-radius: 12px; padding: .75rem 1rem; }
.feed li.fresh { animation: slideIn .6s ease, glow 3s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-12px); } }
@keyframes glow { 0%, 40% { border-color: var(--green); box-shadow: 0 0 0 1px var(--green); } }
.feed .who { font-weight: 700; }
.feed .meta { display: block; font-size: .82rem; color: var(--muted); }
.feed .msg { display: block; font-size: .88rem; font-style: italic; margin-top: .25rem; color: var(--text); opacity: .85; }
.feed .amt { font-weight: 800; color: var(--green); text-align: right; white-space: nowrap; }
.feed .amt .usd { display: block; font-size: .75rem; }

.t-footer { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }

/* Popup */
.alert-layer { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 1.5rem; background: rgba(4, 12, 24, .6); backdrop-filter: blur(3px); }
.alert-layer[hidden] { display: none; }
.alert {
  position: relative; width: min(560px, 100%); text-align: center; overflow: hidden;
  background: linear-gradient(160deg, #17406f, #0f2a4a 70%);
  border: 2px solid var(--green); border-radius: 24px;
  padding: 2.2rem 1.75rem 2rem;
  box-shadow: 0 0 0 6px rgba(61, 220, 151, .15), 0 30px 80px rgba(0, 0, 0, .55);
}
.alert.show { animation: popIn .55s cubic-bezier(.2, 1.4, .4, 1); }
.alert.hide { animation: popOut .4s ease forwards; }
@keyframes popIn { from { opacity: 0; transform: scale(.6) translateY(30px); } }
@keyframes popOut { to { opacity: 0; transform: scale(.9) translateY(-20px); } }
.alert-icon { width: 64px; height: 64px; animation: wiggle 1.2s ease .3s; }
@keyframes wiggle { 20% { transform: rotate(-12deg) scale(1.15); } 40% { transform: rotate(10deg) scale(1.15); } 60% { transform: rotate(-6deg); } 80% { transform: rotate(3deg); } }
.alert-eyebrow { margin: .6rem 0 0; font-size: .95rem; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); }
.alert-amount { margin: .3rem 0 0; font-size: clamp(3rem, 12vw, 4.8rem); font-weight: 900; line-height: 1; color: var(--green); }
.alert-amount .usd { display: block; font-size: 1.05rem; margin-top: .35rem; }
.alert-who { margin: 1rem 0 0; font-size: 1.35rem; font-weight: 800; }
.alert-who span { color: var(--muted); font-weight: 600; }
.alert-msg { margin: .8rem auto 0; max-width: 30em; font-size: 1.05rem; font-style: italic; color: var(--text); }
.alert-msg:empty { display: none; }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; opacity: 0; animation: fall linear forwards; }
@keyframes fall {
  0% { opacity: 1; transform: translate3d(0, 0, 0) rotate(0); }
  100% { opacity: 0; transform: translate3d(var(--dx), 420px, 0) rotate(var(--rot)); }
}

/* Overlay mode (?overlay): a compact widget for an OBS browser source.
   It fills whatever size the source is set to; everything scales with it (recommended 800 × 240). */
body.overlay { background: transparent; min-height: 0; overflow: hidden; }
body.overlay .tracker, body.overlay .alert-layer { display: none !important; }
.widget[hidden] { display: none; }
.widget {
  position: fixed; inset: 0; overflow: hidden;
  font-size: min(10vh, 3.4vw);
  background: linear-gradient(160deg, #17406f, #0f2a4a 70%);
  border: max(2px, .09em) solid var(--green); border-radius: .8em;
}
.w-face {
  position: absolute; inset: 0; display: flex; align-items: center; gap: .9em; padding: .7em 1.1em;
  transition: opacity .45s ease, transform .55s cubic-bezier(.2, .9, .3, 1);
}
.w-body { flex: 1; min-width: 0; }
.w-body p { margin: 0; }
.w-logo, .w-icon { width: 2.8em; height: 2.8em; flex-shrink: 0; border-radius: .5em; object-fit: cover; }
.w-label, .w-eyebrow { font-size: .55em; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-raised, .w-amount { font-size: 1.9em; font-weight: 900; line-height: 1.05; letter-spacing: -.01em; white-space: nowrap; }
.w-raised .usd, .w-amount .usd { font-size: .4em; margin-left: .3em; letter-spacing: 0; }
.w-amount { color: var(--green); font-size: 1.75em; }
.w-bar { height: .38em; margin: .35em 0 .3em; background: var(--bg); border-radius: 999px; overflow: hidden; }
.w-bar-fill { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--green-dark), var(--green)); transition: width 1.2s cubic-bezier(.2, .8, .2, 1); }
.w-meta { font-size: .55em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-meta span:first-child { color: var(--text); font-weight: 800; }
.w-who { font-size: .72em; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: .15em !important; }
.w-who span { color: var(--muted); font-weight: 600; }
.w-msg { font-size: .58em; font-style: italic; margin-top: .2em !important; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.w-msg:empty { display: none; }
.w-raised.bump { animation: bump .8s ease; }

/* Swap: totals slide up and out, the donation slides in from below — and back again. */
.w-alert { opacity: 0; transform: translateY(100%); }
.widget.alerting .w-totals { opacity: 0; transform: translateY(-100%); }
.widget.alerting .w-alert { opacity: 1; transform: none; }
.widget.alerting { animation: flash 1.2s ease; }
@keyframes flash { 0%, 30% { box-shadow: inset 0 0 0 .15em var(--green), inset 0 0 1.2em rgba(61, 220, 151, .45); } }
.widget.alerting .w-icon { animation: wiggle 1.2s ease .35s; }
.widget .confetti i { top: -.5em; }

/* Responsive */
@media (max-width: 860px) {
  .t-grid { grid-template-columns: minmax(0, 1fr); }
  .t-feed-card { position: static; max-height: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
