:root {
  --ink: #f1f7ff; --muted: #9fb4cc; --glass: rgba(10, 22, 44, 0.55); --glass2: rgba(255, 255, 255, 0.09);
  --line: rgba(255, 255, 255, 0.16); --accent: #38bdf8; --accent2: #f472b6; --danger: #fb7185;
  --font: "Baloo 2", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  font-family: var(--font); color: var(--ink); touch-action: none; user-select: none; -webkit-user-select: none;
  background: radial-gradient(120% 80% at 50% 0%, #12325a 0%, #071526 55%, #030a14 100%) center/cover no-repeat fixed;
  background-color: #071526;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; user-select: text; -webkit-user-select: text; touch-action: manipulation; }
[hidden] { display: none !important; }

#world { position: fixed; inset: 0; width: 100vw; height: 100dvh; display: block; }

/* top bar */
#top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px; pointer-events: none;
}
#top > * { pointer-events: auto; }
.logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); }
.logo img { width: 36px; height: 36px; border-radius: 10px; box-shadow: 0 4px 14px rgba(0,0,0,.35); }
.logo span { font-weight: 800; font-size: 1.25rem; letter-spacing: .2px; text-shadow: 0 2px 8px rgba(0,0,0,.5); }
.logo b { color: #fff; margin-left: 3px; background: linear-gradient(135deg,#f472b6,#a78bfa); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; filter: drop-shadow(0 2px 4px rgba(0,0,0,.5)); }
#count { flex: 1; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; text-align: center; font-weight: 700; font-size: .95rem; opacity: .9; text-shadow: 0 1px 6px rgba(0,0,0,.6); }
.tb { display: flex; gap: 6px; }
.tb button, .round {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--glass);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); font-size: 1.15rem; position: relative;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 6px 18px rgba(0,0,0,.3); transition: transform .15s;
}
.tb button:active, .round:active { transform: scale(.88); }
sup#doneCount { position: absolute; top: -2px; right: -2px; background: var(--accent2); font-size: .65rem; border-radius: 9px; padding: 0 5px; line-height: 16px; }
sup#doneCount:empty { display: none; }

#empty { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; z-index: 1; opacity: .85; }
#empty .big { font-size: 4rem; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-14px) scale(1.06); } }

/* bottom bar */
#bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 12px);
}
#quick {
  flex: 1; display: flex; align-items: center; gap: 6px; padding: 5px 5px 5px 16px; border-radius: 30px;
  background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 10px 30px rgba(0,0,0,.35);
}
#qText { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--ink); font-size: 1rem; padding: 8px 0; }
#qText::placeholder { color: var(--muted); }
.blow {
  width: 48px; height: 48px; border-radius: 50%; border: 0; font-size: 1.8rem; font-weight: 800; line-height: 1;
  background: radial-gradient(circle at 30% 28%, #fff 0 8%, #7dd3fc 18%, #0ea5e9 60%, #0369a1 100%);
  box-shadow: 0 0 0 3px rgba(255,255,255,.18), 0 8px 24px rgba(14,165,233,.55); animation: breathe 3s ease-in-out infinite;
}
.blow:active { transform: scale(.85); }
@keyframes breathe { 50% { transform: scale(1.07); box-shadow: 0 0 0 5px rgba(255,255,255,.12), 0 8px 30px rgba(244,114,182,.55); } }

/* list view */
body[data-view="list"] #world { filter: blur(6px) brightness(.55); }
#list {
  position: fixed; z-index: 4; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 66px); bottom: calc(env(safe-area-inset-bottom) + 82px);
  margin: 0 auto; max-width: 640px; padding: 0 12px; display: flex; flex-direction: column; gap: 8px; touch-action: pan-y;
}
#search { width: 100%; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--glass); color: var(--ink); outline: 0; }
#listTabs { display: flex; gap: 6px; }
#listTabs button { flex: 1; padding: 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--glass2); font-weight: 700; }
#listTabs .on { background: var(--accent); color: #04223a; border-color: transparent; }
#listItems { overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 6px; padding-bottom: 10px; -webkit-overflow-scrolling: touch; }
.row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 16px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(12px); }
.row.late { border-color: rgba(251,113,133,.6); }
.row canvas { width: 36px; height: 36px; flex: none; }
.row .rt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row small { color: var(--muted); font-size: .8rem; }
.row .imp { color: var(--accent); font-size: .55rem; letter-spacing: 1px; }
.chk { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--muted); background: none; flex: none; font-size: .9rem; }
.chk:active { background: var(--accent); }

/* sheets */
#scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 9; }
#scrim.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; z-index: 10; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px; max-height: 88dvh; overflow-y: auto;
  padding: 8px 18px calc(env(safe-area-inset-bottom) + 18px); border-radius: 26px 26px 0 0;
  background: linear-gradient(180deg, rgba(20,40,72,.96), rgba(8,18,36,.98)); border: 1px solid var(--line); border-bottom: 0;
  box-shadow: 0 -20px 60px rgba(0,0,0,.5); transform: translateY(105%); transition: transform .38s cubic-bezier(.2,1.25,.4,1);
  touch-action: pan-y;
}
.sheet.show { transform: none; }
.grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 6px; }
.sh-head { display: flex; align-items: center; justify-content: space-between; }
.sh-head h2 { margin: 6px 0; font-size: 1.3rem; display: flex; align-items: center; gap: 8px; }
.sh-head button { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--glass2); }
.ii { width: 30px; height: 30px; border-radius: 8px; }
.lbl { display: block; margin: 12px 0 6px; font-size: .78rem; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 700; }
.lbl b { color: var(--accent); text-transform: none; letter-spacing: 0; margin-left: 4px; }
.ed-top { display: flex; gap: 10px; align-items: center; }
#preview { width: 160px; height: 140px; flex: none; }
.ed-fields { flex: 1; min-width: 0; }
#fTitle, #fDue, #fNotes, select {
  width: 100%; padding: 11px 13px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.06); color: var(--ink); outline: 0; color-scheme: dark;
}
#fTitle { font-size: 1.1rem; font-weight: 600; }
#fTitle:focus, #fDue:focus, #fNotes:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56,189,248,.25); }
input[type=range] { width: 100%; accent-color: var(--accent2); height: 28px; }
.when { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.when button, .chips button { padding: 6px 12px; border-radius: 20px; border: 1px solid var(--line); background: var(--glass2); font-size: .85rem; font-weight: 600; }
.when button:active { background: var(--accent); color: #04223a; }
.hint { color: var(--muted); font-size: .8rem; margin: 6px 0; }
.center { text-align: center; } .pad { padding: 30px 10px; } .muted { color: var(--muted); } .small { font-size: .85rem; }
.pick { display: flex; flex-wrap: wrap; gap: 8px; }
.pick button { min-width: 40px; height: 40px; border-radius: 12px; border: 2px solid transparent; background: var(--glass2); font-size: 1.15rem; transition: transform .12s; }
.pick button.on { border-color: var(--ink); transform: scale(1.1); }
.pick button:active { transform: scale(.85); }
.colors button { width: 36px; min-width: 0; height: 36px; border-radius: 50%; background: radial-gradient(circle at 30% 28%, #fff 0 10%, var(--c) 35%); }
.chips button { height: auto; min-width: 0; }
.emoji button { width: 40px; font-size: 1.25rem; }
.ed-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-top: 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 18px; border-radius: 16px; border: 1px solid var(--line); background: var(--glass2); text-decoration: none; color: var(--ink); font-weight: 700; }
.btn.primary { background: linear-gradient(135deg, #38bdf8, #818cf8 60%, #f472b6); border: 0; color: #fff; box-shadow: 0 6px 20px rgba(129,140,248,.45); }
.btn.danger { color: var(--danger); margin-right: auto; }
.btn.small { padding: 6px 12px; font-size: .85rem; }
.btn.wide { width: 100%; margin-top: 10px; }
.btn:active { transform: scale(.95); }
.modes { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.modes button { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--line); background: var(--glass2); text-align: left; font-weight: 600; }
.modes button i { font-style: normal; font-size: 1.6rem; }
.modes button.on { border-color: var(--accent); background: rgba(56,189,248,.18); }
.bgs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bgs button { aspect-ratio: 3/4; border-radius: 14px; border: 2px solid transparent; background: #0b2340 center/cover; position: relative; overflow: hidden; }
.bgs button span { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px; font-size: .72rem; font-weight: 700; background: linear-gradient(transparent, rgba(0,0,0,.7)); }
.bgs button.on { border-color: var(--accent); }
.row-t { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.row-t input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); }
.row-t select { width: auto; }
.soon { font-size: .75rem; color: var(--accent2); font-style: normal; font-weight: 700; white-space: nowrap; }
.steps { padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; counter-reset: s; }
.steps li { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 16px; background: var(--glass2); }
.steps .ico { width: 42px; height: 42px; border-radius: 12px; background: #0a84ff; color: #fff; display: grid; place-items: center; font-size: 1.2rem; flex: none; }

#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 88px); transform: translate(-50%, 30px); opacity: 0; z-index: 8;
  display: flex; gap: 12px; align-items: center; padding: 10px 16px; border-radius: 20px; background: rgba(8,18,36,.92); border: 1px solid var(--line);
  transition: .3s cubic-bezier(.2,1.3,.4,1); pointer-events: none; max-width: 92vw; white-space: nowrap;
}
#toast span { overflow: hidden; text-overflow: ellipsis; }
#toast.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
#toast button { border: 0; background: none; color: var(--accent); font-weight: 800; }

#gate { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 30px; text-align: center; }
#gate img { width: 110px; height: 110px; border-radius: 28px; box-shadow: 0 16px 50px rgba(56,189,248,.35); animation: bob 3s ease-in-out infinite; }
#gate h1 { margin: 6px 0 0; font-size: 2.2rem; }
#gate p { max-width: 380px; color: var(--muted); }

@media (min-width: 900px) { #quick { max-width: 640px; margin: 0 auto; } }
@media (prefers-reduced-motion: reduce) { .blow, #empty .big, #gate img { animation: none; } }

/* v2: race sheet, start chips, kid chores */
.sheet.full { height: 92dvh; max-height: none; display: flex; flex-direction: column; overflow: hidden; }
#raceCv { flex: 1; width: 100%; min-height: 0; border-radius: 18px; background: rgba(0,0,0,.25); touch-action: none; }
.race-win { position: absolute; left: 18px; right: 18px; bottom: calc(env(safe-area-inset-bottom) + 18px); padding: 16px; border-radius: 20px;
  background: rgba(8,18,36,.95); border: 1px solid #fde047; text-align: center; box-shadow: 0 10px 40px rgba(253,224,71,.3); animation: pop-in .4s cubic-bezier(.2,1.5,.4,1); }
.race-win p { margin: 0; color: var(--muted); } .race-win b { font-size: 1.4rem; display: block; margin: 4px 0 6px; }
@keyframes pop-in { from { transform: scale(.6); opacity: 0; } }
#chores { margin-top: 10px; } #chores button { background: rgba(244,114,182,.18); }
#fRepeat { margin-top: 2px; }
.lbl small { text-transform: none; letter-spacing: 0; font-weight: 500; }
@media (max-width: 420px) { .logo span { font-size: 1.05rem; } #count { font-size: .8rem; } .tb button { width: 38px; height: 38px; } }

/* ===== core frame (same in every theme): + button bottom-right, toys bottom-left, quick add between ===== */
body { -webkit-touch-callout: none; }
#world { touch-action: none; -webkit-user-select: none; user-select: none; }
#bar { padding-right: 92px; }
#bar #quick { padding-right: 8px; }
.fab {
  position: fixed; z-index: 7; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 12px);
  width: 66px; height: 66px; border-radius: 50%; border: 0; padding: 0; touch-action: none;
  background: radial-gradient(circle at 30% 28%, #fff 0 8%, #7dd3fc 18%, #0ea5e9 60%, #0369a1 100%);
  box-shadow: 0 0 0 3px rgba(255,255,255,.2), 0 10px 28px rgba(14,165,233,.55); transition: transform .12s;
}
.fab .plus { font-size: 2.3rem; font-weight: 800; line-height: 1; color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,.35); display: block; transform: translateY(var(--pull, 0px)); transition: transform .05s; }
.fab .rod { display: none; }
.fab:active { transform: scale(.9); }
.tb .act { width: auto; padding: 0 12px; border-radius: 21px; font-size: .85rem; font-weight: 700; white-space: nowrap; }

/* pinball: the + is the plunger knob; it slides down as you pull */
body[data-theme="pinball"] .fab { border-radius: 22px 22px 30px 30px; width: 60px; height: 74px;
  background: linear-gradient(180deg, #f43f5e, #9f1239); box-shadow: 0 0 0 3px #e2e8f0, 0 0 22px rgba(244,63,94,.6); overflow: visible; }
body[data-theme="pinball"] .fab .rod { display: block; position: absolute; left: 50%; top: -34px; width: 10px; height: calc(36px + var(--pull, 0px)); transform: translateX(-50%);
  background: linear-gradient(90deg, #94a3b8, #f8fafc, #94a3b8); border-radius: 4px; z-index: -1; }
body[data-theme="pinball"] .fab { transform: translateY(var(--pull, 0px)); }
body.pin-play .fab { animation: plungerHint 1.4s ease-in-out infinite; }
@keyframes plungerHint { 50% { box-shadow: 0 0 0 3px #fde047, 0 0 30px rgba(253,224,71,.8); } }
/* claw: the + is the big arcade button on the machine's control panel */
body[data-theme="claw"] .fab { background: radial-gradient(circle at 50% 35%, #fda4af, #e11d48 55%, #881337); box-shadow: 0 6px 0 #4c0519, 0 0 0 5px #fbcfe8, 0 0 30px rgba(244,114,182,.55); }
body[data-theme="claw"] .fab:active { transform: translateY(4px); box-shadow: 0 2px 0 #4c0519, 0 0 0 5px #fbcfe8; }
/* sea: a pearl in a shell */
body[data-theme="sea"] .fab { background: radial-gradient(circle at 35% 30%, #fff, #fde68a 30%, #f59e0b 70%, #b45309); box-shadow: 0 0 0 4px rgba(255,255,255,.5), 0 10px 26px rgba(8,145,178,.6); }
body[data-theme="sea"] .fab .plus { color: #7c2d12; text-shadow: none; }

#clawPad { display: none; position: fixed; z-index: 6; left: 12px; right: 96px; bottom: calc(env(safe-area-inset-bottom) + 84px); gap: 8px; justify-content: center; }
body[data-theme="claw"] #clawPad { display: flex; }
#clawPad button { height: 50px; min-width: 56px; border-radius: 14px; border: 0; font-weight: 800; font-size: 1.1rem; color: #fff; touch-action: none;
  background: linear-gradient(180deg, #a78bfa, #6d28d9); box-shadow: 0 5px 0 #3b0764; }
#clawPad #clawDrop { flex: 1; max-width: 160px; background: linear-gradient(180deg, #facc15, #ca8a04); color: #422006; box-shadow: 0 5px 0 #713f12; letter-spacing: 2px; }
#clawPad button:active { transform: translateY(4px); box-shadow: 0 1px 0 #3b0764; }

.themes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.themes button { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px; border-radius: 16px; border: 2px solid transparent; background: var(--glass2); text-align: left; }
.themes button i { font-style: normal; font-size: 1.6rem; }
.themes button b { font-size: .95rem; } .themes button small { color: var(--muted); font-size: .72rem; line-height: 1.25; }
.themes button.on { border-color: var(--accent); background: rgba(56,189,248,.16); }

/* editor: Save is always visible at the top */
.sh-head.sticky { position: sticky; top: -8px; z-index: 2; margin: 0 -18px; padding: 8px 18px; background: linear-gradient(180deg, rgba(20,40,72,.98), rgba(20,40,72,.92)); gap: 8px; }
.sh-head.sticky h2 { margin-right: auto; }
#decideList { width: 100%; padding: 11px 13px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.06); color: var(--ink); outline: 0; font: inherit; }
body[data-theme="pinball"] .fab .plus { transform: none; }
/* phones: keep every top-bar control on screen */
@media (max-width: 480px) {
  .logo span { display: none; }
  #top { gap: 6px; padding-left: 10px; padding-right: 10px; }
  .tb { gap: 4px; }
  .tb button { width: 36px; height: 36px; font-size: 1rem; }
  .tb .act { width: auto; padding: 0 10px; font-size: .78rem; }
  #count { font-size: .78rem; }
  body[data-theme="pinball"] #count, body[data-theme="claw"] #count { display: none; }
}
