:root {
  --bg0: #0f0c1d;
  --bg1: #1b1533;
  --card: rgba(255, 255, 255, .06);
  --line: rgba(160, 130, 255, .22);
  --text: #efeaff;
  --muted: rgba(239, 234, 255, .62);
  --violet: #8b5cf6;
  --pink: #ec4899;
  --gold: #facc15;
  --green: #22c55e;
  --red: #ef4444;
  --grad: linear-gradient(90deg, var(--violet), var(--pink));
  --tabs-h: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 50% -10%, #2a1f4d, var(--bg0) 55%) fixed, var(--bg0);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.35;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, textarea, select {
  font: inherit; color: var(--text); width: 100%;
  background: rgba(255,255,255,.07); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; outline: none;
}
input:focus, textarea:focus { border-color: var(--violet); }
textarea { resize: none; min-height: 84px; }
.hidden { display: none !important; }

#app { padding: 16px 16px calc(var(--tabs-h) + 24px); max-width: 520px; margin: 0 auto; }

/* loading */
.loading { min-height: 80vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--muted); letter-spacing: .1em; }
.orb { width: 54px; height: 54px; border-radius: 50%; background: var(--grad); animation: pulse 1.2s infinite ease-in-out; }
@keyframes pulse { 50% { transform: scale(.8); opacity: .6; } }

/* building blocks */
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.h1 { font-size: 22px; font-weight: 800; margin: 4px 0 2px; }
.h2 { font-size: 17px; font-weight: 700; margin: 18px 0 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px; margin-top: 12px; }
.card.glow { box-shadow: 0 0 0 1px rgba(236,72,153,.35), 0 8px 30px rgba(139,92,246,.25); }
.label { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.btn { display: block; width: 100%; padding: 13px; border-radius: 14px; font-weight: 700; text-align: center; background: var(--grad); color: #fff; margin-top: 12px; transition: transform .08s; }
.btn:active { transform: scale(.97); }
.btn.ghost { background: rgba(255,255,255,.08); color: var(--text); font-weight: 600; }
.btn.small { padding: 9px; font-size: 14px; margin-top: 8px; }
.btn:disabled { opacity: .45; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 11px; background: rgba(255,255,255,.08); }
.chip.gold { background: rgba(250,204,21,.15); color: var(--gold); }
.chip.green { background: rgba(34,197,94,.15); color: #86efac; }
.bar { height: 8px; border-radius: 6px; background: #2e2650; overflow: hidden; }
.bar > div { height: 100%; border-radius: 6px; background: var(--grad); transition: width .6s ease; }
.bar.red > div { background: linear-gradient(90deg, #f97316, var(--red)); }
.bar.green > div { background: linear-gradient(90deg, #16a34a, var(--green)); }

/* hero */
.top { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); }
.top .gear { font-size: 20px; padding: 4px; }
.avatar { width: 116px; height: 116px; border-radius: 50%; margin: 8px auto 8px; display: flex; align-items: center; justify-content: center; }
.avatar span { width: 98px; height: 98px; border-radius: 50%; background: var(--bg1); display: flex; align-items: center; justify-content: center; font-size: 50px; }
.center { text-align: center; }
.title-tag { color: #c4b5fd; font-size: 13px; font-weight: 600; }
.quest { position: relative; }
.quest.done { opacity: .55; }
.quest .q-text { font-weight: 650; font-size: 16px; }
.quest .q-meta { margin-top: 4px; }
.quest .q-actions { display: flex; gap: 8px; }
.quest .q-actions .btn { margin-top: 10px; }
.quest .q-actions .btn.ghost { flex: 0 0 52px; }
.timer { margin-top: 8px; color: var(--muted); }
.timer.urgent { color: #fca5a5; font-weight: 600; }
.branches .b { margin-top: 10px; }
.banner { background: linear-gradient(135deg, rgba(250,204,21,.18), rgba(236,72,153,.15)); border: 1px solid rgba(250,204,21,.35); }

/* tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: flex; background: rgba(15,12,29,.96); border-top: 1px solid var(--line); backdrop-filter: blur(8px); z-index: 10; }
.tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 10px; opacity: .5; }
.tabs button i { font-style: normal; font-size: 20px; }
.tabs button.on { opacity: 1; }
.tabs button.on span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 700; }

/* lists */
.member { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.05); }
.member:last-child { border-bottom: 0; }
.member .ava { width: 36px; height: 36px; border-radius: 50%; background: var(--bg1); display: flex; align-items: center; justify-content: center; font-size: 18px; border: 2px solid var(--line); }
.member .ava.ok { border-color: var(--green); }
.feed { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow-y: auto; padding: 4px 2px; }
.msg { max-width: 85%; padding: 8px 12px; border-radius: 14px; background: rgba(255,255,255,.07); align-self: flex-start; }
.msg.mine { align-self: flex-end; background: rgba(139,92,246,.28); }
.msg .who { font-size: 11px; color: #c4b5fd; margin-bottom: 2px; }
.msg.report { border: 1px solid rgba(250,204,21,.3); max-width: 100%; align-self: stretch; }
.like { margin-top: 6px; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.08); font-size: 13px; }
.like.on { background: rgba(236,72,153,.3); }
.send { display: flex; gap: 8px; margin-top: 10px; }
.send input { flex: 1; }
.send .btn { width: auto; margin: 0; padding: 0 16px; }

/* awards */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.ach { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 6px; text-align: center; font-size: 11px; }
.ach .e { font-size: 30px; margin-bottom: 4px; }
.ach.locked { opacity: .35; filter: grayscale(1); }
.ach.active { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }

/* onboarding */
.step { min-height: 78vh; display: flex; flex-direction: column; justify-content: center; }
.big { font-size: 64px; text-align: center; }
.dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 18px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.18); }
.dots i.on { background: var(--pink); width: 22px; border-radius: 6px; }
.pick { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); margin-top: 10px; width: 100%; text-align: left; }
.pick.on { border-color: var(--pink); background: rgba(236,72,153,.12); }
.pick i { font-style: normal; font-size: 24px; }
.seg { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 12px; }
.seg button { padding: 14px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); font-weight: 600; }
.seg button.on { border-color: var(--pink); background: rgba(236,72,153,.15); }
.seg.three { grid-template-columns: repeat(3, 1fr); }

/* sheet & toast */
.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.6); animation: fade .2s; }
.sheet-body { position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow-y: auto; background: #18122e; border-radius: 24px 24px 0 0; padding: 20px 18px calc(24px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); animation: up .25s ease; }
.sheet-body .x { position: absolute; right: 14px; top: 12px; font-size: 22px; opacity: .6; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + 18px); background: #2a1f4d; border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; z-index: 30; font-size: 14px; animation: fade .2s; max-width: 90vw; }

/* reward */
.reward { text-align: center; }
.reward .xp { font-size: 46px; font-weight: 900; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; animation: pop .5s ease; }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.15); } }
.reward .line { margin-top: 8px; font-size: 15px; }
.reward .ach-got { margin-top: 10px; padding: 10px; border-radius: 14px; background: rgba(250,204,21,.12); border: 1px solid rgba(250,204,21,.35); }

/* chains */
.chain { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 2px 0 8px; font-size: 12px; color: #c4b5fd; font-weight: 600; }
.chain .steps { display: flex; gap: 4px; }
.chain .steps i { width: 14px; height: 6px; border-radius: 3px; background: #2e2650; }
.chain .steps i.ok { background: var(--green); }
.chain .steps i.now { background: var(--gold); }

/* rank */
.avatar.rank { box-shadow: 0 0 34px -6px var(--rank); }
.rank-name { font-size: 13px; font-weight: 700; letter-spacing: .02em; }

/* stats */
.heat { display: grid; grid-template-rows: repeat(7, 1fr); grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; }
.heat i { aspect-ratio: 1; border-radius: 3px; background: #2e2650; }
.heat i.on { background: var(--green); box-shadow: 0 0 6px rgba(34,197,94,.5); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; margin-top: 8px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: 10px; }
.bars .v { width: 100%; border-radius: 6px 6px 2px 2px; background: var(--grad); min-height: 3px; }
.bars span { margin-top: 3px; color: var(--text); }
.bars em { font-style: normal; color: var(--muted); }
.big-num { font-size: 22px; }

/* photos */
.ph { display: block; width: 100%; max-height: 260px; object-fit: cover; border-radius: 12px; margin: 6px 0; cursor: zoom-in; }
label.btn { cursor: pointer; }

/* celebration */
.celebrate { position: fixed; inset: 0; z-index: 40; background: radial-gradient(circle at 50% 40%, rgba(139,92,246,.45), rgba(10,8,20,.96) 70%); display: flex; align-items: center; justify-content: center; animation: fade .25s; overflow: hidden; }
.cel-body { text-align: center; padding: 24px; width: min(360px, 92vw); position: relative; z-index: 2; }
.cel-ava { font-size: 84px; width: 150px; height: 150px; margin: 0 auto 14px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: #1b1533; box-shadow: 0 0 0 4px var(--rank, var(--pink)), 0 0 60px var(--rank, var(--pink)); animation: pop .6s ease; }
.cel-title { font-size: 34px; font-weight: 900; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.cel-sub { font-size: 17px; font-weight: 700; margin-top: 6px; }
.confetti i { position: absolute; top: -40px; font-style: normal; font-size: 22px; animation: fall 2.6s linear infinite; }
@keyframes fall { to { transform: translateY(110vh) rotate(360deg); } }

/* paths & stages */
:root { --s1: #22c55e; --s2: #3b82f6; --s3: #ec4899; }
.stage-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; margin-bottom: 6px; }
.stage-chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; color: #0f0c1d; }
.stage-chip.s1 { background: var(--s1); } .stage-chip.s2 { background: var(--s2); color: #fff; } .stage-chip.s3 { background: var(--s3); color: #fff; }
.bar.thin { height: 6px; margin: 4px 0 10px; }
.bar.thick { height: 12px; margin-top: 12px; }
.bar.s1 > div { background: var(--s1); } .bar.s2 > div { background: var(--s2); } .bar.s3 > div { background: var(--s3); }
.bar .grow { width: var(--w); animation: grow 1s ease; }
@keyframes grow { from { width: 0; } }
.card.path.main { border-color: rgba(250, 204, 21, .35); }
.pips { display: flex; gap: 6px; margin: 10px 0 8px; }
.pip { flex: 1; text-align: center; font-size: 11px; padding: 5px 0; border-radius: 8px; background: #2e2650; color: var(--muted); }
.pip.done { color: #0f0c1d; font-weight: 700; } .pip.s1.done { background: var(--s1); } .pip.s2.done { background: var(--s2); color: #fff; } .pip.s3.done { background: var(--s3); color: #fff; }
.pip.now { color: var(--text); font-weight: 700; box-shadow: inset 0 0 0 2px currentColor; }
.pip.s1.now { color: var(--s1); } .pip.s2.now { color: var(--s2); } .pip.s3.now { color: var(--s3); }
.pip.pop { animation: pop .7s ease .4s both; }
.cel-stages { display: flex; gap: 6px; margin: 14px 0 6px; }
.quest.glow { animation: breathe 3s ease-in-out infinite; }
@keyframes breathe { 50% { box-shadow: 0 0 0 1px rgba(236,72,153,.5), 0 10px 40px rgba(139,92,246,.45); } }
.card { animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.diary .ph { margin-top: 8px; }
.card.path.tap { cursor: pointer; transition: transform .1s; }
.card.path.tap:active { transform: scale(.98); }
.card.path .take { margin-top: 8px; font-size: 12px; font-weight: 700; color: #c4b5fd; text-align: right; }
.btn:disabled { background: rgba(255,255,255,.1); color: var(--muted); }

/* guilds */
.stages { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.st { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,.06); }
.st.s1 { color: var(--s1); } .st.s2 { color: var(--s2); } .st.s3 { color: var(--s3); } .st.s4 { color: var(--gold); }
.filters { display: flex; gap: 6px; overflow-x: auto; margin: 12px 0 10px; padding-bottom: 2px; }
.filters .chip { flex: none; padding: 6px 11px; font-size: 12px; border: 1px solid var(--line); }
.filters .chip.on { background: rgba(236,72,153,.18); border-color: var(--pink); }
.card.player, .member.tap { cursor: pointer; }
.card.player .btn.small, .card.guild .btn.small { margin-top: 10px; }

.task-row { display: grid; grid-template-columns: minmax(0, 1fr) 1.4fr auto; align-items: center; gap: 10px; margin-top: 8px; font-size: 13px; }
.task-row span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn.danger { color: #fca5a5; border-color: rgba(239,68,68,.45); }
.btn.danger:not(.ghost) { background: var(--red); color: #fff; }
.guild-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.guild-actions .chip { padding: 6px 11px; font-size: 12px; border: 1px solid var(--line); }
.why { margin-top: 8px; padding: 9px 11px; border-radius: 12px; background: rgba(139,92,246,.10); border: 1px solid var(--line); font-size: 13px; line-height: 1.45; color: var(--muted); }
.why b { color: var(--text); font-weight: 600; }
