:root {
  --pine: #173d2c;
  --pine-2: #22553e;
  --cream: #fbf6ec;
  --paper: #fffdf8;
  --ink: #23201c;
  --muted: #6f675c;
  --red: #b3362c;
  --red-2: #8f271f;
  --gold: #f2c14e;
  --gold-2: #d9a326;
  --line: #e9dfcc;
  --ok: #2f7d4f;
  --warn: #c07a12;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(23, 61, 44, .12);
  font-family: 'Nunito', system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--cream) radial-gradient(circle at 20% -10%, #fff 0, transparent 50%);
  min-height: 100vh;
  display: flex; flex-direction: column;
}
h1, h2, h3 { font-family: 'Fraunces', Georgia, serif; line-height: 1.15; margin: 0 0 .4em; }
a { color: var(--pine-2); }
button { font: inherit; cursor: pointer; }
input, textarea, select {
  font: inherit; width: 100%; padding: .7em .85em; border-radius: 12px;
  border: 2px solid var(--line); background: #fff; color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--gold-2); box-shadow: 0 0 0 4px rgba(242, 193, 78, .25); }
textarea { min-height: 90px; resize: vertical; }
label { font-weight: 700; display: block; margin: .8em 0 .3em; }
.hint { color: var(--muted); font-size: .9rem; font-weight: 400; }

#snow { position: fixed; inset: 0; pointer-events: none; z-index: 0; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  padding: .7rem clamp(1rem, 3vw, 2rem);
  background: var(--pine); color: #fff;
  box-shadow: 0 2px 0 var(--gold-2);
}
.brand { display: flex; align-items: center; gap: .55rem; color: #fff; text-decoration: none; font-size: 1.15rem; }
.brand b { font-family: 'Fraunces', serif; }
.brand small { color: var(--gold); font-weight: 800; }
.brand-star { color: var(--gold); font-size: 1.5rem; filter: drop-shadow(0 0 6px rgba(242,193,78,.7)); }
.nav { display: flex; gap: .25rem; margin-left: auto; }
.nav a { color: #e9f1ec; text-decoration: none; padding: .45rem .8rem; border-radius: 999px; font-weight: 700; }
.nav a.active, .nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.icon-btn { background: none; border: 0; font-size: 1.3rem; padding: .3rem; border-radius: 10px; }
.icon-btn:hover { background: rgba(255,255,255,.12); }
.nav[hidden] { display: none; }
.nav[hidden] + .icon-btn { margin-left: auto; }
@media (max-width: 560px) {
  .topbar { gap: .4rem; padding: .6rem .7rem; }
  .brand { font-size: 1rem; } .brand small { display: none; }
  .nav a { padding: .35rem .5rem; font-size: .9rem; }
}

.app { position: relative; z-index: 1; width: min(1120px, 100%); margin: 0 auto; padding: clamp(1rem, 3vw, 2rem); flex: 1; }
.footer { position: relative; z-index: 1; text-align: center; color: var(--muted); font-size: .9rem; padding: 1.5rem; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  border: 0; border-radius: 999px; padding: .75em 1.3em; font-weight: 800;
  background: var(--red); color: #fff; box-shadow: 0 4px 0 var(--red-2);
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--red-2); }
.btn.gold { background: var(--gold); color: #3b2a00; box-shadow: 0 4px 0 var(--gold-2); }
.btn.green { background: var(--pine-2); box-shadow: 0 4px 0 var(--pine); }
.btn.ghost { background: transparent; color: var(--pine); box-shadow: inset 0 0 0 2px var(--line); }
.btn.small { padding: .45em .9em; font-size: .9rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

/* ---------- cards ---------- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.3rem; box-shadow: var(--shadow); }
.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

/* ---------- landing ---------- */
.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--pine) 0%, #0f2a1e 100%); color: #fff;
  border-radius: 28px; padding: clamp(1.5rem, 5vw, 3.5rem); box-shadow: var(--shadow);
}
.hero h1 { font-size: clamp(2.2rem, 6vw, 4rem); }
.hero h1 em { color: var(--gold); font-style: normal; }
.hero p.lead { font-size: 1.2rem; max-width: 34em; color: #dfeae4; }
.hero .tree { position: absolute; right: -10px; bottom: -20px; font-size: clamp(8rem, 20vw, 15rem); opacity: .18; transform: rotate(-6deg); }
.countdown { display: flex; gap: .6rem; margin: 1.3rem 0; flex-wrap: wrap; }
.countdown div { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); border-radius: 14px; padding: .5rem .9rem; text-align: center; min-width: 72px; }
.countdown b { display: block; font-size: 1.7rem; font-family: 'Fraunces', serif; color: var(--gold); }
.countdown span { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; }
.prize-strip { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.prize-chip { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: .35rem .8rem; font-weight: 700; font-size: .92rem; }
.prize-chip b { color: var(--red); }
.how { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; gap: .8rem; }
.how li { counter-increment: s; display: flex; gap: .8rem; align-items: flex-start; }
.how li::before { content: counter(s); flex: none; width: 2rem; height: 2rem; border-radius: 50%; background: var(--gold); display: grid; place-items: center; font-weight: 800; }
.tabs { display: flex; background: var(--cream); border-radius: 999px; padding: 4px; margin-bottom: .5rem; }
.tabs button { flex: 1; border: 0; background: none; border-radius: 999px; padding: .55rem; font-weight: 800; color: var(--muted); }
.tabs button.on { background: #fff; color: var(--pine); box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.err { color: var(--red); font-weight: 700; min-height: 1.3em; margin: .5rem 0 0; }

/* ---------- dashboard ---------- */
.kid-tabs { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.kid-tab { display: flex; align-items: center; gap: .5rem; border: 2px solid var(--line); background: #fff; border-radius: 999px; padding: .35rem .9rem .35rem .45rem; font-weight: 800; }
.kid-tab .av { font-size: 1.4rem; width: 2.1rem; height: 2.1rem; display: grid; place-items: center; background: var(--cream); border-radius: 50%; }
.kid-tab.on { border-color: var(--pine-2); background: var(--pine-2); color: #fff; }
.kid-tab.on .av { background: rgba(255,255,255,.18); }
.kid-tab.add { border-style: dashed; color: var(--muted); }

.hero-kid { display: grid; grid-template-columns: auto 1fr auto; gap: 1.5rem; align-items: center; }
@media (max-width: 720px) { .hero-kid { grid-template-columns: 1fr; text-align: center; } .hero-kid .ring { margin: 0 auto; } }
.ring { --p: 0; width: 150px; height: 150px; border-radius: 50%;
  background: conic-gradient(var(--gold-2) calc(var(--p) * 1%), #efe6d4 0);
  display: grid; place-items: center; position: relative; }
.ring::before { content: ''; position: absolute; inset: 14px; border-radius: 50%; background: var(--paper); }
.ring div { position: relative; text-align: center; }
.ring b { font-family: 'Fraunces', serif; font-size: 2rem; display: block; color: var(--pine); }
.ring small { color: var(--muted); font-weight: 700; }
.stats { display: flex; gap: 1.2rem; flex-wrap: wrap; margin-top: .6rem; }
.stats div b { font-size: 1.3rem; display: block; }
.stats div span { color: var(--muted); font-size: .85rem; font-weight: 700; }
.advent { background: linear-gradient(135deg, #fff7e0, #fff); border: 1px dashed var(--gold-2); border-radius: 16px; padding: .9rem 1.1rem; max-width: 260px; }
.advent .day { font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--gold-2); font-weight: 800; }
.advent b { display: block; font-family: 'Fraunces', serif; font-size: 1.1rem; }

.section-title { display: flex; align-items: baseline; gap: .8rem; margin: 2rem 0 1rem; }
.section-title h2 { margin: 0; }
.acts { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.act {
  position: relative; text-align: left; border: 1px solid var(--line); background: var(--paper);
  border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: .4rem; transition: transform .15s, box-shadow .15s;
  border-top: 6px solid var(--c, var(--pine));
}
.act:hover { transform: translateY(-3px); box-shadow: 0 16px 34px rgba(23,61,44,.16); }
.act .icon { font-size: 2.1rem; }
.act h3 { font-size: 1.15rem; margin: 0; }
.act p { margin: 0; color: var(--muted); font-size: .93rem; flex: 1; }
.act .value { position: absolute; top: .9rem; right: .9rem; background: var(--gold); color: #3b2a00; font-weight: 800; border-radius: 999px; padding: .15rem .6rem; }
.status { display: inline-flex; align-items: center; gap: .3rem; font-weight: 800; font-size: .82rem; border-radius: 999px; padding: .2rem .65rem; width: fit-content; }
.status.none { background: #f1ece2; color: var(--muted); }
.status.pending { background: #fff1d6; color: var(--warn); }
.status.approved { background: #dff2e6; color: var(--ok); }
.status.needs_work { background: #fde2df; color: var(--red); }
.act.done { background: linear-gradient(180deg, #f3fbf5, var(--paper)); }
.act.done::after { content: '✓'; position: absolute; right: 1rem; bottom: .8rem; font-size: 2.2rem; color: var(--ok); opacity: .25; font-weight: 800; }

.empty { text-align: center; padding: 3rem 1rem; }
.empty .big { font-size: 4rem; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 1rem; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 30, 22, .55); backdrop-filter: blur(3px); }
.modal-card { position: relative; background: var(--paper); border-radius: 24px; width: min(760px, 100%); max-height: 92vh; overflow: auto; padding: clamp(1.1rem, 3vw, 2rem); box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.modal-x { position: absolute; top: .8rem; right: .8rem; border: 0; background: var(--cream); width: 2.2rem; height: 2.2rem; border-radius: 50%; font-size: 1rem; }
.act-head { display: flex; gap: 1rem; align-items: center; margin-bottom: .5rem; padding-right: 2rem; }
.act-head .icon { font-size: 2.8rem; }
.verse { background: var(--cream); border-left: 4px solid var(--gold-2); padding: .6rem .9rem; border-radius: 0 12px 12px 0; font-style: italic; color: #4c453b; margin: .6rem 0; }
.steps { padding-left: 1.2rem; margin: .4rem 0 1rem; }
.steps li { margin: .2rem 0; }
.note-box { background: #fde9e6; border-radius: 12px; padding: .7rem .9rem; margin: .6rem 0; color: var(--red-2); font-weight: 700; }
.member { border: 1px solid var(--line); border-radius: 14px; padding: .8rem; margin: .6rem 0; background: #fff; }
.member .row input { flex: 1; min-width: 140px; }
.list-inputs input { margin-bottom: .45rem; }

/* ---------- word search ---------- */
.ws-wrap { display: grid; grid-template-columns: 1fr 200px; gap: 1rem; align-items: start; }
@media (max-width: 640px) { .ws-wrap { grid-template-columns: 1fr; } }
.ws-grid { display: grid; user-select: none; touch-action: none; background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 6px; gap: 2px; }
.ws-cell { aspect-ratio: 1; display: grid; place-items: center; font-weight: 800; border-radius: 6px; font-size: clamp(.7rem, 2.6vw, 1.05rem); }
.ws-cell.sel { background: var(--gold); }
.ws-cell.found { background: #cfe9d8; color: var(--pine); }
.ws-words { list-style: none; padding: 0; margin: 0; columns: 2; }
@media (min-width: 641px) { .ws-words { columns: 1; } }
.ws-words li { font-weight: 700; padding: .15rem 0; }
.ws-words li.found { text-decoration: line-through; color: var(--ok); }

/* ---------- horse race ---------- */
.track { background: #6f9e57; border-radius: 16px; padding: .6rem; display: grid; gap: .4rem; border: 4px solid #4f7a3c; }
.lane { position: relative; height: 46px; background: repeating-linear-gradient(90deg, #8fbf72 0 40px, #86b76a 40px 80px); border-radius: 10px; overflow: hidden; }
.lane .finish { position: absolute; right: 0; top: 0; bottom: 0; width: 14px; background: repeating-conic-gradient(#fff 0 25%, #222 0 50%) 0 0 / 14px 14px; }
.lane .horse { position: absolute; top: 50%; transform: translate(-50%, -50%) scaleX(-1); font-size: 2rem; transition: left .45s cubic-bezier(.3,1.4,.6,1); }
.lane .tag { position: absolute; left: 8px; top: 3px; font-size: .75rem; font-weight: 800; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.lane.turn { box-shadow: inset 0 0 0 3px var(--gold); }
.die { font-size: 2.6rem; display: inline-block; }
.die.roll { animation: roll .5s; }
@keyframes roll { 0% { transform: rotate(0) scale(1); } 50% { transform: rotate(200deg) scale(1.3); } 100% { transform: rotate(360deg) scale(1); } }
.scoreboard { display: flex; gap: .5rem; flex-wrap: wrap; margin: .6rem 0; }
.scoreboard span { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: .25rem .7rem; font-weight: 700; }

/* ---------- trivia ---------- */
.q { margin: 1rem 0; }
.q .opts { display: grid; gap: .45rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.q .opt { text-align: left; border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: .6rem .8rem; font-weight: 700; }
.q .opt.on { border-color: var(--pine-2); background: #e6f2eb; }
.q .opt.right { border-color: var(--ok); background: #dff2e6; }
.q .opt.wrong { border-color: var(--red); background: #fde2df; }
.progress { height: 10px; background: #efe6d4; border-radius: 999px; overflow: hidden; }
.progress div { height: 100%; background: var(--gold-2); transition: width .3s; }

/* ---------- parents ---------- */
.review { border: 1px solid var(--line); border-radius: 16px; padding: 1rem; background: #fff; margin-bottom: .8rem; }
.review .meta { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: .5rem; }
.review dl { margin: .4rem 0; }
.review dt { font-weight: 800; margin-top: .4rem; font-size: .9rem; color: var(--muted); }
.review dd { margin: 0 0 .2rem; white-space: pre-wrap; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .4rem; border-bottom: 1px solid var(--line); }
th { font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
td input { width: 90px; padding: .35rem .5rem; }

/* ---------- leaderboard ---------- */
.lb { display: grid; gap: .7rem; }
.lb-row { display: grid; grid-template-columns: 2.5rem 3rem 1fr auto; align-items: center; gap: .8rem; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: .8rem 1rem; box-shadow: var(--shadow); }
.lb-row .rank { font-family: 'Fraunces', serif; font-size: 1.6rem; color: var(--gold-2); }
.lb-row .av { font-size: 2rem; }
.lb-row .bar { height: 10px; background: #efe6d4; border-radius: 999px; overflow: hidden; margin-top: .3rem; }
.lb-row .bar div { height: 100%; background: linear-gradient(90deg, var(--gold-2), var(--red)); }
.badges { display: flex; gap: .2rem; flex-wrap: wrap; font-size: 1.1rem; margin-top: .25rem; }

/* ---------- certificate ---------- */
.cert { background: #fffdf5; border: 12px double var(--gold-2); border-radius: 8px; padding: 3rem 2rem; text-align: center; max-width: 820px; margin: 0 auto; }
.cert h1 { font-size: 2.6rem; color: var(--pine); }
.cert .name { font-family: 'Fraunces', serif; font-size: 3rem; color: var(--red); border-bottom: 2px solid var(--line); display: inline-block; padding: 0 1.5rem .2rem; margin: .5rem 0 1rem; }
@media print {
  .topbar, .footer, #snow, .no-print { display: none !important; }
  body { background: #fff; }
  .app { padding: 0; }
}

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); z-index: 60; background: var(--pine); color: #fff; padding: .8rem 1.3rem; border-radius: 999px; font-weight: 800; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.toast.bad { background: var(--red); }
.confetti { position: fixed; top: -10px; z-index: 70; font-size: 1.4rem; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
