:root {
  /* ---- pastel purple system ---- */
  --lilac-50:  #f7f4fe;
  --lilac-100: #efe9fb;
  --lilac-150: #e7defa;
  --lilac-200: #ded2f6;
  --lilac-300: #c9b8ef;
  --lilac-400: #b9a6ec;
  --lilac-500: #9e85e0;
  --lilac-600: #8167cf;

  --plum-700: #6a5495;
  --ink:      #463c5e;   /* tinted dark, never pure black */
  --ink-soft: #6f658a;

  --mint:   #b8e3d6;     /* gentle complementary accent */
  --blush:  #f3cbe0;
  --gold:   #ecd9a8;

  --paper:  rgba(255, 255, 255, 0.66);
  --paper-line: rgba(140, 116, 196, 0.16);
  --shadow: 24px 30px 60px -28px rgba(108, 84, 170, 0.45);
  --shadow-soft: 0 10px 30px -18px rgba(108, 84, 170, 0.55);

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Quicksand", "Segoe UI", sans-serif;

  --r-lg: 30px;
  --r-md: 22px;
  --r-sm: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(120% 90% at 50% -10%, var(--lilac-50) 0%, var(--lilac-100) 42%, var(--lilac-200) 100%);
  min-height: 100dvh;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- ambient aurora ---------- */
.aurora { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(46px);
  opacity: 0.55;
  will-change: transform;
}
.orb--1 { width: 46vw; height: 46vw; left: -12vw; top: -8vw; background: var(--lilac-300); animation: drift 19s ease-in-out infinite; }
.orb--2 { width: 40vw; height: 40vw; right: -14vw; top: 18vh; background: var(--blush); opacity: 0.4; animation: drift 23s ease-in-out infinite reverse; }
.orb--3 { width: 36vw; height: 36vw; left: 8vw; bottom: -12vh; background: var(--mint); opacity: 0.34; animation: drift 27s ease-in-out infinite; }

@keyframes drift {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(3vw, 4vh, 0) scale(1.08); }
}

/* ---------- app shell ---------- */
.app {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  margin: 0 auto;
  padding: clamp(1.4rem, 4vw, 2.6rem) clamp(1.1rem, 4vw, 1.8rem) 3rem;
  padding-bottom: max(3rem, env(safe-area-inset-bottom));
}

.masthead { text-align: center; margin-bottom: clamp(1.2rem, 4vw, 1.8rem); }
.kicker {
  font-size: 0.72rem;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--lilac-600);
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.wordmark {
  font-family: var(--font-display);
  font-weight: 500;
  font-optical-sizing: auto;
  font-size: clamp(2.5rem, 11vw, 3.6rem);
  line-height: 0.96;
  letter-spacing: -0.02em;
  color: var(--plum-700);
}

/* ---------- companion ---------- */
.companion {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1.6rem;
}
.companion__halo {
  position: relative;
  width: clamp(170px, 52vw, 220px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 42%, rgba(255,255,255,0.9) 0%, rgba(222,210,246,0.5) 45%, rgba(222,210,246,0) 72%);
}
.companion__halo::after {
  content: "";
  position: absolute;
  inset: 14%;
  border-radius: 50%;
  border: 1px dashed var(--paper-line);
  animation: spin 38s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.companion__stage { width: 78%; aspect-ratio: 1; display: grid; place-items: center; }
.companion__stage svg { width: 100%; height: 100%; overflow: visible; }
.companion__stage .bob { transform-box: fill-box; transform-origin: center; animation: bob 4.2s ease-in-out infinite; }
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-7px) rotate(1deg); }
}

.companion__meta { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; }
.companion__name {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--plum-700);
  letter-spacing: -0.01em;
}
.companion__title {
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 600;
}
.levelpill {
  margin-top: 0.2rem;
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.32rem 0.85rem;
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-soft);
}
.levelpill__label { font-size: 0.68rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-soft); font-weight: 600; }
.levelpill__num { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; color: var(--lilac-600); }

/* ---------- energy bar ---------- */
.energy {
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: var(--r-md);
  padding: 1.1rem 1.2rem 1.2rem;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
  margin-bottom: 1rem;
}
.energy__row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.7rem; }
.energy__lead { font-weight: 700; letter-spacing: 0.02em; color: var(--plum-700); }
.energy__count { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink-soft); font-size: 0.92rem; }

.energy__track {
  position: relative;
  height: 16px;
  border-radius: 999px;
  background: var(--lilac-150);
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(108, 84, 170, 0.18);
}
.energy__fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--lilac-400), var(--lilac-500) 60%, var(--blush));
  transition: width 0.85s cubic-bezier(0.22, 1, 0.36, 1);
}
.energy__sheen {
  position: absolute;
  inset: 0 0 auto 0;
  height: 50%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,0.5), transparent);
  pointer-events: none;
}
.energy__hint { margin-top: 0.7rem; font-size: 0.82rem; color: var(--ink-soft); }

/* ---------- stats ---------- */
.stats {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 0.5rem;
  padding: 0.95rem 0.6rem;
  margin-bottom: 1.8rem;
  background: linear-gradient(180deg, rgba(255,255,255,0.5), rgba(255,255,255,0.28));
  border: 1px solid var(--paper-line);
  border-radius: var(--r-md);
}
.stat { display: flex; flex-direction: column; align-items: center; gap: 0.1rem; flex: 1; }
.stat__value { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; color: var(--plum-700); font-variant-numeric: tabular-nums; }
.stat__key { font-size: 0.66rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-soft); font-weight: 600; }
.stat__divider { width: 1px; align-self: stretch; background: var(--paper-line); margin: 0.2rem 0; }

/* ---------- quests ---------- */
.quests__head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 0.9rem; padding: 0 0.2rem; }
.quests__head h2 { font-family: var(--font-display); font-weight: 500; font-size: 1.35rem; color: var(--plum-700); }
.quests__date { font-size: 0.78rem; color: var(--ink-soft); font-weight: 600; }

.questlist { list-style: none; display: flex; flex-direction: column; gap: 0.7rem; }

.quest {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.85rem 0.95rem;
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(8px);
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-family: inherit;
  color: inherit;
  transition: transform 0.18s ease, box-shadow 0.25s ease, background 0.25s ease, opacity 0.3s ease;
}
.quest:hover { transform: translateY(-2px); box-shadow: 0 16px 30px -20px rgba(108, 84, 170, 0.6); }
.quest:active { transform: translateY(0) scale(0.99); }
.quest:focus-visible { outline: 2.5px solid var(--lilac-500); outline-offset: 3px; }

.quest__icon {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 13px;
  background: radial-gradient(circle at 35% 30%, var(--lilac-150), var(--lilac-200));
  color: var(--lilac-600);
}
.quest__icon svg { width: 24px; height: 24px; }

.quest__body { flex: 1; min-width: 0; }
.quest__name { font-weight: 700; font-size: 0.98rem; color: var(--ink); }
.quest__meta { font-size: 0.78rem; color: var(--ink-soft); margin-top: 0.1rem; }

.quest__xp {
  flex: 0 0 auto;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--lilac-600);
  background: var(--lilac-100);
  border: 1px solid var(--paper-line);
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}

.quest__check {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--lilac-300);
  display: grid; place-items: center;
  color: #fff;
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}
.quest__check svg { width: 15px; height: 15px; opacity: 0; transform: scale(0.5); transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.2,1.4,0.4,1); }

/* completed state */
.quest.is-done {
  background: linear-gradient(180deg, rgba(184, 227, 214, 0.34), rgba(222, 210, 246, 0.34));
  cursor: default;
}
.quest.is-done .quest__name { color: var(--ink-soft); }
.quest.is-done .quest__xp { color: var(--plum-700); background: rgba(255,255,255,0.6); }
.quest.is-done .quest__check { background: var(--lilac-500); border-color: var(--lilac-500); transform: scale(1.05); }
.quest.is-done .quest__check svg { opacity: 1; transform: scale(1); }
.quest.is-done:hover { transform: none; box-shadow: var(--shadow-soft); }

/* entrance stagger */
.quest { opacity: 0; transform: translateY(10px); animation: rise 0.5s ease forwards; }
@keyframes rise { to { opacity: 1; transform: translateY(0); } }

/* ---------- footnote ---------- */
.footnote { margin-top: 2.2rem; text-align: center; }
.footnote p { font-size: 0.78rem; color: var(--ink-soft); margin-bottom: 0.8rem; }
.reset {
  font-family: inherit;
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--paper-line);
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.reset:hover { color: var(--plum-700); border-color: var(--lilac-400); background: var(--paper); }
.reset:focus-visible { outline: 2.5px solid var(--lilac-500); outline-offset: 2px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(1.4rem, env(safe-area-inset-bottom));
  transform: translate(-50%, 1.5rem);
  z-index: 30;
  background: var(--plum-700);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.7rem 1.2rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.2,1,0.3,1);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- level-up overlay ---------- */
.levelup {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center;
  padding: 1.5rem;
  background: rgba(70, 60, 94, 0.32);
  backdrop-filter: blur(6px);
  opacity: 0;
  animation: fade 0.3s ease forwards;
}
.levelup[hidden] { display: none; }
@keyframes fade { to { opacity: 1; } }

.levelup__card {
  position: relative;
  width: min(340px, 100%);
  text-align: center;
  background: linear-gradient(180deg, var(--lilac-50), var(--lilac-100));
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: var(--r-lg);
  padding: 2.4rem 1.8rem 1.8rem;
  box-shadow: var(--shadow);
  transform: translateY(12px) scale(0.96);
  animation: pop 0.5s cubic-bezier(0.2, 1.3, 0.4, 1) forwards;
  overflow: hidden;
}
@keyframes pop { to { transform: translateY(0) scale(1); } }
.levelup__spark {
  width: 64px; height: 64px; margin: 0 auto 0.8rem;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #fff, var(--lilac-300));
  box-shadow: 0 0 0 8px rgba(201, 184, 239, 0.3), 0 0 0 18px rgba(201, 184, 239, 0.18);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{ transform: scale(1);} 50%{ transform: scale(1.08);} }
.levelup__eyebrow { font-size: 0.72rem; letter-spacing: 0.26em; text-transform: uppercase; color: var(--lilac-600); font-weight: 700; }
.levelup__rank { font-family: var(--font-display); font-size: 1.7rem; font-weight: 600; color: var(--plum-700); margin: 0.3rem 0 0.15rem; }
.levelup__sub { color: var(--ink-soft); font-weight: 600; margin-bottom: 1.4rem; }
.levelup__close {
  font-family: inherit; font-weight: 700; font-size: 0.95rem;
  color: #fff; background: var(--lilac-500);
  border: none; border-radius: 999px;
  padding: 0.7rem 2rem; cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: background 0.2s ease, transform 0.15s ease;
}
.levelup__close:hover { background: var(--lilac-600); }
.levelup__close:active { transform: scale(0.97); }

/* ---------- responsive nudges ---------- */
@media (min-width: 540px) {
  .quest__icon { width: 48px; height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
