:root {
  --bg: #0B1220;
  --card: #141D33;
  --card-border: #26314F;
  --row: #1A2440;
  --row-deep: #10182B;
  --text: #ECE6D6;
  --soft: #D4CCBA;
  --soft2: #B7BFCD;
  --muted: #A7AFBF;
  --muted2: #8F98AB;
  --gold: #D9B66F;
  --flame: #E8A35A;
  --flame-text: #F1C78E;
  --track: #2A3554;
  --line: #3A4766;
  --ring: #4A5778;
  --links: #7FB2E5;
  --body: #E0965A;
  --order: #7CC2A8;
  --energy: #C3A8EC;
  --serif: 'Cormorant Garamond', Georgia, serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body {
  color: var(--text);
  font-family: Manrope, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input, textarea, select { font-family: inherit; font-size: 16px; }
a { color: var(--gold); }

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px calc(96px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.serif { font-family: var(--serif); font-weight: 700; }
.eyebrow { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.label { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted2); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }

.header { display: flex; justify-content: space-between; align-items: flex-end; padding: 4px 4px 0; gap: 12px; }
.header h1 { margin: 0; font-family: var(--serif); font-weight: 700; font-size: 34px; line-height: 1.05; color: var(--gold); }
.stack { display: flex; flex-direction: column; gap: 2px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px;
  border-radius: 999px; background: var(--row); border: 1px solid #2E3A5C;
  font-weight: 700; color: var(--flame-text);
}

.card {
  background: var(--card); border: 1px solid var(--card-border); border-radius: 18px;
  padding: 18px 16px; display: flex; flex-direction: column; gap: 16px;
}
.card h2 { margin: 0; font-family: var(--serif); font-size: 26px; font-weight: 700; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.group { display: flex; flex-direction: column; gap: 8px; }

.quest {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px;
  background: var(--row); border: 0; color: inherit; text-align: left; width: 100%; cursor: pointer;
}
.quest:disabled { cursor: default; }
.quest .check {
  flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--ring);
  display: flex; align-items: center; justify-content: center;
}
.quest.done .check { background: var(--gold); border-color: var(--gold); }
.quest .body { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.quest .title { font-size: 15px; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.quest .xp { font-size: 13px; font-weight: 700; color: var(--muted2); }
.quest.done .xp { color: var(--gold); }
.empty { padding: 12px; border-radius: 12px; border: 1px dashed var(--line); font-size: 14px; color: var(--muted); line-height: 1.4; }
.note { display: flex; gap: 10px; padding: 12px; border-radius: 12px; background: var(--row-deep); font-size: 13px; line-height: 1.45; color: var(--soft2); }

.v-links { color: var(--links); } .v-body { color: var(--body); } .v-order { color: var(--order); } .v-energy { color: var(--energy); }

.streak-head { display: flex; align-items: center; gap: 12px; }
.streak-head .big { font-family: var(--serif); font-size: 28px; font-weight: 700; line-height: 1; color: var(--flame-text); }
.strip { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 5px; }
.strip span { height: 18px; border-radius: 5px; background: var(--track); }
.strip .on { background: var(--flame); }
.strip .shield { background: transparent; border: 2px solid var(--soft2); }
.strip .today { background: transparent; border: 2px dashed var(--flame); }

.runes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.rune {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px;
  border-radius: 12px; background: var(--row); border: 1px dashed var(--line);
  font-size: 12px; font-weight: 600; color: var(--muted2);
}
.rune .dot { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); }
.rune.lit { border-style: solid; }
.rune.lit .dot { border: 0; }
.rune.lit.links { background: #1F2D4D; border-color: var(--links); color: var(--links); } .rune.lit.links .dot { background: var(--links); }
.rune.lit.body { background: #3A2A20; border-color: var(--body); color: var(--body); } .rune.lit.body .dot { background: var(--body); }
.rune.lit.order { background: #17302A; border-color: var(--order); color: var(--order); } .rune.lit.order .dot { background: var(--order); }
.rune.lit.energy { background: #251E33; border-color: var(--energy); color: var(--energy); } .rune.lit.energy .dot { background: var(--energy); }

.bar { height: 6px; border-radius: 999px; background: var(--track); overflow: hidden; }
.bar.thick { height: 8px; }
.bar > div { height: 100%; background: var(--gold); }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; }
.shield-pill {
  flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--line); font-size: 12px; font-weight: 600; color: var(--soft2);
}

.hero { display: flex; align-items: center; gap: 14px; }
.avatar {
  flex: none; width: 60px; height: 60px; border-radius: 50%; border: 2px solid var(--gold);
  display: flex; align-items: center; justify-content: center; font-family: var(--serif);
  font-size: 28px; font-weight: 700; color: var(--gold); overflow: hidden; background: transparent;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.avatar.lg { width: 72px; height: 72px; font-size: 34px; }
.avatar.sm { width: 38px; height: 38px; font-size: 16px; border-color: var(--ring); color: var(--soft2); }
.avatar.sm.me { border-color: var(--gold); color: var(--gold); }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 54px; width: 100%;
  border-radius: 14px; background: var(--gold); color: var(--bg); font-size: 16px; font-weight: 700;
  border: 0; text-decoration: none; cursor: pointer;
}
.btn.outline { background: transparent; border: 1px solid var(--gold); color: var(--gold); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); min-height: 44px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }

.board { padding: 8px 12px; gap: 0; }
.player { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid #222C47; }
.player:last-child { border-bottom: 0; }
.player.me { background: var(--row); border-radius: 10px; }
.player .rank { flex: none; width: 20px; font-size: 14px; font-weight: 700; color: var(--muted); }
.player.top .rank { color: var(--gold); }
.player .streak { font-size: 16px; font-weight: 700; color: var(--flame-text); }
.mini-runes { display: flex; gap: 4px; }
.mini-runes span { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line); }
.mini-runes .links { background: var(--links); border: 0; } .mini-runes .body { background: var(--body); border: 0; }
.mini-runes .order { background: var(--order); border: 0; } .mini-runes .energy { background: var(--energy); border: 0; }
.ladder div { display: flex; justify-content: space-between; font-size: 14px; color: var(--soft); }
.ladder .current { color: var(--gold); font-weight: 700; }
.invite-box { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 12px; background: var(--row); font-size: 14px; word-break: break-all; }

.survey-choice { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.survey-choice legend { font-size: 13px; color: var(--soft2); margin-bottom: 6px; padding: 0; }
.survey-choice label { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--row); border: 1px solid transparent; font-size: 14px; cursor: pointer; }
.survey-choice label.on { border-color: var(--gold); }
.survey-choice input { position: absolute; opacity: 0; pointer-events: none; }
.survey-choice .lvl { flex: none; width: 26px; height: 26px; border-radius: 8px; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: var(--muted); }
.survey-choice label.on .lvl { background: var(--gold); border-color: var(--gold); color: var(--bg); }
.xp-link { width: 100%; padding: 12px; border-radius: 12px; background: var(--row); border: 0; color: inherit; cursor: pointer; font-size: 15px; }
.reward-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; text-align: left; background: none; border: 0; color: inherit; padding: 0; cursor: pointer; }
.reward-body .title { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.tabs button { max-width: 120px; }
.stat { padding: 16px; gap: 10px; border-radius: 16px; cursor: pointer; }
.stat-head { display: flex; align-items: center; gap: 14px; }
.stat-level {
  flex: none; width: 52px; height: 52px; border-radius: 12px; border: 1px solid;
  display: flex; align-items: center; justify-content: center; font-family: var(--serif); font-size: 28px; font-weight: 700;
}
.stat-name { font-size: 17px; font-weight: 700; }
.stat-note { font-size: 13px; color: var(--soft2); overflow-wrap: anywhere; white-space: pre-line; }
.levels { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; }
.levels button {
  min-height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--row);
  color: var(--text); font-weight: 700; cursor: pointer; padding: 0;
}
.levels button.on { background: var(--gold); color: var(--bg); border-color: var(--gold); }
textarea, input[type=text], input[type=number], input[type=password] {
  width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-size: 16px;
}
textarea { min-height: 84px; resize: vertical; line-height: 1.4; }
.form { display: flex; flex-direction: column; gap: 10px; }
.btn-row { display: flex; gap: 8px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center; gap: 4px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: rgba(11, 18, 32, .96); border-top: 1px solid var(--card-border);
}
.tabs button {
  flex: 1; max-width: 160px; min-height: 48px; border: 0; border-radius: 12px; background: transparent;
  color: var(--muted); font-size: 13px; font-weight: 600; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; cursor: pointer;
}
.tabs button.on { color: var(--gold); background: var(--row); }

.login { min-height: 100vh; padding: 72px 24px 32px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; max-width: 480px; margin: 0 auto; }
.login h1 { margin: 0; font-family: var(--serif); font-size: 44px; font-weight: 700; line-height: 1; color: var(--gold); }
.orbit { position: relative; width: 120px; height: 120px; margin: 0 auto; }
.orbit span { position: absolute; border-radius: 50%; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted2); font-size: 12px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--card-border); }
.error { color: #F08A7E; font-size: 14px; line-height: 1.4; }
.center { text-align: center; }
.loading { min-height: 60vh; display: flex; align-items: center; justify-content: center; color: var(--muted); }

/* Shadow */
.shadow { --bg: #07070C; --text: #E6E1EE; --muted: #9C95AE; --line: #3A3450; --acc: #B9A6E6; }
body.shadow-on { background: #07070C; }
.shadow .app { gap: 16px; }
.shadow h1 { margin: 0; font-family: var(--serif); font-weight: 700; font-size: 40px; line-height: 1; color: var(--acc); }
.s-card { padding: 16px; border-radius: 16px; background: #100E17; border: 1px solid #24202F; display: flex; flex-direction: column; gap: 12px; }
.s-card .title { font-size: 16px; font-weight: 700; }
.s-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.s-grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.s-cell { display: flex; flex-direction: column; gap: 4px; padding: 12px; border-radius: 12px; background: #17131F; font-size: 13px; color: #C9C2D8; }
.s-cell input, .s-row input, .shadow input[type=text], .shadow input[type=password] { background: #0E0C14; border-color: #2E2A3D; color: #E6E1EE; }
.s-cell input, .s-row input { min-height: 44px; padding: 8px 10px; }
.s-cell .prev { font-size: 11px; color: var(--muted); }
.s-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px; color: #C9C2D8; }
.s-row input { width: 96px; flex: none; text-align: right; }
.s-btn { min-height: 48px; border-radius: 14px; border: 1px solid #2E2A3D; background: transparent; color: #C9C2D8; font-size: 14px; font-weight: 600; padding: 0 14px; cursor: pointer; }
.s-btn.primary { background: var(--acc); color: #07070C; border-color: var(--acc); }
.pin { letter-spacing: .4em; text-align: center; font-size: 24px !important; }
