*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand-strong); }
img { max-width: 100%; display: block; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- shell ---------- */
.app { max-width: 560px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px);
}
.brandmark { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: -.01em; flex: 1; min-width: 0; }
.brandmark .logo { width: 30px; height: auto; flex: 0 0 30px; }
.brandmark small { display: block; font-weight: 600; color: var(--text-3); font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
.iconbtn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--surface); box-shadow: var(--shadow);
  display: grid; place-items: center; position: relative; color: var(--text);
}
.iconbtn .dot { position: absolute; top: 9px; right: 10px; width: 9px; height: 9px; border-radius: 50%; background: var(--warm); border: 2px solid var(--surface); }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center; font-weight: 800; font-size: 14px;
  color: #fff; background: linear-gradient(135deg, var(--ink-2), var(--ink)); box-shadow: var(--shadow);
}
.demo-ribbon { background: var(--sun); color: #3b2a00; font-size: 12px; font-weight: 700; text-align: center; padding: 4px 8px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; justify-content: center;
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar nav { display: grid; grid-template-columns: repeat(5, 1fr); width: 100%; max-width: 560px; }
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px 12px; color: var(--text-3);
  text-decoration: none; font-size: 11.5px; font-weight: 600; min-height: 60px;
}
.tabbar a[aria-current="page"] { color: var(--brand-strong); }
.tabbar a[aria-current="page"] svg { stroke-width: 2.4; }

main.page { padding: 4px 16px 24px; }
.page-title { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin: 8px 0 16px; }
.section-title { font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); margin: 28px 0 10px; display: flex; justify-content: space-between; align-items: center; }
.section-title a { font-size: 13px; letter-spacing: 0; text-transform: none; text-decoration: none; font-weight: 700; }

/* ---------- cards ---------- */
.card { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 12px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.muted { color: var(--text-2); }
.tiny { font-size: 12.5px; color: var(--text-3); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }

.hero {
  position: relative; overflow: hidden; border-radius: 28px; padding: 22px 20px 20px; color: #fff;
  background: radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--brand) 70%, transparent), transparent 60%),
              radial-gradient(90% 80% at 0% 100%, color-mix(in srgb, var(--warm) 45%, transparent), transparent 60%), var(--ink);
  box-shadow: var(--shadow-lg);
}
.hero .eyebrow { font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; opacity: .8; }
.hero h2 { font-size: 30px; line-height: 1.05; letter-spacing: -.02em; margin: 10px 0 10px; font-weight: 900; }
.hero p { margin: 0 0 16px; opacity: .92; }
.hero .meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.hero .chip { background: rgba(255, 255, 255, .14); color: #fff; }
.hero.done { background: radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--care) 60%, transparent), transparent 60%), var(--ink); }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.chip .sw { width: 8px; height: 8px; border-radius: 50%; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
button.chip { border: 1px solid var(--line); background: var(--surface); min-height: 36px; padding: 6px 14px; }
button.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 12px 20px;
  border-radius: 999px; border: 0; font-weight: 800; letter-spacing: .01em; background: var(--brand); color: var(--on-brand); text-decoration: none;
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: scale(.98); }
.btn.block { width: 100%; }
.btn.big { min-height: 56px; font-size: 17px; }
.btn.light { background: #fff; color: var(--ink); }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.outline { background: transparent; border: 1.5px solid var(--line); color: var(--text); }
.btn.care { background: var(--care); }
.btn.danger { background: var(--danger); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn.small { min-height: 36px; padding: 6px 14px; font-size: 14px; }
.linkbtn { background: none; border: 0; color: var(--brand-strong); font-weight: 700; padding: 8px 0; }

/* mission list items */
.mission {
  display: flex; gap: 14px; align-items: flex-start; background: var(--surface); border-radius: var(--r); padding: 14px;
  box-shadow: var(--shadow); border: 0; width: 100%; text-align: left;
}
.mission + .mission { margin-top: 10px; }
.mission .badge { flex: 0 0 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-strong); }
.mission.t-secret .badge, .mission.t-flash .badge { background: var(--warm-soft); color: var(--warm); }
.mission.t-collective .badge { background: #fff3d6; color: #b77900; }
.mission.is-done .badge { background: var(--care-soft); color: var(--care); }
.mission .body { flex: 1; min-width: 0; }
.mission h3 { margin: 0 0 3px; font-size: 15.5px; font-weight: 800; letter-spacing: .01em; }
.mission p { margin: 0; color: var(--text-2); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mission .pts { font-weight: 800; color: var(--brand-strong); font-size: 14px; white-space: nowrap; }
.mission.is-done .pts { color: var(--care); }
.mission.is-ended:not(.is-done) { opacity: .6; }

/* stats */
.stat { background: var(--surface); border-radius: var(--r); padding: 12px 4px; min-width: 0; box-shadow: var(--shadow); text-align: center; }
.stat b { display: block; font-size: 22px; font-weight: 900; letter-spacing: -.02em; }
.stat span { display: block; font-size: 11.5px; color: var(--text-3); font-weight: 700; overflow: hidden; text-overflow: ellipsis; }

.meter { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; position: relative; }
.meter > i { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--warm)); }
.meter .tick { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--surface); opacity: .9; }

.team-card { display: flex; gap: 14px; align-items: center; }
.team-emblem { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 24px; color: #fff; font-weight: 900; flex: 0 0 52px; }

/* scoreboard */
.rank-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); }
.rank-row + .rank-row { margin-top: 8px; }
.rank-row.mine { outline: 2.5px solid var(--brand); }
.rank-pos { width: 32px; font-weight: 900; font-size: 20px; text-align: center; color: var(--text-3); }
.rank-row:nth-child(1) .rank-pos { color: var(--brand-strong); }
.rank-row .grow { flex: 1; min-width: 0; }
.rank-row .score { font-weight: 900; font-size: 18px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); padding: 4px; border-radius: 999px; gap: 4px; }
.seg button { border: 0; background: transparent; padding: 10px 4px; border-radius: 999px; font-weight: 700; font-size: 14px; color: var(--text-2); min-height: 40px; min-width: 0; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* mural */
.post { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; }
.post + .post { margin-top: 12px; }
.post .head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 8px; }
.post .who { font-weight: 800; font-size: 14.5px; }
.post .ctx { font-size: 12.5px; color: var(--text-3); }
.post .txt { padding: 0 14px 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.post .img { background: var(--surface-2); aspect-ratio: 4/3; }
.post .img img { width: 100%; height: 100%; object-fit: cover; }
.post .actions { display: flex; gap: 6px; padding: 10px 12px 12px; flex-wrap: wrap; align-items: center; }
.react { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 700; min-height: 36px; color: var(--text-2); }
.react[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand-strong); color: var(--brand-strong); }
.post .more { margin-left: auto; }
.mini-avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 12px; color: #fff; background: var(--ink-2); flex: 0 0 34px; }
.mini-avatar.anon { background: var(--surface-2); color: var(--text-3); }
.pill-status { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--warm-soft); color: var(--warm); }

/* achievements */
.ach-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ach { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 8px 12px; text-align: center; border: 0; }
.ach .medal { width: 58px; height: 58px; margin: 0 auto 8px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--text-3); }
.ach.on .medal { background: linear-gradient(135deg, var(--brand), var(--warm)); color: var(--on-brand); box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 35%, transparent); }
.ach.secret.on .medal { background: linear-gradient(135deg, var(--ink-2), var(--sun)); }
.ach b { display: block; font-size: 12.5px; line-height: 1.2; }
.ach small { display: block; font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* sheets & dialogs */
.scrim { position: fixed; inset: 0; background: rgba(10, 8, 24, .5); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.sheet { background: var(--surface); width: 100%; max-width: 560px; border-radius: 28px 28px 0 0; padding: 12px 20px calc(24px + env(safe-area-inset-bottom)); max-height: 92vh; overflow: auto; animation: up .2s ease; }
.sheet .grab { width: 44px; height: 5px; border-radius: 999px; background: var(--line); margin: 0 auto 14px; }
.sheet h2 { margin: 4px 0 8px; font-size: 22px; letter-spacing: -.01em; }
@media (min-width: 700px) { .scrim { align-items: center; } .sheet { border-radius: 28px; } }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

.celebrate { text-align: center; padding: 8px 0 4px; }
.celebrate .big { font-size: 56px; font-weight: 900; letter-spacing: -.03em; background: linear-gradient(135deg, var(--brand), var(--warm)); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1.1; }
.burst { width: 88px; height: 88px; margin: 6px auto 10px; border-radius: 50%; display: grid; place-items: center; color: var(--on-brand); background: linear-gradient(135deg, var(--warm), var(--brand)); animation: pop .4s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }

.field { display: block; margin: 14px 0; }
.field > span { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.input, textarea.input, select.input {
  width: 100%; min-height: var(--tap); padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); font-size: 16px;
}
textarea.input { min-height: 110px; resize: vertical; }
.input:focus { border-color: var(--brand-strong); outline: none; }
.otp { letter-spacing: .5em; text-align: center; font-size: 26px; font-weight: 800; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; }
.switch input { width: 48px; height: 28px; appearance: none; background: var(--line); border-radius: 999px; position: relative; flex: 0 0 48px; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { left: 23px; }
.notice { background: var(--brand-soft); color: var(--text); border-radius: var(--r); padding: 12px 14px; font-size: 14px; }
.notice.warm { background: var(--warm-soft); }
.notice.care { background: var(--care-soft); }

.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; z-index: 60; box-shadow: var(--shadow-lg); max-width: calc(100% - 32px); font-weight: 600; animation: up .2s ease; }
.toast.err { background: var(--danger); }

.empty { text-align: center; padding: 32px 16px; color: var(--text-2); }
.empty svg { margin: 0 auto 10px; color: var(--text-3); }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--r); min-height: 80px; }
.skeleton + .skeleton { margin-top: 12px; }
@keyframes sk { to { background-position: -200% 0; } }

/* login */
.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: space-between; padding: 24px 20px calc(24px + env(safe-area-inset-bottom)); max-width: 480px; margin: 0 auto; }
.login .splash { margin-top: 6vh; }
.login h1 { font-size: 44px; line-height: .98; letter-spacing: -.035em; margin: 18px 0 12px; font-weight: 900; }
.login h1 em { font-style: normal; background: linear-gradient(135deg, var(--brand), var(--warm)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.orbit { width: 72px; height: 72px; border-radius: 22px; background: linear-gradient(135deg, var(--brand), var(--warm)); display: grid; place-items: center; color: #fff; box-shadow: var(--shadow-lg); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: 13px; margin: 14px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.bars { display: flex; align-items: flex-end; gap: 8px; height: 110px; padding-top: 8px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bars .b i { width: 100%; border-radius: 8px 8px 4px 4px; background: linear-gradient(180deg, var(--brand), var(--ink-2)); min-height: 4px; }
.bars .b.cur i { background: linear-gradient(180deg, var(--warm), var(--brand)); }
.bars .b small { font-size: 11px; color: var(--text-3); font-weight: 700; }

.count-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.count-grid div { background: rgba(255,255,255,.12); border-radius: 14px; padding: 10px 4px; }
.count-grid b { display: block; font-size: 28px; font-weight: 900; }
.count-grid span { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .8; }

.loader { display: grid; place-items: center; min-height: 60vh; color: var(--text-3); }
.spin { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--brand-strong); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.row > svg, .row > a > svg { flex: 0 0 auto; }

.brand-logo { height: 34px; width: auto; display: block; }
.btn.danger { color: #fff; }
.btn.care { color: #fff; }
.hero .chip .sw { box-shadow: 0 0 0 2px rgba(255,255,255,.25); }
