:root {
  --night: #1B1940;
  --dusk: #3A3170;
  --rose: #E3A3A0;
  --lantern: #F6C85F;
  --paper: #F4F0FA;
  --ink: #2B2540;
  --soft: #6A6283;
  --leaf: #3E6B57;
  --round: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Segoe UI", system-ui, sans-serif;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: inherit; }
[hidden] { display: none !important; }   /* layout rules must never un-hide things */

html, body { height: 100%; margin: 0; }
body {
  background: var(--night);
  color: var(--paper);
  font-family: var(--round);
  font-size: 1.0625rem;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--lantern); outline-offset: 3px; border-radius: 12px; }

/* header */
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px clamp(14px, 4vw, 28px) 4px;
}
.title {
  flex: 1 1 12ch;
  margin: 0;
  font-size: clamp(1.25rem, 4.4vw, 1.9rem);
  font-weight: 800;
  letter-spacing: .01em;
  color: var(--paper);
}
.help {
  position: relative;
  z-index: 12;           /* stays tappable above any open sheet */
  flex: none;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  background: var(--lantern);
  color: var(--ink);
  font-weight: 700;
  font-size: .95rem;
  box-shadow: 0 0 0 4px rgba(246, 200, 95, .22);
}

/* map */
.stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 12px; }
.row {
  width: min(100%, calc((100dvh - 285px) * .8), 640px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 0 10px;
}
.hint { margin: 0; color: #CFC8E6; font-size: .98rem; }
.lang {
  flex: none;
  border: 2px solid #8A7FC0;
  border-radius: 999px;
  padding: 6px 14px;
  background: transparent;
  color: var(--paper);
  font-weight: 700;
  font-size: .9rem;
}
.lang:hover { background: rgba(244, 240, 250, .1); }

.map {
  position: relative;
  width: min(100%, calc((100dvh - 285px) * .8), 640px);
  min-width: min(100%, 300px);
  aspect-ratio: 4 / 5;
  border-radius: 28px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}
.town { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.pin {
  position: absolute;
  transform: translate(calc(-50% + var(--nudge, 0px)), -100%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: 999px;
  padding: 5px 11px 5px 7px;
  background: rgba(244, 240, 250, .94);
  color: var(--ink);
  font-weight: 700;
  font-size: clamp(.72rem, 2.4vw, .9rem);
  line-height: 1.2;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(20, 16, 50, .35);
  z-index: 2;
}
.pin::after {
  content: "";
  position: absolute;
  left: calc(50% - var(--nudge, 0px));
  bottom: -5px;
  width: 10px;
  height: 10px;
  background: inherit;
  transform: translateX(-50%) rotate(45deg);
  border-radius: 2px;
}
.pin .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--lantern);
  box-shadow: 0 0 0 3px rgba(246, 200, 95, .35);
}
.pin:hover { background: #FFFFFF; }

/* minggoy */
.cat {
  position: absolute;
  width: 12%;
  aspect-ratio: 1;
  transform: translate(-50%, -96%);
  transition: left .9s ease-in-out, top .9s ease-in-out;
  z-index: 1;
  pointer-events: none;
}
.cat svg { width: 100%; height: 100%; display: block; overflow: visible; }
.cat.left svg { transform: scaleX(-1); }
.cat.walking svg { animation: bob .3s ease-in-out infinite alternate; }
.cat.hop svg { animation: hop .5s ease-out 2; }
.cat .eyes { animation: blink 5s infinite; transform-box: fill-box; transform-origin: center; }
.cat .tail { animation: sway 4s ease-in-out infinite; transform-box: view-box; transform-origin: 47px 56px; }

@keyframes bob { to { transform: translateY(-6%); } }
.cat.left.walking svg { animation-name: bobL; }
@keyframes bobL { from { transform: scaleX(-1); } to { transform: scaleX(-1) translateY(-6%); } }
@keyframes hop { 40% { transform: translateY(-22%); } 100% { transform: translateY(0); } }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
@keyframes sway { 50% { transform: rotate(-9deg); } }

/* lanterns: the one moving thing on the map */
.lantern { transform-box: fill-box; animation: drift 7s ease-in-out infinite alternate; }
.lantern.l2 { animation-duration: 9s; animation-delay: -3s; }
.lantern.l3 { animation-duration: 8s; animation-delay: -5s; }
.lantern.l4 { animation-duration: 11s; animation-delay: -2s; }
@keyframes drift { to { transform: translate(4px, -10px); } }
.riser { animation: rise 7s ease-in forwards; }
@keyframes rise {
  0% { transform: translateY(0); opacity: 0; }
  10% { opacity: 1; }
  100% { transform: translate(-30px, -300px); opacity: 0; }
}
#blades { transform-box: view-box; transform-origin: 200px 386px; }
.breathing #blades { animation: spin 10s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* footer */
.foot {
  display: flex;
  justify-content: center;
  gap: 18px;
  padding: 10px 12px 14px;
  font-size: .85rem;
  color: #A69ECB;
}
.foot a, .linkish {
  color: #CFC8E6;
  background: none;
  border: 0;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: inherit;
}

/* the sheet each place opens in */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(15, 12, 40, .55);
  z-index: 10;
}
.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  width: min(100%, 560px);
  max-height: 88dvh;
  transform: translateX(-50%);
  z-index: 11;
  background: var(--paper);
  color: var(--ink);
  border-radius: 28px 28px 0 0;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, .35);
  overflow-y: auto;
  animation: up .28s ease-out;
}
@keyframes up { from { transform: translate(-50%, 30px); opacity: 0; } }
.sheet-inner { padding: 26px clamp(20px, 5vw, 32px) calc(22px + env(safe-area-inset-bottom, 0px)); }
.sheet h2 { margin: 0 0 10px; font-size: 1.5rem; font-weight: 800; color: var(--dusk); }
.sheet h2:focus { outline: none; }
.sheet p { margin: 0 0 12px; max-width: 60ch; }
.sheet .say {
  background: #FFFFFF;
  border-radius: 18px;
  padding: 14px 16px;
  margin: 14px 0;
  border-left: 5px solid var(--lantern);
}
.sheet .quiet { color: var(--soft); font-size: .92rem; }

.choices { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.choice {
  border: 2px solid #D9D1EC;
  background: #FFFFFF;
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 600;
  font-size: .95rem;
}
.choice[aria-pressed="true"] { border-color: var(--dusk); background: #E7E1F6; }
.go {
  border: 0;
  border-radius: 999px;
  padding: 11px 20px;
  background: var(--dusk);
  color: var(--paper);
  font-weight: 700;
}
.back {
  display: block;
  width: 100%;
  margin-top: 18px;
  border: 0;
  border-radius: 16px;
  padding: 13px;
  background: #E7E1F6;
  color: var(--dusk);
  font-weight: 700;
}

label.field { display: block; font-weight: 700; margin: 10px 0 6px; }
textarea, input[type="text"] {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: #FFFFFF;
  border: 2px solid #D9D1EC;
  border-radius: 16px;
  padding: 12px 14px;
}
textarea { min-height: 130px; resize: vertical; }

/* attic box */
.box {
  min-height: 70px;
  margin: 12px 0;
  padding: 12px;
  border-radius: 16px;
  background: #EADBC8;
  border: 3px dashed #B98E62;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: flex-start;
}
.box:empty::before { content: attr(data-empty); color: #8A6A4A; font-size: .9rem; }
.keep {
  background: #FFF8EC;
  border-radius: 12px;
  padding: 6px 10px;
  font-size: .92rem;
  box-shadow: 0 2px 0 #C9A57C;
}

/* feelings jars */
.jars { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin: 12px 0; }
.jar {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 2px solid transparent;
  background: #FFFFFF;
  border-radius: 14px;
  padding: 9px 10px;
  text-align: left;
  color: var(--ink);
  font-weight: 600;
  font-size: .93rem;
}
.jar i { flex: none; width: 16px; height: 20px; border-radius: 5px; background: var(--c); }
.jar[aria-pressed="true"] { border-color: var(--dusk); }

/* breathing */
.breath { display: grid; place-items: center; margin: 16px 0 6px; height: 190px; }
.orb {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #FFF3D1, var(--lantern));
  box-shadow: 0 0 40px rgba(246, 200, 95, .6);
  transition: transform 4s ease-in-out;
}
.orb.in { transform: scale(2.3); transition-duration: 4s; }
.orb.out { transform: scale(1); transition-duration: 6s; }
.breath-word { text-align: center; font-weight: 700; font-size: 1.15rem; min-height: 1.6em; color: var(--dusk); }

/* letter lantern */
.sent { display: grid; place-items: center; height: 0; overflow: visible; }
.sent span {
  width: 22px; height: 30px; border-radius: 7px;
  background: var(--lantern);
  box-shadow: 0 0 26px 8px rgba(246, 200, 95, .55);
  animation: letterup 3.5s ease-in forwards;
}
@keyframes letterup { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-260px); opacity: 0; } }

/* help numbers */
.lines { display: grid; gap: 8px; margin: 12px 0; }
.line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #FFFFFF;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}
.line b { color: var(--dusk); font-size: 1.1rem; white-space: nowrap; }
.urgent { background: #FFF1D6; border-left-color: #E0656E; }

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

/* diary ribbon: the daily reason to come back */
.ribbon {
  width: min(100%, calc((100dvh - 285px) * .8), 640px);
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 12px;
  padding: 12px 16px;
  border: 0;
  border-radius: 18px;
  background: #2C2862;
  color: var(--paper);
  text-align: left;
  font-weight: 700;
  font-size: 1rem;
}
.ribbon:hover { background: #36317A; }
.book {
  flex: none;
  width: 26px;
  height: 32px;
  border-radius: 3px 7px 7px 3px;
  background: linear-gradient(90deg, #7A4A22 0 5px, var(--rose) 5px);
  box-shadow: inset -3px 0 0 #F4F0FA;
}
.ribbon-text { flex: 1; }
.ribbon-day { color: #CFC8E6; font-weight: 600; }
.new {
  flex: none;
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--lantern);
  color: var(--ink);
  font-size: .8rem;
}
.ribbon.special { background: #4A2F55; }

/* the diary page */
.page-day { margin: -4px 0 8px; color: var(--soft); font-weight: 700; font-size: .9rem; }
.think {
  margin: 16px 0;
  padding: 14px 16px;
  border-radius: 18px;
  background: #E7E1F6;
}
.think b { display: block; color: var(--dusk); margin-bottom: 4px; }
.think p { margin: 0; }
.think .quiet { margin-top: 6px; }
.next { font-style: italic; color: var(--soft); }
.pages { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.pages .choice { min-width: 44px; padding: 6px 12px; }

/* undas candles only during the window */
#candles { display: none; }
.undas #candles { display: inline; }
.flames { animation: flicker 1.6s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: bottom; }
@keyframes flicker { to { transform: scaleY(.8); opacity: .85; } }

/* impact page for grown-ups and funders */
body.impact { align-items: center; justify-content: center; padding: 24px; }
.impact-card { width: min(100%, 620px); background: var(--paper); color: var(--ink); border-radius: 24px; padding: 28px; }
.impact-card h1 { margin: 0 0 6px; color: var(--dusk); font-size: 1.6rem; }
.impact-card table { width: 100%; border-collapse: collapse; margin: 18px 0; }
.impact-card th, .impact-card td { padding: 10px 8px; border-bottom: 1px solid #D9D1EC; text-align: right; }
.impact-card th:first-child, .impact-card td:first-child { text-align: left; }
.impact-card td { font-variant-numeric: tabular-nums; }
.impact-card a { color: var(--dusk); }

/* music toggle: off by default, one gentle tap to turn on */
.toggles { display: flex; gap: 8px; flex: none; }
.music { display: inline-flex; align-items: center; gap: 6px; }
.note {
  width: 10px; height: 13px;
  border-right: 2px solid currentColor;
  border-top: 2px solid currentColor;
  position: relative;
}
.note::before {
  content: ""; position: absolute; left: -5px; bottom: -3px;
  width: 8px; height: 6px; border-radius: 50%; background: currentColor;
}
.music[aria-pressed="true"] { background: var(--lantern); border-color: var(--lantern); color: var(--ink); }

/* Minggoy's house: the feeding corner */
.pet {
  position: relative;
  width: 160px; height: 160px;
  margin: 8px auto 4px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 62%, #EADBC8 0 58%, #E7E1F6 59%);
  display: grid; place-items: center;
}
.pet svg { width: 118px; height: 118px; overflow: visible; }
.pet.eat svg { animation: nibble .35s ease-in-out 5; }
.pet.purr svg { animation: purr .5s ease-in-out 4; }
.pet.hop svg { animation: hop .5s ease-out 2; }
@keyframes nibble { 50% { transform: translateY(5%) scaleY(.96); } }
@keyframes purr { 25% { transform: rotate(-3deg); } 75% { transform: rotate(3deg); } }
.heart {
  position: absolute; left: 50%; top: 30%;
  color: #E0656E; font-size: 22px; pointer-events: none;
  animation: floatup 1.6s ease-out forwards;
}
@keyframes floatup { from { transform: translate(-50%, 0); opacity: 1; } to { transform: translate(-50%, -70px); opacity: 0; } }
.meters { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.meter { background: #FFFFFF; border-radius: 999px; padding: 6px 12px; font-size: .9rem; }
.meter b { color: var(--dusk); margin-right: 4px; }
.care { display: flex; justify-content: center; gap: 8px; margin: 8px 0; }
.foods { justify-content: center; }

/* the night continues past the map on wide screens */
body {
  background:
    radial-gradient(1px 1px at 12% 18%, rgba(255,255,255,.7), transparent 60%),
    radial-gradient(1.5px 1.5px at 22% 64%, rgba(255,255,255,.45), transparent 60%),
    radial-gradient(1px 1px at 31% 36%, rgba(255,255,255,.6), transparent 60%),
    radial-gradient(1.2px 1.2px at 68% 22%, rgba(255,255,255,.6), transparent 60%),
    radial-gradient(1px 1px at 78% 58%, rgba(255,255,255,.5), transparent 60%),
    radial-gradient(1.5px 1.5px at 88% 30%, rgba(255,255,255,.7), transparent 60%),
    radial-gradient(1px 1px at 93% 76%, rgba(255,255,255,.4), transparent 60%),
    radial-gradient(1px 1px at 6% 82%, rgba(255,255,255,.4), transparent 60%),
    radial-gradient(ellipse 120% 45% at 50% 100%, #3A3170 0%, rgba(58,49,112,0) 70%),
    var(--night);
  background-attachment: fixed;
}
.skyfield { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.skyfield span {
  position: absolute; width: 12px; height: 16px; border-radius: 4px;
  background: var(--lantern); box-shadow: 0 0 22px 8px rgba(246,200,95,.35);
  animation: skydrift 14s ease-in-out infinite alternate;
}
.skyfield span:nth-child(1) { left: 9%;  top: 28%; }
.skyfield span:nth-child(2) { left: 16%; top: 62%; transform: scale(.7); animation-duration: 18s; }
.skyfield span:nth-child(3) { right: 11%; top: 38%; animation-duration: 16s; animation-delay: -6s; }
.skyfield span:nth-child(4) { right: 18%; top: 70%; transform: scale(.6); animation-duration: 20s; }
@keyframes skydrift { to { translate: 6px -22px; } }
@media (max-width: 900px) { .skyfield { display: none; } }
.stage, .foot { position: relative; z-index: 1; }
.top {
  position: sticky; top: 0; z-index: 12;      /* help button above every overlay, and never scrolled away */
  background: rgba(27, 25, 64, .88);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  padding-bottom: 10px;
}

.title-btn { all: unset; cursor: pointer; }
.title-btn:focus-visible { outline: 3px solid var(--lantern); outline-offset: 4px; border-radius: 8px; }

/* front door */
.welcome {
  position: fixed; inset: 0; z-index: 11;
  display: grid; place-items: center; padding: 20px;
  background: radial-gradient(ellipse at 50% 30%, rgba(58,49,112,.96), rgba(27,25,64,.98));
  overflow-y: auto;
}
.welcome-card {
  width: min(100%, 440px); text-align: center;
  background: var(--paper); color: var(--ink);
  border-radius: 28px; padding: 26px 24px 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
  animation: up .35s ease-out;
}
.welcome-cat {
  width: 150px; height: 150px; margin: -80px auto 6px;
  border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 62%, #EADBC8 0 58%, #E7E1F6 59%);
  box-shadow: 0 0 0 6px var(--paper), 0 0 40px 10px rgba(246,200,95,.35);
}
.welcome-cat svg { width: 110px; height: 110px; overflow: visible; }
.welcome h2 { margin: 0; font-size: 1.7rem; color: var(--dusk); }
.welcome h2:focus { outline: none; }
.welcome-miss { font-size: 1.15rem; margin: 6px 0 14px; }
.welcome input { text-align: center; }
.welcome .field { text-align: center; }
.welcome-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.welcome-actions .go { padding: 14px; font-size: 1.05rem; }
.welcome-actions .choice { text-decoration: none; text-align: center; padding: 11px; }
.wlang { margin-top: 14px; border-color: #D9D1EC; color: var(--dusk); }
.wlang:hover { background: #E7E1F6; }
.forget {
  display: block; margin: 14px auto 0; border: 0; background: none; padding: 4px;
  color: var(--soft); font-size: .85rem; text-decoration: underline; text-underline-offset: 3px;
}
.forget.armed { color: #B3261E; font-weight: 700; }
.forget-sure { margin: 6px 0 0; font-size: .85rem; color: #B3261E; }
.welcome { padding-top: 120px; }

/* grown-ups homepage */
body.gu { display: block; }
.gu-wrap { position: relative; z-index: 1; width: min(100% - 32px, 760px); margin: 0 auto; padding: 40px 0 30px; }
.gu-hero { text-align: left; padding: 10px 4px 26px; }
.gu-over { color: var(--lantern); font-weight: 800; font-size: .8rem; letter-spacing: .14em; margin: 0 0 8px; }
.gu-hero h1 { margin: 0 0 12px; font-size: clamp(1.8rem, 5vw, 2.6rem); line-height: 1.15; color: #FFFFFF; }
.gu-lead { color: #CFC8E6; font-size: 1.1rem; max-width: 60ch; }
.gu-btn { display: inline-block; margin-top: 6px; padding: 12px 22px; border-radius: 999px; background: var(--lantern); color: var(--ink); font-weight: 800; text-decoration: none; }
.gu-card { background: var(--paper); color: var(--ink); border-radius: 22px; padding: 22px 24px; margin: 0 0 16px; }
.gu-card h2 { margin: 0 0 10px; color: var(--dusk); font-size: 1.3rem; }
.gu-card p { margin: 0 0 10px; max-width: 68ch; }
.gu-card ul { margin: 0; padding-left: 1.1em; }
.gu-card li { margin: 0 0 8px; }
.gu-card a { color: var(--dusk); }
.gu-urgent { background: #FFF1D6; }
.gu-founder { margin: 26px 4px 10px; color: #FFFFFF; }
.gu-founder p:first-child { font-size: 1.25rem; font-style: italic; line-height: 1.5; color: var(--lantern); }
.gu-sign { color: #CFC8E6; }
.gu-foot { text-align: center; color: #A69ECB; }
.gu-foot a { color: #CFC8E6; }

/* title reads as "home" */
.title-btn { display: inline-flex; align-items: center; gap: 10px; border-radius: 10px; }
.home-ico { width: .9em; height: .9em; color: var(--lantern); flex: none; }
.title-btn:hover .home-ico { transform: translateY(-2px); }
.title-btn:hover { color: var(--lantern); }

/* rooftop star catch */
.roofgame { position: relative; margin: 12px 0 8px; border-radius: 18px; overflow: hidden; background: #1B1940; touch-action: manipulation; }
.roofgame canvas { display: block; width: 100%; height: auto; cursor: pointer; }
.roofcount { position: absolute; top: 10px; left: 12px; color: #F4F0FA; font-weight: 800; font-size: .95rem; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.hops { display: flex; gap: 10px; }
.hops .go { flex: 1; padding: 14px; font-size: 1.05rem; }
