/* Palette taken from the "Words of Mother's Love" poster, with 8-bit accents. */
:root {
  color-scheme: light;
  --cream: #fff8dc;
  --yellow: #ffd84a;
  --sun: #ffe98a;
  --sky: #bfe6f7;
  --purple: #6b2a8c;
  --purple-ink: #3a1650;
  --coral: #e8584f;
  --peach: #f4a26b;
  --orange: #f39a3b;
  --leaf: #5bb04a;
  --card: #fffdf4;
  --text: #3a2a1e;
  --muted: #7d6a57;
  --line: #f0e2b8;
  --px: 4px; /* one "pixel" in the 8-bit details */
  --shadow: var(--px) var(--px) 0 var(--purple-ink);
  --pixel-font: "Press Start 2P", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  color: var(--text);
  font: 17px/1.45 "Baloo 2", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  min-height: 100vh;
  background-color: var(--cream);
  /* Soft bubbles like the poster background */
  background-image:
    radial-gradient(circle at 92% 6%, rgba(191, 230, 247, .9) 0 90px, transparent 91px),
    radial-gradient(circle at -10% 30%, rgba(255, 216, 74, .55) 0 180px, transparent 181px),
    radial-gradient(circle at 110% 70%, rgba(244, 162, 107, .35) 0 160px, transparent 161px),
    radial-gradient(circle at 10% 100%, rgba(155, 89, 182, .18) 0 140px, transparent 141px),
    linear-gradient(180deg, #fff3b8 0%, var(--cream) 40%, #fff6d6 100%);
  background-attachment: fixed;
}
.px { image-rendering: pixelated; shape-rendering: crispEdges; flex: none; vertical-align: middle; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 16px;
  background: rgba(255, 248, 220, .92);
  backdrop-filter: blur(6px);
  border-bottom: var(--px) solid var(--purple-ink);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.brand-text b { color: var(--purple); font-size: 17px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { color: var(--coral); font-weight: 700; font-size: 12px; }
.lang {
  font-family: var(--pixel-font); font-size: 11px; padding: 9px 10px;
  background: var(--yellow); color: var(--purple-ink); border: 3px solid var(--purple-ink);
  box-shadow: 3px 3px 0 var(--purple-ink); cursor: pointer;
}
.lang:active { transform: translate(3px, 3px); box-shadow: none; }

main { max-width: 640px; margin: 0 auto; padding: 18px 16px; }
h1 { font-size: 30px; line-height: 1.05; margin: 6px 0 14px; color: var(--purple); font-weight: 800; }
h1 em { font-style: normal; color: var(--coral); }
h2 { font-size: 19px; margin: 0 0 10px; color: var(--purple); font-weight: 800; display: flex; align-items: center; gap: 8px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---------- Cards: soft poster card with a hard 8-bit shadow ---------- */
.card {
  background: var(--card);
  border: 3px solid var(--purple-ink);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 18px;
}

/* ---------- Hero / ribbon ---------- */
.hero { text-align: center; margin: 4px 0 18px; }
.hero .kicker { color: #9a5a2a; font-weight: 700; font-size: 16px; }
.hero .title { font-size: 34px; font-weight: 800; line-height: 1; color: var(--purple); margin: 2px 0; }
.hero .title em { font-style: normal; color: var(--coral); }
.ribbon {
  position: relative; display: block; margin: 14px 12px 0; padding: 10px 14px;
  background: var(--coral); color: #fff; text-align: center;
  clip-path: polygon(0 0, 100% 0, calc(100% - 14px) 50%, 100% 100%, 0 100%, 14px 50%);
}
.ribbon .big { font-family: var(--pixel-font); font-size: 15px; line-height: 1.5; letter-spacing: .5px; }
.ribbon .dates { font-size: 13px; opacity: .95; }
.day-track {
  margin: 12px 4px 0; height: 16px; border: 3px solid var(--purple-ink); background: #fff;
  padding: 2px; display: flex; gap: 2px;
}
.day-track i { flex: 1; background: var(--line); }
.day-track i.on { background: var(--purple); }
.day-track i.now { background: var(--coral); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { background: var(--yellow); } }

.word { background: linear-gradient(135deg, #fffdf4, #fff1c4); }
.word p { margin: 0; font-size: 19px; font-weight: 700; color: var(--coral); white-space: pre-wrap; }

/* ---------- Counters ---------- */
.counter { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-top: 2px dashed var(--line); }
.counter:first-of-type { border-top: 0; }
.counter .label { flex: 1; min-width: 0; display: flex; gap: 10px; align-items: center; }
.counter .label b { display: block; font-size: 17px; line-height: 1.15; }
.counter .label small { display: block; color: var(--muted); font-size: 13px; line-height: 1.25; }
.counter .val {
  min-width: 46px; text-align: center; font-family: var(--pixel-font); font-size: 18px; color: var(--purple-ink);
}
.pxbtn {
  width: 46px; height: 46px; flex: none; cursor: pointer;
  font-family: var(--pixel-font); font-size: 18px; line-height: 1;
  border: 3px solid var(--purple-ink); background: #fff; color: var(--purple-ink);
  box-shadow: 3px 3px 0 var(--purple-ink);
  transition: transform .05s;
}
.pxbtn.plus { background: var(--coral); color: #fff; }
.pxbtn:active { transform: translate(3px, 3px); box-shadow: none; }
.bump { animation: bump .25s steps(3); }
@keyframes bump { 50% { transform: scale(1.35); color: var(--coral); } }

/* ---------- Checklist ---------- */
.check {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 0;
  border-top: 2px dashed var(--line); cursor: pointer;
}
.check:first-of-type { border-top: 0; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check .num {
  flex: none; width: 36px; height: 36px; display: grid; place-items: center;
  font-family: var(--pixel-font); font-size: 14px; color: var(--peach);
  border: 3px solid var(--peach); background: #fff;
}
.check.done .num { background: var(--leaf); border-color: var(--purple-ink); color: #fff; }
.check input:focus-visible + .num { outline: 3px solid var(--purple); outline-offset: 2px; }
.check .desc { display: block; font-size: 14px; color: var(--muted); line-height: 1.3; }
.check .quote { display: block; font-size: 17px; font-weight: 800; color: var(--coral); line-height: 1.25; }
.check.done .quote { color: var(--leaf); }
.streak {
  display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 10px 12px;
  background: #fff1c4; border: 3px solid var(--orange); font-weight: 800; color: #9a4a10;
}
.streak .n { font-family: var(--pixel-font); font-size: 14px; }

/* ---------- Progress (segmented, 8-bit) ---------- */
.progress { margin: 12px 0; }
.progress .row { display: flex; justify-content: space-between; gap: 8px; font-size: 15px; margin-bottom: 4px; align-items: center; }
.progress .row > span:first-child { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.progress .row .num { font-family: var(--pixel-font); font-size: 10px; color: var(--purple-ink); white-space: nowrap; }
.bar { height: 22px; border: 3px solid var(--purple-ink); background: #fff; padding: 2px; }
.bar > div {
  height: 100%;
  background: repeating-linear-gradient(90deg, var(--coral) 0 10px, transparent 10px 12px);
  transition: width .6s steps(12);
}
.bar.done > div { background: repeating-linear-gradient(90deg, var(--leaf) 0 10px, transparent 10px 12px); }

/* ---------- Region board ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 18px; }
.tile {
  background: var(--card); border: 3px solid var(--purple-ink); box-shadow: var(--shadow); border-radius: 6px;
  padding: 12px; display: flex; flex-direction: column; gap: 6px;
}
.tile .n { font-family: var(--pixel-font); font-size: 20px; color: var(--purple); }
.tile .l { font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 6px; line-height: 1.2; }
.rank { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 2px dashed var(--line); }
.rank:first-of-type { border-top: 0; }
.rank .pos { width: 34px; display: grid; place-items: center; font-family: var(--pixel-font); font-size: 13px; color: var(--muted); }
.rank .body { flex: 1; min-width: 0; }
.rank .name { font-weight: 800; }
.rank .progress { margin: 4px 0 0; }

.chart { width: 100%; height: 150px; display: block; }
.chart rect { fill: var(--purple); }
.chart rect.today { fill: var(--coral); }
.seg { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.seg button {
  display: inline-flex; align-items: center; gap: 6px;
  border: 3px solid var(--purple-ink); background: #fff; color: var(--purple-ink);
  padding: 5px 10px; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
}
.seg button.on { background: var(--yellow); box-shadow: 3px 3px 0 var(--purple-ink); }

.story { border-top: 2px dashed var(--line); padding: 12px 0; display: flex; gap: 10px; }
.story:first-of-type { border-top: 0; }
.story p { margin: 0 0 2px; white-space: pre-wrap; }

/* ---------- Forms ---------- */
label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; font-size: 14px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 11px 12px; border: 3px solid var(--purple-ink); border-radius: 0;
  background: #fff; color: var(--text); font: inherit; font-size: 16px;
}
input:focus, select:focus, textarea:focus { outline: 3px solid var(--yellow); outline-offset: 0; }
textarea { min-height: 84px; resize: vertical; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 3px solid var(--purple-ink); padding: 11px 18px; font: inherit; font-weight: 800; cursor: pointer;
  background: var(--purple); color: #fff; box-shadow: var(--shadow); text-decoration: none;
}
.btn:active { transform: translate(var(--px), var(--px)); box-shadow: none; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--yellow); color: var(--purple-ink); }
.btn.danger { background: var(--coral); }
.btn.sm { padding: 6px 12px; font-size: 15px; box-shadow: 3px 3px 0 var(--purple-ink); }
.error { color: var(--coral); font-weight: 700; font-size: 15px; margin-top: 8px; }
.saved { color: var(--leaf); font-size: 14px; font-weight: 700; margin-left: auto; }

.admin-row { border-top: 2px dashed var(--line); padding: 12px 0; display: grid; gap: 8px; }
.admin-row:first-of-type { border-top: 0; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (max-width: 420px) { .grid3 { grid-template-columns: 1fr; } }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
details summary { cursor: pointer; font-weight: 800; color: var(--purple); }
.footer-links { text-align: center; font-size: 14px; }
.footer-links a { color: var(--purple); }

/* ---------- Bottom tabs ---------- */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: flex; background: var(--card); border-top: var(--px) solid var(--purple-ink);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 10px; color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 700;
}
.tabs a .ico { height: 26px; display: flex; align-items: center; }
.tabs a.on { color: var(--purple); background: #fff1c4; }
.tabs a.on .ico { animation: hop .6s steps(2) infinite alternate; }
@keyframes hop { to { transform: translateY(-3px); } }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 20; width: 100%; height: 100%; image-rendering: pixelated; }
.toast {
  position: fixed; left: 50%; top: 76px; transform: translateX(-50%); z-index: 21;
  background: var(--yellow); color: var(--purple-ink); padding: 12px 16px;
  border: 3px solid var(--purple-ink); box-shadow: var(--shadow);
  font-weight: 800; max-width: 90vw; text-align: center;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Teams ---------- */
.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.row-between .num, .award .num { font-family: var(--pixel-font); font-size: 12px; color: var(--purple); }
.bar.thin { height: 14px; border-width: 2px; padding: 1px; margin-top: 4px; }
.tiles.mini { grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 8px; }
.tiles.mini .tile { padding: 8px; box-shadow: 3px 3px 0 var(--purple-ink); gap: 4px; }
.tiles.mini .tile .n { font-size: 15px; }
.tiles.mini .tile .l { font-size: 12px; }
.awards { display: grid; gap: 10px; }
.award {
  display: flex; gap: 12px; align-items: center; padding: 10px 12px;
  background: #fff1c4; border: 3px solid var(--orange);
}
.award b { color: var(--purple-ink); }
.cta {
  display: flex; gap: 12px; align-items: center; text-decoration: none;
  color: var(--purple); font-weight: 800; background: #fff1c4;
}
.codebox {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 12px; border: 3px dashed var(--purple-ink); background: #fff;
}
.codebox b { font-family: var(--pixel-font); font-size: 13px; color: var(--purple); word-break: break-all; }
.tabs a { font-size: 12px; }

/* ---------- Levels & badges ---------- */
.levelbox { display: flex; gap: 14px; align-items: center; margin: 4px 0 12px; }
.level-art {
  width: 84px; height: 84px; flex: none; display: grid; place-items: center;
  background: var(--sky); border: 3px solid var(--purple-ink); box-shadow: 3px 3px 0 var(--purple-ink);
}
.level-name { font-family: var(--pixel-font); font-size: 12px; color: var(--purple); line-height: 1.6; margin-bottom: 4px; }
.badge-card > summary { list-style: none; }
.badge-card > summary::-webkit-details-marker { display: none; }
.badge-card > summary h2::after { content: '▸'; margin-left: auto; color: var(--purple); }
.badge-card[open] > summary h2::after { content: '▾'; }
.badge-count {
  font-family: var(--pixel-font); font-size: 11px; background: var(--yellow); color: var(--purple-ink);
  border: 2px solid var(--purple-ink); padding: 3px 6px; margin-left: 6px;
}
.badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 360px) { .badges { grid-template-columns: repeat(2, 1fr); } }
.badge {
  --frame: var(--purple);
  text-align: center; padding: 10px 6px 8px; background: #fff;
  border: 3px solid var(--frame); box-shadow: 3px 3px 0 var(--purple-ink);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.badge.bronze { --frame: #c98a5a; }
.badge.silver { --frame: #a9b0bc; }
.badge.gold { --frame: #e8b923; background: #fff8d6; }
.badge.diamond { --frame: #3a8fc4; background: #eef8ff; }
.badge.legend { --frame: #6b2a8c; background: #f6ecff; }
.badge.special { --frame: var(--coral); }
.badge-icon {
  width: 44px; height: 44px; display: grid; place-items: center; background: var(--cream);
  border: 2px solid var(--frame); border-radius: 50%;
}
.badge-name { font-weight: 800; font-size: 13px; line-height: 1.15; color: var(--purple-ink); }
.badge-tier { font-family: var(--pixel-font); font-size: 8px; color: var(--frame); text-transform: uppercase; }
.badge-desc { font-size: 11px; color: var(--muted); line-height: 1.2; }
.badge.locked { background: #f4f1e8; box-shadow: none; border-style: dashed; }
.badge.locked .badge-icon svg { filter: grayscale(1); opacity: .35; }
.badge.locked .badge-name, .badge.locked .badge-tier { opacity: .55; }

/* ---------- Sides, focus, weekly ---------- */
.side-tag {
  display: inline-block; margin-left: 8px; padding: 1px 6px; font-size: 11px; font-weight: 800; vertical-align: middle;
  border: 2px solid var(--purple-ink); background: #fff;
}
.side-tag.sisters, .side-head.sisters { background: #ffe0e6; color: #a3264b; }
.side-tag.brothers, .side-head.brothers { background: #dcefff; color: #1f5f8f; }
.side-head { font-weight: 800; padding: 2px 8px; border: 2px solid var(--purple-ink); margin-bottom: 6px; display: inline-block; }
.warn { color: var(--coral); font-weight: 800; font-size: 14px; }
.focus-card { background: linear-gradient(135deg, #fffdf4, #ffe9e6); }
.focus-num {
  margin-left: auto; font-family: var(--pixel-font); font-size: 14px; color: #fff; background: var(--coral);
  border: 3px solid var(--purple-ink); width: 34px; height: 34px; display: grid; place-items: center;
}
.focus-quote { font-size: 21px; font-weight: 800; color: var(--coral); margin: 0 0 4px; line-height: 1.2; }
.check.focus { background: #fff1ef; margin: 0 -10px; padding-left: 10px; padding-right: 10px; }
.weekly { background: linear-gradient(135deg, #fffdf4, #e9f6ff); }
.weekly .row-between { padding: 3px 0; }

/* ---------- Garden ---------- */
.garden {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 12px; min-height: 64px; align-items: flex-end;
  background: linear-gradient(180deg, var(--sky) 0 60%, #a8d98a 60%); border: 3px solid var(--purple-ink);
}
.plant { animation: grow .5s steps(4) both; transform-origin: bottom; }
@keyframes grow { from { transform: scaleY(0); } }
.garden .more { font-family: var(--pixel-font); font-size: 12px; color: var(--purple-ink); padding: 4px; }

/* ---------- Feed ---------- */
.feed-item { display: flex; gap: 12px; padding: 12px 0; border-top: 2px dashed var(--line); }
.feed-item:first-of-type { border-top: 0; }
.feed h2 + .feed-item { border-top: 0; }
.feed-icon {
  width: 46px; height: 46px; flex: none; display: grid; place-items: center;
  background: var(--cream); border: 3px solid var(--purple-ink);
}
.feed-title { font-weight: 800; line-height: 1.2; }
.feed-item p { margin: 4px 0; white-space: pre-wrap; }
.feed-stats { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; font-family: var(--pixel-font); font-size: 11px; color: var(--purple-ink); }
.feed-stats span { display: inline-flex; align-items: center; gap: 2px; }
.feed-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; }
.cheers { display: flex; gap: 6px; }
.cheer {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; cursor: pointer;
  background: #fff; border: 2px solid var(--purple-ink); font: inherit; font-weight: 800; font-size: 13px; color: var(--purple-ink);
}
.cheer.on { background: var(--yellow); box-shadow: 2px 2px 0 var(--purple-ink); }
.cheer.pop { animation: bump .3s steps(3); }

/* ---------- Share ---------- */
.share-row { display: flex; justify-content: center; margin: -4px 0 18px; }
.card .share-row { margin: 10px 0 0; }
.share-btn { background: #25a35a; }

/* ---------- TV mode ---------- */
body.tv-mode { padding-bottom: 0; }
body.tv-mode .topbar, body.tv-mode .tabs { display: none; }
body.tv-mode main { max-width: 1100px; padding-top: 10px; }
body.tv-mode { font-size: 22px; }
body.tv-mode .card h2 { font-size: 28px; }
body.tv-mode .tiles.tv-tiles { grid-template-columns: repeat(5, 1fr); }
.tv-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; color: var(--purple); }
.tv-head b { font-size: 28px; }
.tv-head span { color: var(--coral); font-weight: 800; }
.tv-exit { margin-left: auto; text-decoration: none; color: var(--muted); font-size: 22px; }
.tv-stage.enter { animation: slidein .5s steps(6); }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } }
.tv-dots { display: flex; justify-content: center; gap: 8px; margin-top: 8px; }
.tv-dots i { width: 14px; height: 14px; background: var(--line); border: 2px solid var(--purple-ink); }
.tv-dots i.on { background: var(--coral); }

/* ---------- Certificate ---------- */
.cert {
  background: var(--yellow); padding: 14px; border: 4px solid var(--purple-ink); box-shadow: 6px 6px 0 var(--purple-ink);
}
.cert-inner {
  background: var(--cream); border: 4px dashed var(--coral); padding: 28px 18px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.cert-art { display: flex; align-items: flex-end; gap: 14px; }
.cert-kicker { color: #9a5a2a; font-weight: 800; }
.cert-title { font-family: var(--pixel-font); font-size: 16px; line-height: 1.6; color: var(--purple); }
.cert-body { font-size: 20px; font-weight: 700; }
.cert-for { color: var(--muted); }
.cert-award { font-size: 30px; font-weight: 800; color: var(--coral); line-height: 1.1; }
.cert-stats { font-family: var(--pixel-font); font-size: 10px; color: var(--purple-ink); line-height: 1.8; }
.cert-foot { margin-top: 10px; font-size: 13px; color: var(--muted); }
@media print {
  body { background: #fff !important; padding: 0; }
  .topbar, .tabs, .no-print, #confetti { display: none !important; }
  .cert { box-shadow: none; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
body.tv-mode .awards { grid-template-columns: repeat(2, 1fr); }
body.tv-mode .award { padding: 8px 12px; }
body.tv-mode .card { margin-bottom: 10px; }
body.tv-mode .feed .feed-item { padding: 8px 0; }
.how { background: #fff1c4; border-left: 4px solid var(--orange); padding: 8px 10px; color: #6b4a1e; }
.story.current { background: #fff1c4; margin: 0 -10px; padding-left: 10px; padding-right: 10px; }
.invite-banner {
  display: flex; gap: 12px; align-items: center; padding: 12px; margin-bottom: 14px;
  background: #fff1c4; border: 3px solid var(--orange); color: var(--purple-ink);
}
label.field small { display: block; margin-top: 4px; font-size: 13px; }
.save-spot { border-color: var(--coral); background: #fff4f2; }
.ok { color: var(--leaf); font-weight: 700; }
details.card > summary { list-style: none; cursor: pointer; }
details.card > summary::-webkit-details-marker { display: none; }
.word-passage {
  margin: 12px 0 0; padding-top: 10px; border-top: 2px dashed var(--line);
  font-size: 15px !important; font-weight: 600 !important; color: var(--purple) !important; white-space: pre-wrap;
}
