/* Point Taken: navy header, bright blue actions, blue vs pink for the two of you. */

:root {
    --bg: #F1F5FC;
    --surface: #FFFFFF;
    --surface-2: #E9F0FB;
    --ink: #12284D;
    --muted: #64789C;
    --line: #E0E8F5;
    --navy: #14305E;
    --navy-deep: #0E2247;
    --blue: #1F7AE6;
    --blue-soft: #DCEBFD;
    --sky: #7DB9FF;
    --pink: #E64F7B;
    --pink-soft: #FDE2EA;
    --good: #1B9A67;
    --good-soft: #DDF5EA;
    --bad: #DD3B41;
    --bad-soft: #FDE4E5;
    --gold: #F0A21B;
    --gold-soft: #FFF3CF;
    --orange: #E8830A;
    --orange-soft: #FFE8CF;
    --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --r-lg: 24px;
    --r-md: 18px;
    --r-sm: 14px;
    --shadow: 0 6px 16px -10px rgba(20, 48, 94, .35);
    --page: 480px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0A1428;
        --surface: #12203D;
        --surface-2: #1B2C50;
        --ink: #EAF1FF;
        --muted: #93A4C6;
        --line: #22355C;
        --navy: #0F2549;
        --blue: #4A9BFF;
        --blue-soft: #16305A;
        --pink: #FF7A9F;
        --pink-soft: #3B2038;
        --good: #4CCB8D;
        --good-soft: #123528;
        --bad: #FF7076;
        --bad-soft: #3D2024;
        --gold-soft: #3A3117;
        --orange-soft: #40290F;
        --shadow: 0 6px 16px -10px rgba(0, 0, 0, .6);
    }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 600 16px/1.45 var(--font);
    -webkit-tap-highlight-color: transparent;
}
body.has-nav { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: var(--blue); font-weight: 800; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }

.wrap { max-width: var(--page); margin: 0 auto; padding: 0 16px 24px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 14px; margin: 8px 4px 0; }
.center { text-align: center; }

.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- top bar & tab bar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 5;
    padding-top: env(safe-area-inset-top);
    background: var(--navy); color: #fff;
}
.topbar-in {
    display: flex; align-items: center; justify-content: space-between;
    max-width: var(--page); margin: 0 auto; padding: 12px 16px;
}
.brand { font: 900 24px/1 var(--font); letter-spacing: -.02em; }
.brand b { color: var(--sky); font-weight: 900; }
.logo { display: block; max-width: 100%; object-fit: contain; }
.logo-sm { height: 38px; width: auto; }
.logo-lg { height: 108px; width: auto; margin: 0 auto; }
.logo.is-icon { border-radius: 22%; }
.who { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.who form { display: contents; }
.who-btn {
    display: flex; align-items: center; gap: 8px; padding: 3px 10px 3px 3px;
    background: none; border: 0; border-radius: 999px; color: inherit; font: inherit; font-weight: 700;
}
.who-btn:active { background: rgba(255, 255, 255, .14); }
.topbar .icon-btn { color: rgba(255, 255, 255, .8); }
.topbar .icon-btn:active { background: rgba(255, 255, 255, .12); }
.topbar .avatar { border-color: var(--sky); background: #fff; }

.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
    background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar-in {
    display: grid; grid-template-columns: repeat(4, 1fr);
    max-width: var(--page); margin: 0 auto;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.tabbar a {
    display: grid; justify-items: center; gap: 2px; padding: 6px 0;
    text-decoration: none; font-size: 12px; font-weight: 700; color: var(--muted);
}
.tabbar a.is-active { color: var(--blue); font-weight: 900; }
.tabbar a.is-active .i { fill: color-mix(in srgb, var(--blue) 20%, transparent); }

/* ---------- headings ---------- */
.page-title { font: 900 32px/1.1 var(--font); letter-spacing: -.02em; margin: 20px 4px 4px; }
.section-title {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin: 26px 4px 10px;
}
.section-title, .section-title h2 { font: 900 20px/1.2 var(--font); letter-spacing: -.01em; }

/* ---------- scores ---------- */
.scores { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.score {
    position: relative; display: grid; justify-items: center; gap: 2px;
    padding: 18px 10px 16px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
    box-shadow: var(--shadow);
}
.score-name { margin-top: 6px; font-weight: 800; overflow-wrap: anywhere; text-align: center; }
.score-num { font: 900 46px/1.05 var(--font); letter-spacing: -.03em; }
.score-num.pos { color: var(--good); }
.score-num.neg { color: var(--bad); }
.score-num.zero { color: var(--muted); }
.crown { position: absolute; top: -14px; right: 10px; font-size: 26px; transform: rotate(14deg); }
.score.leading { border-color: var(--gold); box-shadow: 0 0 0 2px color-mix(in srgb, var(--gold) 35%, transparent), var(--shadow); }
.verdict { margin-top: 12px; text-align: center; font-weight: 800; color: var(--muted); }

.week {
    display: flex; align-items: center; gap: 12px; margin-top: 16px; padding: 14px 16px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
}
.week-text { display: grid; flex: 1; }
.week-text strong { font-weight: 900; font-size: 17px; }
.week-text small { color: var(--muted); font-size: 14px; }
.week-text .is-alert { color: var(--bad); font-weight: 800; }
.cal-btn {
    display: grid; place-items: center; width: 46px; height: 46px; flex: none;
    border: 0; border-radius: 14px; background: var(--orange-soft); color: var(--orange);
}
.cal-btn:active { transform: scale(.95); }

.alert-card {
    display: grid; gap: 12px; margin-top: 12px; padding: 16px;
    background: var(--gold-soft); border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
    border-radius: var(--r-md);
}
.alert-card strong { font-weight: 900; }

/* ---------- lists (each row is its own card) ---------- */
.group { display: grid; gap: 10px; }
.group > form { display: contents; }

.row {
    display: flex; align-items: center; gap: 12px;
    width: 100%; min-height: 66px; padding: 12px 14px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
    box-shadow: var(--shadow);
}
.row form { display: contents; }
.row-button { text-align: left; }
.row-button:active { transform: scale(.985); }
.row-button.do { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.row-button.dont { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.row-text { display: grid; flex: 1; min-width: 0; }
.row-text strong { font-weight: 800; overflow-wrap: anywhere; }
.row-text small { display: flex; flex-wrap: wrap; gap: 0 12px; color: var(--muted); font-size: 13px; font-weight: 600; }

.pts { font: 900 26px/1 var(--font); letter-spacing: -.02em; min-width: 2ch; text-align: right; }
.pts.pos { color: var(--good); }
.pts.neg { color: var(--bad); }
.pts.zero { color: var(--muted); }

.badge { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 50%; color: #fff; }
.badge .i { stroke-width: 3; }
.badge.do { background: var(--good); }
.badge.dont { background: var(--bad); }

.avatar {
    display: inline-grid; place-items: center; flex: none;
    width: 44px; height: 44px; border-radius: 50%; font-size: 23px;
    border: 2.5px solid var(--ring); background: var(--fill);
}
.avatar.sm { width: 34px; height: 34px; font-size: 18px; border-width: 2px; }
.avatar.lg { width: 66px; height: 66px; font-size: 34px; border-width: 3px; }
.avatar.is-me { --ring: var(--blue); --fill: var(--blue-soft); }
.avatar.is-them { --ring: var(--pink); --fill: var(--pink-soft); }

.wishes { counter-reset: wish; }
.wish-mark {
    counter-increment: wish;
    display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 50%;
    background: var(--blue-soft); color: var(--blue); font-weight: 900;
}
.wish-mark::before { content: counter(wish); }
.row.is-chosen { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.is-chosen .wish-mark { background: var(--good); color: #fff; }
.is-chosen .wish-mark::before { content: '✓'; }

.empty {
    display: block; width: 100%; padding: 18px; text-align: center;
    color: var(--muted); font-size: 15px; font-weight: 700; text-decoration: none;
    background: none; border: 2px dashed var(--line); border-radius: var(--r-md);
}
button.empty:active, a.empty:active { background: var(--surface-2); }

.prize {
    display: grid; gap: 12px; margin-top: 18px; padding: 16px 14px 14px;
    background: var(--gold-soft); border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
    border-radius: var(--r-lg);
}
.prize-head { display: flex; align-items: center; gap: 12px; }
.prize-crown { font-size: 34px; line-height: 1; }
.prize h2 { font: 900 19px/1.2 var(--font); }
.prize .hint, .prize .muted { margin: 0 4px; }

.past {
    display: grid; gap: 14px; margin-top: 16px; padding: 16px 14px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
    box-shadow: var(--shadow);
}
.past-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.past-head h2 { font: 900 21px/1.15 var(--font); }
.past-head small { color: var(--muted); font-weight: 700; }
.past-scores { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.past-score { display: grid; gap: 2px; padding: 12px 14px; border-radius: var(--r-sm); color: #fff; font-weight: 800; }
.past-score.is-me { background: var(--blue); }
.past-score.is-them { background: var(--pink); }
.past-score strong { font: 900 34px/1.05 var(--font); letter-spacing: -.02em; }
.reward-line { font-weight: 700; }
.reward-line em { font-style: normal; color: var(--muted); margin-left: 6px; }
details summary { padding: 4px 0 10px; font-weight: 800; color: var(--blue); cursor: pointer; }
details .group { margin-top: 2px; }
details .row { box-shadow: none; }

/* ---------- buttons & fields ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 50px; padding: 0 20px; border-radius: var(--r-sm);
    border: 2px solid transparent; font-weight: 800; text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn-block { display: flex; width: 100%; }
.btn-sm { min-height: 40px; padding: 0 16px; font-size: 15px; border-radius: 12px; }
.btn-primary { background: var(--blue); color: #fff; box-shadow: 0 8px 16px -8px color-mix(in srgb, var(--blue) 80%, transparent); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-ghost-danger { background: none; border-color: color-mix(in srgb, var(--bad) 30%, transparent); color: var(--bad); }
.btn-danger { background: var(--bad); color: #fff; }

.icon-btn {
    display: grid; place-items: center; flex: none; width: 40px; height: 40px;
    border: 0; border-radius: 50%; background: none; color: var(--muted);
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn.danger { color: var(--bad); }

.stack { margin-top: 20px; }
.stack > * + * { margin-top: 14px; }
.sheet-body > * + * { margin-top: 14px; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 14px; font-weight: 800; color: var(--muted); }
input:not([type=radio]):not([type=checkbox]) {
    width: 100%; min-height: 50px; padding: 0 14px;
    background: var(--surface); border: 2px solid var(--line); border-radius: var(--r-sm);
    font-size: 16px; font-weight: 700;
}
input:focus { outline: none; border-color: var(--blue); }
input[readonly] { background: var(--surface-2); }
.form-error { padding: 12px 14px; border-radius: var(--r-sm); background: var(--bad-soft); color: var(--bad); font-weight: 800; }

.add-row { display: flex; gap: 8px; }
.group + .add-row, .group + .hint { margin-top: 12px; }
.add-row input { flex: 1; }
.add-row .btn { min-height: 50px; }

.stepper { display: grid; grid-template-columns: 50px 1fr 50px; gap: 8px; align-items: center; }
.stepper .icon-btn { width: 50px; height: 50px; border-radius: var(--r-sm); background: var(--surface-2); color: var(--ink); }
.stepper input[type=number] { text-align: center; font: 900 28px/1 var(--font); -moz-appearance: textfield; }
.stepper input[type=number]::-webkit-outer-spin-button, .stepper input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: var(--r-md); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: grid; place-items: center; min-height: 52px; padding: 6px 8px; border-radius: var(--r-sm); text-align: center; font-size: 14px; font-weight: 800; color: var(--muted); }
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .15); }
.seg input[value=do]:checked + span { color: var(--good); }
.seg input[value=dont]:checked + span { color: var(--bad); }
.seg input:focus-visible + span { outline: 3px solid var(--sky); }

.emoji-pick { display: flex; flex-wrap: wrap; gap: 10px; padding: 5px; }
.emoji-pick input { position: absolute; opacity: 0; pointer-events: none; }
.emoji-pick span { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: var(--surface-2); font-size: 24px; }
.emoji-pick input:checked + span { background: var(--blue-soft); box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--blue); }
.emoji-pick input:focus-visible + span { outline: 3px solid var(--sky); }

/* ---------- sign-in hero & invite ---------- */
.hero {
    margin-top: 22px; padding: 36px 22px 32px; text-align: center; color: #fff;
    border-radius: var(--r-lg);
    background: radial-gradient(120% 100% at 50% 0%, #2F66B5 0%, var(--navy) 55%, var(--navy-deep) 100%);
}
.wordmark { font: 900 48px/1 var(--font); letter-spacing: -.03em; }
.wordmark b { color: var(--sky); }
.hero p { margin-top: 10px; color: rgba(255, 255, 255, .85); font-weight: 600; }
.code {
    padding: 14px 10px; text-align: center; color: var(--navy);
    font: 900 32px/1 var(--font); letter-spacing: .2em; text-indent: .2em;
    background: var(--surface); border: 2px dashed var(--blue); border-radius: var(--r-md);
}
@media (prefers-color-scheme: dark) { .code { color: var(--ink); } }

/* ---------- install banner ---------- */
.install {
    position: fixed; z-index: 6; left: 12px; right: 12px; bottom: calc(84px + env(safe-area-inset-bottom));
    display: grid; gap: 10px; max-width: calc(var(--page) - 24px); margin: 0 auto; padding: 14px 16px;
    background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--blue);
    border-radius: var(--r-md); box-shadow: 0 12px 30px -10px rgba(20, 48, 94, .45);
    font-weight: 700;
}
.install-actions { display: flex; gap: 8px; }

/* ---------- sheets & dialogs ---------- */
dialog { border: 0; padding: 0; background: transparent; color: inherit; max-width: none; max-height: none; overflow: visible; }
dialog::backdrop { background: rgba(8, 18, 40, .55); backdrop-filter: blur(3px); }
dialog.sheet { width: 100%; max-width: var(--page); margin: auto auto 0; }
dialog.modal { width: min(92vw, 360px); margin: auto; }
.sheet-body { background: var(--surface); padding: 20px 20px calc(24px + env(safe-area-inset-bottom)); }
.sheet .sheet-body { border-radius: var(--r-lg) var(--r-lg) 0 0; animation: sheet-up .25s cubic-bezier(.2, .8, .2, 1); }
.modal .sheet-body { border-radius: var(--r-lg); padding-bottom: 20px; animation: pop .18s ease-out; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h3, .modal h3 { font: 900 24px/1.15 var(--font); letter-spacing: -.01em; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }

[data-edit-only], [data-new-only] { display: none; }
dialog[data-mode=edit] span[data-edit-only], dialog[data-mode=new] span[data-new-only] { display: inline; }
dialog[data-mode=edit] form[data-edit-only] { display: block; }

/* ---------- toast ---------- */
.toast {
    position: fixed; z-index: 20; left: 50%; top: calc(74px + env(safe-area-inset-top));
    transform: translateX(-50%);
    max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 999px;
    background: var(--navy); color: #fff; font-weight: 800; text-align: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
    animation: toast 3.6s ease forwards; pointer-events: none;
}
.toast-bad { background: var(--bad); }
@keyframes toast {
    0% { opacity: 0; transform: translate(-50%, -12px); }
    8%, 80% { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, -8px); visibility: hidden; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; }
}
