:root {
    --bg1: #e8f7f4;
    --bg2: #fff6e8;
    --ink: #1d2a32;
    --muted: #5d6d76;
    --teal: #1fa2a0;
    --teal-dark: #157e7c;
    --sun: #f0a202;
    --coral: #ef6f6c;
    --card: rgba(255, 255, 255, 0.88);
    --line: rgba(29, 42, 50, 0.08);
    --shadow: 0 10px 30px rgba(31, 80, 90, 0.12);
    --radius: 22px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --font: "Nunito", "Segoe UI", sans-serif;
    --display: "ZCOOL KuaiLe", "Nunito", sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    font-family: var(--font);
    color: var(--ink);
    background:
        radial-gradient(circle at 10% 0%, #ffe8b5 0%, transparent 35%),
        radial-gradient(circle at 90% 10%, #b8f0e8 0%, transparent 40%),
        linear-gradient(160deg, var(--bg1), var(--bg2));
    background-attachment: fixed;
    -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; }
a { color: var(--teal-dark); text-decoration: none; font-weight: 700; }

.app-shell {
    min-height: 100dvh;
    max-width: 520px;
    margin: 0 auto;
    padding: 12px 14px calc(88px + var(--safe-bottom));
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
    width: 44px; height: 44px;
    display: grid; place-items: center;
    border-radius: 14px;
    background: linear-gradient(145deg, #ffe28a, #ffc94a);
    box-shadow: var(--shadow);
    font-size: 1.4rem;
}
.brand-name { font-family: var(--display); font-size: 1.35rem; line-height: 1.1; }
.brand-sub { color: var(--muted); font-size: 0.82rem; font-weight: 700; }

.points-chip {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 12px;
    border-radius: 999px;
    background: #fff;
    box-shadow: var(--shadow);
    color: var(--sun);
    font-weight: 800;
}
.points-chip strong { color: var(--ink); font-size: 1.1rem; }

.page-body { animation: rise .35s ease; }
@keyframes rise {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

.hero-card, .panel, .stat, .gift-card, .preset-card, .gate, .auth-card {
    background: var(--card);
    backdrop-filter: blur(8px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.hero-card {
    padding: 22px 18px 18px;
    text-align: center;
    background:
        linear-gradient(180deg, rgba(255,255,255,.95), rgba(255,255,255,.82)),
        radial-gradient(circle at 50% 0%, #ffe9a8, transparent 55%);
}

.hero-avatar {
    width: 78px; height: 78px; margin: 0 auto 8px;
    display: grid; place-items: center;
    font-size: 2.5rem;
    border-radius: 28px;
    background: #fff;
    box-shadow: var(--shadow);
    animation: bob 2.4s ease-in-out infinite;
}
@keyframes bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.hero-title, .page-title {
    font-family: var(--display);
    margin: 0 0 6px;
    font-size: 1.7rem;
}
.hero-desc, .page-desc {
    margin: 0 0 14px;
    color: var(--muted);
    font-weight: 700;
}

.hero-score {
    margin: 10px auto 16px;
    padding: 12px;
    max-width: 220px;
    border-radius: 18px;
    background: linear-gradient(135deg, #1fa2a0, #2bc4a8);
    color: #fff;
}
.score-label { font-size: .85rem; opacity: .9; font-weight: 700; }
.score-value { font-size: 2.6rem; font-weight: 800; line-height: 1.1; }

.hero-actions, .btn-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.hero-actions .btn { min-width: 120px; }

.btn {
    border: 0;
    border-radius: 14px;
    padding: 12px 16px;
    font-weight: 800;
    cursor: pointer;
    transition: transform .12s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: linear-gradient(135deg, var(--teal), #2bc4a8); color: #fff; }
.btn-secondary { background: #fff4d6; color: #8a5a00; }
.btn-ghost { background: #eef3f5; color: var(--ink); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: .9rem; border-radius: 12px; }

.child-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 12px;
}
.child-chip {
    border: 2px solid transparent;
    background: #fff5f8;
    color: #7a8494;
    border-radius: 999px;
    padding: 6px 14px;
    font-weight: 700;
    font-size: .85rem;
    cursor: pointer;
}
.child-chip.on {
    border-color: #ff8fab;
    background: #ffe8ef;
    color: #d4507a;
}

.stats-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 12px 0;
}
.stat { padding: 14px; text-align: center; }
.stat-num { font-size: 1.6rem; font-weight: 800; color: var(--teal-dark); }
.stat-label { color: var(--muted); font-size: .85rem; font-weight: 700; }

.panel { padding: 16px; margin-bottom: 12px; }
.panel-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px;
}
.panel-head h2 { margin: 0; font-size: 1.15rem; font-family: var(--display); }

.empty, .loading {
    text-align: center;
    color: var(--muted);
    font-weight: 700;
    padding: 24px 8px;
}

.record-list { list-style: none; margin: 0; padding: 0; }
.record-list li {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.record-list li:last-child { border-bottom: 0; }
.record-reason { font-weight: 800; }
.record-time { color: var(--muted); font-size: .8rem; font-weight: 700; margin-top: 2px; }
.record-delta { font-weight: 800; font-size: 1.1rem; white-space: nowrap; }
.record-delta.plus { color: var(--teal-dark); }
.record-delta.minus { color: var(--coral); }

.kind-tag {
    display: inline-block;
    margin-right: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: .72rem;
    vertical-align: middle;
}
.kind-tag.earn { background: #d8f5ef; color: var(--teal-dark); }
.kind-tag.spend { background: #ffe3e2; color: #b33b38; }
.kind-tag.adjust { background: #fff1cc; color: #8a5a00; }

.preset-grid, .gift-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.preset-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 14px;
    text-align: left;
    cursor: pointer;
}
.preset-card:active { transform: scale(.97); }
.preset-emoji { font-size: 1.5rem; }
.preset-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: cover;
}
.preset-name { font-weight: 800; }
.preset-pts { color: var(--teal-dark); font-weight: 800; }
.preset-pts.minus { color: #ef6f6c; }

.divider {
    text-align: center;
    color: var(--muted);
    font-weight: 800;
    margin: 18px 0 12px;
    font-size: .9rem;
}

.form-grid { display: grid; gap: 12px; }
.form-grid.compact { margin-bottom: 16px; }
.form-grid label { display: grid; gap: 6px; font-weight: 800; font-size: .92rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.input {
    width: 100%;
    border: 1.5px solid #d7e2e6;
    border-radius: 14px;
    padding: 12px 14px;
    background: #fff;
    outline: none;
}
.input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(31,162,160,.15); }

.toast {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    font-weight: 800;
}
.toast.ok { background: #d8f5ef; color: var(--teal-dark); }
.toast.err { background: #ffe3e2; color: #b33b38; }

.balance-banner {
    margin-bottom: 12px;
    padding: 12px 14px;
    border-radius: 16px;
    background: #fff4d6;
    font-weight: 800;
    text-align: center;
}

.gift-card { padding: 14px; display: grid; gap: 8px; }
.gift-card.disabled { opacity: .72; }
.gift-emoji { font-size: 2rem; }
.gift-card h3 { margin: 0; font-size: 1.05rem; }
.gift-card p { margin: 0; color: var(--muted); font-size: .88rem; font-weight: 700; min-height: 2.4em; }
.gift-meta { display: flex; justify-content: space-between; font-weight: 800; }
.gift-meta .cost { color: var(--sun); }
.gift-meta .stock { color: var(--muted); font-size: .85rem; }

.segmented {
    display: grid;
    gap: 6px;
    margin-bottom: 14px;
    background: #eef4f5;
    padding: 6px;
    border-radius: 16px;
}
.segmented button {
    border: 0;
    background: transparent;
    border-radius: 12px;
    padding: 10px 4px;
    font-weight: 800;
    color: var(--muted);
    cursor: pointer;
}
.segmented button.active {
    background: #fff;
    color: var(--teal-dark);
    box-shadow: 0 4px 12px rgba(0,0,0,.06);
}

.emoji-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.emoji-btn {
    width: 44px; height: 44px;
    border: 1.5px solid #d7e2e6;
    border-radius: 14px;
    background: #fff;
    font-size: 1.3rem;
    cursor: pointer;
}
.emoji-btn.active { border-color: var(--teal); background: #e8f8f6; }

.manage-list { list-style: none; margin: 0; padding: 0; }
.manage-list li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.manage-list .muted { color: var(--muted); font-size: .85rem; font-weight: 700; margin-top: 2px; }

.tab-bar {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 0;
    width: min(520px, 100%);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 2px;
    padding: 8px 8px calc(8px + var(--safe-bottom));
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 24px rgba(31,80,90,.08);
    z-index: 20;
}
.tab-item {
    display: grid;
    justify-items: center;
    gap: 2px;
    padding: 8px 4px;
    border-radius: 14px;
    color: var(--muted);
    font-size: .72rem;
    font-weight: 800;
    text-decoration: none;
}
.tab-item .tab-ico { font-size: 1.15rem; line-height: 1; }
.tab-item.active { color: var(--teal-dark); background: #e8f8f6; }

.auth-shell {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 20px 14px;
}
.auth-card { width: min(420px, 100%); padding: 24px 18px 18px; border-radius: 28px; }
.auth-brand { text-align: center; margin-bottom: 18px; }
.auth-logo {
    width: 72px; height: 72px; margin: 0 auto 10px;
    display: grid; place-items: center;
    font-size: 2.2rem;
    border-radius: 24px;
    background: linear-gradient(145deg, #ffe28a, #ffc94a);
    box-shadow: var(--shadow);
}
.auth-brand h1 { font-family: var(--display); margin: 0 0 6px; font-size: 1.8rem; }
.auth-brand p { margin: 0; color: var(--muted); font-weight: 700; font-size: .92rem; }
.auth-tabs { grid-template-columns: 1fr 1fr; }
.auth-links { margin-top: 16px; text-align: center; font-weight: 700; color: var(--muted); }

.parent-tabs { grid-template-columns: repeat(5, 1fr); }
.parent-tabs button { font-size: .78rem; padding: 10px 2px; }

.invite-box {
    text-align: center;
    padding: 16px;
    margin-bottom: 16px;
    border-radius: 18px;
    background: linear-gradient(135deg, #e8f8f6, #fff4d6);
}
.invite-label { font-weight: 800; color: var(--muted); margin-bottom: 6px; }
.invite-code {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 0.25em;
    color: var(--teal-dark);
    font-family: var(--display);
}
