:root {
  --sky-bg: #EAF6FF;
  --ink: #1E2A44;
  --rocket: #FF5C5C;
  --sun: #FFC53D;
  --leaf: #49C97A;
  --sky: #3BA7F0;
  --paper: #FFFFFF;
  --mute: #6B7A99;
  --radius: 28px;
  --line: 3px solid var(--ink);
  --sticker: 6px 6px 0 var(--ink);
  --font-tc: "Baloo 2", "Noto Sans TC", "PingFang TC", system-ui, sans-serif;
  --font-num: "Baloo 2", "Noto Sans TC", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--sky-bg);
  background-image: radial-gradient(circle at 10% 10%, #fff 0 10px, transparent 11px), radial-gradient(circle at 85% 30%, #fff 0 14px, transparent 15px), radial-gradient(circle at 70% 85%, #fff 0 9px, transparent 10px);
  color: var(--ink);
  font-family: var(--font-tc);
  font-size: 20px;
  font-weight: 500;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }
.app { min-height: 100%; padding: max(16px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom)); max-width: 1100px; margin: 0 auto; }

/* ---------- buttons (sticker style) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  min-height: 72px; padding: 14px 28px; border-radius: 999px;
  background: var(--paper); border: var(--line); box-shadow: var(--sticker);
  font-weight: 900; font-size: 24px; line-height: 1.1; transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translate(4px, 4px); box-shadow: 2px 2px 0 var(--ink); }
.btn:focus-visible { outline: 4px solid var(--sky); outline-offset: 3px; }
.btn[disabled] { opacity: .45; box-shadow: none; transform: none; cursor: default; }
.btn-rocket { background: var(--rocket); color: #fff; }
.btn-leaf { background: var(--leaf); color: #fff; }
.btn-sun { background: var(--sun); }
.btn-sky { background: var(--sky); color: #fff; }
.btn-ghost { background: transparent; box-shadow: none; border-color: transparent; font-weight: 700; color: var(--mute); min-height: 56px; }
.btn-ghost:active { transform: none; box-shadow: none; }
.btn-xl { font-size: 34px; min-height: 96px; padding: 20px 40px; }
.btn .ico { font-size: 1.3em; }

/* ---------- top bar ---------- */
.top { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; min-height: 56px; }
.top .back { background: var(--paper); border: var(--line); border-radius: 999px; width: 56px; height: 56px; font-size: 26px; font-weight: 900; box-shadow: 4px 4px 0 var(--ink); }
.top h1 { font-size: 28px; font-weight: 900; margin: 0; }
.top .spacer { flex: 1; }
.top .who { display: flex; align-items: center; gap: 8px; font-weight: 700; background: var(--paper); border: var(--line); border-radius: 999px; padding: 6px 14px 6px 8px; box-shadow: 3px 3px 0 var(--ink); }
.top .who .sw { color: var(--mute); font-size: 18px; }
.top .who .av { font-size: 30px; }

/* ---------- PIN pad ---------- */
.pin { min-height: calc(100vh - 40px); display: grid; place-items: center; }
.pin-card { text-align: center; }
.pin-card .logo { font-size: 52px; margin-bottom: 6px; }
.pin-card h1 { font-size: 30px; font-weight: 900; margin: 0 0 6px; }
.pin-card .hint { color: var(--mute); margin: 0 0 20px; font-weight: 700; }
.dots { display: flex; gap: 18px; justify-content: center; margin: 10px 0 26px; }
.dots i { width: 26px; height: 26px; border-radius: 50%; border: var(--line); background: var(--paper); transition: background .1s; }
.dots i.on { background: var(--sun); }
.dots.shake { animation: shake .4s; }
@keyframes shake { 20%,60% { transform: translateX(-10px); } 40%,80% { transform: translateX(10px); } }
.keys { display: grid; grid-template-columns: repeat(3, 96px); gap: 14px; justify-content: center; }
.keys button { height: 96px; border-radius: 24px; background: var(--paper); border: var(--line); box-shadow: 5px 5px 0 var(--ink); font-family: var(--font-num); font-size: 40px; font-weight: 800; }
.keys button:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink); }
.keys button.soft { background: transparent; border-color: transparent; box-shadow: none; font-size: 28px; font-weight: 700; color: var(--mute); }
.lock { background: var(--rocket); color: #fff; border-radius: 18px; padding: 14px 18px; font-weight: 900; margin-top: 18px; }

/* ---------- home ---------- */
.home { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .home { grid-template-columns: 380px 1fr; align-items: start; } }
.me {
  background: var(--sun); border: var(--line); border-radius: 36px; box-shadow: var(--sticker);
  padding: 22px 24px 20px; position: relative; overflow: hidden;
}
.me .name { display: flex; align-items: center; gap: 12px; font-size: 28px; font-weight: 900; }
.me .name .av { font-size: 44px; line-height: 1; }
.me .label { margin-top: 14px; font-weight: 700; color: #6b4e00; }
.me .bal { font-family: var(--font-num); font-size: 84px; font-weight: 800; line-height: 1; letter-spacing: -1px; }
.me .bal small { font-family: var(--font-tc); font-size: 24px; font-weight: 900; margin-left: 6px; }
.me .bal.neg { color: var(--rocket); }
.me .row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.chip { background: var(--paper); border: var(--line); border-radius: 999px; padding: 6px 14px; font-weight: 900; font-size: 17px; }
.chip.bad { background: var(--rocket); color: #fff; }
.chip.debt { background: var(--ink); color: var(--sun); }
.tiles { display: grid; gap: 18px; grid-template-columns: repeat(2, 1fr); }
.tile {
  border: var(--line); border-radius: var(--radius); box-shadow: var(--sticker); background: var(--paper);
  min-height: 150px; padding: 20px; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start; gap: 6px;
  text-align: left; font-size: 26px; font-weight: 900; line-height: 1.1; transition: transform .08s, box-shadow .08s;
}
.tile:active { transform: translate(4px, 4px); box-shadow: 2px 2px 0 var(--ink); }
.tile .ico { font-size: 46px; line-height: 1; }
.tile .sub { font-size: 16px; font-weight: 700; color: var(--mute); }
.tile.hero { grid-column: 1 / -1; background: var(--sky); color: #fff; min-height: 190px; font-size: 38px; }
.tile.hero .sub { color: #e6f4ff; }
.tile.hero .ico { font-size: 64px; }
.tile.game { background: #fff; }
.tile.happy { background: linear-gradient(135deg, #FFC53D, #FF8A5C); grid-column: 1 / -1; }
.tile.resume { background: var(--rocket); color: #fff; }
.tile.resume .sub { color: #ffe3e3; }
.tile[disabled] { opacity: .55; }

/* ---------- category ---------- */
.cats { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.cat { border: var(--line); border-radius: var(--radius); box-shadow: var(--sticker); background: var(--paper); min-height: 170px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; font-size: 26px; font-weight: 900; }
.cat .ico { font-size: 60px; line-height: 1; }
.cat:active { transform: translate(4px, 4px); box-shadow: 2px 2px 0 var(--ink); }

/* ---------- reading timer ---------- */
.timer-wrap { text-align: center; padding-top: 10px; }
.timer-wrap .cat-name { font-weight: 900; font-size: 22px; color: var(--mute); }
.clock { font-family: var(--font-num); font-size: clamp(96px, 22vw, 200px); font-weight: 800; line-height: 1; letter-spacing: -2px; margin: 10px 0 6px; font-variant-numeric: tabular-nums; }
.clock.paused { color: var(--mute); }
.cap { font-weight: 700; color: var(--mute); margin-bottom: 26px; }
.cap b { color: var(--rocket); }
.actions { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; }
.paused-banner { display: inline-block; background: var(--sun); border: var(--line); border-radius: 999px; padding: 8px 20px; font-weight: 900; margin-bottom: 12px; }

/* ---------- forms ---------- */
.card { background: var(--paper); border: var(--line); border-radius: var(--radius); box-shadow: var(--sticker); padding: 22px; }
.card + .card { margin-top: 18px; }
.card h2 { margin: 0 0 14px; font-size: 26px; font-weight: 900; }
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 900; }
.field input[type=text], .field input[type=number] { min-height: 64px; border: var(--line); border-radius: 18px; padding: 10px 16px; font-size: 24px; font-weight: 700; background: #fff; color: var(--ink); -webkit-user-select: text; user-select: text; }
.field input:focus { outline: 4px solid var(--sky); outline-offset: 2px; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.row2 > * { min-width: 0; }
.field input[type=text], .field input[type=number] { width: 100%; max-width: 100%; }
.note { color: var(--mute); font-weight: 700; }

/* ---------- photos ---------- */
.shots { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; margin: 10px 0 20px; }
.shot { border: var(--line); border-radius: var(--radius); background: #fff; min-height: 240px; display: grid; place-items: center; position: relative; overflow: hidden; box-shadow: var(--sticker); cursor: pointer; }
.shot .ph { text-align: center; font-weight: 900; font-size: 24px; }
.shot .ph .ico { font-size: 54px; display: block; }
.shot img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.shot .tag { position: absolute; top: 10px; left: 10px; background: var(--sun); border: var(--line); border-radius: 999px; padding: 4px 12px; font-weight: 900; }
.shot input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.shot.done { border-color: var(--leaf); }
.retake { background: var(--rocket); color: #fff; border-radius: 18px; padding: 14px 18px; font-weight: 900; margin-bottom: 14px; }

/* ---------- quiz ---------- */
.qprog { display: flex; gap: 10px; justify-content: center; margin-bottom: 18px; }
.qprog i { width: 18px; height: 18px; border-radius: 50%; border: var(--line); background: #fff; }
.qprog i.ok { background: var(--leaf); } .qprog i.bad { background: var(--rocket); } .qprog i.cur { background: var(--sun); }
.q { font-size: 30px; font-weight: 900; line-height: 1.35; margin: 0 0 22px; }
.opts { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .opts { grid-template-columns: 1fr 1fr; } }
.opt { min-height: 84px; border: var(--line); border-radius: 22px; background: #fff; box-shadow: var(--sticker); text-align: left; padding: 14px 20px; font-size: 24px; font-weight: 700; display: flex; gap: 14px; align-items: center; }
.opt .k { flex: 0 0 44px; height: 44px; border-radius: 50%; border: var(--line); display: grid; place-items: center; font-family: var(--font-num); font-weight: 800; background: var(--sun); }
.opt.right { background: var(--leaf); color: #fff; }
.opt.wrong { background: var(--rocket); color: #fff; }
.opt[disabled] { opacity: 1; }
.opt.dim { opacity: .5; box-shadow: none; }
.feedback { text-align: center; font-size: 28px; font-weight: 900; margin: 20px 0 10px; min-height: 40px; }

/* ---------- result ---------- */
.result { text-align: center; padding-top: 20px; position: relative; }
.result .big { font-family: var(--font-num); font-size: clamp(72px, 16vw, 150px); font-weight: 800; line-height: 1; }
.result .big small { font-family: var(--font-tc); font-size: .3em; font-weight: 900; }
.result h2 { font-size: 34px; font-weight: 900; margin: 6px 0 10px; }
.result p { font-size: 22px; font-weight: 700; color: var(--mute); margin: 0 0 24px; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 5; }
.confetti i { position: absolute; top: -20px; font-size: 28px; animation: fall 2.6s ease-in forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); opacity: .8; } }

/* ---------- game ---------- */
.game-wrap { text-align: center; padding-top: 10px; }
.game-wrap .left { font-weight: 900; font-size: 24px; color: var(--mute); }
.game-wrap .clock { color: var(--leaf); }
.game-wrap .clock.low { color: var(--rocket); }
.timeup { position: fixed; inset: 0; background: var(--rocket); color: #fff; display: grid; place-items: center; text-align: center; z-index: 10; font-size: clamp(48px, 10vw, 110px); font-weight: 900; padding: 20px; }
.timeup .btn { font-size: 28px; margin-top: 24px; }

/* ---------- tasks ---------- */
.tasks { display: grid; gap: 16px; }
.task { display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center; background: var(--paper); border: var(--line); border-radius: 24px; box-shadow: var(--sticker); padding: 14px 18px; }
.task .ico { font-size: 44px; text-align: center; }
.task .t { font-size: 24px; font-weight: 900; }
.task .m { font-weight: 700; color: var(--mute); font-size: 17px; margin-top: 2px; }
.task .m .rew { color: #9a6b00; }
.task .m .joint { background: var(--sky); color: #fff; border-radius: 999px; padding: 1px 10px; margin-left: 6px; }
.task .m .weekly { background: var(--ink); color: var(--sun); border-radius: 999px; padding: 1px 10px; margin-left: 6px; }
.task .act { display: flex; gap: 10px; }
.task .act .btn { min-height: 60px; font-size: 20px; padding: 10px 20px; }
.task.waiting { background: #fff7d6; }
.task .wait { font-weight: 900; color: #9a6b00; }
.task .retn { color: var(--rocket); font-weight: 900; }
@media (max-width: 600px) { .task { grid-template-columns: 56px 1fr; } .task .act { grid-column: 1 / -1; justify-content: flex-end; } }
.empty { text-align: center; color: var(--mute); font-weight: 700; padding: 40px 0; font-size: 22px; }

/* ---------- loan ---------- */
.loan-preview { background: var(--sun); border: var(--line); border-radius: 22px; padding: 16px 18px; font-size: 26px; font-weight: 900; margin-bottom: 18px; text-align: center; }
.loan-preview b { font-family: var(--font-num); font-size: 1.3em; }
input[type=range] { width: 100%; height: 44px; accent-color: var(--rocket); }
.pending { background: #fff7d6; border: var(--line); border-radius: 22px; padding: 16px 18px; font-weight: 900; font-size: 22px; }

/* ---------- happy hour ---------- */
.hh-list { display: grid; gap: 10px; margin-bottom: 20px; }
.hh-list div { display: flex; align-items: center; gap: 12px; font-size: 22px; font-weight: 900; background: #fff; border: var(--line); border-radius: 18px; padding: 12px 16px; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 14px 22px; border-radius: 999px; font-weight: 900; z-index: 20; max-width: 90vw; text-align: center; }
.toast.err { background: var(--rocket); }

@media (prefers-reduced-motion: reduce) { .confetti i, .dots.shake { animation: none; } .btn, .tile, .cat, .opt { transition: none; } }

/* ---------- history ---------- */
.hrow { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 2px solid #eef3f8; font-size: 19px; }
.hrow:first-of-type { border-top: 0; }
.hrow .note { font-size: 15px; }
.hd { font-family: var(--font-num); font-weight: 800; font-size: 24px; white-space: nowrap; }
.hd.pos { color: #2e9e5b; } .hd.neg { color: var(--rocket); }
