@font-face { font-family: "Baloo 2"; font-style: normal; font-weight: 400 800; font-display: swap; src: url("fonts/baloo2-latin.woff2") format("woff2"); }

:root {
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  --choc: #5B2A1A;
  --lav: #DCCBF3;
  --lav-deep: #9C7FD6;
  --peach: #FDAE84;
  --mint: #B8EDC0;
  --sky: #9FD4F5;
  --butter: #FFE08A;
  --pink: #F4A7B5;
  --coral: #F07C6E;
  --page: #FFF3E6;
  --panel: #FFFDF9;
  --ink: #5B2A1A;
  --ink-soft: #8C5E4B;
  --line: #5B2A1A;
  --track: #F4E2D2;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #231A2C;
    --panel: #30263B;
    --ink: #F9EADF;
    --ink-soft: #CDB3C4;
    --line: #EBCDBD;
    --track: #43364F;
  }
}
:root[data-theme="dark"] {
  --page: #231A2C;
  --panel: #30263B;
  --ink: #F9EADF;
  --ink-soft: #CDB3C4;
  --line: #EBCDBD;
  --track: #43364F;
}
*, *::before, *::after { box-sizing: inherit; }
[hidden] { display: none !important; }
html { height: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--page); color: var(--ink);
  font-family: "Baloo 2", "Nunito", "Arial Rounded MT Bold", ui-rounded, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none;
}
button { font: inherit; color: inherit; }
.app {
  height: 100%; max-width: 560px; margin: 0 auto;
  display: flex; flex-direction: column;
}

/* ---------- HUD ---------- */
.hud { flex: none; padding: 10px 16px 8px; }
.title-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) 40px; align-items: center; gap: 10px; }
.wordmark { display: block; width: min(164px, 100%); height: 48px; object-fit: contain; justify-self: center; }
.stage-chip {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 15px; font-weight: 700; color: var(--ink-soft);
  padding-top: 0;
}
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; border: 2px solid var(--line); background: transparent; }
.dots i.on { background: var(--lav-deep); border-color: var(--lav-deep); }
.menu-btn {
  margin-left: auto; width: 40px; height: 40px; border-radius: 50%;
  border: 3px solid var(--line); background: var(--panel); cursor: pointer;
  display: grid; place-items: center; padding: 0;
}
.menu-btn svg { width: 20px; height: 20px; }
.menu-btn:focus-visible, .act:focus-visible .ico, .sheet button:focus-visible, .reveal button:focus-visible { outline: 3px solid var(--lav-deep); outline-offset: 3px; }

.growth { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.growth .bar { height: 12px; }
.growth .bar i { background: linear-gradient(90deg, #E9D7FF, var(--lav-deep)); }
.growth-label { flex: none; font-size: 13px; font-weight: 700; color: var(--ink-soft); min-width: 78px; text-align: right; }

.needs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px 14px; margin-top: 10px; }
.need { display: flex; align-items: center; gap: 6px; background: none; border: 0; padding: 0; cursor: pointer; }
.need svg { width: 22px; height: 22px; flex: none; }
.bar { flex: 1; height: 10px; border-radius: 7px; background: var(--track); border: 2px solid var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; width: 50%; border-radius: 5px; background: var(--c, var(--lav)); transition: width .45s ease; }
.need.low .bar i { background: var(--coral); animation: lowpulse 1.4s ease-in-out infinite; }
@keyframes lowpulse { 50% { opacity: .55; } }

/* ---------- Scene ---------- */
.scene {
  flex: 1 1 auto; position: relative; overflow: hidden;
  margin: 2px 10px 0; border-radius: 30px;
  border: 3px solid var(--line);
  background: #FCEBD3;
  touch-action: none;
  isolation: isolate;
}
.layer { position: absolute; top: 0; bottom: 0; left: -26px; right: -26px; will-change: transform; }
.layer svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.layer.mid { pointer-events: none; }
.layer.front svg { pointer-events: none; }
.hot { pointer-events: visiblePainted; cursor: pointer; }
.sky { opacity: 0; transition: opacity 1.4s ease; }
.tod-day .sky-day, .tod-evening .sky-eve, .tod-night .sky-night { opacity: 1; }

.pet { position: absolute; left: 50%; z-index: 1; transform: translateX(-50%); pointer-events: none; }
.pet canvas { position: absolute; left: 0; bottom: 0; pointer-events: auto; touch-action: none; outline: none; }
.pet.charging { animation: charge .42s ease-in-out 4; }
@keyframes charge { 50% { filter: brightness(1.9) drop-shadow(0 0 16px #fff); } }
.shadow {
  position: absolute; left: 50%; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(91,42,26,.28), rgba(91,42,26,0));
  transform-origin: 50% 50%;
}
.brushing .pet canvas { cursor: crosshair; }

.bubble {
  position: absolute; width: 50px; height: 46px; pointer-events: none;
  opacity: 0; transform: scale(.4); transform-origin: 20% 100%;
  transition: opacity .3s, transform .35s cubic-bezier(.3,1.6,.5,1);
}
.bubble.show { opacity: 1; transform: scale(1); }
.bubble .b-in {
  position: absolute; inset: 0; border-radius: 22px; background: #fff;
  border: 3px solid var(--choc); display: grid; place-items: center;
  animation: bob 2.2s ease-in-out infinite;
}
.bubble .b-in svg { width: 28px; height: 28px; }
.bubble::before, .bubble::after {
  content: ""; position: absolute; background: #fff; border: 2.5px solid var(--choc); border-radius: 50%;
}
.bubble::before { width: 12px; height: 12px; left: -4px; bottom: -8px; }
.bubble::after { width: 7px; height: 7px; left: -12px; bottom: -16px; }
@keyframes bob { 50% { transform: translateY(-4px); } }

.poops { position: absolute; z-index: 2; inset: 0; pointer-events: none; }
.poop {
  position: absolute; transform: translateX(-50%); pointer-events: auto; cursor: pointer;
  background: none; border: 0; padding: 0; touch-action: none;
  animation: plop .45s cubic-bezier(.3,1.7,.5,1);
}
.poop svg { width: 100%; height: 100%; display: block; pointer-events: none; }
.poop-carry { position: absolute; z-index: 14; pointer-events: none; filter: drop-shadow(0 7px 4px rgba(91,42,26,.25)); }
.poop-carry svg { width: 100%; height: 100%; display: block; }
.poop .stink { position: absolute; left: 50%; top: -30%; width: 60%; transform: translateX(-50%); animation: stink 1.8s ease-in-out infinite; }
@keyframes plop { from { transform: translateX(-50%) scale(.2); } }
@keyframes stink { 0%,100% { transform: translateX(-50%) translateY(0); opacity: .9; } 50% { transform: translateX(-40%) translateY(-5px); opacity: .5; } }
#trash .bin-lid { transform-box: fill-box; transform-origin: center bottom; transition: transform .22s cubic-bezier(.2,1.4,.4,1); }
#trash.bin-ready .bin-lid, #trash.bin-swallow .bin-lid { transform: translate(-4px,-13px) rotate(-11deg); }
#trash.bin-ready .bin-shell { filter: drop-shadow(0 0 7px #fff7ca); }
#trash.bin-swallow .bin-shell { animation: bin-nom .45s ease-in-out; }
@keyframes bin-nom { 45% { transform: scale(1.1,.85) translateY(5px); } 75% { transform: scale(.95,1.09) translateY(-3px); } }

.fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.p { position: absolute; left: 0; top: 0; pointer-events: none; will-change: transform, opacity; }
.p svg { width: 100%; height: 100%; display: block; }
.p.float { animation: floatUp var(--dur, 1.1s) cubic-bezier(.2,.7,.3,1) forwards; }
@keyframes floatUp {
  0% { transform: translate(-50%, -50%) scale(.3) rotate(0deg); opacity: 0; }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(var(--s, 1)) rotate(0deg); }
  100% { transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, -80px))) scale(calc(var(--s, 1) * .8)) rotate(var(--rot, 0deg)); opacity: 0; }
}
.zz { font-weight: 800; color: #B79BE6; -webkit-text-stroke: 1.5px var(--choc); line-height: 1; }

.night { position: absolute; inset: 0; pointer-events: none; background: #1C1644; mix-blend-mode: multiply; opacity: 0; transition: opacity 1.2s ease, background-color 1.2s; }
.tod-evening .night { opacity: .12; background: #5B2E55; }
.tod-night .night { opacity: .3; }
.lights-off .night { opacity: .62; background: #1C1644; }
.lampglow {
  position: absolute; pointer-events: none; mix-blend-mode: screen; opacity: 0; transition: opacity 1s;
  background: radial-gradient(closest-side, rgba(255,214,150,.7), rgba(255,214,150,0));
  transform: translate(-50%, -50%);
}
.tod-night .lampglow, .tod-evening .lampglow { opacity: 1; }
.lights-off .lampglow { opacity: 0; }
.flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .38s ease;
  background: radial-gradient(circle at 50% 62%, #fff 0%, #fff 45%, rgba(255,250,255,.9) 100%); }
.flash.on { opacity: 1; }

.toast {
  position: absolute; left: 50%; top: 14px; transform: translate(-50%, -12px);
  max-width: calc(100% - 40px); width: max-content;
  background: #FFFDF9; color: #5B2A1A; border: 3px solid #5B2A1A; border-radius: 18px;
  box-shadow: 0 4px 0 #5B2A1A; padding: 6px 14px; font-size: 16px; font-weight: 700; text-align: center;
  opacity: 0; transition: opacity .25s, transform .3s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.banner {
  position: absolute; left: 50%; top: 18%; transform: translate(-50%, 0) scale(.6);
  background: #FFFDF9; color: #5B2A1A; border: 3px solid #5B2A1A; border-radius: 24px; box-shadow: 0 5px 0 #5B2A1A;
  padding: 10px 22px 12px; text-align: center; opacity: 0; pointer-events: none;
  transition: opacity .3s, transform .45s cubic-bezier(.3,1.6,.5,1);
}
.banner.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.banner b { display: block; font-size: 24px; line-height: 1.1; font-weight: 800; }
.banner span { font-size: 16px; font-weight: 600; color: #8C5E4B; }

.hint {
  position: absolute; left: 50%; bottom: 6%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
  background: rgba(255,253,249,.94); color: #5B2A1A; border: 3px solid #5B2A1A; border-radius: 18px;
  padding: 5px 14px 5px 8px; font-size: 16px; font-weight: 700; pointer-events: none;
  opacity: 0; transition: opacity .4s;
}
.hint.show { opacity: 1; }
.hint svg { width: 28px; height: 28px; animation: swipe 1.6s ease-in-out infinite; }
@keyframes swipe { 0%,100% { transform: translateX(-5px) rotate(-8deg); } 50% { transform: translateX(6px) rotate(8deg); } }

/* ---------- Dock ---------- */
.dock { flex: none; display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; padding: 12px 8px 12px; }
.act {
  appearance: none; background: none; border: 0; padding: 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  font-size: 14px; font-weight: 700; line-height: 1.1; color: var(--ink); touch-action: manipulation;
}
.act[data-act="clean"], .act[data-act="brush"], .act[data-act="play"] { touch-action: none; }
.act:is([data-act="clean"],[data-act="brush"],[data-act="play"]) .ico {
  width: min(66px, 17.5vw); height: min(66px, 17.5vw);
}
.act:is([data-act="clean"],[data-act="brush"],[data-act="play"]) .ico svg { width: 42px; height: 42px; }
.held-tool {
  position: fixed; z-index: 19; width: 80px; height: 80px;
  display: grid; place-items: center; pointer-events: none;
  filter: drop-shadow(0 5px 4px rgba(91,42,26,.33));
  transform: translate3d(-50%, -50%, 0); will-change: left, top;
}
.held-tool svg { display: block; width: 76px; height: 76px; transform: rotate(var(--tool-rotation, 0deg)); }
.held-tool.on-pet { filter: drop-shadow(0 0 8px #fff) drop-shadow(0 4px 3px rgba(91,42,26,.3)); }
.act .ico {
  width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center;
  background: var(--btn, #fff); border: 3px solid var(--line); box-shadow: 0 4px 0 var(--line);
  transition: transform .1s ease, box-shadow .1s ease, background-color .2s;
}
.act .ico svg { width: 32px; height: 32px; }
.act:active .ico { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.act[data-act="feed"] { --btn: #FFD9C2; }
.act[data-act="clean"] { --btn: #D6EEFC; }
.act[data-act="brush"] { --btn: #EDE3FB; }
.act[data-act="play"] { --btn: #D7F5DB; }
.act[data-act="light"] { --btn: #FFF1BF; }
.act.is-on .ico { background: var(--lav-deep); }
.act.is-on .ico svg { transform: rotate(-12deg); }
.locked .act { pointer-events: none; opacity: .55; }

/* ---------- Sheet & reveal ---------- */
.sheet, .reveal { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden], .reveal[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(35,20,40,.45); }
.sheet-panel {
  position: relative; width: min(560px, 100%); background: var(--panel); color: var(--ink);
  border: 3px solid var(--line); border-bottom: 0; border-radius: 28px 28px 0 0;
  padding: 18px 20px calc(18px + env(safe-area-inset-bottom, 0px));
  animation: up .3s cubic-bezier(.2,.9,.3,1);
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-panel h2 { margin: 0 0 8px; font-size: 24px; font-weight: 800; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 2px dashed var(--track); font-size: 17px; font-weight: 600; }
.seg { display: inline-flex; border: 3px solid var(--line); border-radius: 14px; overflow: hidden; }
.seg button { width: 44px; height: 36px; border: 0; background: transparent; font-weight: 800; font-size: 17px; cursor: pointer; }
.seg button + button { border-left: 3px solid var(--line); }
.seg button.on { background: var(--lav); color: #5B2A1A; }
.switch { appearance: none; width: 52px; height: 30px; border-radius: 16px; border: 3px solid var(--line); background: var(--track); position: relative; cursor: pointer; flex: none; margin: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--line); transition: left .2s; }
.switch:checked { background: var(--mint); }
.switch:checked::after { left: 24px; }
.switch:focus-visible { outline: 3px solid var(--lav-deep); outline-offset: 3px; }
.btn-plain { border: 0; background: none; padding: 0; font-size: 17px; font-weight: 700; cursor: pointer; color: #C2553F; }
.note { margin: 10px 0 4px; font-size: 14px; color: var(--ink-soft); }
.btn-main {
  width: 100%; margin-top: 10px; height: 50px; border-radius: 18px; cursor: pointer;
  background: var(--lav); color: #5B2A1A; border: 3px solid var(--line); box-shadow: 0 4px 0 var(--line);
  font-size: 19px; font-weight: 800;
}
.btn-main:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }

.reveal { align-items: center; background: rgba(35,20,40,.5); padding: 20px; }
.reveal-card {
  width: min(360px, 100%); background: #FFFDF9; color: #5B2A1A; border: 3px solid #5B2A1A; border-radius: 30px;
  box-shadow: 0 6px 0 #5B2A1A; padding: 22px 22px 20px; text-align: center;
  animation: pop .55s cubic-bezier(.3,1.6,.5,1);
}
@keyframes pop { from { transform: scale(.5); opacity: 0; } }
.rarity { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 16px; color: #7A55C9;
  background: #F1E8FE; border: 2.5px solid #9C7FD6; border-radius: 14px; padding: 2px 12px; }
.rarity span { font-weight: 600; color: #8C5E4B; }
.reveal-card h2 { font-size: 27px; line-height: 1.1; margin: 12px 0 8px; font-weight: 800; }
.reveal-card p { margin: 0 0 6px; font-size: 17px; line-height: 1.35; color: #8C5E4B; }
.reveal-card .btn-main { color: #5B2A1A; border-color: #5B2A1A; box-shadow: 0 4px 0 #5B2A1A; }

@media (max-height: 700px) {
  .wordmark { width: min(145px, 100%); height: 40px; }
  .needs { margin-top: 6px; gap: 5px 12px; }
  .act .ico { width: 50px; height: 50px; }
  .act .ico svg { width: 28px; height: 28px; }
  .act:is([data-act="clean"],[data-act="brush"],[data-act="play"]) .ico { width: min(57px, 17vw); height: min(57px, 17vw); }
  .act:is([data-act="clean"],[data-act="brush"],[data-act="play"]) .ico svg { width: 36px; height: 36px; }
  .dock { padding: 8px 6px 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .bubble .b-in, .hint svg, .poop .stink, .need.low .bar i { animation: none; }
}

html { box-sizing: border-box; padding: 0; }
body { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); overscroll-behavior: none; }
.sheet-panel { max-height: 92vh; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain; }
.backup-actions { display: flex; gap: 8px; margin: 14px 0; flex-wrap: wrap; }
.btn-secondary { border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px; background: var(--panel); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; min-height: 44px; }
.btn-secondary:focus-visible, summary:focus-visible { outline: 3px solid var(--lav-deep); outline-offset: 3px; }
.local-info { padding: 12px 0; border-top: 2px dashed var(--track); font-size: 14px; line-height: 1.45; color: var(--ink-soft); }
.local-info summary { cursor: pointer; font-size: 16px; font-weight: 700; color: var(--ink); min-height: 32px; }
.local-info p { margin: 9px 0; }
.version { opacity: .8; font-size: 12px; }
.restore-confirm { background: var(--track); border-radius: 12px; padding: 10px; }
.restore-confirm p { margin: 0 0 8px; }
#saveNote[data-error="true"] { color: #B43625; font-weight: 700; }
