:root {
    --ink: #17212b;
    --muted: #64748b;
    --paper: #fffaf0;
    --blue: #19a7ce;
    --green: #54d68a;
    --yellow: #ffd166;
    --coral: #ff7a59;
    --violet: #7c5cff;
    --line: rgba(23, 33, 43, .12);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 12% 12%, rgba(255, 209, 102, .38), transparent 28%),
        radial-gradient(circle at 86% 8%, rgba(84, 214, 138, .28), transparent 24%),
        linear-gradient(180deg, #f5fbff 0%, var(--paper) 52%, #ffffff 100%);
}

[hidden] {
    display: none !important;
}

button {
    border: 0;
    font: inherit;
    cursor: pointer;
}

.app-shell,
main {
    width: min(1160px, calc(100% - 32px));
    margin: 0 auto;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 0;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 46px;
    height: 46px;
    place-items: center;
    border: 3px solid var(--ink);
    border-radius: 14px;
    background: var(--yellow);
    box-shadow: 5px 5px 0 var(--ink);
    font-weight: 900;
}

.brand small,
.subtitle,
.mission-card p,
.reward-card p,
.review-copy p,
.stats-panel span,
.camera-copy p,
.task-card p {
    color: var(--muted);
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.role-switch {
    display: flex;
    gap: 6px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, .76);
}

.role-switch button {
    min-width: 86px;
    padding: 10px 16px;
    border-radius: 999px;
    color: var(--muted);
    background: transparent;
    font-weight: 800;
}

.role-switch .is-active {
    color: #fff;
    background: var(--ink);
}

.hero-panel {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(290px, .9fr);
    gap: 24px;
    align-items: stretch;
    min-height: 430px;
    padding: 34px;
    border: 3px solid var(--ink);
    border-radius: 24px;
    background:
        linear-gradient(135deg, rgba(25, 167, 206, .16), rgba(255, 209, 102, .3)),
        #fff;
    box-shadow: 9px 9px 0 var(--ink);
}

.auth-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, .85fr);
    gap: 22px;
    align-items: stretch;
    padding: 20px 0 34px;
}

.connection-banner {
    display: grid;
    gap: 4px;
    margin: 8px 0 18px;
    padding: 14px 16px;
    border: 2px solid var(--ink);
    border-radius: 14px;
    background: #fff0d9;
    box-shadow: 4px 4px 0 var(--ink);
}

.connection-banner span {
    color: var(--muted);
}

.auth-panel {
    padding: 22px;
    border: 2px solid var(--ink);
    border-radius: 18px;
    background: rgba(255, 255, 255, .9);
    box-shadow: 5px 5px 0 var(--ink);
}

.form-grid,
.form-row {
    display: grid;
    gap: 14px;
}

.form-row {
    grid-template-columns: repeat(5, minmax(130px, 1fr));
    align-items: end;
}

.notify-row {
    grid-template-columns: minmax(180px, .7fr) minmax(180px, .9fr) minmax(240px, 1.4fr) auto;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: .86rem;
    font-weight: 800;
}

input,
select,
textarea {
    width: 100%;
    min-height: 46px;
    padding: 10px 12px;
    border: 2px solid var(--ink);
    border-radius: 12px;
    color: var(--ink);
    background: #fff;
    font: inherit;
}

select[multiple] {
    min-height: 92px;
}

textarea {
    min-height: 96px;
    resize: vertical;
}

.check {
    grid-auto-flow: column;
    align-items: center;
    justify-content: start;
}

.check input {
    width: 20px;
    min-height: 20px;
}

.hint {
    margin: 14px 0 0;
    color: var(--muted);
}

.hero-copy {
    align-self: center;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--coral);
    font-size: .78rem;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    max-width: 720px;
    margin-bottom: 14px;
    font-size: clamp(2.5rem, 7vw, 5.6rem);
    line-height: .94;
}

h2 {
    font-size: clamp(1.7rem, 4vw, 2.7rem);
    line-height: 1;
}

h3 {
    font-size: 1.18rem;
}

.subtitle {
    max-width: 560px;
    font-size: 1.22rem;
}

.hero-actions,
.review-actions,
.camera-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
}

.primary,
.secondary,
.danger,
.reward-card button,
.mission-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 12px 18px;
    border: 2px solid var(--ink);
    border-radius: 12px;
    box-shadow: 4px 4px 0 var(--ink);
    font-weight: 900;
}

.primary {
    color: #fff;
    background: var(--blue);
}

.secondary,
.reward-card button,
.mission-action {
    color: var(--ink);
    background: #fff;
}

.danger {
    color: #fff;
    background: var(--coral);
}

.icon {
    display: grid;
    width: 22px;
    height: 22px;
    place-items: center;
    border-radius: 999px;
    background: #fff;
    color: var(--blue);
}

.mission-card {
    position: relative;
    display: grid;
    align-content: end;
    min-height: 100%;
    padding: 24px;
    overflow: hidden;
    border: 3px solid var(--ink);
    border-radius: 22px;
    background: var(--yellow);
}

.mission-card.active::before {
    content: "";
    position: absolute;
    inset: 18px 18px auto auto;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: -70px 55px 0 var(--coral), -170px 15px 0 var(--blue);
}

.mascot {
    position: relative;
    width: 180px;
    height: 180px;
    margin: 0 auto 26px;
}

.mascot span {
    position: absolute;
    inset: 0;
    border: 4px solid var(--ink);
    border-radius: 42% 58% 48% 52%;
    background:
        radial-gradient(circle at 34% 42%, var(--ink) 0 7px, transparent 8px),
        radial-gradient(circle at 64% 42%, var(--ink) 0 7px, transparent 8px),
        radial-gradient(ellipse at 50% 65%, var(--coral) 0 18px, transparent 19px),
        var(--green);
    box-shadow: 8px 8px 0 var(--ink);
    transform: rotate(-5deg);
}

.chip {
    display: inline-flex;
    width: fit-content;
    padding: 7px 11px;
    border-radius: 999px;
    color: var(--ink);
    background: #fff;
    font-size: .78rem;
    font-weight: 900;
}

.chip.warning {
    background: var(--yellow);
}

.dashboard,
.rewards,
.adult-board,
.kid-dashboard {
    padding: 72px 0 24px;
}

.section-title {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.mission-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.score-band {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.score-band div {
    padding: 18px;
    border: 2px solid var(--ink);
    border-radius: 18px;
    background: #fff;
    box-shadow: 5px 5px 0 var(--ink);
}

.score-band span {
    display: block;
    color: var(--muted);
    font-size: .82rem;
    font-weight: 900;
    text-transform: uppercase;
}

.score-band strong {
    display: block;
    font-size: 2.4rem;
    line-height: 1;
}

.task-card,
.reward-card,
.review-card,
.stats-panel {
    border: 2px solid var(--ink);
    border-radius: 18px;
    background: rgba(255, 255, 255, .86);
    box-shadow: 5px 5px 0 var(--ink);
}

.task-card {
    display: grid;
    gap: 18px;
    padding: 18px;
}

.task-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.points {
    display: grid;
    min-width: 64px;
    min-height: 64px;
    place-items: center;
    border: 2px solid var(--ink);
    border-radius: 18px;
    background: var(--yellow);
    font-weight: 900;
}

.progress {
    height: 12px;
    overflow: hidden;
    border: 2px solid var(--ink);
    border-radius: 999px;
    background: #fff;
}

.progress span {
    display: block;
    width: var(--value);
    height: 100%;
    background: linear-gradient(90deg, var(--green), var(--blue));
}

.reward-track {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.reward-card {
    display: grid;
    gap: 8px;
    padding: 20px;
}

.reward-icon {
    display: grid;
    width: 68px;
    height: 68px;
    place-items: center;
    border: 2px solid var(--ink);
    border-radius: 20px;
    background: var(--violet);
    color: #fff;
    font-weight: 900;
    font-size: 1.8rem;
}

.reward-card.unlocked .reward-icon {
    background: var(--green);
}

.adult-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 290px;
    gap: 18px;
}

.stack {
    display: grid;
    gap: 18px;
}

.review-list {
    display: grid;
    gap: 16px;
}

.management-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.inbox-panel {
    display: grid;
    gap: 12px;
    margin-bottom: 18px;
}

.mini-list {
    display: grid;
    gap: 10px;
}

.mini-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, .74);
}

.mini-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.mini-actions button {
    min-height: 34px;
    padding: 7px 10px;
    border: 2px solid var(--ink);
    border-radius: 10px;
    background: #fff;
    font-weight: 900;
}

.mini-row.unread {
    border: 2px solid var(--ink);
    background: #fff8db;
}

.mini-row strong,
.mini-row small {
    display: block;
}

.mini-row small {
    color: var(--muted);
    margin-top: 3px;
}

.color-dot {
    width: 18px;
    height: 18px;
    border: 2px solid var(--ink);
    border-radius: 999px;
    background: var(--dot);
    flex: 0 0 auto;
}

.tight {
    margin-bottom: 12px;
}

.review-card {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    overflow: hidden;
}

.review-card img {
    width: 100%;
    height: 100%;
    min-height: 260px;
    object-fit: cover;
}

.review-copy,
.stats-panel {
    padding: 22px;
}

.stats-panel {
    display: grid;
    gap: 14px;
}

.stats-panel div {
    padding: 16px;
    border-radius: 14px;
    background: #f8fafc;
}

.stats-panel strong {
    display: block;
    font-size: 2rem;
}

.camera-dialog {
    width: min(920px, calc(100% - 24px));
    padding: 0;
    border: 3px solid var(--ink);
    border-radius: 22px;
    box-shadow: 9px 9px 0 var(--ink);
}

.camera-dialog::backdrop {
    background: rgba(15, 23, 42, .44);
}

.close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    width: 38px;
    height: 38px;
    border: 2px solid var(--ink);
    border-radius: 50%;
    background: #fff;
    font-weight: 900;
}

.camera-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(260px, .85fr);
}

.camera-stage {
    display: grid;
    min-height: 420px;
    place-items: center;
    background: #dff6ff;
}

.camera-stage video,
.camera-stage img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-copy {
    align-self: center;
    padding: 28px;
}

.compact {
    min-height: 38px;
    padding: 8px 13px;
    border-radius: 10px;
    box-shadow: 3px 3px 0 var(--ink);
}

button:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.empty {
    min-height: 120px;
    align-content: center;
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 30;
    max-width: min(360px, calc(100% - 36px));
    padding: 14px 16px;
    border: 2px solid var(--ink);
    border-radius: 14px;
    background: var(--yellow);
    box-shadow: 5px 5px 0 var(--ink);
    font-weight: 900;
    transform: translateY(140%);
    transition: transform .22s ease;
}

.toast.show {
    transform: translateY(0);
}

@media (max-width: 860px) {
    body {
        background: linear-gradient(180deg, #f5fbff 0%, var(--paper) 100%);
    }

    .app-shell,
    main {
        width: min(100% - 22px, 620px);
    }

    .topbar,
    .top-actions,
    .section-title {
        align-items: stretch;
        flex-direction: column;
    }

    .role-switch,
    .role-switch button,
    .top-actions > button {
        width: 100%;
    }

    .hero-panel,
    .auth-grid,
    .adult-layout,
    .review-card,
    .camera-layout {
        grid-template-columns: 1fr;
    }

    .mission-grid,
    .reward-track,
    .score-band,
    .form-row,
    .notify-row,
    .management-grid {
        grid-template-columns: 1fr;
    }

    .hero-panel {
        padding: 22px;
        min-height: auto;
    }

    h1 {
        font-size: clamp(2.25rem, 13vw, 3.6rem);
    }

    h2 {
        font-size: clamp(1.55rem, 8vw, 2.15rem);
    }

    input,
    select,
    textarea,
    .primary,
    .secondary,
    .danger,
    .mission-action {
        min-height: 52px;
    }

    .auth-panel,
    .task-card,
    .reward-card,
    .stats-panel,
    .review-card {
        border-radius: 14px;
        box-shadow: 4px 4px 0 var(--ink);
    }

    .adult-board,
    .kid-dashboard,
    .rewards {
        padding-top: 34px;
    }

    .mini-row {
        align-items: stretch;
        flex-direction: column;
    }

    .mini-actions {
        justify-content: stretch;
    }

    .mini-actions button {
        flex: 1 1 120px;
    }

    .camera-stage {
        min-height: 300px;
    }

    .mission-card {
        min-height: 340px;
    }
}

@media (max-width: 420px) {
    .brand small {
        display: none;
    }

    .brand-mark {
        width: 42px;
        height: 42px;
    }

    .auth-panel {
        padding: 18px;
    }
}

@media (prefers-reduced-motion: no-preference) {
    .mascot span {
        animation: bob 2.7s ease-in-out infinite;
    }

    @keyframes bob {
        0%, 100% {
            transform: translateY(0) rotate(-5deg);
        }

        50% {
            transform: translateY(-10px) rotate(3deg);
        }
    }
}
