:root {
  --bg: #F3F0FF;
  --card: #FFFFFF;
  --ink: #2B2350;
  --soft: #6B6490;
  --line: #E2DCF7;
  --purple: #6A5AE0;
  --blue: #4FB3F6;
  --gold: #FFB000;
  --gold-soft: #FFF3C4;
  --green: #2FBF71;
  --green-soft: #DDF7E8;
  --wait: #FFE7A3;
  --red: #E0444E;
  --kid: #6A5AE0;
  --radius: 22px;
  --shadow: 0 3px 0 rgba(43, 35, 80, 0.08), 0 8px 24px rgba(43, 35, 80, 0.08);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #17132B; --card: #241E42; --ink: #F4F1FF; --soft: #B5AED6; --line: #3A3361; --gold-soft: #4A3D12; --green-soft: #173B2A; --wait: #574814; }
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); -webkit-user-select: none; user-select: none; }
input, textarea, select { -webkit-user-select: text; user-select: text; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 4px solid var(--blue); outline-offset: 2px; }
h1, h2, h3 { margin: 0; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 16px 16px 120px; }

/* ---------- Top bar ---------- */
.top { display: flex; align-items: center; gap: 12px; padding: 12px 16px; max-width: 1100px; margin: 0 auto; }
.top h1 { font-size: 30px; font-weight: 900; letter-spacing: -0.5px; flex: 1; display: flex; align-items: center; gap: 10px; }
.top h1 img { width: 44px; height: 44px; border-radius: 11px; }
.round { width: 56px; height: 56px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow); font-size: 28px; display: grid; place-items: center; flex: none; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 999px; background: var(--gold-soft); font-weight: 900; font-size: 24px; }
.grownup-btn { font-size: 15px; font-weight: 700; color: var(--soft); padding: 10px 14px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow); }

/* ---------- Home: pick a kid ---------- */
.ask { text-align: center; font-size: 26px; font-weight: 800; margin: 12px 0 18px; color: var(--soft); }
.kids { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 18px; }
.kid-tile { background: var(--card); border-radius: 30px; padding: 22px 12px 18px; box-shadow: var(--shadow); text-align: center; border: 6px solid var(--kid); transition: transform 0.12s; }
.kid-tile:active { transform: scale(0.96); }
.kid-tile .face { font-size: 86px; line-height: 1.1; }
.kid-tile .name { font-size: 28px; font-weight: 900; margin-top: 6px; }
.kid-tile .stars { margin-top: 8px; font-size: 22px; font-weight: 800; }
.kid-tile .bar { height: 12px; border-radius: 6px; background: var(--line); margin: 12px 8px 0; overflow: hidden; }
.kid-tile .bar i { display: block; height: 100%; background: var(--green); border-radius: 6px; }

/* ---------- Kid screen ---------- */
.kid-head { display: flex; align-items: center; gap: 12px; }
.kid-head .face { font-size: 52px; }
.kid-head .name { font-size: 30px; font-weight: 900; flex: 1; color: var(--kid); }
.chores { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
.chore { position: relative; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 10px 14px; text-align: center; border: 5px solid transparent; min-height: 210px; display: flex; flex-direction: column; align-items: center; justify-content: center; transition: transform 0.12s; width: 100%; }
.chore:active { transform: scale(0.96); }
.chore .pic { font-size: 84px; line-height: 1.05; }
.chore .label { font-size: 21px; font-weight: 800; margin-top: 8px; line-height: 1.15; }
.chore .pips { margin-top: 6px; font-size: 22px; letter-spacing: 2px; }
.chore.done { background: var(--green-soft); border-color: var(--green); }
.chore.done .pic { opacity: 0.8; }
.chore.waiting { background: var(--wait); border-color: var(--gold); }
.chore .mark { position: absolute; top: 8px; left: 8px; width: 50px; height: 50px; border-radius: 50%; background: var(--green); color: #fff; font-size: 32px; font-weight: 900; display: grid; place-items: center; pointer-events: none; box-shadow: 0 2px 0 rgba(0,0,0,0.15); }
.chore.waiting .mark { background: var(--gold); font-size: 26px; }
.say { position: absolute; top: 8px; right: 8px; width: 46px; height: 46px; border-radius: 50%; background: var(--bg); font-size: 22px; display: grid; place-items: center; z-index: 2; }
.alldone { text-align: center; background: linear-gradient(135deg, #FFE45C, #FFB000); color: #4A2E00; border-radius: var(--radius); padding: 18px; font-size: 28px; font-weight: 900; margin-bottom: 16px; box-shadow: var(--shadow); }
.empty { text-align: center; color: var(--soft); font-size: 20px; padding: 40px 10px; }
.empty .big { font-size: 80px; display: block; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 10px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); z-index: 5; }
.tab { flex: 1; max-width: 200px; border-radius: 20px; padding: 8px 6px; text-align: center; font-weight: 800; font-size: 16px; color: var(--soft); background: var(--card); box-shadow: var(--shadow); }
.tab b { display: block; font-size: 34px; line-height: 1.1; }
.tab.on { background: var(--kid); color: #fff; }

/* Prizes */
.prizes { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.prize { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; text-align: center; border: 5px solid transparent; display: flex; flex-direction: column; align-items: center; }
.prize .pic { font-size: 76px; line-height: 1.1; }
.prize .label { font-size: 21px; font-weight: 800; margin: 6px 0 8px; }
.prize .need { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; font-size: 20px; max-width: 220px; }
.prize .need .off { filter: grayscale(1); opacity: 0.3; }
.prize .meter { width: 100%; height: 16px; border-radius: 8px; background: var(--line); overflow: hidden; margin-top: 6px; }
.prize .meter i { display: block; height: 100%; background: var(--gold); }
.prize .count { font-weight: 800; color: var(--soft); margin-top: 6px; font-size: 17px; }
.prize.ready { border-color: var(--gold); }
.get { margin-top: 10px; background: var(--gold); color: #3A2400; font-weight: 900; font-size: 22px; padding: 12px 22px; border-radius: 999px; box-shadow: 0 4px 0 #C98700; animation: wiggle 1.6s ease-in-out infinite; }
@keyframes wiggle { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-4deg); } 90% { transform: rotate(4deg); } 95% { transform: rotate(-2deg); } }
@media (prefers-reduced-motion: reduce) { .get { animation: none; } }
.jar-strip { display: flex; align-items: center; gap: 14px; background: var(--card); padding: 14px 18px; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.jar-strip img { width: 64px; height: 64px; border-radius: 14px; }
.jar-strip .n { font-size: 40px; font-weight: 900; }
.jar-strip .t { color: var(--soft); font-weight: 700; }

/* Week chart */
.week { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px; overflow-x: auto; }
.week table { border-collapse: separate; border-spacing: 4px; width: 100%; }
.week th { font-size: 18px; color: var(--soft); font-weight: 800; padding: 4px; }
.week th.today { color: #fff; background: var(--kid); border-radius: 12px; }
.week td { text-align: center; font-size: 26px; height: 50px; min-width: 42px; border-radius: 12px; background: var(--bg); }
.week td.pic { font-size: 36px; background: none; text-align: left; white-space: nowrap; }
.week td.pic small { font-size: 15px; font-weight: 700; color: var(--soft); margin-left: 4px; }
.week td.off { background: none; }
.week td.miss { color: var(--line); }
.week td.today { outline: 3px solid var(--kid); }
.week tfoot td { background: var(--gold-soft); font-size: 18px; font-weight: 900; }
.week-total { text-align: center; font-size: 24px; font-weight: 900; margin: 16px 0 4px; }

/* ---------- Grown-up area ---------- */
.gu { max-width: 860px; }
.gu-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 16px; }
.gu-tabs button { padding: 10px 14px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow); font-weight: 800; font-size: 16px; }
.gu-tabs button.on { background: var(--purple); color: #fff; }
.gu-tabs .badge { display: inline-block; background: var(--red); color: #fff; border-radius: 10px; padding: 0 7px; margin-left: 4px; font-size: 13px; }
.list { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); width: 100%; text-align: left; font-size: 18px; }
.row:last-child { border-bottom: 0; }
.row .pic { font-size: 36px; width: 46px; text-align: center; flex: none; }
.row .main { flex: 1; min-width: 0; }
.row .main b { display: block; font-size: 19px; }
.row .main small { color: var(--soft); font-size: 15px; }
.row .end { color: var(--soft); font-weight: 800; white-space: nowrap; }
.row .plus { color: var(--green); } .row .minus { color: var(--red); }
.add { display: block; width: 100%; margin-top: 12px; padding: 14px; border-radius: 16px; background: var(--purple); color: #fff; font-weight: 800; font-size: 18px; box-shadow: var(--shadow); }
.btn { padding: 12px 18px; border-radius: 14px; font-weight: 800; font-size: 17px; background: var(--bg); box-shadow: inset 0 0 0 2px var(--line); }
.btn.primary { background: var(--purple); color: #fff; box-shadow: none; }
.btn.good { background: var(--green); color: #fff; box-shadow: none; }
.btn.danger { color: var(--red); }
.note { color: var(--soft); font-size: 15px; line-height: 1.4; margin: 10px 4px; }
.section { margin: 22px 0 8px; font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--soft); }
.toggle-row { display: flex; align-items: center; gap: 12px; padding: 14px; border-bottom: 1px solid var(--line); font-size: 18px; }
.toggle-row:last-child { border-bottom: 0; }
.toggle-row span { flex: 1; }
.toggle-row small { display: block; color: var(--soft); font-size: 14px; }
.switch { appearance: none; -webkit-appearance: none; width: 54px; height: 32px; border-radius: 16px; background: var(--line); position: relative; flex: none; transition: background 0.15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3); transition: left 0.15s; }
.switch:checked { background: var(--green); }
.switch:checked::after { left: 25px; }

/* ---------- Modal sheets ---------- */
.modal { position: fixed; inset: 0; background: rgba(23, 19, 43, 0.5); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.modal[hidden] { display: none; }
.sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; border-radius: 26px 26px 0 0; padding: 18px 18px calc(24px + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .modal { align-items: center; } .sheet { border-radius: 26px; } }
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sheet-head h2 { flex: 1; font-size: 22px; }
.field { display: block; margin: 14px 0 6px; font-weight: 800; color: var(--soft); font-size: 15px; }
.text { width: 100%; font: inherit; font-size: 20px; padding: 12px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); color: var(--ink); }
.picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 6px; }
.picks button { font-size: 34px; height: 58px; border-radius: 14px; background: var(--card); border: 3px solid transparent; }
.picks button.on { border-color: var(--purple); background: color-mix(in srgb, var(--purple) 14%, var(--card)); }
.colors { display: flex; gap: 10px; flex-wrap: wrap; }
.colors button { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--bg); box-shadow: 0 0 0 2px var(--line); }
.colors button.on { box-shadow: 0 0 0 3px var(--ink); }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { min-width: 48px; padding: 10px 12px; border-radius: 12px; background: var(--card); font-weight: 800; font-size: 18px; box-shadow: inset 0 0 0 2px var(--line); }
.seg button.on { background: var(--purple); color: #fff; box-shadow: none; }
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper button { width: 52px; height: 52px; border-radius: 50%; background: var(--card); font-size: 28px; font-weight: 900; box-shadow: inset 0 0 0 2px var(--line); }
.stepper output { font-size: 28px; font-weight: 900; min-width: 90px; text-align: center; }
.actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.actions .grow { flex: 1; }

/* PIN pad */
.pin { text-align: center; }
.pin h2 { font-size: 24px; margin: 6px 0; }
.pin .dots { display: flex; gap: 14px; justify-content: center; margin: 16px 0; }
.pin .dots i { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--purple); }
.pin .dots i.on { background: var(--purple); }
.pin .dots.shake { animation: shake 0.35s; }
@keyframes shake { 25% { transform: translateX(-10px); } 75% { transform: translateX(10px); } }
.pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 12px; justify-content: center; }
.pad button { height: 76px; border-radius: 50%; background: var(--card); font-size: 30px; font-weight: 800; box-shadow: var(--shadow); }
.pad button.blank { visibility: hidden; }
.pin .msg { min-height: 24px; color: var(--red); font-weight: 700; }
.link { color: var(--purple); font-weight: 800; text-decoration: underline; padding: 10px; }

/* Celebration */
.party { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(23, 19, 43, 0.35); overflow: hidden; }
.party[hidden] { display: none; }
.party .card { background: var(--card); border-radius: 30px; padding: 26px 34px; text-align: center; box-shadow: var(--shadow); animation: pop 0.4s cubic-bezier(.2,1.6,.4,1); z-index: 2; max-width: 90vw; }
.party .card .pic { font-size: 96px; line-height: 1.1; }
.party .card h2 { font-size: 34px; font-weight: 900; margin-top: 4px; }
.party .card p { font-size: 26px; font-weight: 800; margin: 6px 0 0; color: var(--gold); }
.party .fly { position: absolute; font-size: 44px; animation: burst 1.3s ease-out forwards; z-index: 1; }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes burst { from { transform: translate(0, 0) scale(0.4) rotate(0); opacity: 1; } to { transform: translate(var(--x), var(--y)) scale(1.2) rotate(var(--r)); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .party .fly { display: none; } .party .card { animation: none; } }

/* Welcome */
.welcome { text-align: center; max-width: 560px; margin: 30px auto; }
.welcome img { width: 140px; height: 140px; border-radius: 32px; box-shadow: var(--shadow); }
.welcome h1 { font-size: 38px; font-weight: 900; margin: 16px 0 6px; }
.welcome p { font-size: 19px; color: var(--soft); line-height: 1.45; }
.welcome .add { max-width: 360px; margin: 22px auto 0; font-size: 21px; padding: 16px; }

@media (max-width: 600px) {
  .week td.pic small { display: none; }
  .week td { min-width: 36px; font-size: 22px; height: 46px; }
  .week td.pic { font-size: 32px; }
}
@media (max-width: 420px) {
  .chores { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .chore { min-height: 180px; }
  .chore .pic { font-size: 66px; }
  .chore .label { font-size: 18px; }
  .kids { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .kid-tile .face { font-size: 66px; }
  .kid-tile .name { font-size: 23px; }
  .top h1 { font-size: 24px; }
}
@media print {
  .tabs, .round, .grownup-btn, .say { display: none !important; }
  body { background: #fff; }
}

/* ---------- Money mode ---------- */
.pay { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; letter-spacing: 0; }
.pay b { font-size: 20px; font-weight: 900; color: var(--ink); }
.stack { display: block; overflow: visible; }
.coin { vertical-align: middle; }
.pill .coin, .kid-tile .coin, .jar-strip .coin { margin-top: -3px; }
.prize .cost { font-weight: 900; font-size: 20px; }
.pay-preview { display: flex; justify-content: center; padding: 12px; background: var(--card); border-radius: 16px; margin-top: 10px; }
.coin-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.coin-pick button { background: var(--card); border-radius: 16px; padding: 10px 6px; border: 3px solid transparent; display: flex; flex-direction: column; align-items: center; gap: 2px; box-shadow: var(--shadow); }
.coin-pick button.on { border-color: var(--purple); }
.coin-pick small { color: var(--soft); font-weight: 700; }
.week td .coin { display: inline-block; }

/* ---------- Kid pictures ---------- */
.ava { border-radius: 50%; object-fit: cover; vertical-align: middle; box-shadow: 0 0 0 3px var(--card); }
.kid-tile .ava { border: 5px solid var(--kid); box-shadow: none; }
.emo { line-height: 1; vertical-align: middle; }
.kid-head .face { line-height: 1; padding: 0; }
.photo-row { display: flex; align-items: center; gap: 14px; margin: 6px 0 10px; }
.photo-btn { display: block; text-align: center; margin: 6px 0 12px; cursor: pointer; }

/* Special days, special chores and matching */
.banner { text-align: center; border-radius: var(--radius); padding: 14px; font-size: 22px; font-weight: 900; margin-bottom: 14px; }
.banner.special { background: linear-gradient(135deg, #FFD1E8, #FF9CC8); color: #5A0A33; }
.banner.match { background: linear-gradient(135deg, #D9F2FF, #A9DCFF); color: #0A3558; font-size: 19px; }
.chore .ribbon { margin-top: 6px; display: inline-block; background: #FFE45C; color: #4A2E00; border-radius: 999px; padding: 3px 12px; font-size: 14px; font-weight: 900; }
.dates { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.dates label { flex: 1 1 150px; font-weight: 700; font-size: 15px; display: grid; gap: 4px; }

.emoji-in { margin-top: 8px; }
.chore .ribbon.first { background: #D9F2FF; color: #0A3558; }

/* Paying a chore more than once */
.check-row { flex-wrap: wrap; }
.check-btns { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.times { display: inline-flex; align-items: center; gap: 2px; background: var(--bg); border-radius: 999px; padding: 3px; }
.times button { width: 36px; height: 36px; border-radius: 50%; background: var(--card); font-size: 22px; font-weight: 900; line-height: 1; }
.times button:disabled { opacity: .35; }
.times output { min-width: 34px; text-align: center; font-weight: 900; }
@media (max-width: 640px) { .check-btns { flex: 1 0 100%; justify-content: flex-end; margin-top: 6px; } }
.emoji-help { margin-top: 4px; font-size: 14px; }
