*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 62%, #E9FBEE 100%);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  overscroll-behavior: none;
  user-select: none;
}

h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; }

/* ---------- Decorative background ---------- */
.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.cloud {
  position: absolute;
  width: 160px;
  height: 56px;
  background: rgba(255, 255, 255, .85);
  border-radius: var(--r-pill);
  filter: blur(.3px);
  animation: drift linear infinite;
}
.cloud::before,
.cloud::after {
  content: '';
  position: absolute;
  background: inherit;
  border-radius: 50%;
}
.cloud::before { width: 74px; height: 74px; left: 22px; top: -32px; }
.cloud::after  { width: 54px; height: 54px; right: 24px; top: -22px; }

.cloud--1 { top: 12%;  left: -220px; animation-duration: 68s; transform: scale(.9); }
.cloud--2 { top: 30%;  left: -260px; animation-duration: 95s; animation-delay: -30s; transform: scale(1.25); opacity: .75; }
.cloud--3 { top: 6%;   left: -200px; animation-duration: 120s; animation-delay: -70s; transform: scale(.6); opacity: .6; }

@keyframes drift { to { transform: translateX(calc(100vw + 400px)); } }

.hill {
  position: absolute;
  bottom: -60px;
  left: -5vw;
  width: 110vw;
  height: 220px;
  border-radius: 50% 50% 0 0;
}
.hill--back  { background: var(--grass-dark); opacity: .55; height: 260px; bottom: -110px; }
.hill--front { background: var(--grass); opacity: .75; }

/* ---------- Layout ---------- */
.app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  padding: calc(var(--hud-h) + 12px) 16px 32px;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.fx-layer,
.fly-layer {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
}

/* ---------- Screen transitions ---------- */
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: screen-in .34s var(--bounce) both;
}
.screen--leaving {
  position: absolute;
  inset: calc(var(--hud-h) + 12px) 16px 32px;
  animation: screen-out .2s var(--swift) both;
  pointer-events: none;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(22px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
@keyframes screen-out {
  to { opacity: 0; transform: translateY(-14px) scale(.98); }
}

/* ---------- Shared motion ---------- */
@keyframes pop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.28); }
  100% { transform: scale(1); }
}
@keyframes wiggle {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-6deg); }
  75% { transform: rotate(6deg); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-10px); }
  30% { transform: translateX(9px); }
  45% { transform: translateX(-7px); }
  60% { transform: translateX(5px); }
  80% { transform: translateX(-3px); }
}
@keyframes float-y {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* One-shot utilities — they deliberately override any idle animation
   (e.g. the home portrait's gentle float) for the length of the effect. */
.is-popping { animation: pop .4s var(--bounce) !important; }
.is-shaking { animation: shake .45s var(--swift) !important; }

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

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
