/* The Lily Game — preview prototype */
:root {
  --ink: #3A2A32;
  --ink-soft: #7A6570;
  --ink-faint: #A3929A;
  --paper: #FFFBFA;
  --blush: #E8A0B4;
  --blush-deep: #C45C86;
  --gold: #D4A84A;
  --gold-soft: #F3E2A0;
  --sage: #7FA98C;
  --lilac: #B8A4D8;
  --sky: #8BB8D8;
  --peach: #F6E4D4;
  --shadow: 0 10px 28px rgba(80, 40, 55, 0.08);
  --shadow-soft: 0 6px 18px rgba(80, 40, 55, 0.06);
  --radius: 22px;
  --safe-top: max(16px, env(safe-area-inset-top, 0px));
  --safe-bot: max(14px, env(safe-area-inset-bottom, 0px));
  --stg: 1;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  height: 100%;
  background: #2A1C22;
  font-family: Nunito, "Nunito", system-ui, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; color: inherit; cursor: pointer; }
input, textarea { font-family: inherit; color: inherit; }

/* Desktop: center a phone canvas. Phone: fill the screen. */
body { display: grid; place-items: center; }
#phone {
  width: 390px;
  height: 844px;
  max-width: 100vw;
  max-height: 100dvh;
  background: #F7EBE3;
  position: relative;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,.35);
}
@media (max-width: 430px) {
  body { display: block; background: #F7EBE3; }
  #phone { width: 100vw; height: 100dvh; max-height: 100dvh; box-shadow: none; }
}

#app, .view {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.view {
  display: none;
  flex-direction: column;
  background: #F7EBE3;
  opacity: 0;
  transform: translateY(8px);
}
.view.on {
  display: flex;
  opacity: 1;
  transform: none;
  animation: rise .28s ease;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Home ---------- */
#view-home { background: linear-gradient(180deg, #F8E6D4 0%, #F3D7C8 38%, #EED5E6 100%); }

.topbar {
  position: relative;
  z-index: 3;
  padding: calc(var(--safe-top) + 6px) 16px 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.wordmark {
  grid-column: 2;
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-weight: 600;
  font-size: 20px;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.wordmark em { font-style: italic; font-weight: 500; }
.top-left, .top-right { display: flex; align-items: center; gap: 8px; }
.top-right { justify-content: flex-end; }

.sparkle-pill, .icon-btn, .text-btn {
  border: 0;
  background: rgba(255,251,250,.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-soft);
}
.sparkle-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 10px 0 8px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 14px;
}
.icon-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid; place-items: center;
  padding: 0;
}
.text-btn {
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.hero {
  position: relative;
  height: 318px;
  flex: 0 0 318px;
  margin-top: -8px;
}
.meadow-bg { position: absolute; inset: 0; pointer-events: none; }
.mascot-wrap {
  position: absolute;
  left: 50%;
  bottom: 18px;
  width: 280px;
  height: 280px;
  transform: translateX(-50%);
  z-index: 2;
  border: 0;
  background: transparent;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
}
.mascot-wrap .mascot { width: 100%; height: 100%; }
.mascot { width: 100%; height: 100%; display: grid; place-items: end center; position: relative; }
.mascot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  display: block;
  pointer-events: none;
  animation: idle 3.4s ease-in-out infinite;
}
@keyframes idle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}
.friend .mini img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  display: block;
  animation: none;
}
.reward-mascot img, #tm-mascot img, #tm-mascot .mascot img {
  object-position: center bottom;
}
.star-glow { filter: drop-shadow(0 0 14px rgba(255,230,150,.8)); }
.star-sparkles { position: absolute; inset: 0; pointer-events: none; }
.star-sparkles i {
  position: absolute;
  width: 8px; height: 8px;
  background: #fff6c8;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation: twinkle 2.4s ease-in-out infinite;
  opacity: .9;
}
@keyframes twinkle {
  0%, 100% { opacity: .25; transform: scale(.7) rotate(0); }
  50% { opacity: 1; transform: scale(1.15) rotate(20deg); }
}

.hero-meta {
  position: relative;
  z-index: 3;
  text-align: center;
  padding: 0 20px 8px;
  margin-top: -6px;
}
.stage-line {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.02em;
}
.week-line {
  margin: 2px 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
}
.stage-dots, .week-sparkles {
  display: flex;
  justify-content: center;
  gap: 8px;
  align-items: center;
}
.stage-dots span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: rgba(58,42,50,.18);
}
.stage-dots span.on { background: var(--blush-deep); transform: scale(1.15); }
.stage-dots span.now { box-shadow: 0 0 0 3px rgba(196,92,134,.22); }

.home-cards {
  padding: 10px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.activity {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 12px;
  align-items: center;
  background: var(--paper);
  border: 0;
  border-radius: 18px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  text-align: left;
  width: 100%;
  min-height: 68px;
  transition: transform .12s ease;
}
.activity:active { transform: scale(.985); }
.activity .glyph {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: grid; place-items: center;
}
.activity .glyph.sp { background: #F8E0C8; }
.activity .glyph.vs { background: #E8D8F4; }
.activity .glyph.rd { background: #D8EBD8; }
.activity .name { display: block; font-weight: 800; font-size: 16px; letter-spacing: -.01em; }
.activity .prog { display: block; margin-top: 1px; font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.activity .end {
  font-size: 12px;
  font-weight: 800;
  color: var(--blush-deep);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.activity.done .end { color: var(--sage); }
.activity .end .chk {
  display: grid; place-items: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #E4F0E6;
  color: #3D7A52;
  font-size: 14px;
}

.meadow-link {
  margin: 10px 16px var(--safe-bot);
  height: 48px;
  border: 0;
  border-radius: 999px;
  background: rgba(255,251,250,.55);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-soft);
  font-weight: 800;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.preview-note {
  position: absolute;
  right: 12px;
  bottom: calc(var(--safe-bot) + 52px);
  font-size: 9px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  pointer-events: none;
  display: none;
}

/* ---------- Shared inner screens ---------- */
.screen-head {
  padding: calc(var(--safe-top) + 6px) 12px 8px;
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  z-index: 2;
}
.screen-head h2 {
  margin: 0;
  text-align: center;
  font-family: Fraunces, Georgia, serif;
  font-weight: 600;
  font-size: 20px;
  letter-spacing: -.02em;
}
.back {
  width: 40px; height: 40px;
  border: 0; background: rgba(255,251,250,.7);
  border-radius: 50%;
  display: grid; place-items: center;
  box-shadow: var(--shadow-soft);
  padding: 0;
}
.screen-sub {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  margin: -2px 0 8px;
}
.scroll {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 16px 20px;
}

/* ---------- Spelling ---------- */
#view-spelling { background: linear-gradient(180deg, #F8E6D4 0%, #F7EBE3 30%, #F7EBE3 100%); }
.speak-btn {
  width: 88px; height: 88px;
  margin: 6px auto 8px;
  border: 0;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: var(--shadow);
  display: grid; place-items: center;
}
.speak-btn:active { transform: scale(.96); }
.speak-caption {
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 0 16px;
}
.hint {
  text-align: center;
  font-family: Fraunces, Georgia, serif;
  font-style: italic;
  font-size: 16px;
  color: var(--ink-soft);
  margin: 0 16px 18px;
  min-height: 24px;
}
.slots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 0 8px 28px;
  min-height: 62px;
}
.slot {
  width: 38px; height: 52px;
  border-radius: 12px;
  background: rgba(255,251,250,.7);
  border: 1.5px dashed rgba(58,42,50,.18);
  display: grid; place-items: center;
  font-weight: 800;
  font-size: 24px;
  text-transform: lowercase;
}
.slot.filled {
  background: var(--paper);
  border: 1.5px solid transparent;
  box-shadow: var(--shadow-soft);
  animation: pop .22s ease;
}
@keyframes pop {
  0% { transform: scale(.8); }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
.tiles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding: 0 12px;
}
.tile {
  width: 56px; height: 58px;
  border: 0;
  border-radius: 16px;
  background: var(--paper);
  box-shadow: 0 6px 0 #E8D4C8, var(--shadow-soft);
  font-weight: 800;
  font-size: 26px;
  text-transform: lowercase;
  padding: 0 0 2px;
}
.tile:active { transform: translateY(3px); box-shadow: 0 3px 0 #E8D4C8, var(--shadow-soft); }
.tile.used { display: none; }
.tile.shake { animation: shake .35s ease; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.tile.hint-pulse { box-shadow: 0 6px 0 #E8D4C8, 0 0 0 4px rgba(196,92,134,.28); }

.nice {
  position: absolute;
  left: 50%; top: 42%;
  transform: translate(-50%,-50%);
  font-family: Fraunces, Georgia, serif;
  font-style: italic;
  font-size: 42px;
  color: var(--blush-deep);
  pointer-events: none;
  opacity: 0;
}
.nice.show { animation: nice .9s ease; }
@keyframes nice {
  0% { opacity: 0; transform: translate(-50%,-40%) scale(.8); }
  25% { opacity: 1; transform: translate(-50%,-50%) scale(1.05); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%,-60%) scale(1); }
}

/* ---------- Verse ---------- */
#view-verse { background: linear-gradient(180deg, #EEDCF4 0%, #F7EBE3 28%, #F7EBE3 100%); }
.verse-card {
  background: var(--paper);
  border-radius: 24px;
  padding: 28px 22px 22px;
  box-shadow: var(--shadow);
  text-align: center;
  margin-top: 8px;
}
.verse-text {
  font-family: Fraunces, Georgia, serif;
  font-style: italic;
  font-weight: 500;
  font-size: 28px;
  line-height: 1.35;
  letter-spacing: -.02em;
  margin: 0 0 14px;
}
.verse-ref {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  margin: 0 0 18px;
}
.primary, .secondary {
  display: block;
  width: 100%;
  height: 52px;
  border: 0;
  border-radius: 999px;
  font-weight: 800;
  font-size: 16px;
}
.primary {
  background: var(--ink);
  color: #FFF8F4;
  margin-top: 8px;
  box-shadow: var(--shadow-soft);
}
.secondary {
  background: transparent;
  color: var(--ink-soft);
  margin-top: 4px;
}
.verse-build {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  min-height: 90px;
  margin: 8px 0 24px;
  align-content: flex-start;
}
.verse-slot {
  min-width: 64px;
  height: 40px;
  padding: 0 10px;
  border-radius: 12px;
  border: 1.5px dashed rgba(58,42,50,.2);
  background: rgba(255,251,250,.65);
  display: grid; place-items: center;
  font-weight: 800;
  font-size: 15px;
}
.verse-slot.filled {
  border-style: solid;
  border-color: transparent;
  background: var(--paper);
  box-shadow: var(--shadow-soft);
  animation: pop .22s ease;
}
.word-bank {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.word-tile {
  border: 0;
  height: 44px;
  padding: 0 14px;
  border-radius: 14px;
  background: var(--paper);
  box-shadow: 0 5px 0 #E4D0E4, var(--shadow-soft);
  font-weight: 800;
  font-size: 15px;
}
.word-tile:active { transform: translateY(3px); box-shadow: 0 2px 0 #E4D0E4; }
.word-tile.used { display: none; }
.word-tile.shake { animation: shake .35s ease; }

/* ---------- Reading ---------- */
#view-reading, #view-timer { background: linear-gradient(180deg, #DCECD8 0%, #F7EBE3 28%, #F7EBE3 100%); }
.read-list { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.read-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
  align-items: flex-start;
  background: var(--paper);
  border-radius: 18px;
  padding: 16px 16px 14px;
  box-shadow: var(--shadow);
  border: 0;
  text-align: left;
  width: 100%;
}
.read-item .box {
  width: 28px; height: 28px;
  border-radius: 8px;
  border: 1.5px solid rgba(58,42,50,.22);
  display: grid; place-items: center;
  margin-top: 1px;
  background: #fff;
}
.read-item.done .box {
  background: var(--sage);
  border-color: var(--sage);
  color: #fff;
}
.read-item .title { font-weight: 800; font-size: 16px; line-height: 1.3; }
.read-item .meta { display: block; margin-top: 3px; font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.read-item.done .title { color: var(--ink-soft); }
.together-card {
  margin-top: 16px;
  background: var(--paper);
  border-radius: 22px;
  padding: 18px;
  box-shadow: var(--shadow);
  text-align: center;
}
.together-card p { margin: 0 0 12px; font-size: 14px; font-weight: 600; color: var(--ink-soft); }
.timer-stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 20px 40px; }
.timer-clock {
  font-family: Fraunces, Georgia, serif;
  font-weight: 600;
  font-size: 64px;
  letter-spacing: -.04em;
  margin: 8px 0 8px;
}
.timer-note {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-soft);
  text-align: center;
  max-width: 260px;
  margin: 0 0 24px;
}

/* ---------- Reward ---------- */
#view-reward {
  background: radial-gradient(ellipse at 50% 36%, #FFF6D8 0%, #F8E0D0 42%, #E8D0F0 100%);
}
.reward-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 24px calc(var(--safe-bot) + 20px);
  text-align: center;
  position: relative;
}
.reward-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 8px;
}
.reward-title {
  font-family: Fraunces, Georgia, serif;
  font-style: italic;
  font-weight: 600;
  font-size: 36px;
  letter-spacing: -.03em;
  margin: 0 0 6px;
  line-height: 1.15;
}
.reward-sub {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-soft);
  margin: 0 0 8px;
  max-width: 280px;
}
.reward-mascot { width: 260px; height: 270px; margin: 4px 0 16px; }
.burst { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.burst i {
  position: absolute;
  width: 10px; height: 10px;
  background: #fff6c8;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation: burst 1.4s ease-out both;
}
@keyframes burst {
  0% { opacity: 0; transform: translate(0,0) scale(.4); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.2); }
}

/* ---------- Meadow / collection ---------- */
#view-meadow { background: linear-gradient(180deg, #F8E6D4 0%, #F0D8E8 100%); }
.meadow-hero { height: 250px; position: relative; }
.meadow-hero .mascot-wrap { width: 260px; height: 270px; bottom: 0; }
.color-row {
  display: flex;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 8px;
  padding: 4px 16px 16px;
}
.swatch {
  width: 34px; height: 34px;
  flex: 0 0 34px;
  border-radius: 50%;
  border: 2px solid rgba(255,251,250,.9);
  box-shadow: var(--shadow-soft);
  padding: 0;
  position: relative;
  background: var(--c);
}
.swatch.on { box-shadow: 0 0 0 3px var(--ink), var(--shadow-soft); }
.swatch.locked { filter: grayscale(.4) brightness(.92); }
.swatch.locked::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(40,24,32,.28);
}
.friends-label {
  margin: 4px 20px 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.friends {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  padding: 0 16px 20px;
}
.friend {
  background: var(--paper);
  border: 0;
  border-radius: 20px;
  padding: 8px 6px 10px;
  box-shadow: var(--shadow);
  text-align: center;
  min-height: 150px;
}
.friend .mini { height: 110px; }
.friend .mini.locked { filter: grayscale(1) contrast(.8); opacity: .55; }
.friend .fn { display: block; font-weight: 800; font-size: 12px; margin-top: 2px; }
.friend .fh { display: block; font-size: 10px; font-weight: 600; color: var(--ink-soft); line-height: 1.3; padding: 0 4px; }
.friend.on { box-shadow: 0 0 0 2.5px var(--ink), var(--shadow); }

/* ---------- Parent ---------- */
#view-parent { background: #F4EEEA; }
.example-banner {
  margin: 0 16px 10px;
  background: #F3E2A0;
  color: #5A4418;
  border-radius: 12px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  flex: 0 0 auto;
}
.field { margin: 0 0 8px; }
.field label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 8px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--paper);
  border-radius: 999px;
  padding: 4px 4px 4px 10px;
  font-weight: 700;
  font-size: 13px;
  box-shadow: var(--shadow-soft);
}
.chip button {
  width: 22px; height: 22px;
  border: 0; background: #F0E4E0;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}
.row-input {
  display: flex;
  gap: 8px;
}
.row-input input, .field input, .field textarea {
  flex: 1;
  border: 0;
  background: var(--paper);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 15px;
  font-weight: 600;
  box-shadow: var(--shadow-soft);
  outline: none;
  width: 100%;
}
.field textarea { min-height: 56px; resize: vertical; }
.row-input button.add, .add-btn {
  border: 0;
  background: var(--ink);
  color: #FFF8F4;
  border-radius: 12px;
  font-weight: 800;
  padding: 0 14px;
  height: 44px;
}
.parent-actions {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 16px calc(var(--safe-bot) + 8px);
  background: #F4EEEA;
  box-shadow: 0 -8px 20px rgba(80,40,55,.04);
  flex: 0 0 auto;
}
.parent-actions .primary { height: 48px; }
.parent-links { display: flex; justify-content: space-between; }
.parent-actions .ghost { padding: 8px 4px; }
#view-parent { background: #F4EEEA; }
#view-parent .scroll { padding-bottom: 12px; }

.ghost {
  background: transparent;
  border: 0;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 13px;
  padding: 8px;
}
.saved-toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bot) + 16px);
  transform: translateX(-50%);
  background: var(--ink);
  color: #FFF8F4;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
}
.saved-toast.show { animation: toast 1.6s ease; }
@keyframes toast {
  0% { opacity: 0; transform: translateX(-50%) translateY(8px); }
  15%, 75% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; }
}

/* Confirm sheet */
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(40, 24, 32, .35);
  z-index: 20;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.sheet-backdrop.on { display: flex; }
.sheet {
  background: var(--paper);
  width: 100%;
  border-radius: 24px 24px 0 0;
  padding: 22px 20px calc(var(--safe-bot) + 16px);
  text-align: center;
  animation: rise .25s ease;
}
.sheet h3 { margin: 0 0 6px; font-family: Fraunces, Georgia, serif; font-size: 22px; }
.sheet p { margin: 0 0 16px; font-weight: 600; color: var(--ink-soft); font-size: 14px; }

html.shot .mascot img,
html.shot .star-sparkles i { animation: none !important; }
html.shot .burst i { animation: none !important; opacity: .9; }
