/* Purrcincts: a calm night page, the honeycomb in the middle, the election panel above it. The title screen and the
   sheets are shared/mainmenu.js (menu.css, loaded after this); only their colours are set here (--sg-*). The board
   look (logic.js LOOKS) sets --bg and --bg2 on the page. */
:root {
  --bg: #0a0e1a; --bg2: #141c33; --ink: #eef1fa; --ink-soft: #9aa3bd; --line: rgba(222, 230, 255, 0.16);
  --panel: rgba(255, 255, 255, 0.035); --chip: #20283c; --sheet: #121829; --gold: #ffd75e;
  --nap: #ff6fb1; --zoom: #4fa3ff; --snack: #ffc23d; --draw: #c9cfdf; --open: #2a3247;
  --good: #5fd39a;
  --bw: 360px; --bh: 300px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
* { touch-action: manipulation; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Baloo 2", ui-rounded, system-ui, sans-serif; color: var(--ink);
  background: radial-gradient(ellipse 120% 55% at 50% 62%, var(--bg2), transparent 72%), var(--bg);
  overflow: hidden; overscroll-behavior: none;
}
button { font: inherit; color: inherit; }
.app {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center;
  padding: calc(var(--sg-corner-top) - 2px) 12px calc(env(safe-area-inset-bottom, 0px) + 10px);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}

/* ---- top bar ---- */
.bar { width: 100%; max-width: 520px; display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: 8px; }
.icon-btn {
  width: 48px; height: 48px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 16px;
  background: rgba(255, 255, 255, 0.05); cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:active { transform: scale(0.94); }
.head { text-align: center; min-width: 0; }
.name { margin: 0; font-weight: 800; font-size: 22px; line-height: 1.1; letter-spacing: 0.02em; }
.sub { margin: 0; font-weight: 600; font-size: 15px; line-height: 1.2; color: var(--ink-soft); white-space: nowrap; }
.sub .tag { display: inline-block; margin-left: 6px; padding: 1px 8px 0; border-radius: 999px; background: rgba(255, 215, 94, 0.16); color: var(--gold); font-size: 13px; font-weight: 700; }

/* ---- the goal ---- */
.goal { width: 100%; max-width: 440px; margin: 6px 0 8px; text-align: center; font-weight: 500; font-size: 16px; line-height: 1.3; color: var(--ink-soft); }
.goal b { color: var(--ink); font-weight: 700; }
.goal .party { font-weight: 800; }

/* ---- the election panel ---- */
.panel { width: 100%; max-width: 440px; padding: 10px 14px 10px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.row { display: grid; grid-template-columns: 78px 1fr; align-items: center; gap: 10px; min-height: 26px; }
.row + .row { margin-top: 6px; }
.label { font-weight: 600; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.bar-track { display: flex; height: 22px; border-radius: 999px; overflow: hidden; background: #4a5268; gap: 2px; }
.bar-track .seg {
  display: grid; place-items: center; min-width: 0; font-weight: 800; font-size: 14px; line-height: 1; color: #0b0f1c;
  font-variant-numeric: tabular-nums; transition: flex-grow 0.25s ease-out;
}
.bar-track .seg.n { background: var(--nap); } .bar-track .seg.z { background: var(--zoom); } .bar-track .seg.s { background: var(--snack); }
.bar-track .seg.draw { background: repeating-linear-gradient(-45deg, #c9cfdf 0 5px, #8f97ad 5px 10px); }
.bar-track .seg.open { background: #4a5268; color: transparent; }
.slots-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 9px; }
.slots { flex: 1; min-width: 0; display: grid; grid-template-columns: repeat(var(--n, 5), minmax(0, 40px)); gap: 6px; }
.slot {
  width: 100%; aspect-ratio: 1; display: grid; place-items: center; border: 2px dashed rgba(222, 230, 255, 0.28); border-radius: 10px;
  font-weight: 800; font-size: 13px; line-height: 1; color: var(--ink-soft); font-variant-numeric: tabular-nums; position: relative;
}
.slot.going { border-style: solid; border-color: rgba(255, 255, 255, 0.55); color: var(--ink); background: rgba(255, 255, 255, 0.06); }
.slot.full { border-style: solid; border-color: transparent; }
.slot.full.n { background: var(--nap); } .slot.full.z { background: var(--zoom); } .slot.full.s { background: var(--snack); }
.slot.full.draw { background: repeating-linear-gradient(-45deg, #c9cfdf 0 5px, #8f97ad 5px 10px); color: #0b0f1c; font-size: 18px; }
.slot svg { display: block; width: 84%; height: 84%; }
.slot.pop { animation: slotpop 0.32s ease-out; }
@keyframes slotpop { 0% { transform: scale(0.7); } 60% { transform: scale(1.12); } 100% { transform: none; } }
.clock {
  margin: 0; flex: none; display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: 18px; line-height: 1;
  color: var(--ink); font-variant-numeric: tabular-nums;
}
.clock svg { width: 18px; height: 18px; fill: none; stroke: var(--ink-soft); stroke-width: 2.2; stroke-linecap: round; margin-top: -2px; }
.clock.stopped { color: var(--good); }
.clock.stopped svg { stroke: var(--good); }
.clock[hidden] { display: inline-flex; visibility: hidden; }
/* 7 or 8 slots: tighter boxes */
.slots.many { gap: 4px; }
.slots.many .slot { font-size: 12px; border-radius: 8px; }

/* ---- the board ---- */
.stage { flex: 1 1 auto; min-height: 0; width: calc(100% + 16px); margin: 0 -8px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 10px 0 max(10px, 2vh); }
.board { flex: none; margin-top: auto; width: var(--bw); height: var(--bh); position: relative; touch-action: none; cursor: pointer; --up: 0px; }
/* the view: at fit exactly the board's box; zoomed in (a pinch) it grows up into the empty stage (--up, as far as the
   info card), clips the board and shows its edge, with the fit button in its corner */
.board-view { position: absolute; inset: 0; }
.board svg { position: absolute; left: 0; bottom: 0; display: block; width: var(--bw); height: var(--bh); overflow: visible; transform-origin: 0 0; }
.board.zoomed .board-view { top: calc(-1 * var(--up)); overflow: hidden; border-radius: 14px; }
.board.zoomed .board-view::after { content: ''; position: absolute; inset: 0; border-radius: 14px; box-shadow: inset 0 0 0 1.5px rgba(222, 230, 255, 0.28); pointer-events: none; }
.pc-fit {
  position: absolute; top: 6px; right: 6px; z-index: 2; width: 44px; height: 44px; padding: 0; display: grid; place-items: center;
  border: 1px solid rgba(222, 230, 255, 0.4); border-radius: 14px; background: rgba(10, 14, 26, 0.84); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pc-fit[hidden] { display: none; }
.pc-fit svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.pc-fit:active { transform: scale(0.94); }
.board .voters use { transform-box: fill-box; transform-origin: center; }
.board .voters use.hop { animation: hop 0.3s ease-out; }
.app.paused .board { filter: blur(9px) saturate(0.6); }
.app.won .board .voters use { animation: cheer 0.7s ease-in-out both; }
@keyframes hop { 0% { transform: translateY(0); } 40% { transform: translateY(-7px); } 100% { transform: none; } }
@keyframes cheer { 0%, 100% { transform: none; } 40% { transform: translateY(-10px) scale(1.08); } 70% { transform: scale(1.04, 0.96); } }
.note { min-height: 22px; max-width: 420px; margin: 8px 0 0; text-align: center; font-weight: 600; font-size: 15px; line-height: 1.3; color: var(--ink-soft); }
.note.bad { color: #ffb3c8; }
.note.good { color: var(--good); }
.note[hidden] { display: none; }

/* ---- under the board ---- */
.controls { display: flex; gap: 10px; margin-top: auto; padding-top: 10px; }
.controls[hidden] { display: none; }
.pill {
  min-height: 48px; min-width: 96px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 4px 16px 2px;
  border: 1.5px solid rgba(222, 230, 255, 0.5); border-radius: 12px; background: transparent; color: var(--ink); font-weight: 700; font-size: 17px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pill svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; margin-top: -2px; }
.pill:active { transform: translateY(1px); background: rgba(255, 255, 255, 0.08); }
.pill:disabled { opacity: 0.38; cursor: default; }
.pill .count { font-size: 13px; color: var(--gold); margin-left: -2px; }
.pill.primary { background: #eef1fa; color: #0b0f1c; border-color: #eef1fa; }
.done { width: 100%; max-width: 440px; margin-top: auto; padding-top: 8px; text-align: center; }
.done-title { margin: 0; font-weight: 800; font-size: 24px; line-height: 1.15; }
.done-next { margin: 0 0 8px; font-weight: 600; font-size: 15px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.done-row { display: flex; gap: 8px; justify-content: center; }
.done-row .pill { min-width: 0; flex: 1; padding: 4px 10px 2px; }
.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 64px); z-index: 5; margin: 0; padding: 8px 16px 6px; max-width: calc(100% - 32px);
  border-radius: 14px; background: #eef1fa; color: #0b0f1c; font-weight: 700; font-size: 16px; text-align: center;
  transform: translate(-50%, -6px); opacity: 0; transition: opacity 0.18s, transform 0.18s; pointer-events: none;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---- short phones ---- */
@media (max-height: 700px) {
  .goal { font-size: 14px; margin: 2px 0 6px; }
  .panel { padding: 7px 12px 8px; }
  .row { min-height: 22px; }
  .bar-track { height: 18px; }
  .bar-track .seg { font-size: 12px; }
  .slots { grid-template-columns: repeat(var(--n, 5), minmax(0, 34px)); }
  .slots-row { margin-top: 6px; }
  .stage { padding-top: 6px; }
  .note { margin-top: 4px; font-size: 14px; min-height: 18px; }
  .pill { min-height: 44px; }
}

/* ---- sheets (stats, archive, challenges, campaign) ---- */
.pc-nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 4px 0 6px; }
.pc-nums.two { grid-template-columns: repeat(2, 1fr); }
.pc-num { text-align: center; }
.pc-num b { display: block; font-size: 28px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.pc-num span { display: block; font-size: 13px; font-weight: 600; line-height: 1.15; color: var(--ink-soft); }
.pc-h { margin: 12px 0 4px; font-weight: 800; font-size: 17px; }
.pc-note { margin: 6px 0 0; font-weight: 500; font-size: 15px; line-height: 1.35; color: var(--ink-soft); }
.pc-fresh { margin: 0 0 6px; font-weight: 700; font-size: 15px; line-height: 1.3; color: var(--gold); }
.pc-next { margin: 10px 0 0; text-align: center; font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
.pc-share { width: 100%; min-height: 50px; margin-top: 8px; border: 0; border-radius: 14px; background: #eef1fa; color: #0b0f1c; font-weight: 800; font-size: 18px; cursor: pointer; }
.pc-squares { display: flex; justify-content: center; gap: 4px; margin: 4px 0 2px; }
.pc-squares svg { display: block; }
.pc-week { display: grid; gap: 4px; }
.pc-wd { display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 8px; padding: 6px 12px 4px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); font-weight: 600; font-size: 15px; }
.pc-wd b { font-weight: 800; }
.pc-wd small { color: var(--ink-soft); font-size: 13px; }
.pc-wd .t { font-variant-numeric: tabular-nums; text-align: right; }
.pc-wd.today { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5); }
.pc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.pc-day {
  width: 100%; min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 14px 4px;
  border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 255, 255, 0.04); text-align: left; cursor: pointer; font-weight: 700; font-size: 16px;
}
.pc-day small { display: block; font-weight: 500; font-size: 13px; color: var(--ink-soft); }
.pc-day .chip { flex: none; padding: 3px 10px 1px; border-radius: 999px; font-size: 14px; background: rgba(255, 255, 255, 0.1); font-variant-numeric: tabular-nums; }
.pc-day .chip.win { background: var(--good); color: #062014; }
.pc-day .chip.go { background: #eef1fa; color: #0b0f1c; }
.pc-day:disabled { cursor: default; opacity: 0.85; }
.pc-day .who { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.pc-more { min-height: 48px; border: 0; border-radius: 14px; background: rgba(255, 255, 255, 0.08); font-weight: 700; font-size: 16px; cursor: pointer; }
.pc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.pc-pick {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 100px; padding: 6px 4px 4px;
  border: 2px solid transparent; border-radius: 16px; background: rgba(255, 255, 255, 0.05); cursor: pointer;
}
.pc-pick svg { display: block; }
.pc-pick small { font-weight: 600; font-size: 12px; line-height: 1.1; color: var(--ink-soft); text-align: center; }
.pc-pick[aria-pressed="true"] { border-color: #eef1fa; background: rgba(255, 255, 255, 0.1); }
.pc-pick.locked { cursor: default; background: rgba(255, 255, 255, 0.03); }
.pc-pick.locked .q { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; border: 2px dashed rgba(222, 230, 255, 0.3); font-weight: 800; font-size: 24px; color: rgba(222, 230, 255, 0.4); }
.pc-stamps { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pc-ach { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.pc-ach li { display: flex; gap: 10px; align-items: center; padding: 8px 12px 6px; border-radius: 14px; background: rgba(255, 255, 255, 0.05); font-weight: 500; font-size: 15px; line-height: 1.25; }
.pc-ach li b { display: block; font-size: 16px; font-weight: 700; }
.pc-ach li.no { opacity: 0.5; }
.pc-ach .medal { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--gold); color: #4a3505; font-weight: 800; }
.pc-ach li.no .medal { background: rgba(255, 255, 255, 0.12); color: transparent; }
.pc-how-art { display: flex; justify-content: center; margin: 2px 0 4px; }
.pc-how-art svg { width: 220px; height: auto; }
.pc-how-row { display: flex; gap: 10px; align-items: center; }
.pc-how-row svg { flex: none; }
.pc-faces { display: flex; gap: 14px; justify-content: center; margin: 4px 0; }
.pc-faces span { display: flex; flex-direction: column; align-items: center; font-weight: 700; font-size: 13px; }
.pc-sheet-btns { display: flex; gap: 8px; margin-top: 12px; }
.pc-sheet-btns button { flex: 1; min-height: 48px; border-radius: 12px; border: 1.5px solid rgba(222, 230, 255, 0.5); background: transparent; color: var(--ink); font-weight: 700; font-size: 17px; cursor: pointer; }
.pc-sheet-btns button.primary { background: #eef1fa; color: #0b0f1c; border-color: #eef1fa; }

/* ---- the title screen's colours (the layout is shared/mainmenu.js) ---- */
#mm {
  --sg-bg: radial-gradient(ellipse 110% 60% at 50% 30%, var(--bg2), transparent 75%), var(--bg);
  --sg-ink: var(--ink); --sg-ink-soft: var(--ink-soft);
  --sg-title: #ffffff; --sg-title-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
  --sg-accent: #eef1fa; --sg-accent-ink: #0b0f1c;
  --sg-card: #161d30; --sg-card-ink: var(--ink); --sg-line: rgba(222, 230, 255, 0.18);
}
#mm .pc-title-art { width: 172px; height: 150px; }
#mm .pc-title-art svg { display: block; width: 100%; height: 100%; }
.sg-sheet { --sg-sheet-bg: var(--sheet); --sg-sheet-ink: var(--ink); --sg-accent: #eef1fa; --sg-accent-ink: #0b0f1c; --sg-ink-soft: var(--ink-soft); --sg-line: rgba(222, 230, 255, 0.18); --pb-track: rgba(255, 255, 255, 0.12); }

@media (prefers-reduced-motion: reduce) {
  .board .voters use.hop, .app.won .board .voters use, .slot.pop { animation: none; }
  .bar-track .seg { transition: none; }
  .toast { transition: none; }
}

/* election night: a district's result flips in */
.fills path.flip { animation: pc-flip 0.42s ease-out; }
@keyframes pc-flip { 0% { fill-opacity: 0.85; } 100% { } }
@media (prefers-reduced-motion: reduce) { .fills path.flip { animation: none; } }
