/* =========================================================================
   Scripture Quest — design system v2 "Morning Trail"
   Warm paper, marigold & terracotta, Ensign Sans, crafted SVG art,
   hand-tuned motion. Light-first; dark is a warm candlelit night.
   ========================================================================= */

/* Ensign Sans from the Church type foundry (Latin ranges) */
@font-face {
  font-family: 'Ensign Sans';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  unicode-range: u+9-d, u+20-7e;
  src: url('https://foundry.churchofjesuschrist.org/Foundry/v1/Ensign:Sans:300@en/f00.woff2') format('woff2');
}
@font-face {
  font-family: 'Ensign Sans';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  unicode-range: u+85, u+a0-ff;
  src: url('https://foundry.churchofjesuschrist.org/Foundry/v1/Ensign:Sans:300@en/f01.woff2') format('woff2');
}
@font-face {
  font-family: 'Ensign Sans';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  unicode-range: u+2002-2015, u+2017-2033, u+2039-203a, u+203c, u+203e, u+2042, u+2044, u+2060-206f;
  src: url('https://foundry.churchofjesuschrist.org/Foundry/v1/Ensign:Sans:300@en/f27.woff2') format('woff2');
}

:root {
  --font: 'Ensign Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* paper & ink */
  --bg: #FBF5E9;
  --bg-deep: #F4EBD8;
  --surface: #FFFDF7;
  --surface-2: #F6EEDC;
  --border: #E7DBC0;
  --ink: #3A2E20;
  --ink-2: #776852;
  --ink-3: #A4957C;

  /* jubilant accents */
  --gold: #E9A319;      --gold-deep: #B87D0E;   --gold-soft: #FBEECE;
  --coral: #E2725B;     --coral-deep: #B9503B;  --coral-soft: #FAE4DE;
  --sky: #3E8EC4;       --sky-deep: #2A6E9E;    --sky-soft: #E0EEF7;
  --leaf: #5B9E62;      --leaf-deep: #3F7C46;   --leaf-soft: #E2F1E3;
  --plum: #8C6BAE;      --plum-deep: #6D4E8E;   --plum-soft: #EEE7F6;

  --good: var(--leaf);  --good-deep: var(--leaf-deep);  --good-soft: var(--leaf-soft);
  --bad: #C94F35;       --bad-deep: #A03A24;    --bad-soft: #F8E3DC;
  --chart: #B87D0E;

  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 1px 2px rgba(93, 70, 32, .10), 0 10px 30px rgba(93, 70, 32, .08);
  --shadow-lift: 0 6px 16px rgba(93, 70, 32, .18), 0 16px 40px rgba(93, 70, 32, .12);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.05'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] {
  --bg: #221B12;
  --bg-deep: #1B150D;
  --surface: #2C241A;
  --surface-2: #3A3023;
  --border: #4A3D2B;
  --ink: #F4EAD5;
  --ink-2: #C4B296;
  --ink-3: #8E7D63;

  --gold: #F0B440;      --gold-deep: #B8860F;   --gold-soft: #453413;
  --coral: #EF8A73;     --coral-deep: #C05C46;  --coral-soft: #4A2A21;
  --sky: #6FAED8;       --sky-deep: #417FA8;    --sky-soft: #22374A;
  --leaf: #7FBF85;      --leaf-deep: #4E8A54;   --leaf-soft: #253E28;
  --plum: #AD8FCB;      --plum-deep: #7E5FA0;   --plum-soft: #372B47;

  --good: var(--leaf);  --good-deep: var(--leaf-deep);  --good-soft: var(--leaf-soft);
  --bad: #E3745A;       --bad-deep: #B04B32;    --bad-soft: #47251B;
  --chart: #F0B440;

  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 10px 30px rgba(0,0,0,.35);
  --shadow-lift: 0 6px 16px rgba(0,0,0,.55), 0 16px 40px rgba(0,0,0,.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-weight: 300;
  background:
    radial-gradient(1200px 500px at 50% -10%, var(--gold-soft), transparent 65%),
    var(--grain),
    var(--bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100dvh;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}
b, strong, h1, h2, h3, .bold { font-weight: 600; }  /* synthesized from 300 */
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; }
.art { display: inline-block; vertical-align: middle; }

#app {
  max-width: 620px;
  margin: 0 auto;
  padding: 14px 16px calc(90px + env(safe-area-inset-bottom));
  min-height: 100dvh;
}
@media (min-width: 900px) {
  #app { max-width: 700px; padding-top: 28px; padding-left: 130px; }
}

/* ------------------------------------------------ motion vocabulary */
@keyframes fadeUp   { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes popIn    { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
@keyframes shake    { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
@keyframes breathe  { 0%,100% { transform: scale(1); box-shadow: 0 0 0 0 color-mix(in srgb, var(--vc, var(--gold)) 45%, transparent); }
                      50% { transform: scale(1.045); box-shadow: 0 0 0 12px transparent; } }
@keyframes shimmer  { from { background-position: -140px 0; } to { background-position: 220px 0; } }
@keyframes flicker  { 0%,100% { transform: scale(1) rotate(0deg); } 30% { transform: scale(1.06) rotate(-2deg); } 60% { transform: scale(.97) rotate(1.6deg); } }
@keyframes needleSwing { 0%,100% { transform: rotate(0deg); } 40% { transform: rotate(14deg); } 70% { transform: rotate(-9deg); } }
@keyframes floaty   { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes riseFade { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-46px); } }
@keyframes ripple   { from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--gold) 55%, transparent); } to { box-shadow: 0 0 0 18px transparent; } }
@keyframes trailDash { to { stroke-dashoffset: -24; } }

.anim-in { animation: fadeUp .45s cubic-bezier(.22,1,.36,1) both; }
.anim-in:nth-child(2) { animation-delay: .05s; }
.anim-in:nth-child(3) { animation-delay: .1s; }
.anim-in:nth-child(4) { animation-delay: .15s; }
.anim-in:nth-child(5) { animation-delay: .2s; }
.anim-in:nth-child(6) { animation-delay: .25s; }

.flame-outer { transform-origin: 50% 85%; animation: flicker 1.6s ease-in-out infinite; }
.flame-inner { transform-origin: 50% 88%; animation: flicker 1.2s ease-in-out infinite reverse; }
.needle-a { transform-origin: 24px 24px; animation: needleSwing 5s ease-in-out infinite; }
.needle-b { transform-origin: 24px 24px; animation: needleSwing 6.5s ease-in-out infinite reverse; }

/* ------------------------------------------------ top bar */
.topbar { display: flex; align-items: center; gap: 9px; margin-bottom: 16px; }
.topbar .logo {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 19px; letter-spacing: -.2px; margin-right: auto;
}
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 999px; padding: 5px 12px 5px 8px;
  font-weight: 600; font-size: 14px;
  box-shadow: 0 2px 0 var(--border);
}
.pill .art { width: 20px; height: 20px; }
.pill.flame { color: var(--coral-deep); }
.pill.xp { color: var(--gold-deep); }
:root[data-theme="dark"] .pill.flame { color: var(--coral); }
:root[data-theme="dark"] .pill.xp { color: var(--gold); }

/* ------------------------------------------------ cards */
.card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.card h2 { font-size: 18px; margin-bottom: 10px; letter-spacing: -.2px; display: flex; align-items: center; gap: 8px; }
.card h2 .art { width: 26px; height: 26px; }
.sub { color: var(--ink-2); font-size: 14px; }
.fine { color: var(--ink-3); font-size: 12.5px; }

/* ------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  border-radius: var(--radius-sm);
  padding: 15px 22px;
  font-weight: 600; font-size: 16px; letter-spacing: .2px;
  transition: transform .07s ease, box-shadow .07s ease, filter .2s ease;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}
.btn .art { width: 22px; height: 22px; }
.btn:active { transform: translateY(3px); }
.btn.gold  { background: var(--gold);  color: #402D05; box-shadow: 0 4px 0 var(--gold-deep); }
.btn.coral { background: var(--coral); color: #FFF6F3; box-shadow: 0 4px 0 var(--coral-deep); }
.btn.leaf  { background: var(--leaf);  color: #F2FBF3; box-shadow: 0 4px 0 var(--leaf-deep); }
.btn.sky   { background: var(--sky);   color: #F0F8FF; box-shadow: 0 4px 0 var(--sky-deep); }
.btn.gold:active, .btn.coral:active, .btn.leaf:active, .btn.sky:active { box-shadow: 0 1px 0 rgba(0,0,0,.3); }
.btn.ghost {
  background: var(--surface); border: 2px solid var(--border);
  box-shadow: 0 4px 0 var(--border); color: var(--ink-2);
}
.btn.ghost:active { box-shadow: 0 1px 0 var(--border); }
.btn.block { display: flex; width: 100%; }
.btn.small { padding: 9px 14px; font-size: 14px; border-radius: 11px; }
.btn.small .art { width: 18px; height: 18px; }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.pulse { animation: ripple 1.6s ease-out infinite; }

/* ------------------------------------------------ welcome / auth */
.welcome { text-align: center; padding-top: 6vh; }
.welcome .halo {
  width: 132px; height: 132px; margin: 0 auto 6px;
  display: grid; place-items: center;
  background: radial-gradient(circle, var(--gold-soft) 0%, transparent 70%);
  animation: floaty 4s ease-in-out infinite;
}
.welcome .halo .art { width: 108px; height: 108px; filter: drop-shadow(0 8px 14px rgba(150, 100, 10, .35)); }
.welcome h1 { font-size: 34px; letter-spacing: -.6px; margin-bottom: 6px; }
.welcome .tag { color: var(--ink-2); font-size: 16.5px; margin-bottom: 30px; }
.welcome .stack { display: flex; flex-direction: column; gap: 12px; max-width: 380px; margin: 0 auto; }

.auth-form { max-width: 380px; margin: 0 auto; text-align: left; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 5px; color: var(--ink-2); }
.input {
  width: 100%; padding: 13px 15px; border-radius: var(--radius-sm);
  border: 2px solid var(--border); background: var(--surface); color: var(--ink);
  font-size: 16px; transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 4px var(--gold-soft); }
.form-err { color: var(--bad); font-weight: 600; font-size: 14px; min-height: 20px; margin: 4px 0 8px; }

.avatar-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 6px 0 8px; }
@media (max-width: 430px) { .avatar-grid { grid-template-columns: repeat(4, 1fr); } }
.avatar-pick {
  aspect-ratio: 1; border-radius: 14px;
  background: var(--surface); border: 2px solid var(--border);
  display: grid; place-items: center; color: var(--ink-2);
  transition: transform .1s ease, border-color .15s, color .15s;
}
.avatar-pick .art { width: 30px; height: 30px; }
.avatar-pick:active { transform: scale(.92); }
.avatar-pick.on { border-color: var(--gold); color: var(--gold-deep); background: var(--gold-soft); box-shadow: 0 3px 0 var(--gold); }

/* ------------------------------------------------ daily goal */
.goal-row { display: flex; align-items: center; gap: 14px; }
.goal-ring { position: relative; width: 64px; height: 64px; flex: none; }
.goal-ring svg { transform: rotate(-90deg); }
.goal-ring circle { transition: stroke-dashoffset .8s cubic-bezier(.22,1,.36,1); }
.goal-ring .num { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 600; font-size: 13px; }

/* ------------------------------------------------ volume tabs */
.vol-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.vol-tab {
  border-radius: var(--radius-sm);
  padding: 10px 4px 8px;
  text-align: center;
  background: var(--surface); border: 2px solid var(--border);
  font-weight: 600; font-size: 12.5px; color: var(--ink-2);
  transition: transform .08s ease, border-color .15s, background .15s;
  box-shadow: 0 3px 0 var(--border);
}
.vol-tab:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--border); }
.vol-tab .bar { display: block; height: 4px; border-radius: 2px; background: var(--surface-2); margin: 7px 8px 0; overflow: hidden; }
.vol-tab .bar > span { display: block; height: 100%; background: var(--vc, var(--gold)); border-radius: 2px; }
.vol-tab.active { border-color: var(--vc); color: var(--vc-deep); background: var(--vcs); box-shadow: 0 3px 0 var(--vc); }

/* volume theming hooks */
.th-sky   { --vc: var(--sky);   --vc-deep: var(--sky-deep);   --vcs: var(--sky-soft); }
.th-coral { --vc: var(--coral); --vc-deep: var(--coral-deep); --vcs: var(--coral-soft); }
.th-leaf  { --vc: var(--leaf);  --vc-deep: var(--leaf-deep);  --vcs: var(--leaf-soft); }
.th-gold  { --vc: var(--gold);  --vc-deep: var(--gold-deep);  --vcs: var(--gold-soft); }

/* ------------------------------------------------ learning trail */
.trail { position: relative; display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 10px 0 24px; }
.trail-line { position: absolute; top: 20px; bottom: 20px; width: 4px; z-index: 0; }
.trail-line svg { height: 100%; width: 4px; }
.trail-line line {
  stroke: var(--border); stroke-width: 4; stroke-linecap: round;
  stroke-dasharray: 1 14; animation: trailDash 2.2s linear infinite;
}
.trail-node {
  position: relative; z-index: 1;
  width: min(430px, 100%);
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  text-align: left;
  transition: transform .1s ease, box-shadow .15s ease;
}
.trail-node:not(.locked):hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.trail-node:active { transform: scale(.985); }
.trail-node .orb {
  flex: none; width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--vcs, var(--gold-soft));
  border: 3px solid var(--vc, var(--gold));
  box-shadow: 0 4px 0 var(--vc-deep, var(--gold-deep));
  color: var(--vc-deep);
}
.trail-node .orb .art { width: 30px; height: 30px; }
.trail-node.next .orb { animation: breathe 2.4s ease-in-out infinite; }
.trail-node.locked { opacity: .58; }
.trail-node.locked .orb { border-color: var(--border); box-shadow: 0 4px 0 var(--border); background: var(--surface-2); color: var(--ink-3); }
.trail-node .meta { flex: 1; min-width: 0; }
.trail-node .name { font-weight: 600; font-size: 15.5px; }
.trail-node .refs { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trail-node .stars { display: flex; gap: 2px; margin-top: 4px; color: var(--gold); align-items: center; }
.trail-node .stars .art { width: 16px; height: 16px; }
.trail-node .stars .off { color: var(--border); }
.trail-node .stars .count { font-size: 11.5px; color: var(--ink-3); font-weight: 600; margin-left: 5px; }
.trail-node .go { flex: none; color: var(--vc, var(--gold)); }
.trail-node .go .art { width: 24px; height: 24px; }

.strength-bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 7px; }
.strength-bar > div {
  height: 100%; border-radius: 4px; background: var(--vc, var(--gold));
  transition: width .5s cubic-bezier(.22,1,.36,1);
  background-image: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.45) 50%, transparent 70%);
  background-size: 140px 100%; background-repeat: no-repeat;
  animation: shimmer 2.6s ease-in-out infinite;
}

/* ------------------------------------------------ lesson */
.lesson-top { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.lesson-top .quit { color: var(--ink-3); padding: 4px; }
.lesson-top .quit .art { width: 20px; height: 20px; }
.progress-track { flex: 1; height: 15px; border-radius: 8px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.progress-fill {
  height: 100%; width: 0%;
  background: var(--leaf);
  border-radius: 8px;
  transition: width .4s cubic-bezier(.22,1,.36,1);
  background-image: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.5) 50%, transparent 70%);
  background-size: 140px 100%; background-repeat: no-repeat;
  animation: shimmer 2.2s ease-in-out infinite;
}
.combo {
  display: flex; align-items: center; gap: 3px;
  font-weight: 600; color: var(--coral-deep); font-size: 14.5px; min-width: 48px; justify-content: flex-end;
}
:root[data-theme="dark"] .combo { color: var(--coral); }
.combo .art { width: 18px; height: 18px; }

.q-kicker {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 600; letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 8px;
}
.q-kicker .art { width: 17px; height: 17px; }
.q-prompt { font-size: 20px; font-weight: 600; letter-spacing: -.2px; margin-bottom: 8px; }
.q-passage {
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 18px; font-size: 17px; line-height: 1.62;
  box-shadow: var(--shadow); margin: 12px 0 18px;
}
.q-passage .ref-tag { display: block; margin-top: 10px; font-size: 13px; font-weight: 600; color: var(--ink-3); }
.q-emojis { font-size: 40px; text-align: center; letter-spacing: 6px; line-height: 1.4; padding: 10px 0; }

.choices { display: grid; gap: 10px; }
.choice {
  position: relative;
  text-align: left;
  background: var(--surface); border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 15.5px;
  box-shadow: 0 3px 0 var(--border);
  transition: transform .08s ease, border-color .15s, background .15s;
}
.choice:not(:disabled):hover { border-color: var(--gold); }
.choice:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--border); }
.choice.right { border-color: var(--leaf); background: var(--leaf-soft); box-shadow: 0 3px 0 var(--leaf); animation: popIn .3s ease; }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); box-shadow: 0 3px 0 var(--bad); animation: shake .4s ease; }
.choice:disabled { pointer-events: none; }

/* word-bank + drag exercises */
.assembly {
  min-height: 62px;
  border-bottom: 2px dashed var(--border);
  display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start;
  padding: 6px 2px 12px; margin-bottom: 18px;
  border-radius: 6px;
  transition: background .15s ease;
}
.assembly.drop-hot { background: var(--gold-soft); }
.sentence-build {
  display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: baseline;
  font-size: 17.5px; line-height: 2; font-weight: 300;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 18px;
}
.sentence-build .word.ghosted { color: var(--ink-3); opacity: .35; }
.next-slot {
  display: inline-flex; min-width: 88px; height: 32px; border-radius: 9px;
  border: 2px dashed var(--gold); background: var(--gold-soft);
  transition: transform .12s ease, background .15s;
}
.next-slot.drop-hot { transform: scale(1.08); background: var(--gold); opacity: .55; }
.blank-line { display: flex; flex-wrap: wrap; gap: 6px 8px; font-size: 17px; line-height: 2; }
.blank-slot {
  display: inline-block; min-width: 76px; text-align: center;
  border-bottom: 3px solid var(--border);
  color: var(--gold-deep); font-weight: 600;
  border-radius: 4px 4px 0 0;
  transition: background .15s ease, transform .12s ease;
  cursor: pointer;
}
.blank-slot.drop-hot { background: var(--gold-soft); transform: scale(1.06); }
.blank-slot.filled { border-bottom-color: var(--gold); }

.bank { display: flex; flex-wrap: wrap; gap: 9px; justify-content: center; margin-top: 10px; }
.token {
  background: var(--surface); border: 2px solid var(--border);
  border-radius: 11px; padding: 9px 15px;
  font-weight: 600; font-size: 15px;
  box-shadow: 0 3px 0 var(--border);
  transition: transform .08s ease, opacity .15s ease;
  touch-action: none;                     /* pointer-drag friendly */
  cursor: grab;
}
.token:active { cursor: grabbing; }
.token.used { opacity: .22; pointer-events: none; }
.token.placed { border-color: var(--gold); background: var(--gold-soft); color: var(--gold-deep); box-shadow: 0 3px 0 var(--gold); }
.drag-ghost {
  position: fixed; z-index: 80; pointer-events: none;
  transform: translate(-50%, -60%) rotate(-3deg) scale(1.08);
  box-shadow: var(--shadow-lift);
  opacity: .95;
  transition: none;
}
.drag-ghost.snap-back { transition: left .22s cubic-bezier(.22,1,.36,1), top .22s cubic-bezier(.22,1,.36,1), opacity .22s; opacity: .4; }

/* quad game */
.quad-stage { display: grid; place-items: center; margin: 6px 0 16px; }
.quad-stage svg { max-width: 100%; height: auto; filter: drop-shadow(0 10px 18px rgba(93,70,32,.25)); }
.quad-marker { animation: floaty 2.4s ease-in-out infinite; }

/* floating +XP crumb */
.xp-float {
  position: fixed; z-index: 70; pointer-events: none;
  font-weight: 600; font-size: 19px; color: var(--gold-deep);
  text-shadow: 0 1px 0 var(--surface);
  animation: riseFade 1s ease-out forwards;
}

/* feedback bar */
.feedback {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  transform: translateY(105%);
  transition: transform .3s cubic-bezier(.22,1,.36,1);
  z-index: 40;
}
.feedback.show { transform: translateY(0); }
.feedback .inner { max-width: 620px; margin: 0 auto; }
.feedback.ok { background: var(--leaf-soft); border-top: 2.5px solid var(--leaf); }
.feedback.no { background: var(--bad-soft); border-top: 2.5px solid var(--bad); }
.feedback .headline { font-weight: 600; font-size: 17px; display: flex; gap: 9px; align-items: center; margin-bottom: 4px; }
.feedback.ok .headline { color: var(--leaf-deep); }
.feedback.no .headline { color: var(--bad-deep); }
:root[data-theme="dark"] .feedback.ok .headline { color: var(--leaf); }
:root[data-theme="dark"] .feedback.no .headline { color: var(--bad); }
.feedback .headline .art { width: 24px; height: 24px; }
.feedback .detail { font-size: 14.5px; color: var(--ink-2); margin-bottom: 12px; }

.check-dock {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 35%);
  z-index: 30;
}
.check-dock .inner { max-width: 620px; margin: 0 auto; }

/* ------------------------------------------------ results */
.results { text-align: center; padding-top: 26px; }
.results .medal { width: 120px; height: 120px; margin: 0 auto 8px; display: grid; place-items: center; animation: popIn .5s cubic-bezier(.22,1,.36,1); }
.results .medal .art { width: 104px; height: 104px; }
.results h1 { font-size: 27px; letter-spacing: -.4px; margin-bottom: 4px; }
.results .sub { margin-bottom: 24px; }
.result-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 24px; }
.rtile {
  border-radius: var(--radius); padding: 15px 8px;
  border: 2px solid var(--border); background: var(--surface);
  box-shadow: var(--shadow);
}
.rtile .label { font-size: 11px; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; color: var(--ink-3); }
.rtile .val { font-size: 25px; font-weight: 600; margin-top: 2px; }
.rtile.xp .val { color: var(--gold-deep); }
.rtile.acc .val { color: var(--leaf-deep); }
.rtile.combo .val { color: var(--coral-deep); }
:root[data-theme="dark"] .rtile.xp .val { color: var(--gold); }
:root[data-theme="dark"] .rtile.acc .val { color: var(--leaf); }
:root[data-theme="dark"] .rtile.combo .val { color: var(--coral); }

/* ------------------------------------------------ compete */
.tier-head { text-align: center; margin-bottom: 16px; }
.tier-head .crest {
  width: 96px; height: 96px; border-radius: 50%; margin: 0 auto 8px;
  display: grid; place-items: center;
  border: 3px solid var(--tier, var(--gold));
  background: var(--surface);
  box-shadow: 0 5px 0 color-mix(in srgb, var(--tier, var(--gold)) 70%, black 20%), var(--shadow);
  color: var(--tier, var(--gold));
  animation: floaty 4.5s ease-in-out infinite;
}
.tier-head .crest .art { width: 62px; height: 62px; }
.tier-head h1 { font-size: 23px; }
.tier-progress { max-width: 320px; margin: 8px auto 0; }

.seg-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: var(--surface-2); border-radius: 12px; padding: 5px; margin-bottom: 12px; }
.seg-tabs button { border-radius: 9px; padding: 8px 4px; font-weight: 600; font-size: 13.5px; color: var(--ink-3); transition: background .15s, color .15s; }
.seg-tabs button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.lb { display: flex; flex-direction: column; gap: 8px; }
.lb-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px;
  animation: fadeUp .35s ease both;
  animation-delay: calc(var(--i, 0) * .04s);
}
.lb-row .rank { font-weight: 600; width: 30px; color: var(--ink-3); font-size: 14.5px; }
.lb-row .rank.top { color: var(--gold-deep); }
.lb-row .face {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--ink-2);
  border: 2px solid var(--border);
}
.lb-row .face .art { width: 22px; height: 22px; }
.lb-row .name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
.lb-row .name .u { display: block; font-weight: 300; font-size: 11.5px; color: var(--ink-3); }
.lb-row .score { font-weight: 600; color: var(--gold-deep); font-size: 14.5px; }
:root[data-theme="dark"] .lb-row .score { color: var(--gold); }
.lb-row.me { border-color: var(--gold); background: var(--gold-soft); }
.lb-empty { text-align: center; color: var(--ink-3); padding: 22px 10px; }

.arcade-grid { display: grid; gap: 10px; }
.arcade-card {
  display: flex; align-items: center; gap: 14px; text-align: left;
  background: var(--surface); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow);
  transition: transform .1s ease, box-shadow .15s;
}
.arcade-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.arcade-card:active { transform: scale(.985); }
.arcade-card .ic {
  flex: none; width: 52px; height: 52px; border-radius: 14px;
  display: grid; place-items: center; color: var(--ac, var(--gold-deep));
  background: var(--acs, var(--gold-soft));
}
.arcade-card .ic .art { width: 30px; height: 30px; }
.arcade-card .t { font-weight: 600; font-size: 15.5px; }
.arcade-card .d { font-size: 12.5px; color: var(--ink-3); }

/* lightning hud */
.lightning-hud { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.lightning-hud .timer { font-size: 31px; font-weight: 600; font-variant-numeric: tabular-nums; }
.lightning-hud .timer.low { color: var(--bad); animation: flicker .5s infinite; }
.lightning-hud .score { display: flex; align-items: center; gap: 6px; font-size: 20px; font-weight: 600; color: var(--gold-deep); }
:root[data-theme="dark"] .lightning-hud .score { color: var(--gold); }

/* ------------------------------------------------ profile */
.profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.profile-head .face {
  width: 68px; height: 68px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--gold-soft); border: 3px solid var(--gold);
  color: var(--gold-deep);
  box-shadow: 0 4px 0 var(--gold-deep);
}
.profile-head .face .art { width: 40px; height: 40px; }
.profile-head .who .nm { font-size: 21px; font-weight: 600; }
.profile-head .who .since { font-size: 13px; color: var(--ink-3); }

.stat-tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 560px) { .stat-tiles { grid-template-columns: repeat(4, 1fr); } }
.stile {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
}
.stile .label { font-size: 11px; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; color: var(--ink-3); }
.stile .val { font-size: 26px; font-weight: 600; letter-spacing: -.5px; margin-top: 2px; }
.stile .val .unit { font-size: 13px; color: var(--ink-3); margin-left: 3px; }

.chart-wrap { padding: 4px 2px 0; }
.chart-wrap svg { display: block; width: 100%; height: auto; }
.chart-bar { fill: var(--chart); }
.chart-bar.today { fill: var(--coral); }
.chart-bar:hover { filter: brightness(1.12); }
.chart-axis-text { font-size: 11px; font-weight: 600; fill: var(--ink-3); font-family: var(--font); }
.chart-val-text { font-size: 11px; font-weight: 600; fill: var(--ink-2); font-family: var(--font); }
.chart-grid { stroke: var(--border); stroke-width: 1; }

.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.badge {
  text-align: center; padding: 13px 6px;
  border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  background: var(--surface); color: var(--gold-deep);
  transition: transform .1s ease;
}
.badge:hover { transform: translateY(-2px); }
.badge .art { width: 34px; height: 34px; }
.badge .nm { font-size: 11.5px; font-weight: 600; margin-top: 5px; color: var(--ink); }
.badge.locked { opacity: .4; filter: grayscale(.9); }

.settings-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 0; border-bottom: 1.5px solid var(--border);
  font-weight: 600; font-size: 15px;
}
.settings-row:last-child { border-bottom: 0; }
.settings-row .hint { display: block; font-size: 12.5px; font-weight: 300; color: var(--ink-3); }
.toggle {
  width: 54px; height: 31px; border-radius: 999px; position: relative; flex: none;
  background: var(--surface-2); border: 2px solid var(--border); transition: background .2s, border-color .2s;
}
.toggle.on { background: var(--leaf); border-color: var(--leaf); }
.toggle .knob {
  position: absolute; top: 2px; left: 2px; width: 23px; height: 23px;
  background: #fff; border-radius: 50%; transition: left .2s cubic-bezier(.22,1,.36,1);
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.toggle.on .knob { left: 25px; }

/* ------------------------------------------------ library */
.lib-row {
  width: 100%;
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 8px;
  transition: transform .1s ease;
}
.lib-row:hover { transform: translateX(3px); }
.lib-row .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--vc, var(--gold)); flex: none; }
.lib-row .info { flex: 1; min-width: 0; }
.lib-row .rf { font-weight: 600; font-size: 14.5px; display: flex; align-items: center; gap: 6px; }
.lib-row .rf .art { width: 14px; height: 14px; color: var(--gold); }
.lib-row .tp { font-size: 12.5px; color: var(--ink-3); }
.lib-row .pct { font-weight: 600; font-size: 13px; color: var(--ink-2); flex: none; }

/* ------------------------------------------------ nav */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1.5px solid var(--border);
  display: flex; justify-content: space-around;
  padding: 7px 4px calc(7px + env(safe-area-inset-bottom));
}
.nav button {
  flex: 1; max-width: 110px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 2px; border-radius: 13px;
  font-size: 10.5px; font-weight: 600; color: var(--ink-3);
  transition: color .15s, background .15s, transform .1s;
}
.nav button .art { width: 24px; height: 24px; transition: transform .18s cubic-bezier(.34,1.56,.64,1); }
.nav button.active { color: var(--gold-deep); background: var(--gold-soft); }
.nav button.active .art { transform: translateY(-2px) scale(1.12); }
:root[data-theme="dark"] .nav button.active { color: var(--gold); }
@media (min-width: 900px) {
  .nav {
    left: 0; right: auto; top: 0; bottom: 0;
    width: 104px; flex-direction: column; justify-content: flex-start;
    gap: 8px; padding: 22px 10px; border-top: 0; border-right: 1.5px solid var(--border);
  }
  .nav button { max-width: none; flex: none; }
}

/* ------------------------------------------------ toast + confetti */
.toast {
  position: fixed; top: 14px; left: 50%; transform: translate(-50%, -140%);
  background: var(--ink); color: var(--bg);
  padding: 12px 20px; border-radius: 999px;
  font-weight: 600; font-size: 14px;
  display: flex; align-items: center; gap: 8px;
  box-shadow: var(--shadow-lift); z-index: 90;
  transition: transform .4s cubic-bezier(.34,1.4,.64,1);
  max-width: min(92vw, 480px); text-align: center;
}
.toast .art { width: 22px; height: 22px; }
.toast.show { transform: translate(-50%, 0); }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; }

/* helpers */
.center { text-align: center; }
.mt { margin-top: 14px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.spacer { height: 10px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.linkish { color: var(--sky-deep); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
:root[data-theme="dark"] .linkish { color: var(--sky); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
