:root {
  --bg: #f7f3e8;
  --card: #fffdf7;
  --ink: #1b2419;
  --muted: #4a5546;
  --line: #d9d2bf;
  --accent: #2f6b34;       /* pasture green, 6.4:1 on --card */
  --accent-ink: #ffffff;
  --accent-soft: #e3efdc;
  --gold: #a86a00;
  --mine: #c2410c;
  --wool: #ffffff;
  --wool-line: #cfc7b3;
  --face: #2b2724;
  --bubble: #eef4e8;
  --radius: 18px;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111611;
    --card: #1a211a;
    --ink: #f2efe4;
    --muted: #c3c9bd;
    --line: #344033;
    --accent: #8fd18f;
    --accent-ink: #0f1a0f;
    --accent-soft: #233423;
    --gold: #f2b84b;
    --mine: #ff8a5b;
    --wool: #ece8dc;
    --wool-line: #9c9585;
    --bubble: #223022;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
a { color: var(--accent); font-weight: 600; }
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- header */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0)) 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.logo { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.day-no { color: var(--muted); font-weight: 700; font-size: 18px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  border: 2px solid var(--ink); background: transparent; color: var(--ink);
  font-weight: 800; font-size: 18px; display: grid; place-items: center;
}

/* ---------------------------------------------------------------- layout */
.wrap { max-width: 480px; margin: 0 auto; padding: 16px 16px 8px; display: grid; gap: 16px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 18px;
  box-shadow: 0 1px 0 var(--line);
}
.loading, .error { text-align: center; color: var(--muted); padding: 40px 0; }
.error { color: var(--mine); font-weight: 600; }

/* ---------------------------------------------------------------- Gerald */
.gerald-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.gerald { flex: 0 0 84px; }
.gerald-svg { width: 84px; height: auto; display: block; }
.wool circle { fill: var(--wool); stroke: var(--wool-line); stroke-width: 1.5; }
.head, .ear { fill: var(--face); }
.eye-white { fill: #fff; }
.pupil { fill: #111; }
.lid { fill: var(--face); }
.brow { stroke: #fff; stroke-width: 2.5; stroke-linecap: round; fill: none; }
.mouth { stroke: #fff; stroke-width: 2.5; stroke-linecap: round; fill: none; }
.mouth-o { fill: #fff; }
.gerald-svg .smug-only, .gerald-svg .alarmed-only, .gerald-svg .happy-only, .gerald-svg .neutral-only { display: none; }
.mood-neutral .neutral-only, .mood-smug .smug-only, .mood-alarmed .alarmed-only, .mood-happy .happy-only { display: inline; }
.mood-alarmed .pupil { r: 2.4; }
.mood-alarmed .eye-white { r: 8; }
.gerald-svg { animation: bob 3.2s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes bob { 50% { transform: translateY(-2px) rotate(-1.5deg); } }
@media (prefers-reduced-motion: reduce) { .gerald-svg { animation: none; } }

.bubble {
  position: relative; margin: 0;
  background: var(--bubble); color: var(--ink);
  padding: 10px 14px; border-radius: 14px;
  font-size: 15.5px; font-weight: 600;
}
.bubble::before {
  content: ""; position: absolute; left: -7px; top: 50%; transform: translateY(-50%);
  border: 7px solid transparent; border-left: 0; border-right-color: var(--bubble);
}

/* ---------------------------------------------------------------- rule */
.rule-label { margin: 0; text-transform: uppercase; letter-spacing: 0.08em; font-size: 12.5px; font-weight: 800; color: var(--muted); }
.rule-name { margin: 2px 0 6px; font-size: 28px; line-height: 1.15; letter-spacing: -0.02em; }
.rule-howto { margin: 0 0 18px; color: var(--muted); font-size: 15.5px; }

/* ---------------------------------------------------------------- progress */
.progress { display: flex; justify-content: center; gap: 8px; margin: -4px 0 14px; }
.dot {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--line); display: grid; place-items: center; font-size: 16px;
}
.dot.current { border-color: var(--accent); background: var(--accent-soft); }
.dot.done { border-color: transparent; background: var(--bg); }

/* ---------------------------------------------------------------- question */
.question { margin: 4px 0 18px; font-size: 26px; line-height: 1.2; letter-spacing: -0.02em; }
.options { display: grid; gap: 12px; }
.option {
  display: flex; align-items: center; gap: 14px;
  min-height: 72px; padding: 14px 18px; border-radius: 16px;
  background: var(--card); color: var(--ink);
  border: 2.5px solid var(--ink);
  font-size: 20px; font-weight: 800; text-align: left;
  touch-action: manipulation;
  transition: transform .08s ease, background .15s ease;
}
.option:active { transform: scale(0.98); }
.option:hover:not(:disabled) { background: var(--accent-soft); }
.option.picked { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.option:disabled { cursor: default; }
.option-emoji { font-size: 32px; line-height: 1; }

/* the split bars */
.split {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 54px; padding: 10px 16px; border-radius: 14px;
  background: var(--bg); border: 2px solid var(--line);
  font-weight: 700; font-size: 17px;
}
.split + .split { margin-top: 8px; }
.split-fill { position: absolute; inset: 0 auto 0 0; background: var(--line); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.split.is-flock .split-fill { background: var(--accent-soft); }
.split.is-mine { border-color: var(--ink); border-width: 2.5px; }
.split-text, .split-pct { position: relative; }
.split-pct { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.you {
  display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px;
  background: var(--ink); color: var(--bg); font-size: 12px; font-weight: 800; vertical-align: 2px;
}
.verdict-line { margin: 14px 0 14px; text-align: center; font-weight: 800; font-size: 18px; }
.verdict-line.flock { color: var(--accent); }
.verdict-line.lone { color: var(--mine); }

.primary, .secondary {
  width: 100%; min-height: 54px; border-radius: 14px;
  font-size: 18px; font-weight: 800; letter-spacing: 0.01em;
  touch-action: manipulation;
}
.primary { background: var(--accent); color: var(--accent-ink); border: 0; }
.primary:disabled { opacity: 0.6; }
.secondary { background: transparent; color: var(--ink); border: 2px solid var(--ink); }
.primary:focus-visible, .secondary:focus-visible, .option:focus-visible, .icon-btn:focus-visible, .banner:focus-visible { outline: 3px solid var(--mine); outline-offset: 2px; }
.fineprint { margin: 10px 0 0; text-align: center; font-size: 13.5px; color: var(--muted); }

/* ---------------------------------------------------------------- summary */
.score { text-align: center; margin: 0 0 18px; }
.score-big { font-size: 52px; font-weight: 800; letter-spacing: -0.04em; line-height: 1.05; }
.score-title { font-size: 22px; font-weight: 800; color: var(--accent); margin-top: 2px; }
.score-row { font-size: 34px; letter-spacing: 4px; margin: 10px 0 4px; }
.score-blurb { margin: 0; color: var(--muted); font-weight: 600; }
.flock-count { text-align: center; margin: 16px 0 2px; font-weight: 700; }
.countdown { text-align: center; margin: 0; color: var(--muted); font-weight: 600; }
.countdown-time { color: var(--ink); font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 800; }
.review { margin-top: 20px; display: grid; gap: 18px; }
.review-q { margin: 0 0 8px; font-weight: 800; }
.review .split { min-height: 44px; font-size: 15.5px; }
.review .split-pct { font-size: 17px; }

/* ---------------------------------------------------------------- yesterday */
.y-title { margin: 4px 0 2px; font-size: 24px; letter-spacing: -0.02em; }
.y-sub { margin: 0; color: var(--muted); font-weight: 600; }

.banner {
  width: 100%; text-align: left; border: 0; border-radius: 14px;
  background: var(--accent-soft); color: var(--ink);
  padding: 12px 16px; font-weight: 700; font-size: 15.5px;
}
.ad-slot { min-height: 100px; }

/* ---------------------------------------------------------------- footer / toast / dialogs */
.footer { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 18px; padding: 18px 16px 28px; font-size: 14.5px; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px;
  font-weight: 700; box-shadow: 0 6px 20px rgba(0,0,0,.25); z-index: 20; max-width: calc(100% - 32px);
}
dialog {
  border: 0; border-radius: var(--radius); padding: 22px 20px;
  width: min(440px, calc(100% - 32px));
  background: var(--card); color: var(--ink);
}
dialog::backdrop { background: rgba(10, 14, 10, 0.55); }
dialog h2 { margin: 0 0 10px; }
dialog ol { padding-left: 20px; }
dialog li { margin-bottom: 8px; }
.levels-legend { font-weight: 700; text-align: center; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 8px 0 6px; }
.stats-grid div { display: flex; flex-direction: column; align-items: center; background: var(--bg); border-radius: 12px; padding: 10px 4px; }
.stat-v { font-size: 26px; font-weight: 800; }
.stat-k { font-size: 12.5px; color: var(--muted); font-weight: 700; text-align: center; }

/* ---------------------------------------------------------------- static pages */
.page { max-width: 640px; margin: 0 auto; padding: 24px 16px 40px; }
.page h1 { font-size: 32px; letter-spacing: -0.02em; margin: 8px 0 12px; }
.page h2 { margin-top: 28px; }
.page .back { display: inline-block; margin-bottom: 8px; }

/* ---------------------------------------------------------------- small phones (iPhone SE, compact Androids) */
@media (max-width: 360px) {
  .wrap { padding: 12px 12px 8px; gap: 12px; }
  .card { padding: 16px 14px; }
  .gerald { flex-basis: 64px; }
  .gerald-svg { width: 64px; }
  .gerald-row { margin-bottom: 10px; }
  .bubble { font-size: 14.5px; padding: 8px 12px; }
  .progress { margin-bottom: 10px; }
  .question { font-size: 22px; margin-bottom: 14px; }
  .option { min-height: 62px; font-size: 18px; }
  .split { min-height: 48px; }
  .verdict-line { font-size: 16px; margin: 10px 0; }
  .score-big { font-size: 44px; }
}
#play, #done, #yesterday { scroll-margin-top: 72px; }

/* ---------------------------------------------------------------- One a Day home */
.hub-hero { text-align: center; padding: calc(36px + env(safe-area-inset-top, 0)) 16px 8px; }
.hub-mark {
  width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  font-size: 38px; font-weight: 800;
}
.hub-title { margin: 0; font-size: 40px; font-weight: 800; letter-spacing: -0.03em; }
.hub-tag { margin: 6px auto 0; max-width: 360px; color: var(--muted); font-weight: 600; }
.game-card {
  display: flex; gap: 16px; align-items: center;
  background: var(--card); border: 2px solid var(--ink); border-radius: var(--radius);
  padding: 18px 16px; color: var(--ink); text-decoration: none; font-weight: 400;
  transition: transform .1s ease;
}
.game-card:active { transform: scale(0.99); }
.game-card:hover:not(.soon) { background: var(--accent-soft); }
.game-card.soon { border: 2px dashed var(--line); }
.game-art { flex: 0 0 88px; }
.game-art .gerald-svg { width: 88px; }
.soon-art {
  height: 88px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg); color: var(--muted); font-size: 40px; font-weight: 800;
}
.game-name { margin: 0; font-size: 24px; letter-spacing: -0.02em; }
.game-desc { margin: 2px 0 8px; color: var(--muted); font-size: 15.5px; }
.game-play { color: var(--accent); font-weight: 800; }
.soon .game-name { color: var(--muted); }
