:root {
  color: #302a26;
  background: #ddd8d0;
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
  font-synthesis: none;
  --ink: #302a26;
  --paper: #fffaf1;
  --line: #ded4c7;
  --coral: #df674a;
  --orange: #ed9c32;
  --green: #779b51;
  --aqua: #58aab4;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button { font: inherit; color: inherit; cursor: pointer; }

.app-shell {
  position: relative;
  width: min(100%, 480px);
  min-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 0 0 40px rgb(56 42 30 / 16%);
  padding-bottom: 74px;
}

.topbar {
  height: 72px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fffdf8;
  border-bottom: 1px solid var(--line);
}

.topbar h1, .section-heading h2 { margin: 2px 0 0; font-size: 21px; letter-spacing: 0; }
.eyebrow { margin: 0; color: #887a6b; font-size: 11px; font-weight: 700; }
.icon-button, .profile-button {
  width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; font-weight: 800;
}
.top-actions { display: flex; gap: 7px; }
.profile-button { background: #2d473b; color: white; border-color: #2d473b; }

.view { display: none; min-height: calc(100dvh - 146px); }
.view.active { display: block; }

.habitat {
  position: relative;
  min-height: 58dvh;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 35%, rgb(248 133 48 / 40%), transparent 22%),
    linear-gradient(#443832 0 56%, #2c2826 56% 100%);
}
.habitat-sky {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 15% 20%, #ffb44f 0 2px, transparent 3px),
    radial-gradient(circle at 82% 31%, #ffdf9a 0 2px, transparent 3px),
    radial-gradient(circle at 63% 12%, #e56b36 0 3px, transparent 4px);
}
.habitat::after {
  content: ""; position: absolute; left: 8%; right: 8%; bottom: -65px; height: 180px;
  border-radius: 50%; background: #403a36; border: 8px solid #5c4a40;
  box-shadow: inset 0 10px 30px #221f1d;
}
.status-row { position: absolute; z-index: 3; top: 14px; left: 14px; display: flex; gap: 6px; }
.status-chip {
  padding: 6px 10px; border-radius: 6px; background: rgb(255 250 241 / 90%);
  font-size: 11px; font-weight: 800;
}
.note-bubble {
  position: absolute; z-index: 4; top: 56px; right: 14px; width: 174px;
  padding: 10px; text-align: left; border: 0; border-radius: 8px; background: #fffaf1;
  box-shadow: 0 6px 20px rgb(0 0 0 / 20%);
}
.note-bubble strong, .note-bubble span { display: block; }
.note-bubble strong { color: var(--coral); font-size: 11px; margin-bottom: 3px; }
.note-bubble span { font-size: 12px; line-height: 1.5; }
.creature-stage {
  position: absolute; z-index: 3; left: 50%; bottom: 4%; width: 78%; max-width: 355px;
  transform: translateX(-50%); border: 0; background: transparent; padding: 0;
  transition: transform .18s ease;
}
.creature-stage:active { transform: translateX(-50%) scale(.96); }
.creature-stage img, .care-creature img { width: 100%; display: block; filter: drop-shadow(0 15px 12px rgb(0 0 0 / 30%)); }
.living-creature img, .living-creature-image { animation: creature-breathe 3.8s ease-in-out infinite; transform-origin: 50% 82%; }
.living-creature.reacting img { animation: creature-react .65s ease-out; }
.ember { position: absolute; z-index: 2; width: 8px; height: 8px; border-radius: 50%; background: #ff9d43; box-shadow: 0 0 12px #ff7b2e; }
.ember-one { left: 15%; bottom: 30%; }.ember-two { right: 12%; bottom: 44%; }.ember-three { right: 31%; top: 30%; }

.today-panel {
  min-height: 90px; padding: 14px 16px; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; background: #fffdf8; border-top: 1px solid #6a5145;
}
.experience-dots { display: flex; gap: 7px; margin-top: 8px; }
.experience-dot { width: 20px; height: 8px; border-radius: 2px; background: #e3dcd2; }
.experience-dot.used { background: var(--orange); }
.secondary-button {
  min-height: 42px; padding: 0 16px; border: 1px solid #c99b62; border-radius: 7px;
  background: #fff2d8; font-weight: 800;
}

.care-creature { padding: 18px 20px 8px; text-align: center; background: #39322e; color: #fffaf1; }
.care-creature img { height: 34dvh; object-fit: contain; }
.care-creature p { min-height: 24px; margin: 4px 0; font-size: 13px; }
.care-grid { padding: 14px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.care-action {
  min-height: 96px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px;
  font-weight: 800; font-size: 12px;
}
.care-action span { font-size: 28px; }
.care-action:active { background: #fff1d8; transform: translateY(1px); }

.section-heading { padding: 20px 18px 14px; display: flex; align-items: end; justify-content: space-between; }
.report-date { color: #887a6b; font-size: 11px; }
.report-paper {
  margin: 0 14px; padding: 18px; border: 1px solid #d5c8b6; border-radius: 7px;
  background: #fffdf8; box-shadow: 0 5px 16px rgb(75 57 39 / 8%); line-height: 1.75;
}
.trait-list { display: grid; gap: 9px; margin-top: 18px; }
.trait-row { display: flex; justify-content: space-between; gap: 12px; padding-top: 9px; border-top: 1px solid #eee5d9; }
.trait-row strong { font-size: 13px; }.trait-row span { color: #7c6e61; font-size: 12px; }
.condition-section { padding: 20px 16px; }
.condition-section h3 { margin: 0 0 12px; font-size: 15px; }
.condition-row { display: grid; grid-template-columns: 70px 1fr 36px; align-items: center; gap: 8px; margin: 10px 0; font-size: 12px; }
.meter { height: 7px; overflow: hidden; border-radius: 2px; background: #e9e1d7; }
.meter span { display: block; height: 100%; background: var(--green); }

.placeholder { min-height: calc(100dvh - 146px); display: grid; place-content: center; text-align: center; padding: 32px; }
.placeholder span { font-size: 56px; color: var(--aqua); }
.placeholder h2 { margin: 12px 0 4px; }.placeholder p { color: #7c6e61; font-size: 13px; }

.bottom-nav {
  position: absolute; z-index: 10; left: 0; right: 0; bottom: 0; height: 74px;
  display: grid; grid-template-columns: repeat(5, 1fr); background: #fffdf8; border-top: 1px solid var(--line);
}
.nav-item { border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: #8b8177; font-size: 10px; font-weight: 800; }
.nav-item span { font-size: 21px; line-height: 1; }
.nav-item.active { color: var(--coral); background: #fff5e9; }

.toast {
  position: fixed; z-index: 20; left: 50%; bottom: 90px; width: min(86%, 400px);
  transform: translate(-50%, 18px); padding: 11px 14px; border-radius: 7px;
  background: #2f2a27; color: white; text-align: center; font-size: 12px;
  opacity: 0; pointer-events: none; transition: .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.sync-badge {
  padding: 6px 8px; border-radius: 5px; background: #edf3ed;
  color: #5e765f; font-size: 10px; font-weight: 800;
}
.creature-summary {
  margin: 0 14px 14px; padding: 12px; display: grid; grid-template-columns: 88px 1fr;
  align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 8px; background: #3a332f; color: white;
}
.creature-summary img { width: 88px; height: 88px; object-fit: contain; }
.creature-summary h3 { margin: 3px 0; font-size: 20px; }.creature-summary span { color: #d2c7bd; font-size: 11px; }
.mypage-list { padding: 0 14px 24px; display: grid; gap: 8px; }
.mypage-list button {
  min-height: 58px; padding: 0 14px; display: flex; align-items: center; justify-content: space-between;
  border: 1px solid var(--line); border-radius: 7px; background: white; text-align: left;
}
.mypage-list span { font-size: 13px; font-weight: 800; }.mypage-list strong { color: #887a6b; font-size: 10px; }

.welcome-screen {
  position: fixed; z-index: 50; inset: 0; display: none; min-height: 100dvh;
  background: #263a31; color: white; overflow: auto;
}
.welcome-screen.active { display: grid; grid-template-rows: minmax(260px, 44vh) 1fr; }
.welcome-visual { position: relative; display: grid; place-items: center; overflow: hidden; background: #3c332f; }
.welcome-visual::after { content: ""; position: absolute; left: 15%; right: 15%; bottom: -70px; height: 130px; border-radius: 50%; background: #1e1c1b; }
.welcome-visual img { position: relative; z-index: 2; width: min(90%, 390px); height: 100%; object-fit: contain; filter: drop-shadow(0 16px 14px rgb(0 0 0 / 35%)); }
.welcome-panel { padding: 28px 22px 36px; background: #fffaf1; color: var(--ink); }
.welcome-panel h1 { margin: 4px 0 8px; font-size: 30px; }.welcome-panel > p:not(.eyebrow) { margin: 0 0 22px; color: #776b61; font-size: 13px; }
.welcome-panel label { display: block; margin-bottom: 6px; font-size: 11px; font-weight: 800; }
.welcome-panel input { width: 100%; height: 48px; padding: 0 12px; border: 1px solid #cfc4b7; border-radius: 6px; background: white; font: inherit; }
.primary-button { width: 100%; min-height: 48px; margin-top: 10px; border: 0; border-radius: 6px; background: var(--coral); color: white; font-weight: 900; }
.welcome-panel a, .welcome-panel small { display: block; margin-top: 16px; text-align: center; font-size: 11px; }
.welcome-panel a { color: #587969; font-weight: 800; }.welcome-panel small { color: #9b8e82; }

.onboarding-screen {
  position: fixed; z-index: 45; inset: 0; display: none; min-height: 100dvh;
  overflow: auto; background: #f7f4ed; color: var(--ink);
}
.onboarding-screen.active { display: block; }
.onboarding-header { padding: 32px 18px 18px; }
.onboarding-header h1 { max-width: 380px; margin: 4px 0 8px; font-size: 27px; line-height: 1.35; }
.onboarding-header > p:last-child { margin: 0; color: #786d63; font-size: 12px; line-height: 1.7; }
.egg-grid { padding: 0 14px 28px; display: grid; gap: 10px; }
.egg-card {
  min-height: 140px; padding: 10px 12px; display: grid; grid-template-columns: 116px 1fr;
  align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 8px;
  background: white; text-align: left;
}
.egg-card img { width: 116px; height: 116px; object-fit: contain; }
.egg-card strong, .egg-card span, .egg-card small { display: block; }
.egg-card strong { margin: 4px 0; font-size: 18px; }.egg-card span { color: var(--coral); font-size: 10px; font-weight: 800; }
.egg-card small { color: #7f746a; font-size: 11px; line-height: 1.6; }

.prologue-screen { background: #17251f; color: white; }
.prologue-screen.active { display: block; }
.prologue-scene { position: relative; min-height: 100dvh; overflow: hidden; }
.prologue-scene > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center; transition: .25s ease; }
.prologue-shade { position: absolute; inset: 0; background: linear-gradient(0deg, rgb(18 31 25 / 96%) 0 31%, rgb(18 31 25 / 10%) 74%); }
.prologue-copy { position: absolute; z-index: 2; left: 20px; right: 20px; bottom: 34px; }
.prologue-copy h1 { margin: 4px 0 10px; font-size: 30px; line-height: 1.35; }
.prologue-copy > p:not(.eyebrow) { min-height: 64px; margin: 0 0 20px; color: #d7e0db; font-size: 13px; line-height: 1.8; }
.prologue-copy button { width: 100%; min-height: 48px; border: 0; border-radius: 6px; background: var(--coral); color: white; font-weight: 900; }

.incubation-screen.active { display: grid; grid-template-rows: minmax(300px, 52vh) 1fr; }
.incubation-visual { padding: 20px; display: grid; place-items: center; align-content: center; background: #312d2a; color: white; }
.incubation-visual img { width: min(90%, 340px); max-height: 42vh; object-fit: contain; filter: drop-shadow(0 20px 16px rgb(0 0 0 / 35%)); }
.incubation-visual img { animation: egg-breathe 4s ease-in-out infinite; transform-origin: 50% 86%; }
.incubation-visual img.egg-wiggle { animation: egg-wiggle .8s ease-in-out; }
.incubation-visual img.egg-glow { animation: egg-glow 1s ease-out; }
.incubation-panel { padding: 24px 20px 34px; }
.incubation-panel h1 { margin: 3px 0 8px; font-size: 28px; }.incubation-panel > p:not(.eyebrow) { margin: 0; color: #786d63; font-size: 12px; line-height: 1.7; }
.hatch-timer { margin: 20px 0 12px; padding: 13px 14px; display: flex; justify-content: space-between; border: 1px solid var(--line); border-radius: 7px; background: white; }
.hatch-timer span { font-size: 11px; font-weight: 800; }.hatch-timer strong { color: var(--coral); font-size: 13px; }
.egg-care-record { margin-bottom: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.egg-care-record span { padding: 9px; border-radius: 6px; background: #eee9df; color: #776c62; text-align: center; font-size: 10px; font-weight: 800; }
.egg-care-record strong { margin-left: 3px; color: var(--coral); }
.incubation-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.incubation-actions button { min-height: 48px; border: 1px solid #cdbfae; border-radius: 7px; background: white; font-weight: 800; font-size: 11px; }

.hatching-screen { background: #24211f; color: white; }
.hatching-screen.active { display: grid; grid-template-rows: minmax(360px, 62vh) 1fr; }
.hatching-stage { position: relative; display: grid; place-items: center; overflow: hidden; background: radial-gradient(circle, #6d5540, #24211f 62%); }
.hatching-stage img { position: absolute; z-index: 3; width: min(88%, 360px); max-height: 52vh; object-fit: contain; transform-origin: 50% 85%; }
.hatching-baby { opacity: 0; }
.hatch-light { position: absolute; z-index: 1; width: 80px; height: 80px; border-radius: 50%; background: #fff8d5; opacity: 0; filter: blur(10px); }
.hatch-spark { position: absolute; z-index: 2; width: 7px; height: 7px; border-radius: 50%; background: #fff1b2; opacity: 0; box-shadow: 0 0 14px #fff1b2; }
.spark-one { left: 24%; top: 32%; }.spark-two { right: 22%; top: 42%; }.spark-three { left: 48%; top: 20%; }
.hatching-panel { position: relative; z-index: 5; padding: 24px 20px 34px; background: #fffaf1; color: var(--ink); }
.hatching-panel h1 { margin: 3px 0 8px; font-size: 27px; line-height: 1.35; }
.hatching-panel > p:not(.eyebrow) { min-height: 48px; margin: 0 0 18px; color: #786d63; font-size: 12px; line-height: 1.8; }
.hatching-panel button { width: 100%; min-height: 48px; border: 0; border-radius: 6px; background: var(--coral); color: white; font-weight: 900; }
.hatching-stage.phase-shake .hatching-egg { animation: hatch-shake 1.4s ease-in-out infinite; }
.hatching-stage.phase-light .hatching-egg { animation: hatch-crack 1.3s ease-in forwards; }
.hatching-stage.phase-light .hatch-light { animation: hatch-light 1.3s ease-out forwards; }
.hatching-stage.phase-light .hatch-spark { animation: hatch-spark 1.2s ease-out infinite; }
.hatching-stage.phase-reveal .hatching-egg { opacity: 0; transform: scale(1.18); transition: .45s ease; }
.hatching-stage.phase-reveal .hatching-baby { animation: baby-arrive 1.2s ease-out forwards, creature-breathe 3.8s ease-in-out 1.2s infinite; }
.hatching-stage.phase-meeting .hatching-egg { display: none; }
.hatching-stage.phase-meeting .hatching-baby { opacity: 1; animation: baby-greet .9s ease-out, creature-breathe 3.8s ease-in-out .9s infinite; }

@media (min-width: 700px) {
  body { padding: 24px 0; }
  .app-shell { min-height: calc(100dvh - 48px); border-radius: 16px; }
  .welcome-screen { left: 50%; width: min(100%, 480px); transform: translateX(-50%); box-shadow: 0 0 40px rgb(56 42 30 / 24%); }
  .onboarding-screen { left: 50%; width: min(100%, 480px); transform: translateX(-50%); box-shadow: 0 0 40px rgb(56 42 30 / 24%); }
}

@keyframes creature-breathe {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-5px) scale(1.018, .988); }
}
@keyframes creature-react {
  0%, 100% { transform: translateY(0) rotate(0) scale(1); }
  30% { transform: translateY(-18px) rotate(-3deg) scale(1.04); }
  60% { transform: translateY(-5px) rotate(3deg) scale(.99); }
}
@keyframes egg-breathe {
  0%, 100% { transform: translateY(0) scale(1); filter: drop-shadow(0 20px 16px rgb(0 0 0 / 35%)); }
  50% { transform: translateY(-4px) scale(1.012); filter: drop-shadow(0 24px 20px rgb(0 0 0 / 42%)); }
}
@keyframes egg-wiggle {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-4deg); } 40% { transform: rotate(4deg); }
  60% { transform: rotate(-2deg); } 80% { transform: rotate(2deg); }
}
@keyframes egg-glow {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 20px 16px rgb(0 0 0 / 35%)); }
  45% { transform: scale(1.035); filter: drop-shadow(0 0 28px rgb(255 190 92 / 80%)); }
}
@keyframes hatch-shake {
  0%, 100% { transform: translateY(0) rotate(0); }
  18% { transform: translateY(-4px) rotate(-3deg); } 35% { transform: translateY(0) rotate(3deg); }
  52% { transform: translateY(-8px) rotate(-5deg); } 70% { transform: translateY(0) rotate(4deg); }
}
@keyframes hatch-crack {
  0% { transform: scale(1); filter: brightness(1); }
  65% { transform: scale(1.04); filter: brightness(1.25); }
  100% { transform: scale(1.12); filter: brightness(2.2); opacity: .45; }
}
@keyframes hatch-light {
  0% { opacity: 0; transform: scale(.4); } 55% { opacity: .85; }
  100% { opacity: 0; transform: scale(7); }
}
@keyframes hatch-spark {
  0% { opacity: 0; transform: translateY(20px) scale(.5); }
  40% { opacity: 1; } 100% { opacity: 0; transform: translateY(-80px) scale(1.5); }
}
@keyframes baby-arrive {
  0% { opacity: 0; transform: translateY(18px) scale(.72); filter: brightness(2); }
  60% { opacity: 1; transform: translateY(-8px) scale(1.04); filter: brightness(1.2); }
  100% { opacity: 1; transform: translateY(0) scale(1); filter: brightness(1); }
}
@keyframes baby-greet {
  0%, 100% { transform: translateY(0) rotate(0); }
  35% { transform: translateY(-18px) rotate(-4deg); }
  65% { transform: translateY(-5px) rotate(4deg); }
}
@media (prefers-reduced-motion: reduce) {
  .living-creature img, .living-creature-image, .incubation-visual img,
  .hatching-stage img, .hatch-light, .hatch-spark { animation: none !important; }
}
