:root {
  --bg: #fbf7ff;
  --bg2: #f2ecff;
  --card: #ffffff;
  --ink: #2e2645;
  --quiet: #6f6688;
  --line: #e6def5;
  --purple: #7b5cd6;
  --purple-soft: #ece5ff;
  --pink: #ff8fb8;
  --pink-soft: #ffe6f0;
  --mint: #4cc9a6;
  --mint-soft: #ddf7ef;
  --gold: #f5b83d;
  --gold-soft: #fff3d6;
  --red: #e0607a;
  --radius: 22px;
  --shadow: 0 6px 22px rgba(80, 60, 140, .10);
  font-family: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: linear-gradient(180deg, var(--bg), var(--bg2)); }
body { -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
img { max-width: 100%; }
.hidden { display: none !important; }

/* ---------- layout */
.app { max-width: 1180px; margin: 0 auto; padding: 12px 16px 32px; }
.site-footer { position: static; padding: 8px 16px max(12px, env(safe-area-inset-bottom)); text-align: center; font-size: 13px; color: var(--quiet); }
.site-footer a { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 0 12px; color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.topbar { display: flex; align-items: center; gap: 10px; min-height: 56px; }
.topbar .title { font-size: 20px; font-weight: 700; color: var(--purple); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); font-weight: 600; }
.chip.star { background: var(--gold-soft); color: #8a5a00; }
.chip.btn:active { transform: scale(.97); }
.stars-big { font-size: 22px; }
.sync-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--mint); display: inline-block; }
.sync-dot.off { background: #c9c1d9; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.grid { display: grid; gap: 14px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .cols-3, .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .cols-2, .cols-3, .cols-4 { grid-template-columns: minmax(0, 1fr); } }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.25; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
.muted { color: var(--quiet); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; }

/* ---------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 0 18px; border-radius: 16px; font-weight: 700; background: var(--purple); color: #fff; transition: transform .08s; }
.btn:active { transform: scale(.97); }
.btn.big { min-height: 60px; font-size: 19px; border-radius: 20px; }
.btn.soft { background: var(--purple-soft); color: var(--purple); }
.btn.pink { background: var(--pink); }
.btn.mint { background: var(--mint); }
.btn.ghost { background: transparent; color: var(--purple); box-shadow: inset 0 0 0 2px var(--purple-soft); }
.btn.danger { background: #fde8ec; color: var(--red); }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 12px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.linkbtn { color: var(--purple); font-weight: 600; padding: 6px 4px; }

/* ---------- forms */
label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
input[type=text], input[type=number], input[type=password], input[type=file], select, textarea {
  border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; background: #fff; width: 100%; font-size: 16px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--purple); }
textarea { min-height: 70px; resize: vertical; }
.pin-input { letter-spacing: 8px; text-align: center; font-size: 26px !important; }
.seg { display: inline-flex; background: var(--purple-soft); border-radius: 14px; padding: 4px; gap: 4px; flex-wrap: wrap; }
.seg button { padding: 9px 14px; border-radius: 11px; font-weight: 600; color: var(--purple); }
.seg button.on { background: #fff; box-shadow: 0 2px 8px rgba(80,60,140,.15); }
.check { display: inline-flex; align-items: center; gap: 8px; padding: 6px 0; font-weight: 600; }
.check input { width: 22px; height: 22px; accent-color: var(--purple); }

/* ---------- tabs */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 6px 2px 10px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; padding: 12px 18px; border-radius: 16px; background: var(--card); box-shadow: var(--shadow); font-weight: 700; color: var(--quiet); font-size: 16px; }
.tab.on { background: var(--purple); color: #fff; }
.tab .badge { display: inline-block; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--pink); color: #fff; font-size: 12px; margin-left: 4px; }

/* ---------- chooser */
.hero { text-align: center; padding: 22px 8px 10px; }
.hero h1 { font-size: 34px; color: var(--purple); letter-spacing: 1px; }
.kid-card { display: flex; align-items: center; gap: 16px; padding: 18px; border-radius: 28px; background: var(--card); box-shadow: var(--shadow); text-align: left; width: 100%; }
.kid-card .pet { width: 120px; height: 120px; flex: none; }
.kid-card .name { font-size: 28px; font-weight: 800; }
.kid-card:active { transform: scale(.98); }

/* ---------- pet stage */
.island { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .island { grid-template-columns: minmax(0, 1fr); } }
.stage { position: relative; border-radius: 28px; overflow: hidden; background: #f6efe4 center/cover no-repeat; aspect-ratio: 16 / 10.5; box-shadow: var(--shadow); user-select: none; }
.stage .pet-wrap { position: absolute; left: 50%; bottom: 14%; width: 46%; transform: translateX(-50%); }
.stage .pet-img { width: 100%; display: block; filter: drop-shadow(0 10px 12px rgba(60, 40, 90, .25)); cursor: pointer; }
.stage .furniture { position: absolute; font-size: clamp(30px, 5.5vw, 54px); transform: translate(-50%, -50%); filter: drop-shadow(0 4px 4px rgba(0,0,0,.15)); }
.stage .bubble { position: absolute; left: 50%; top: 6%; transform: translateX(-50%); max-width: 82%; background: #fff; border-radius: 18px; padding: 10px 16px; font-weight: 600; box-shadow: var(--shadow); text-align: center; animation: pop .25s ease-out; }
.stage .wear { position: absolute; font-size: clamp(22px, 3.5vw, 34px); }
.stage .fx { position: absolute; left: 50%; top: 40%; pointer-events: none; font-size: 36px; animation: floatup 1.6s ease-out forwards; }
.stage .timer { position: absolute; right: 12px; top: 12px; background: rgba(255,255,255,.92); border-radius: 14px; padding: 6px 12px; font-weight: 800; font-size: 20px; }
.growbar { height: 16px; background: var(--purple-soft); border-radius: 999px; overflow: hidden; }
.growbar > div { height: 100%; background: linear-gradient(90deg, var(--pink), var(--purple)); border-radius: 999px; transition: width .6s; }
.dots { display: flex; gap: 6px; }
.dots span { width: 18px; height: 18px; border-radius: 50%; background: var(--purple-soft); }
.dots span.on { background: var(--gold); }

@keyframes pop { from { transform: translateX(-50%) scale(.6); opacity: 0; } }
@keyframes floatup { to { transform: translate(-50%, -120px); opacity: 0; } }
@keyframes bounce { 0%,100% { transform: translateY(0); } 30% { transform: translateY(-14%); } 60% { transform: translateY(-4%); } }
@keyframes wiggle { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
@keyframes breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.025); } }
@keyframes rock { 0%,100% { transform: rotate(0); } 20% { transform: rotate(-8deg); } 40% { transform: rotate(7deg); } 60% { transform: rotate(-4deg); } }
.anim-bounce { animation: bounce .7s ease-out; }
.anim-wiggle { animation: wiggle .5s ease-in-out 2; }
.anim-breathe { animation: breathe 3.2s ease-in-out infinite; transform-origin: 50% 90%; }
.anim-rock { animation: rock 1.8s ease-in-out infinite; transform-origin: 50% 90%; }

/* ---------- tasks */
.task { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 14px; border-radius: 20px; background: var(--card); box-shadow: var(--shadow); }
.task .ic { font-size: 34px; text-align: center; }
.task .t { font-weight: 800; font-size: 18px; }
.task.done { background: var(--mint-soft); }
.task.pending { background: var(--gold-soft); }
.task .acts { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
@media (max-width: 560px) { .task { grid-template-columns: 44px minmax(0, 1fr); } .task .acts { grid-column: 1 / -1; } }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--purple-soft); color: var(--purple); }
.tag.spark { background: var(--pink-soft); color: #c2457a; }
.tag.gold { background: var(--gold-soft); color: #8a5a00; }
.tag.mint { background: var(--mint-soft); color: #1f8a6c; }
.tag.gray { background: #eee; color: #777; }

/* ---------- shop */
.product { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 10px; border-radius: 20px; background: var(--card); box-shadow: var(--shadow); text-align: center; }
.product .emo { font-size: 46px; line-height: 1.1; }
.product .pimg { width: 84px; height: 84px; object-fit: contain; }
.product .nm { font-weight: 700; }
.product .price { color: #8a5a00; font-weight: 800; }
.product.owned { opacity: .75; }
.silhouette { filter: grayscale(1) brightness(1.6) contrast(.6); opacity: .6; }

/* ---------- parent */
.parent-shell { border-top: 4px solid var(--purple); }
.claim { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.claim:last-child { border-bottom: 0; }
.tm-col { min-width: 0; }
.tm-item { display: grid; grid-template-columns: 34px minmax(0,1fr) auto; gap: 8px; align-items: center; padding: 10px; border-radius: 14px; background: #faf8ff; margin-bottom: 8px; border: 2px solid transparent; }
.tm-item.dragging { opacity: .5; }
.tm-item.over { border-color: var(--purple); }
.tm-item .ic { font-size: 24px; text-align: center; }
.tm-item .handle { cursor: grab; color: var(--quiet); padding: 0 6px; font-size: 20px; touch-action: none; }
.tm-item.off { opacity: .55; }
.stepper { display: inline-flex; align-items: center; gap: 2px; background: var(--gold-soft); border-radius: 12px; }
.stepper button { width: 34px; height: 34px; font-weight: 800; font-size: 18px; color: #8a5a00; }
.stepper span { min-width: 34px; text-align: center; font-weight: 800; color: #8a5a00; }
table.log { width: 100%; border-collapse: collapse; font-size: 14px; }
table.log td { padding: 7px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }

/* ---------- dialog */
.overlay { position: fixed; inset: 0; background: rgba(40, 30, 70, .45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.dialog { background: #fff; border-radius: 26px; padding: 22px; width: min(560px, 100%); max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(40,30,70,.3); }
.dialog h2 { margin-bottom: 14px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 16px; z-index: 60; font-weight: 600; max-width: calc(100% - 32px); text-align: center; }
details.adv summary { cursor: pointer; font-weight: 700; color: var(--purple); padding: 8px 0; }

/* ---------- hatch celebration */
.celebrate { text-align: center; }
.celebrate img, .celebrate svg { width: 220px; height: 220px; animation: bounce 1.2s ease-out infinite; }
.confetti { position: fixed; top: -20px; font-size: 26px; z-index: 55; animation: fall linear forwards; pointer-events: none; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

/* ---------- TV */
.tv { min-height: 100vh; background: radial-gradient(circle at 20% 10%, #fff 0, var(--bg2) 60%); padding: 28px 36px; }
.tv h1 { font-size: 40px; color: var(--purple); }
.tv .kid { background: #fff; border-radius: 32px; box-shadow: var(--shadow); padding: 26px; text-align: center; }
.tv .kid .pet { width: 260px; height: 260px; margin: 0 auto; }
.tv .kid .name { font-size: 40px; font-weight: 800; }
.tv .kid .big { font-size: 30px; font-weight: 700; }
.rest { text-align: center; padding: 60px 20px; }
.rest .moon { font-size: 90px; }

/* ---------- 互动 V2：姿势 + 小游戏 */
.stage .pet-img.pose { animation: none; filter: drop-shadow(0 10px 10px rgba(60, 40, 90, .22)); }
.stage .pet-wrap.sleeping::after { content: ''; position: absolute; right: 2%; top: 18%; width: 26%; aspect-ratio: 1; background: url('/web/assets/pose/prop_zzz.webp') center/contain no-repeat; animation: zzz 2.4s ease-in-out infinite; pointer-events: none; }
@keyframes zzz { 0%,100% { transform: translateY(0); opacity: .85; } 50% { transform: translateY(-14%); opacity: 1; } }
.game { position: fixed; inset: 0; z-index: 55; background: #2c2347; display: flex; flex-direction: column; touch-action: none; user-select: none; -webkit-user-select: none; }
.game-top { display: flex; align-items: center; gap: 12px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); color: #fff; font-weight: 800; }
.game-title { font-size: 20px; flex: 1; }
.game-score, .game-time { background: rgba(255,255,255,.16); border-radius: 14px; padding: 6px 12px; font-size: 20px; }
.game-time::before { content: '⏱ '; }
.game-close { width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.2); color: #fff; font-size: 22px; }
.game-arena { position: relative; flex: 1; overflow: hidden; background: #f6efe4 center/cover no-repeat; border-radius: 22px 22px 0 0; touch-action: none; }
.game-hint { color: #fff; text-align: center; padding: 8px 12px max(10px, env(safe-area-inset-bottom)); font-size: 15px; opacity: .85; }
.game img { -webkit-user-drag: none; pointer-events: none; }
.g-uni { position: absolute; bottom: 2%; left: 0; width: clamp(150px, 32vmin, 320px); filter: drop-shadow(0 8px 8px rgba(60,40,90,.25)); }
.g-uni.feed { left: 50%; width: var(--fw); transform: translateX(-50%); }
.g-uni.corner { left: 2%; width: clamp(110px, 22vmin, 220px); }
.game { --fw: clamp(220px, 52vmin, 480px); --mw: clamp(70px, 14vmin, 130px); }
.g-mouth { position: absolute; left: calc(50% + var(--fw) * .195 - var(--mw) / 2); bottom: calc(2% + var(--fw) * .523 - var(--mw) / 2); width: var(--mw); aspect-ratio: 1; border-radius: 50%; border: 4px dashed #ff7eb6; background: rgba(255,182,213,.35); box-shadow: 0 0 18px rgba(255,126,182,.8); animation: breathe 1.4s ease-in-out infinite; }
.g-food { position: absolute; left: 14%; bottom: 10%; font-size: clamp(56px, 12vmin, 96px); transform: translate(-50%, -50%); cursor: grab; touch-action: none; filter: drop-shadow(0 6px 6px rgba(0,0,0,.2)); }
.g-food:not(.dragging) { animation: wiggle 1.2s ease-in-out infinite; transform: none; }
.g-food.dragging { bottom: auto; cursor: grabbing; font-size: clamp(64px, 14vmin, 110px); }
.g-star { position: absolute; left: 0; top: 0; width: 56px; height: 56px; }
.g-bubble { position: absolute; left: 0; top: 0; pointer-events: auto !important; cursor: pointer; }
.g-bubble.popped { transition: opacity .3s; opacity: 0; }
.g-burst { position: absolute; width: 48px; height: 48px; animation: burst .6s ease-out forwards; }
@keyframes burst { from { transform: scale(.4); opacity: 1; } to { transform: scale(1.6) translateY(-20px); opacity: 0; } }
.game-result { position: absolute; inset: 0; background: rgba(40,30,70,.55); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: #fff; text-align: center; padding: 16px; }
.game-result img { width: clamp(160px, 36vmin, 300px); }
.game-result h2 { color: #fff; margin: 0; }
.game-result .muted { color: #ece5ff; }

/* ---------- 家长 AI 试验台 */
.ai-reply { background: #f4efff; border-radius: 14px; padding: 12px 14px; line-height: 1.6; }
.ai-reply.err, .ai-log.err { background: #fff1f0; color: #a8323a; }
.ai-log { border-bottom: 1px solid #eee6fb; padding: 8px 0; font-size: 14px; line-height: 1.5; }
.ai-log.err { padding: 8px; border-radius: 10px; }
.parent-shell pre { white-space: pre-wrap; background: #2c2347; color: #f4efff; padding: 10px; border-radius: 10px; }

.game-level { color: #ffe9a8; text-align: center; font-weight: 700; padding: 0 12px 8px; font-size: 15px; }
.game-badges { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 0; }
.game-badges span { background: #ffe9a8; color: #6b4a00; border-radius: 999px; padding: 6px 14px; font-weight: 800; font-size: 18px; }
.mic.on { background: #ff7eb6; color: #fff; animation: breathe 1.2s ease-in-out infinite; }

.talk-card { align-items: center; text-align: center; }
.talk-btn { width: 100%; font-size: 22px; padding: 18px; background: linear-gradient(135deg, #a77bff, #ff8ac2); color: #fff; }
.talk-btn.on { background: #ff5fa2; animation: breathe 1.2s ease-in-out infinite; }
.room-switch { white-space: nowrap; font-weight: 700; }
.row.wrap { flex-wrap: wrap; align-items: end; }
