@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@700;800;900&family=Instrument+Sans:wght@400;500;600;700&display=swap');
:root {
  --bg: #f5f6fb; --card: #ffffff; --text: #0f172a; --muted: #64748b; --border: #e3e7f0;
  --accent: #4f46e5; --accent-soft: #eef0ff; --shadow: 0 1px 2px rgba(15,23,42,.05), 0 6px 18px rgba(15,23,42,.05);
  --sports: #2563eb; --global: #7c3aed; --track: #edf0f7; --ok: #16a34a; --err: #dc2626;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020; --card: #131a2e; --text: #e8ecf8; --muted: #93a0bd; --border: #232d4a;
    --accent: #8b93ff; --accent-soft: #1b2447; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.25);
    --sports: #6ea0ff; --global: #b497ff; --track: #1c2542; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
a { color: var(--accent); }

/* header */
.top { padding: 28px 0 8px; }
.top .wrap { display: flex; flex-direction: column; gap: 6px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--accent); text-decoration: none; font-weight: 800; font-size: 1.35rem; letter-spacing: -.02em; }
.brand span { color: var(--text); }
.tagline { margin: 0; color: var(--muted); font-size: 1.02rem; max-width: 60ch; }

/* controls */
.controls { padding-top: 14px; padding-bottom: 6px; position: sticky; top: 0; z-index: 5; background: linear-gradient(var(--bg) 85%, transparent); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.tabs { display: inline-flex; background: var(--track); border-radius: 12px; padding: 4px; gap: 2px; }
.tabs button { white-space: nowrap; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 9px; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(15,23,42,.12); }
.search { flex: 1 1 220px; }
input[type="search"], select, .field {
  width: 100%; font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--border); border-radius: 12px; padding: 9px 12px;
}
select { width: auto; padding-right: 8px; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { border: 1px solid var(--border); background: var(--card); color: var(--text); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: .9rem; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .chip[aria-pressed="true"] { color: #0b1020; } }

/* list */
main { padding-top: 14px; padding-bottom: 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 16px; align-items: start; }
.status { color: var(--muted); min-height: 1.5em; margin-bottom: 8px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.card .thumb { width: 100%; height: 130px; object-fit: cover; display: block; background: var(--track); }
.card .body { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: .82rem; color: var(--muted); }
.badge { font-weight: 700; font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); }
.badge.sports { color: var(--sports); } .badge.global { color: var(--global); }
.card h2 { margin: 0; font-size: 1.1rem; line-height: 1.3; letter-spacing: -.01em; overflow-wrap: anywhere; }
.desc { margin: 0; color: var(--muted); font-size: .92rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.loc { margin: 0; color: var(--muted); font-size: .85rem; }
.prompt { margin: 2px 0 -2px; font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* vote options: each row is a button with a filled bar behind it */
.options { display: flex; flex-direction: column; gap: 8px; }
.opt {
  --c: #64748b; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; text-align: left; font: inherit; color: var(--text); background: var(--card);
  border: 1.5px solid var(--border); border-radius: 12px; padding: 10px 12px; cursor: pointer; min-height: 44px;
  transition: border-color .15s, transform .05s;
}
.opt:hover:not([aria-disabled="true"]) { border-color: var(--c); }
.opt:active:not([aria-disabled="true"]) { transform: scale(.995); }
.opt .fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--c); opacity: .16; transition: width .5s cubic-bezier(.2,.8,.2,1); }
.opt .label, .opt .num { position: relative; }
.opt .label { font-weight: 600; overflow-wrap: anywhere; display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.opt .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.opt .num { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .88rem; white-space: nowrap; }
.opt .num b { color: var(--text); }
.opt[aria-disabled="true"] { cursor: default; }
.opt.mine { border-color: var(--c); box-shadow: 0 0 0 1px var(--c) inset; }
.opt.mine .label::after { content: "Your vote"; font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #fff; background: var(--c); border-radius: 999px; padding: 1px 8px; }
.opt.busy { opacity: .6; }

.foot-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; font-size: .84rem; color: var(--muted); }
.link-btn { background: none; border: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 2px 0; }
.link-btn:hover { text-decoration: underline; }
.first-vote { color: var(--accent); font-weight: 700; }
.opt .num:empty { display: none; }
.share { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: .84rem; color: var(--muted); }
.share-label { font-weight: 600; margin-right: 2px; }
.share-btn { text-decoration: none; color: var(--text); background: var(--track); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; font-weight: 600; font-size: .82rem; }
.share-btn:hover { border-color: var(--accent); color: var(--accent); }
.hint { font-size: .82rem; color: var(--muted); margin: 0; }
.hint.locked { color: var(--ok); }

/* country breakdown */
.countries { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 9px; }
.countries h3 { margin: 0; font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.crow { display: grid; grid-template-columns: minmax(110px, 40%) 1fr auto; gap: 10px; align-items: center; font-size: .88rem; }
.crow .cn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stack { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--track); }
.stack i { display: block; height: 100%; }
.crow .ct { color: var(--muted); font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .78rem; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); margin-right: 5px; }
.empty { color: var(--muted); font-size: .9rem; margin: 0; }

/* misc */
.btn { font: inherit; font-weight: 600; background: var(--accent); color: #fff; border: 0; border-radius: 12px; padding: 10px 20px; cursor: pointer; }
@media (prefers-color-scheme: dark) { .btn { color: #0b1020; } }
.btn.secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.more { display: flex; justify-content: center; padding: 22px 0; }
.foot { color: var(--muted); font-size: .88rem; padding-top: 12px; padding-bottom: 40px; border-top: 1px solid var(--border); margin-top: 10px; }
.foot .small { font-size: .8rem; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); max-width: min(92vw, 460px); background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 12px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.25); z-index: 20; }
.toast.err { background: var(--err); color: #fff; }
.skeleton { height: 220px; border-radius: 16px; background: linear-gradient(90deg, var(--track), var(--card), var(--track)); background-size: 200% 100%; animation: sh 1.3s infinite; }
@keyframes sh { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .opt .fill { transition: none; } .skeleton { animation: none; } }
@media (max-width: 520px) { .controls { position: static; } .tabs { width: 100%; } .tabs button { flex: 1; padding: 8px 4px; font-size: .92rem; } select { width: 100%; } .sort { flex: 1 1 100%; } }

/* admin */
.panel { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 18px; margin: 16px 0; display: grid; gap: 12px; }
.panel label { display: grid; gap: 4px; font-weight: 600; font-size: .9rem; }
.panel textarea.field { min-height: 70px; resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .two { grid-template-columns: 1fr; } }

/* ---- homepage: hero, live activity, discovery rails ---- */
.hero { padding-top: 6px; padding-bottom: 4px; }
.hero-card { background: linear-gradient(135deg, var(--accent-soft), transparent 70%), var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 22px 22px 16px; box-shadow: var(--shadow); }
.hero h1 { margin: 0; font-size: clamp(1.55rem, 3.6vw, 2.3rem); line-height: 1.15; letter-spacing: -.025em; max-width: 24ch; }
.hero .sub { margin: 8px 0 16px; color: var(--muted); max-width: 62ch; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 10px 14px; min-width: 0; }
.stat b { display: block; font-size: clamp(1.25rem, 2.6vw, 1.7rem); line-height: 1.2; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat span { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.live { list-style: none; margin: 14px 0 0; padding: 12px 0 0; border-top: 1px dashed var(--border); display: grid; gap: 6px; font-size: .88rem; color: var(--muted); }
.live li { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.live li > span.txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.live b { color: var(--text); font-weight: 600; }
.live time { flex: none; font-size: .78rem; font-variant-numeric: tabular-nums; }
.live-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); align-self: center; box-shadow: 0 0 0 0 rgba(22,163,74,.5); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(22,163,74,0); } 100% { box-shadow: 0 0 0 0 rgba(22,163,74,0); } }
.live-title { font-weight: 700; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ok); }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2, 1fr); } .hero-card { padding: 18px 16px 12px; } }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 6px 0 12px; }
.section-title { margin: 0; font-size: 1.25rem; letter-spacing: -.015em; }
.section-head .status { margin: 0; }
.rail { margin: 6px 0 22px; }
.rail-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.rail-head h2 { margin: 0; font-size: 1.25rem; letter-spacing: -.015em; }
.rail-head p { margin: 0; color: var(--muted); font-size: .88rem; }
.rail-row { display: grid; grid-auto-flow: column; grid-auto-columns: min(84vw, 330px); gap: 14px; overflow-x: auto; padding: 2px 2px 12px; scroll-snap-type: x proximity; align-items: start; scrollbar-width: thin; }
.rail-row > .card { scroll-snap-align: start; }
.card.compact .body { padding: 14px; gap: 9px; }
.card.compact h2 { font-size: 1.02rem; }
.rank { font-weight: 800; font-size: .78rem; color: #fff; background: var(--accent); border-radius: 999px; padding: 1px 9px; }
@media (prefers-color-scheme: dark) { .rank { color: #0b1020; } }
.live li:nth-child(n+6) { display: none; }
@media (max-width: 720px) { .live li:nth-child(n+5) { display: none; } }

/* Brand type (CallItPoll Brand Kit): Nunito for display, Instrument Sans for body text */
:root { --font-display: 'Nunito', 'Trebuchet MS', system-ui, sans-serif; --font-body: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; }
body { font-family: var(--font-body); }
h1, h2, h3, .brand, .stat b, .rank { font-family: var(--font-display); }

/* Poll pages (event, create, privacy) and header pieces */
.topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.topline .btn { text-decoration: none; padding: 9px 16px; font-size: .92rem; }
.accent-word { color: var(--accent); }
.card h2 a { color: inherit; text-decoration: none; }
.card h2 a:hover { text-decoration: underline; }
.grid.one { grid-template-columns: 1fr; max-width: 640px; margin: 0 auto; }
.card h1 { margin: 0; font-size: 1.5rem; line-height: 1.25; letter-spacing: -.02em; overflow-wrap: anywhere; }
.desc-full { margin: 0; color: var(--muted); }
.badge.private { color: var(--muted); background: var(--track); }
.toast { transition: opacity .25s; }
/* the single-poll page toggles the country panel with a class instead of the hidden attribute */
body[data-event-id] .countries { display: none; }
body[data-event-id] .countries.open { display: flex; }
.countries-inner { display: flex; flex-direction: column; gap: 9px; }
.brand .accent-word { color: var(--accent); }

/* ---- LIVE -> FINAL -> ARCHIVE ---- */
.topnav { display: inline-flex; align-items: center; gap: 16px; }
.topnav a:not(.btn) { color: var(--muted); font-weight: 600; font-size: .92rem; text-decoration: none; }
.topnav a:not(.btn):hover { color: var(--text); text-decoration: underline; }
.when:empty, .state-slot:empty, .result-slot:empty { display: none; }
.badge.live-now { display: inline-flex; align-items: center; gap: 6px; color: #fff; background: var(--err); }
.live-pip { width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: pulse-w 1.6s infinite; }
@keyframes pulse-w { 0% { box-shadow: 0 0 0 0 rgba(255,255,255,.7); } 70%, 100% { box-shadow: 0 0 0 6px rgba(255,255,255,0); } }
.badge.final { color: #fff; background: var(--ok); }
.badge.void { color: var(--muted); background: var(--track); }
@media (prefers-reduced-motion: reduce) { .live-pip { animation: none; } }

.result-banner { border: 1px solid var(--border); border-left: 4px solid var(--ok); border-radius: 12px; background: color-mix(in srgb, var(--ok) 8%, var(--card)); padding: 10px 12px; display: grid; gap: 3px; }
.result-banner.void { border-left-color: var(--muted); background: var(--track); color: var(--muted); font-size: .9rem; margin: 0; }
.result-head { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; line-height: 1.3; overflow-wrap: anywhere; }
.result-sub { margin: 0; color: var(--muted); font-size: .86rem; }
.verdict { margin: 2px 0 0; font-weight: 700; font-size: .86rem; }
.verdict.right { color: var(--ok); }
.verdict.wrong { color: var(--err); }
.opt.winner { border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok) inset; }
.opt.winner .fill { opacity: .3; }
.win-chip { flex: none; white-space: nowrap; font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #fff; background: var(--ok); border-radius: 999px; padding: 1px 8px; }
.card.is-final .opt { cursor: default; }
.card.is-final h2 a, .card.is-final h1 { overflow-wrap: anywhere; }

.record { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 18px; margin-top: 4px; }
.record-big { display: inline-flex; align-items: baseline; gap: 10px; }
.record-big b { font-family: var(--font-display); font-size: clamp(2.2rem, 6vw, 3.2rem); line-height: 1; letter-spacing: -.03em; color: var(--accent); font-variant-numeric: tabular-nums; }
.record-big span { color: var(--muted); font-weight: 600; }
.record-detail, .record-empty { margin: 0; color: var(--muted); font-size: .92rem; }

/* header: brand left, actions right, one row at every width (short labels on phones) */
.topnav a:not(.btn) { white-space: nowrap; }
.topnav .btn { white-space: nowrap; }
@media (max-width: 520px) {
  .topline { flex-wrap: nowrap; gap: 10px; }
  .brand { font-size: 1.2rem; gap: 8px; min-width: 0; }
  .brand svg { width: 26px; height: 26px; flex: none; }
  .topnav { gap: 12px; flex: none; }
  .topnav .btn { padding: 8px 13px; font-size: .88rem; }
  .topnav .wide { display: none; }
}

/* ---- "The world is divided": each country's favourite ---- */
.split { border-top: 1px dashed var(--border); padding-top: 10px; display: grid; gap: 6px; }
.split-title { margin: 0; font-size: .74rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.split ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.split li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; font-size: .88rem; min-width: 0; }
.split .flag { font-size: 1.15rem; line-height: 1; }
.split .cn { min-width: 0; line-height: 1.25; }
.split .pick { --c: #64748b; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; color: var(--text); }
.split .pick i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.split .pick b { font-variant-numeric: tabular-nums; }
.split .cn small { display: block; color: var(--muted); font-size: .74rem; line-height: 1.2; }
.split-slot:empty { display: none; }
.rail-more { margin-left: auto; font-size: .88rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.rail-more:hover { text-decoration: underline; }

/* ---- admin: manage polls ---- */
.manage { display: grid; gap: 8px; }
.manage-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.manage-row:first-child { border-top: 0; }
.manage-title { font-weight: 600; overflow-wrap: anywhere; }
.manage-sub { color: var(--muted); font-size: .82rem; }
.manage-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.manage-actions .btn { padding: 6px 10px; font-size: .82rem; }
.tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--track); color: var(--muted); margin-left: 6px; }
@media (max-width: 520px) { .manage-row { grid-template-columns: 1fr; } .manage-actions { justify-content: flex-start; } }
