:root {
  --blue: #2f6fed;
  --blue-soft: #e8f0ff;
  --green: #29b473;
  --green-soft: #e6f7ee;
  --orange: #f5a623;
  --orange-soft: #fff3dd;
  --red: #e55353;
  --ink: #17233a;
  --muted: #71809a;
  --line: #e6ebf3;
  --card: #ffffff;
  --bg: #f4f7fc;
  --shadow: 0 8px 24px rgba(30, 60, 110, .08);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; }
body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
button, input, select, textarea { font-family: inherit; font-size: 16px; }
button { cursor: pointer; border: 0; }
.hidden { display: none !important; }

#app { max-width: 560px; margin: 0 auto; min-height: 100vh; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 10px; }
.brand { display: flex; align-items: center; gap: 11px; }
.logo { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: linear-gradient(135deg, #2f6fed, #29b473); font-size: 26px; box-shadow: var(--shadow); }
.top h1 { margin: 0; font-size: 19px; letter-spacing: .5px; }
.top p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.icon-btn { background: var(--card); color: var(--blue); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: 13px; font-weight: 600; box-shadow: 0 2px 8px rgba(30,60,110,.05); }

.kid-switch { display: flex; gap: 10px; padding: 8px 18px 14px; }
.kid-switch button { flex: 1; background: var(--card); border: 2px solid transparent; border-radius: 16px; padding: 12px 8px; text-align: left; box-shadow: var(--shadow); color: var(--ink); transition: .15s; }
.kid-switch button.active { border-color: var(--blue); background: var(--blue-soft); }
.kid-switch .kname { display: block; font-size: 15px; font-weight: 700; }
.kid-switch .kgrade { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }

main { padding: 0 18px 24px; }
.card { background: var(--card); border-radius: 20px; padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 12px; font-size: 15px; }
.card h3 { margin: 18px 0 8px; font-size: 13px; color: var(--muted); }
.muted { color: var(--muted); font-size: 12px; }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }

.pet-stage { text-align: center; padding: 6px 0 0; }
.pet-art { width: 190px; height: 190px; margin: 0 auto; display: grid; place-items: center; border-radius: 50%; background: radial-gradient(circle at 40% 30%, #fff, var(--blue-soft)); }
.pet-art svg { width: 86%; height: 86%; }
.pet-name { margin-top: 8px; font-size: 20px; font-weight: 800; }
.pet-level { display: inline-block; margin-top: 4px; padding: 3px 12px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-size: 12px; font-weight: 700; }
.speech { position: relative; margin: 14px auto 0; max-width: 300px; background: var(--orange-soft); border-radius: 16px; padding: 12px 14px; font-size: 14px; line-height: 1.55; min-height: 48px; }
.speech:after { content: ""; position: absolute; top: -7px; left: 50%; transform: translateX(-50%); border-left: 8px solid transparent; border-right: 8px solid transparent; border-bottom: 8px solid var(--orange-soft); }
.speech .en { display: block; font-size: 15px; font-weight: 700; color: #a96a00; }
.bar { height: 9px; border-radius: 99px; background: #eef2f8; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--blue), var(--green)); transition: width .3s; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.stat { background: #f7f9fd; border-radius: 14px; padding: 10px 6px; text-align: center; }
.stat b { display: block; font-size: 18px; }
.stat span { font-size: 11px; color: var(--muted); }
.actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 14px; }

.btn { border-radius: 13px; padding: 12px 14px; font-weight: 700; font-size: 14px; background: #f0f4fa; color: var(--ink); }
.btn.primary { background: var(--blue); color: #fff; }
.btn.green { background: var(--green); color: #fff; }
.btn.orange { background: var(--orange); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { background: #fdecec; color: var(--red); }
.btn.sm { padding: 8px 11px; font-size: 12px; border-radius: 10px; }
.btn:disabled { opacity: .45; }

.game-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.game-card { border-radius: 18px; padding: 18px 12px; text-align: center; background: linear-gradient(160deg, #eaf1ff, #fff); box-shadow: var(--shadow); }
.game-card:nth-child(2) { background: linear-gradient(160deg, #e8f8ef, #fff); }
.game-card .gi { font-size: 38px; }
.game-card b { display: block; margin-top: 8px; font-size: 14px; }
.game-card span { font-size: 11px; color: var(--muted); }
.msg { background: var(--blue-soft); border-radius: 12px; padding: 10px 12px; font-size: 12px; color: #2452b8; margin-bottom: 12px; }

.task-row { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.task-row:last-child { border-bottom: 0; }
.task-row .ti { font-size: 22px; width: 28px; text-align: center; }
.task-row .tn { flex: 1; font-size: 13px; }
.task-row .tn small { display: block; color: var(--muted); margin-top: 2px; }
.badge { font-size: 10px; padding: 3px 7px; border-radius: 99px; background: #f0f4fa; color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.wait { background: var(--orange-soft); color: #b97500; }
.badge.over { background: #fdecec; color: var(--red); }

input[type=text], input[type=number], select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; background: #fff; margin: 5px 0 8px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--blue); }
label { font-size: 12px; color: var(--muted); }
.task-add { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.task-add .btn { padding: 10px 6px; font-size: 12px; }
.sec { border-top: 1px dashed var(--line); margin-top: 16px; padding-top: 12px; }
.sec:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.toggle { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; font-size: 13px; }
.switch { width: 48px; height: 28px; border-radius: 99px; background: #cfd8e6; position: relative; transition: .2s; }
.switch:after { content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: .2s; }
.switch.on { background: var(--green); }
.switch.on:after { left: 23px; }

.tabs { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 560px; display: grid; grid-template-columns: repeat(4, 1fr); background: rgba(255,255,255,.96); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 8px 6px calc(8px + env(safe-area-inset-bottom)); z-index: 20; }
.tabs button { background: transparent; color: var(--muted); font-size: 11px; padding: 5px 0; border-radius: 10px; }
.tabs button span { display: block; font-size: 20px; line-height: 1.3; }
.tabs button.active { color: var(--blue); font-weight: 700; }

.mask { position: fixed; inset: 0; background: rgba(16,28,50,.55); display: grid; place-items: center; z-index: 50; padding: 18px; }
.mask-card, .game-box { background: #fff; border-radius: 22px; padding: 22px; width: 100%; max-width: 420px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.mask-emoji { font-size: 52px; }
.mask-card h2 { margin: 8px 0; font-size: 19px; }
.mask-card p { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.game-box { text-align: left; max-width: 480px; }
.game-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.game-head h2 { margin: 0; font-size: 16px; }
.toast { position: fixed; left: 50%; bottom: 92px; transform: translate(-50%, 20px); background: rgba(23,35,58,.92); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 13px; opacity: 0; pointer-events: none; transition: .25s; z-index: 80; max-width: 88%; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.star-area { position: relative; height: 330px; border-radius: 16px; background: linear-gradient(#0f1b3d, #243b7a); overflow: hidden; }
.star { position: absolute; font-size: 26px; cursor: pointer; user-select: none; transform: translateX(-50%); line-height: 1; }
.star.bad { filter: grayscale(1) opacity(.6); }
.game-score { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin: 10px 0; }
.mem-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mem-card { aspect-ratio: 1/1; border-radius: 12px; background: var(--blue-soft); display: grid; place-items: center; font-size: 26px; cursor: pointer; transition: .15s; }
.mem-card.flipped, .mem-card.matched { background: #fff; box-shadow: inset 0 0 0 2px var(--green); }
.mem-card.matched { opacity: .55; }
.mem-card span { display: none; }
.mem-card.flipped span, .mem-card.matched span { display: block; }
.hint { font-size: 12px; color: var(--muted); margin-top: 10px; text-align: center; }
