:root {
  --bg:        #1E1533;
  --bg-deep:   #150D26;
  --surface:   #2A1F47;
  --surface-2: #372A59;
  --line:      rgba(255, 255, 255, 0.09);
  --text:      #F5F0FF;
  --muted:     #A99CC9;
  --magenta:   #FF4D9D;
  --yellow:    #FFD23F;
  --violet:    #8B5CF6;
  --danger:    #FF6B6B;
  --green:     #3DD68C;

  --fusion: linear-gradient(135deg, #FF4D9D 0%, #8B5CF6 100%);
  --radius: 22px;

  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

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

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

body {
  /* Default fallback — overridden by monthly .month-* class */
  background: linear-gradient(to top,
    #2fd47f 0%,
    #2f8fe0 32%,
    #7c3aed 60%,
    #2a1240 82%,
    #000000 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Nunito", system-ui, -apple-system, sans-serif;
  font-weight: 600;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ---------- Seasonal backgrounds (one per month, auto-applied) ---------- */
body[class*="month-"] {
  background: none;
  background-color: #000;
}
body[class*="month-"]::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image: var(--season-bg);   /* the month's picture, set once per month below */
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
body[class*="month-"]::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(to bottom, rgba(0,0,0,0.10) 0%, rgba(0,0,0,0.80) 100%);
}
body.month-1 { --season-bg: url(../images/backgrounds/1.jpg); }
body.month-2 { --season-bg: url(../images/backgrounds/2.jpg); }
body.month-3 { --season-bg: url(../images/backgrounds/3.jpg); }
body.month-4 { --season-bg: url(../images/backgrounds/4.jpg); }
body.month-5 { --season-bg: url(../images/backgrounds/5.jpg); }
body.month-6 { --season-bg: url(../images/backgrounds/6.jpg); }
body.month-7 { --season-bg: url(../images/backgrounds/7.jpg); }
body.month-8 { --season-bg: url(../images/backgrounds/8.jpg); }
body.month-9 { --season-bg: url(../images/backgrounds/9.jpg); }
body.month-10 { --season-bg: url(../images/backgrounds/10.jpg); }
body.month-11 { --season-bg: url(../images/backgrounds/11.jpg); }
body.month-12 { --season-bg: url(../images/backgrounds/12.jpg); }

/* ---------- Intro splash ---------- */
.intro {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px calc(24px + env(safe-area-inset-right, 0px)) 24px calc(24px + env(safe-area-inset-left, 0px));
  background:
    radial-gradient(1200px 600px at 50% -10%, #3A265E 0%, transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  animation: fade .3s ease;
}
.intro[hidden] { display: none; }
.intro.is-hiding {
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s ease;
}
.intro-avatar {
  width: clamp(190px, 56vw, 260px);
  aspect-ratio: 1;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 28%;               /* keep her face in frame */
  border: 4px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45), 0 0 60px rgba(255, 77, 157, 0.25);
}
.intro-title {
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
  font-size: clamp(30px, 9vw, 46px);
  letter-spacing: -0.5px;
  margin: 26px 0 0;
  line-height: 1;
}
.intro-version {
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin: 8px 0 0;
  opacity: 0.85;
}
.intro-text {
  color: var(--muted);
  font-size: clamp(16px, 4.6vw, 21px);
  font-weight: 700;
  line-height: 1.4;
  margin: 16px 0 0;
}
.intro-btn {
  margin-top: 34px;
  padding: 18px 52px;
  border: 0;
  border-radius: var(--radius);
  font-family: "Fredoka", sans-serif;
  font-weight: 600;
  font-size: 24px;
  color: #fff;
  background: var(--fusion);
  box-shadow: 0 14px 34px rgba(255, 77, 157, 0.4);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .2s ease;
}
.intro-btn:active { transform: translateY(2px) scale(0.98); }

.app {
  min-height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  padding: 0 20px 108px;   /* room for the tab bar */
  display: flex;
  flex-direction: column;
}

/* Subtle refresh button, top-right */
.refresh-btn {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 52px);   /* just under the avatar (10px + 34px + 8px gap) */
  right: 12px;
  z-index: 30;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  opacity: 0.55;
  cursor: pointer;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: opacity .15s ease, transform .3s ease, color .15s ease;
}
.refresh-btn:hover { opacity: 1; color: var(--text); }
.refresh-btn:active { transform: scale(0.9); }

/* Subtle version number, left of the refresh button */
.bg-cycle-btn {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 6px);
  left: 6px;
  z-index: 30;
  width: 40px;
  height: 40px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  opacity: 0;
  -webkit-tap-highlight-color: transparent;
}

.version {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: 54px;
  z-index: 30;
  height: 34px;
  display: flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: rgba(255, 255, 255, 0.28);
  pointer-events: none;
}
.refresh-btn.is-spinning svg { animation: spin .7s linear infinite; }

/* ---------- Views ---------- */
.view { display: none; flex: 1; flex-direction: column; animation: viewIn .25s ease; }
.view.is-active { display: flex; }

/* Centre the Create view in the viewport. Safe because .app uses min-height,
   not height: if the content ever outgrows the screen the page simply grows
   and scrolls, instead of centring clipping the top out of reach.
   Library stays top-aligned — a gallery reads top-down, and its empty state
   already centres itself. */
#view-create.is-active { justify-content: center; }
/* Everything on the main screen lives in this stack. js/app.js ("Fit the main screen") measures how much room
   there is above the tab bar and sets --fit (1 = full size) so the avatar, tiles, names and both buttons always
   fit, on any phone or iPad in either orientation, instead of the bottom being hidden under the tab bar. */
.create-stack {
  display: flex;
  flex-direction: column;
  width: 100%;
  flex: 0 0 auto;
  transform: scale(var(--fit, 1));
  transform-origin: 50% 50%;      /* the stack is centred in its space, so it shrinks toward the middle */
}
@keyframes viewIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Top bar ---------- */
.topbar { padding: 26px 4px 8px; }

.topbar-head {
  display: flex;
  flex-direction: column;   /* picture stacked above the title */
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: fit-content;       /* shrink to the lockup so it can actually centre */
  max-width: 100%;
  margin: 0 auto;
}
.avatar-wrap {
  position: relative;
  flex: 0 0 auto;
  width: 181px;
  height: 181px;
}
.avatar-lock {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 18px;
  line-height: 1;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,.6));
  pointer-events: none;
  z-index: 1;
  animation: lockPop .25s ease;
}
.avatar-lock[hidden] { display: none; }
@keyframes lockPop {
  0%   { transform: scale(0); }
  60%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}
.topbar-avatar {
  width: 181px;
  height: 181px;
  border-radius: 50%;
  object-fit: cover;
  cursor: pointer;
  transition: transform .15s ease;
  animation: avatarGlow 5s ease-in-out infinite;
}
@keyframes avatarGlow {
  0%, 100% { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3), 0 0 22px 4px rgba(255, 255, 255, 0.35); }
  50%      { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3), 0 0 48px 12px rgba(255, 255, 255, 0.8); }
}
.topbar-avatar:active { transform: scale(0.96); }
@media (prefers-reduced-motion: reduce) {
  .topbar-avatar { animation: none; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3), 0 0 30px 6px rgba(255, 255, 255, 0.5); }
}
/* Showing your latest creation instead of the photo: fill the circle nicely */
.topbar-avatar.showing-emoji {
  object-fit: contain;
  padding: 18px;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 77, 157, 0.35), transparent 70%),
    var(--surface);
}
.topbar-text {
  min-width: 0;
  text-align: center;
  position: relative;
  z-index: 1;
  margin-top: -52px;   /* pull the title up so it overlaps the photo */
  padding: 10px 24px;
  /* soft dark glow behind the title for contrast against the photo */
  background: radial-gradient(ellipse at center,
    rgba(21, 13, 38, 0.9) 0%,
    rgba(21, 13, 38, 0.6) 45%,
    transparent 75%);
}
.topbar-text .wordmark { text-shadow: 0 2px 14px rgba(0, 0, 0, 0.7); }

.wordmark {
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
  font-size: 30px;
  letter-spacing: -0.5px;
  margin: 0;
  line-height: 1;
}
#view-create .wordmark { font-size: 38px; }   /* a little bigger on the main screen */
.wordmark-accent { color: var(--yellow); }

.tagline {
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  margin: 8px 0 0;
}

/* ---------- Fusion (the hero) ---------- */
.fusion {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 30px 0 26px;
  /* Room for the name labels under the tiles (two lines at most). It is padding, not margin, on purpose:
     the short-screen rules below change .fusion's margin, which used to squeeze the labels under SPIN. */
  padding-bottom: 50px;
}

.slot-wrap {
  position: relative;
  flex: 1 1 0;                 /* grow to fill the row width */
  max-width: 200px;           /* but not too big on wide screens */
}
/* The emoji's name, under its tile. Absolutely placed so it never shifts the tiles or the + between them. */
.slot-label {
  position: absolute;
  left: -6px;
  right: -6px;
  top: 100%;
  margin-top: 10px;
  text-align: center;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.85), 0 0 2px rgba(0, 0, 0, 0.6);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  pointer-events: none;
}
.slot-hint {
  position: absolute;
  top: -22px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  pointer-events: none;
  display: none;              /* shown only on first load via .show-hints */
  animation: hintBob 1s ease-in-out infinite alternate;
}
.fusion.show-hints .slot-hint { display: block; }
@keyframes hintBob { from { transform: translateY(0); } to { transform: translateY(-4px); } }

.slot {
  position: relative;
  width: 100%;                 /* fill the wrapper */
  height: auto;
  aspect-ratio: 1;            /* keep the slots square */
  border-radius: 30px;
  border: 2px solid var(--line);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, box-shadow .2s ease;
  font-family: inherit;
}
.slot:active { transform: scale(0.95); }
.slot:focus-within {
  outline: none;
  border-color: var(--magenta);
  box-shadow: 0 0 0 4px rgba(255, 77, 157, 0.25), 0 10px 30px rgba(255, 77, 157, 0.2);
}
.slot-glyph {
  font-size: clamp(62px, 20vw, 104px);   /* scales with the wider slots */
  line-height: 1;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35));
  pointer-events: none;
}
.slot-glyph.is-empty { opacity: 0.28; }

/* Casino-reel spin for "I feel lucky" */
.slot { overflow: hidden; }              /* clip the rolling glyph like a reel window */
@keyframes reelRoll {
  0%   { transform: translateY(-16%); }
  100% { transform: translateY(16%); }
}
.slot-glyph.is-spinning {
  animation: reelRoll .1s linear infinite;
  filter: blur(0.7px) drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35));
}
@keyframes reelLand {
  0%   { transform: translateY(-34%) scale(1.18); }
  55%  { transform: translateY(7%)   scale(0.9); }
  100% { transform: translateY(0)    scale(1); }
}
.slot-glyph.is-landed { animation: reelLand .36s cubic-bezier(.2, .8, .3, 1.25); }

@media (prefers-reduced-motion: reduce) {
  .slot-glyph.is-spinning { animation: none; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35)); }
  .slot-glyph.is-landed { animation: none; }
}

.fusion-mark {
  font-family: "Fredoka", sans-serif;
  font-weight: 600;
  font-size: 30px;
  color: var(--yellow);
  opacity: 0.85;
}

/* ---------- Merge button ---------- */
.merge-btn {
  position: relative;
  width: 100%;
  margin-top: 12px;
  border: 0;
  border-radius: var(--radius);
  padding: 18px;
  font-family: "Fredoka", sans-serif;
  font-weight: 600;
  font-size: 20px;
  color: #fff;
  background: var(--fusion);
  box-shadow: 0 12px 30px rgba(255, 77, 157, 0.32);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .2s ease, opacity .2s ease;
  overflow: hidden;
}
.merge-btn:active { transform: translateY(2px) scale(0.99); box-shadow: 0 6px 16px rgba(255, 77, 157, 0.3); }
/* Quick wiggle, then rest; repeats until MASH or SPIN is pressed. */
.merge-btn.is-nudging { animation: mashNudge 2.4s ease-in-out .3s infinite; }
@keyframes mashNudge {
  0%, 30%, 100% { transform: rotate(0) scale(1); }
  5%  { transform: rotate(-2.5deg) scale(1.03); }
  10% { transform: rotate(2.5deg) scale(1.03); }
  15% { transform: rotate(-2deg) scale(1.03); }
  20% { transform: rotate(1.5deg) scale(1.02); }
  25% { transform: rotate(-0.5deg) scale(1.01); }
}
@media (prefers-reduced-motion: reduce) {
  .merge-btn.is-nudging { animation: none; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.7), 0 12px 30px rgba(255, 77, 157, 0.32); }
}
.merge-btn:disabled { cursor: default; }
.merge-btn.is-loading .merge-btn-label { visibility: hidden; }
.merge-btn.is-loading .merge-btn-spinner { display: block; }

.merge-btn-spinner {
  display: none;
  position: absolute;
  top: 50%; left: 50%;
  width: 24px; height: 24px;
  margin: -12px 0 0 -12px;
  border: 3px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- I feel lucky ---------- */
.lucky-btn {
  position: relative;
  display: block;
  width: 100%;
  margin: 12px 0 0;
  padding: 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--yellow);
  color: #1E1533;
  font-family: "Nunito", sans-serif;
  font-weight: 800;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(255, 210, 63, 0.32);
  transition: transform .12s ease, box-shadow .2s ease, opacity .2s ease;
}
.lucky-btn:active { transform: scale(0.96); }
.lucky-btn:disabled { cursor: default; opacity: 0.6; }
.lucky-btn.is-loading .lucky-btn-label { visibility: hidden; }
.lucky-btn.is-loading .lucky-btn-spinner { display: block; }

.lucky-btn-spinner {
  display: none;
  position: absolute;
  top: 50%; left: 50%;
  width: 18px; height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid rgba(30, 21, 51, 0.25);
  border-top-color: #1E1533;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.hint {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  min-height: 20px;
  /* The negative bottom margin cancels the hint's own height (20px + 14px) so its reserved line
     doesn't count when the Mash stack is centred; the text still shows just below MASH. */
  margin: 14px 0 -34px;
}
.hint.is-error { color: var(--yellow); font-weight: 700; }

.mash-counter {
  text-align: center;
  color: rgba(255, 255, 255, 0.3);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin: 4px 0 0;
}

/* Mash screen fits one screen: no page scroll or rubber-banding. Library still scrolls. */
html:has(body.lock-scroll) { overflow: hidden; height: 100%; }
body.lock-scroll { position: fixed; inset: 0; overflow: hidden; }
body.lock-scroll .app { height: 100dvh; min-height: 0; overflow: hidden; }
/* body is pinned to the edges here, so the root's safe-area padding no longer applies. */
body.lock-scroll .app { padding-top: calc(env(safe-area-inset-top, 0px) + 12px); }
/* iPad landscape (~768px tall) has no spare room for the extra 12px. */
@media (min-height: 761px) and (max-height: 800px) {
  body.lock-scroll .topbar { padding-top: 14px; }
}
/* Create view: nothing above the avatar, and the whole stack is centred in the space above the
   tab bar (its real height, measured by JS, replaces the old fixed 108px of bottom padding).
   The #id selector beats the short-screen .topbar padding rules below. */
body.lock-scroll .app:has(#view-create.is-active) {
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: var(--tabbar-h, 84px);
}
#view-create .topbar { padding-top: 0; }

/* Short screens (Safari toolbars, iPhone SE): shrink so MASH stays above the tab bar. */
@media (max-height: 760px) {
  .topbar { padding-top: 14px; }
  .avatar-wrap, .topbar-avatar { width: 140px; height: 140px; }
  .topbar-text { margin-top: -44px; }
  .fusion { margin: 16px 0 12px; }
  .slot-wrap { max-width: 150px; }
  .slot-glyph { font-size: clamp(56px, 16vw, 84px); }
  .lucky-btn, .merge-btn { padding: 14px; }
  .lucky-btn { margin-top: 8px; }
  .merge-btn { margin-top: 10px; }
  .hint { margin-top: 10px; }
}
@media (max-height: 620px) {
  .slot-label { font-size: 12.5px; margin-top: 6px; }
  .fusion { padding-bottom: 40px; }
  .topbar { padding-top: 8px; }
  .avatar-wrap, .topbar-avatar { width: 104px; height: 104px; }
  .topbar-text { margin-top: -34px; padding: 6px 20px; }
  #view-create .wordmark { font-size: 30px; }
  .fusion { margin: 14px 0 8px; }
  .slot-wrap { max-width: 118px; }
  .slot-glyph { font-size: clamp(48px, 13vw, 66px); }
  .lucky-btn, .merge-btn { padding: 11px; font-size: 18px; }
  .hint { margin-top: 6px; }
}

/* iOS ignores orientation locks, so ask phones in landscape to rotate back. */
.rotate-notice { display: none; }
@media (orientation: landscape) and (max-height: 500px) {
  .rotate-notice {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    /* same seasonal picture as the app (dark layer on top keeps the words readable) */
    background:
      linear-gradient(to bottom, rgba(21, 13, 38, 0.30) 0%, rgba(21, 13, 38, 0.78) 100%) center / cover no-repeat,
      var(--season-bg, none) center / cover no-repeat,
      #150D26;
    color: var(--text);
    font-family: "Fredoka", sans-serif;
    font-size: 20px;
    text-align: center;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
  }
  .rotate-notice p { margin: 0; }
  .rotate-notice-icon { font-size: 48px; animation: rotateHint 1.6s ease-in-out infinite; }
}
@keyframes rotateHint {
  0%, 30% { transform: rotate(-90deg); }
  60%, 100% { transform: rotate(0deg); }
}

/* ---------- Result ---------- */
/* Centered popup reveal (uses .sheet-backdrop for the overlay) */
.result-modal {
  width: 100%;
  max-width: 360px;
  margin: 0 16px;
  padding: 24px;             /* consistent all the way around */
  border-radius: 28px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  animation: pop .35s cubic-bezier(.2, 1.3, .4, 1);
}
@keyframes pop { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }

.result-frame {
  width: 208px;
  height: 208px;
  margin: 0 auto;
  border-radius: 50%;
  border: 1px solid #fff;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 77, 157, 0.45), rgba(139, 92, 246, 0.28) 45%, transparent 72%),
    var(--surface);
  display: grid;
  place-items: center;
  box-shadow: 0 0 44px rgba(255, 77, 157, 0.35), inset 0 0 30px rgba(139, 92, 246, 0.22);
  animation: resultGlow 2.6s ease-in-out infinite;
}
@keyframes resultGlow {
  0%, 100% { box-shadow: 0 0 32px rgba(255, 77, 157, 0.30), inset 0 0 24px rgba(139, 92, 246, 0.20); }
  50%      { box-shadow: 0 0 60px rgba(255, 77, 157, 0.58), inset 0 0 38px rgba(139, 92, 246, 0.36); }
}

/* 25% bigger (128 -> 160) with a white outline traced around the emoji */
.result-img {
  width: 160px;
  height: 160px;
  object-fit: contain;
  filter:
    drop-shadow(2px 0 0 #fff)   drop-shadow(-2px 0 0 #fff)
    drop-shadow(0 2px 0 #fff)   drop-shadow(0 -2px 0 #fff)
    drop-shadow(1.5px 1.5px 0 #fff)  drop-shadow(-1.5px 1.5px 0 #fff)
    drop-shadow(1.5px -1.5px 0 #fff) drop-shadow(-1.5px -1.5px 0 #fff);
  /* gentle grow + wiggle in on reveal (replays each time the popup opens) */
  animation: emojiReveal .6s ease .14s both;
  transform-origin: center;
}
@keyframes emojiReveal {
  0%   { transform: scale(0.7) rotate(0deg); opacity: 0; }
  45%  { transform: scale(1.1) rotate(-5deg); opacity: 1; }
  65%  { transform: scale(1.04) rotate(4deg); }
  80%  { transform: scale(1.01) rotate(-2deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.result-img.is-cat {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  filter: none;
}

@media (prefers-reduced-motion: reduce) {
  .result-frame { animation: none; }
  .result-img { animation: none; }
}

.result-name {
  display: block;
  width: 100%;
  margin: 0 0 16px;                       /* title sits at the top of the modal */
  padding: 4px 6px;
  text-align: center;
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
  font-size: clamp(38px, 13vw, 52px);     /* much larger title */
  line-height: 1.05;
  color: var(--text);
  background: transparent;
  border: 0;
  border-bottom: 2px dashed transparent;
  border-radius: 8px;
  transition: border-color .15s ease, background .15s ease;
  /* grow + bounce in on reveal (replays each time the popup opens) */
  animation: titlePop .55s cubic-bezier(.2, 1.5, .4, 1) .08s both;
  transform-origin: center;
}
@keyframes titlePop {
  0%   { transform: scale(0.2); opacity: 0; }
  55%  { transform: scale(1.18); opacity: 1; }
  75%  { transform: scale(0.94); }
  90%  { transform: scale(1.04); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .result-name { animation: none; }
}
/* Longer names (>12 chars) get a 20% smaller font so they don't clip. */
.result-name.is-long { font-size: clamp(30px, 10.4vw, 42px); }
.result-name:focus {
  outline: none;
  border-bottom-color: var(--magenta);
  background: rgba(255, 255, 255, 0.04);
}

.result-recipe {
  text-align: center;
  font-size: 26px;
  margin: 8px 0 0;
  color: var(--muted);
}

.result-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

/* ---------- Buttons ---------- */
.btn {
  flex: 1;
  border: 0;
  border-radius: 14px;
  padding: 13px 10px;
  font-family: "Nunito", sans-serif;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  transition: transform .12s ease, filter .15s ease;
}
.btn:active { transform: scale(0.96); }
.btn-primary   { background: var(--yellow); color: #3A2A00; }
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-ghost     { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-danger    { background: rgba(255, 107, 107, 0.14); color: var(--danger); }

/* Result popup: pastel red / yellow / green */
.btn-discard { background: #FFB3B3; color: #6B1414; }
.btn-share   { background: #FFE9A3; color: #6B5410; }
.btn-save    { background: #AEE6C4; color: #14563A; }

/* ---------- Gallery ---------- */
.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 22px;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}
@media (min-width: 600px) { .gallery { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 380px) { .gallery { grid-template-columns: repeat(2, 1fr); } }

.card {
  position: relative;
  aspect-ratio: 1;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 8px 8px;
  cursor: pointer;
  transition: transform .12s ease, border-color .15s ease;
  animation: pop .3s ease backwards;
  overflow: hidden;
}
.card:active { transform: scale(0.95); }
.card img { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
.egg-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 14px;
  line-height: 1;
  padding: 3px 4px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.egg-tag {
  align-self: center;
  width: fit-content;
  margin: -8px auto 16px;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-family: "Fredoka", sans-serif;
  font-weight: 500;
  font-size: 13px;
  color: var(--muted);
}
.egg-tag[hidden] { display: none; }
.card-name {
  font-family: "Fredoka", sans-serif;
  font-weight: 500;
  font-size: 12px;
  text-align: center;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  margin-top: 4px;
  flex-shrink: 0;
}

/* ---------- Empty state ---------- */
.empty {
  flex: 1;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding-bottom: 60px;
  color: var(--muted);
}
.empty.is-shown { display: flex; }
.empty-glyph { font-size: 44px; color: var(--yellow); opacity: 0.7; }
.empty-title { font-family: "Fredoka", sans-serif; font-size: 20px; color: var(--text); margin: 14px 0 4px; }
.empty-sub { font-size: 14px; margin: 0; }

/* ---------- Easter egg: Cosmic Rainbow Cat ---------- */
/* ---------- Universal Easter egg overlay (data-driven) ---------- */
.egg-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #12082e 0%, #05010f 70%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: fade .25s ease;
}
.egg-overlay[hidden] { display: none; }
.egg-overlay.bg-fireworks {
  background: radial-gradient(circle at 50% 30%, #2a1a4a 0%, #0a0618 75%);
}

/* starfield */
.egg-bg-stars {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 10px 20px, #fff 99%, transparent),
    radial-gradient(1.5px 1.5px at 90px 50px, #fff 99%, transparent),
    radial-gradient(1px 1px at 130px 100px, #fff 99%, transparent),
    radial-gradient(2px 2px at 50px 130px, #fff 99%, transparent),
    radial-gradient(1px 1px at 30px 90px, #fff 99%, transparent),
    radial-gradient(1.5px 1.5px at 150px 30px, #fff 99%, transparent);
  background-size: 160px 160px;
  animation: eggStars 2.2s linear infinite;
  opacity: 0.85;
}
.egg-bg-stars[hidden] { display: none; }
@keyframes eggStars { to { background-position: -160px 0; } }

/* fireworks */
.egg-bg-fireworks { position: absolute; inset: 0; pointer-events: none; opacity: 0.8; }
.egg-bg-fireworks[hidden] { display: none; }
.fw {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  opacity: 0;
  box-shadow:
    0 -62px 0 0, 44px -44px 0 0, 62px 0 0 0, 44px 44px 0 0,
    0 62px 0 0, -44px 44px 0 0, -62px 0 0 0, -44px -44px 0 0,
    0 -84px 0 0, 60px -60px 0 0, 84px 0 0 0, 60px 60px 0 0,
    0 84px 0 0, -60px 60px 0 0, -84px 0 0 0, -60px -60px 0 0;
  animation: fwBurst 2.4s ease-out infinite;
}
@keyframes fwBurst {
  0%   { transform: scale(0.1); opacity: 0; }
  12%  { opacity: 1; }
  70%  { opacity: 0.6; }
  100% { transform: scale(1.15); opacity: 0; }
}
.fw1 { top: 20%; left: 22%; color: #ff5d8f; animation-delay: 0s;    animation-duration: 2.6s; }
.fw2 { top: 26%; left: 74%; color: #46b6ff; animation-delay: .5s;   animation-duration: 2.2s; }
.fw3 { top: 58%; left: 28%; color: #ffd23f; animation-delay: 1.1s;  animation-duration: 2.8s; }
.fw4 { top: 66%; left: 76%; color: #57e08b; animation-delay: 1.7s;  animation-duration: 2.4s; }
.fw5 { top: 44%; left: 52%; color: #b45aff; animation-delay: .9s;   animation-duration: 3s; }
.fw6 { top: 78%; left: 48%; color: #ff9a2d; animation-delay: 2.1s;  animation-duration: 2.5s; }

/* egg image — two preset styles */
.egg-image {
  position: relative;
  z-index: 1;
  width: clamp(280px, 92vw, 520px);
  max-width: 100%;
  height: auto;
  border-radius: 10px;
}
.egg-image.is-photo {
  width: clamp(280px, 88vw, 460px);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  animation: pop .4s cubic-bezier(.2, 1.3, .4, 1);
}

.egg-caption {
  position: relative;
  z-index: 1;
  margin: 34px 0 0;
  font-family: "Fredoka", sans-serif;
  font-weight: 600;
  font-size: clamp(20px, 6vw, 28px);
  color: #fff;
  text-shadow: 0 0 16px rgba(180, 90, 255, 0.7);
}
.egg-actions {
  position: relative;
  z-index: 1;
  margin-top: 26px;
  display: flex;
  gap: 12px;
}
.egg-close, .egg-save {
  padding: 12px 28px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-family: "Nunito", sans-serif;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
}
.egg-save {
  background: rgba(61, 214, 140, 0.25);
  border-color: rgba(61, 214, 140, 0.5);
}

/* --- particle container (shared by confetti, hearts, bubbles, snow, sparkle, disco, rain, aurora) --- */
.egg-bg-particles { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.egg-bg-particles[hidden] { display: none; }

/* --- confetti: falling colorful rectangles --- */
.bg-confetti { background: radial-gradient(circle at 50% 40%, #1a0a3e 0%, #080218 70%); }
.bg-confetti .pt {
  position: absolute; top: -20px;
  width: 10px; height: 14px; border-radius: 2px;
  animation: confettiFall linear infinite;
}
@keyframes confettiFall {
  0%   { transform: translateY(-20px) rotate(0deg); opacity: 0.9; }
  100% { transform: translateY(calc(100vh + 20px)) rotate(720deg); opacity: 0.2; }
}
.bg-confetti .pt1 { left: 8%;  background: #ff5d8f; animation-duration: 2.8s; }
.bg-confetti .pt2 { left: 22%; background: #46b6ff; animation-duration: 3.4s; animation-delay: .4s; width: 8px; height: 12px; }
.bg-confetti .pt3 { left: 38%; background: #ffd23f; animation-duration: 2.6s; animation-delay: .8s; }
.bg-confetti .pt4 { left: 52%; background: #57e08b; animation-duration: 3.2s; animation-delay: 1.2s; width: 12px; height: 10px; }
.bg-confetti .pt5 { left: 65%; background: #b45aff; animation-duration: 2.9s; animation-delay: .2s; }
.bg-confetti .pt6 { left: 78%; background: #ff9a2d; animation-duration: 3.6s; animation-delay: .6s; width: 8px; height: 16px; }
.bg-confetti .pt7 { left: 90%; background: #ff5d8f; animation-duration: 3.1s; animation-delay: 1s; }
.bg-confetti .pt8 { left: 45%; background: #46b6ff; animation-duration: 2.7s; animation-delay: 1.5s; width: 12px; height: 8px; }

/* --- hearts: floating hearts rising --- */
.bg-hearts { background: radial-gradient(circle at 50% 60%, #3a0a2e 0%, #0a0210 70%); }
.bg-hearts .pt {
  position: absolute; bottom: -30px;
  font-size: 24px; line-height: 1;
  animation: heartFloat ease-in-out infinite;
}
@keyframes heartFloat {
  0%   { transform: translateY(0) scale(.5) rotate(0deg); opacity: 0; }
  10%  { opacity: .7; }
  90%  { opacity: .4; }
  100% { transform: translateY(calc(-100vh - 40px)) scale(1) rotate(15deg); opacity: 0; }
}
.bg-hearts .pt1 { left: 10%; animation-duration: 4s; }
.bg-hearts .pt1::before { content: '❤️'; }
.bg-hearts .pt2 { left: 25%; animation-duration: 5s; animation-delay: .8s; }
.bg-hearts .pt2::before { content: '💖'; }
.bg-hearts .pt3 { left: 40%; animation-duration: 4.5s; animation-delay: 1.5s; }
.bg-hearts .pt3::before { content: '💜'; }
.bg-hearts .pt4 { left: 55%; animation-duration: 3.8s; animation-delay: .3s; }
.bg-hearts .pt4::before { content: '💗'; }
.bg-hearts .pt5 { left: 70%; animation-duration: 4.8s; animation-delay: 2s; }
.bg-hearts .pt5::before { content: '❤️'; }
.bg-hearts .pt6 { left: 85%; animation-duration: 4.2s; animation-delay: 1s; }
.bg-hearts .pt6::before { content: '💕'; }
.bg-hearts .pt7 { left: 15%; animation-duration: 5.2s; animation-delay: 2.5s; }
.bg-hearts .pt7::before { content: '💖'; }
.bg-hearts .pt8 { left: 60%; animation-duration: 3.5s; animation-delay: .5s; }
.bg-hearts .pt8::before { content: '💗'; }

/* --- bubbles: translucent circles rising --- */
.bg-bubbles { background: radial-gradient(circle at 50% 60%, #0a1a3e 0%, #020810 70%); }
.bg-bubbles .pt {
  position: absolute; bottom: -40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .25);
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.15), transparent);
  animation: bubbleRise ease-in infinite;
}
@keyframes bubbleRise {
  0%   { transform: translateY(0) translateX(0); opacity: 0; }
  10%  { opacity: .6; }
  100% { transform: translateY(calc(-100vh - 50px)) translateX(30px); opacity: 0; }
}
.bg-bubbles .pt1 { left: 12%; width: 30px; height: 30px; animation-duration: 5s; }
.bg-bubbles .pt2 { left: 28%; width: 20px; height: 20px; animation-duration: 4s;   animation-delay: .7s; }
.bg-bubbles .pt3 { left: 42%; width: 36px; height: 36px; animation-duration: 6s;   animation-delay: 1.4s; }
.bg-bubbles .pt4 { left: 58%; width: 24px; height: 24px; animation-duration: 4.5s; animation-delay: .3s; }
.bg-bubbles .pt5 { left: 72%; width: 28px; height: 28px; animation-duration: 5.5s; animation-delay: 2s; }
.bg-bubbles .pt6 { left: 85%; width: 18px; height: 18px; animation-duration: 3.8s; animation-delay: 1s; }
.bg-bubbles .pt7 { left: 20%; width: 22px; height: 22px; animation-duration: 4.8s; animation-delay: 2.5s; }
.bg-bubbles .pt8 { left: 65%; width: 32px; height: 32px; animation-duration: 5.2s; animation-delay: .5s; }

/* --- snow: gently falling snowflakes --- */
.bg-snow { background: radial-gradient(circle at 50% 30%, #1a2a4a 0%, #060a18 70%); }
.bg-snow .pt {
  position: absolute; top: -10px;
  background: #fff; border-radius: 50%;
  animation: snowFall linear infinite;
}
@keyframes snowFall {
  0%   { transform: translateY(-10px) translateX(0); opacity: .8; }
  50%  { transform: translateY(50vh) translateX(20px); }
  100% { transform: translateY(calc(100vh + 10px)) translateX(-10px); opacity: .3; }
}
.bg-snow .pt1 { left: 5%;  width: 6px; height: 6px; animation-duration: 6s; }
.bg-snow .pt2 { left: 18%; width: 10px; height: 10px; animation-duration: 8s;   animation-delay: 1s; }
.bg-snow .pt3 { left: 32%; width: 5px; height: 5px; animation-duration: 5.5s; animation-delay: 2s; }
.bg-snow .pt4 { left: 48%; width: 8px; height: 8px; animation-duration: 7s;   animation-delay: .5s; }
.bg-snow .pt5 { left: 62%; width: 6px; height: 6px; animation-duration: 6.5s; animation-delay: 3s; }
.bg-snow .pt6 { left: 75%; width: 12px; height: 12px; animation-duration: 9s;   animation-delay: 1.5s; }
.bg-snow .pt7 { left: 88%; width: 7px; height: 7px; animation-duration: 5s;   animation-delay: .8s; }
.bg-snow .pt8 { left: 40%; width: 4px; height: 4px; animation-duration: 7.5s; animation-delay: 2.5s; }

/* --- sparkle: twinkling dots fading in and out --- */
.bg-sparkle { background: radial-gradient(circle at 50% 40%, #12082e 0%, #05010f 70%); }
.bg-sparkle .pt {
  position: absolute;
  width: 4px; height: 4px;
  background: #fff; border-radius: 50%;
  box-shadow: 0 0 6px 2px rgba(255, 255, 255, .6);
  animation: sparklePulse ease-in-out infinite;
}
@keyframes sparklePulse {
  0%, 100% { transform: scale(0); opacity: 0; }
  50%      { transform: scale(1); opacity: 1; }
}
.bg-sparkle .pt1 { top: 15%; left: 20%; animation-duration: 2s; }
.bg-sparkle .pt2 { top: 30%; left: 75%; animation-duration: 2.5s; animation-delay: .5s; box-shadow: 0 0 8px 3px rgba(255,200,100,.6); }
.bg-sparkle .pt3 { top: 55%; left: 35%; animation-duration: 1.8s; animation-delay: 1s; }
.bg-sparkle .pt4 { top: 70%; left: 80%; animation-duration: 2.2s; animation-delay: .3s; box-shadow: 0 0 8px 3px rgba(180,90,255,.6); }
.bg-sparkle .pt5 { top: 25%; left: 50%; animation-duration: 2.8s; animation-delay: 1.5s; }
.bg-sparkle .pt6 { top: 80%; left: 15%; animation-duration: 2s;   animation-delay: .8s; box-shadow: 0 0 8px 3px rgba(100,200,255,.6); }
.bg-sparkle .pt7 { top: 45%; left: 90%; animation-duration: 2.4s; animation-delay: 2s; }
.bg-sparkle .pt8 { top: 65%; left: 55%; animation-duration: 1.6s; animation-delay: .2s; }

/* --- disco: drifting colored light blobs --- */
.bg-disco { background: #0a0010; }
.bg-disco .pt {
  position: absolute;
  border-radius: 50%;
  filter: blur(50px);
  animation: discoMove ease-in-out infinite;
}
@keyframes discoMove {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25%      { transform: translate(30px, -40px) scale(1.1); }
  50%      { transform: translate(-20px, 30px) scale(.9); }
  75%      { transform: translate(40px, 20px) scale(1.05); }
}
.bg-disco .pt1 { top: 10%; left: 10%; width: 140px; height: 140px; background: rgba(255,0,255,.3);  animation-duration: 6s; }
.bg-disco .pt2 { top: 50%; left: 55%; width: 160px; height: 160px; background: rgba(0,255,255,.25); animation-duration: 8s;  animation-delay: 1s; }
.bg-disco .pt3 { top: 70%; left: 25%; width: 120px; height: 120px; background: rgba(255,255,0,.2);  animation-duration: 5s;  animation-delay: 2s; }
.bg-disco .pt4 { top: 25%; left: 70%; width: 130px; height: 130px; background: rgba(255,0,100,.25); animation-duration: 7s;  animation-delay: .5s; }
.bg-disco .pt5 { top: 40%; left: 40%; width: 100px; height: 100px; background: rgba(0,200,100,.2);  animation-duration: 9s;  animation-delay: 3s; }
.bg-disco .pt6 { top: 80%; left: 75%; width: 110px; height: 110px; background: rgba(100,0,255,.25); animation-duration: 6.5s; animation-delay: 1.5s; }
.bg-disco .pt7 { top: 5%;  left: 50%; width: 90px; height: 90px;   background: rgba(255,100,0,.2);  animation-duration: 7.5s; animation-delay: 2.5s; }
.bg-disco .pt8 { top: 60%; left: 5%;  width: 150px; height: 150px; background: rgba(0,100,255,.2);  animation-duration: 8.5s; animation-delay: .8s; }

/* --- rain: falling streaks --- */
.bg-rain { background: linear-gradient(to bottom, #0a1020 0%, #081018 100%); }
.bg-rain .pt {
  position: absolute; top: -30px;
  width: 2px;
  background: linear-gradient(to bottom, transparent, rgba(150,200,255,.5));
  border-radius: 0 0 2px 2px;
  animation: rainDrop linear infinite;
}
@keyframes rainDrop {
  0%   { transform: translateY(-30px); opacity: .7; }
  100% { transform: translateY(calc(100vh + 30px)); opacity: .3; }
}
.bg-rain .pt1 { left: 8%;  height: 28px; animation-duration: .8s; }
.bg-rain .pt2 { left: 22%; height: 22px; animation-duration: .7s; animation-delay: .15s; }
.bg-rain .pt3 { left: 35%; height: 32px; animation-duration: .9s; animation-delay: .35s; }
.bg-rain .pt4 { left: 50%; height: 24px; animation-duration: .65s; animation-delay: .1s; }
.bg-rain .pt5 { left: 63%; height: 30px; animation-duration: .85s; animation-delay: .25s; }
.bg-rain .pt6 { left: 78%; height: 20px; animation-duration: .75s; animation-delay: .45s; }
.bg-rain .pt7 { left: 88%; height: 26px; animation-duration: .6s; animation-delay: .05s; }
.bg-rain .pt8 { left: 42%; height: 18px; animation-duration: .95s; animation-delay: .3s; }

/* --- aurora: shifting color bands --- */
.bg-aurora { background: #020810; }
.bg-aurora .pt {
  position: absolute; top: 0; left: -20%;
  width: 80%; height: 55%;
  border-radius: 0 0 50% 50%;
  filter: blur(60px);
  animation: auroraWave ease-in-out infinite;
}
@keyframes auroraWave {
  0%, 100% { transform: translateX(0) scaleX(1); opacity: .2; }
  50%      { transform: translateX(15%) scaleX(1.3); opacity: .4; }
}
.bg-aurora .pt1 { background: rgba(0,255,128,.35);  animation-duration: 8s; left: -20%; }
.bg-aurora .pt2 { background: rgba(0,128,255,.3);   animation-duration: 10s; animation-delay: 2s; left: 10%; }
.bg-aurora .pt3 { background: rgba(128,0,255,.3);   animation-duration: 7s;  animation-delay: 1s; left: 30%; }
.bg-aurora .pt4 { background: rgba(0,200,200,.25);  animation-duration: 9s;  animation-delay: 3s; left: 50%; }
.bg-aurora .pt5 { background: rgba(80,255,80,.2);   animation-duration: 11s; animation-delay: 4s; left: -10%; top: 10%; }
.bg-aurora .pt6 { background: rgba(0,180,255,.2);   animation-duration: 8.5s; animation-delay: 1.5s; left: 40%; top: 5%; }
.bg-aurora .pt7 { display: none; }
.bg-aurora .pt8 { display: none; }

@media (prefers-reduced-motion: reduce) {
  .egg-bg-stars { animation: none; }
  .fw { animation: none; opacity: 0.5; }
  .pt { animation: none; opacity: 0.5; }
  .egg-image.is-photo { animation: none; }
}

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  gap: 8px;
  align-items: center;
  /* 20px less than the home-indicator inset, but never under 10px, so the tabs sit evenly
     between the top edge and the bottom edge of the bar. */
  padding: 10px 16px max(10px, calc(env(safe-area-inset-bottom, 0px) - 20px));
  background: linear-gradient(180deg, rgba(21, 13, 38, 0.4), rgba(21, 13, 38, 0.92));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1;
  max-width: 200px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: "Nunito", sans-serif;
  font-weight: 800;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px;
  border-radius: 12px;
  cursor: pointer;
  transition: color .15s ease;
}
.tab-glyph {
  font-size: 20px;
  line-height: 1;
  width: 24px;      /* same box for every icon (emoji, symbol, svg) so they share one centre line */
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s ease;
}
.tab.is-active { color: var(--text); }
.tab.is-active .tab-glyph { color: var(--magenta); transform: scale(1.1); }
.tab-share:active .tab-glyph { transform: scale(0.9); }

/* ---------- Share modal ---------- */
.share-modal {
  width: 100%;
  max-width: 340px;
  margin: 0 16px;
  padding: 28px 24px;
  border-radius: 28px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  animation: pop .35s cubic-bezier(.2, 1.3, .4, 1);
  text-align: center;
}
.share-title {
  font-family: "Fredoka", sans-serif;
  font-weight: 600;
  font-size: 22px;
  margin: 0 0 20px;
}
.share-qr {
  display: block;
  margin: 0 auto 16px;
  border-radius: 12px;
  background: #fff;
  padding: 12px;
  width: 200px;
  height: 200px;
}
.share-actions {
  display: flex;
  gap: 10px;
}
.share-close { display: block; width: 100%; margin-top: 10px; padding: 14px 10px; font-size: 14px; }
.share-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  padding: 14px 10px;
}
.share-action-btn:first-child { background: var(--yellow); color: #3A2A00; }
.share-action-btn:last-child  { background: #AEE6C4; color: #14563A; }

/* ---------- Detail sheet ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(10, 6, 20, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: grid;
  align-items: end;
  animation: fade .2s ease;
}
/* display:grid above would otherwise beat the hidden attribute and leave the
   sheet covering the whole app (it's inset:0, so it eats every tap). */
.sheet-backdrop[hidden] { display: none; }
/* Center the dialog on screen instead of docking it to the bottom. */
.sheet-backdrop.backdrop-center { align-items: center; justify-items: center; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border-top-left-radius: 28px;
  border-top-right-radius: 28px;
  border-top: 1px solid var(--line);
  padding: 26px 22px calc(26px + env(safe-area-inset-bottom, 0px));
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
  animation: sheetUp .3s cubic-bezier(.2, 1, .3, 1);
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.sheet-frame {
  width: 180px; height: 180px;
  margin: 0 auto;
  border-radius: 28px;
  background: radial-gradient(circle at 50% 40%, rgba(139, 92, 246, 0.25), transparent 70%), var(--bg);
  display: grid; place-items: center;
}
.sheet-img { width: 132px; height: 132px; object-fit: contain; }
.sheet-name { font-family: "Fredoka", sans-serif; font-weight: 600; font-size: 26px; text-align: center; margin: 16px 0 2px; }
.sheet-recipe { text-align: center; color: var(--muted); font-size: 22px; margin: 0 0 20px; }
.sheet-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-feature { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); flex-basis: 100%; }
.sheet-close {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 14px 12px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 14px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
  color: var(--text);
  font-family: "Nunito", sans-serif;
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  transition: transform .12s ease, background .15s ease;
}
.sheet-close:active {
  transform: scale(0.97);
  background: rgba(255, 255, 255, 0.2);
}

/* ---------- Emoji picker ---------- */
/* The picker fills the screen top to bottom with a small margin, and never moves or resizes:
   the keyboard opening or the results changing only affects the scroll area inside it (see
   syncKeyboardInset in app.js). */
/* minmax(0, 1fr) caps the grid row at the screen height; a plain auto row grows with a long
   emoji list, so the sheet ran off-screen and the list inside it stopped scrolling. */
#pickerBackdrop { align-items: stretch; grid-template-rows: minmax(0, 1fr); }
.sheet-picker {
  display: flex;
  flex-direction: column;
  align-self: stretch;
  margin: calc(env(safe-area-inset-top, 0px) + 12px) auto calc(env(safe-area-inset-bottom, 0px) + 12px);
  padding-bottom: 16px;
  border-radius: 28px;
  border: 1px solid var(--line);
}

.picker-header {
  display: flex;
  align-items: center;      /* title sits level with the 34px buttons */
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;      /* breathing room above the tiles */
}
.picker-header .sheet-name {
  margin: 0;                /* drop the sheet's default top/bottom offset */
  line-height: 1.1;
  text-align: left;
}
.picker-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.picker-back {
  width: 44px;
  height: 44px;
  flex: none;
  font-size: 32px;
  padding-bottom: 4px;
  animation: picker-back-pulse 1.8s ease-in-out infinite;
}
@keyframes picker-back-pulse {
  0%, 100% { scale: 1; }
  50% { scale: 1.08; }
}
@media (prefers-reduced-motion: reduce) {
  .picker-back { animation: none; }
}
.picker-back[hidden],
.picker-body [hidden] { display: none !important; }
.picker-tools {
  display: flex;
  gap: 6px;
}
.picker-zoom-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background .15s ease;
}
.picker-zoom-btn:active { background: rgba(255, 255, 255, 0.15); }

.picker-search { margin-bottom: 12px; }
.picker-search-input {
  width: 100%;
  height: 46px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-family: inherit;
  font-size: 18px;               /* 16px+ stops iOS zooming the page on focus */
  outline: none;
}
.picker-search-input:focus { border-color: rgba(255, 255, 255, 0.4); }
.picker-search-input::placeholder { color: var(--muted); }
.picker-no-results {
  text-align: center;
  color: var(--muted);
  margin: 24px 0;
}

.picker-keyboard {
  position: absolute;
  left: -9999px;
  opacity: 0;
  pointer-events: none;
}
.picker-kb-input {
  width: 1px;
  height: 1px;
  border: 0;
  padding: 0;
  font-size: 22px;
  background: transparent;
  color: transparent;
  caret-color: transparent;
}

.picker-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  margin-top: 6px;
}

.picker-group {
  font-family: "Fredoka", sans-serif;
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin: 18px 0 8px;
}
.picker-cats + .picker-group { margin-top: 2px; }

/* Category list: one big tile per category, shown before the emoji grid. */
.picker-cats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(96px, 28vw, 150px), 1fr));
  gap: clamp(8px, 2vw, 14px);
}
.picker-cat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 6px;
  border: 0;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  transition: transform .1s ease, background .15s ease;
}
.picker-cat:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.13);
}
.picker-cat-emoji {
  font-size: clamp(36px, 9vw, 64px);
  line-height: 1;
}
.picker-cat-label {
  font-family: "Fredoka", sans-serif;
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-align: center;
}

.picker-grid {
  display: grid;
  /* Cells grow with the viewport width so emojis are bigger on tablets. */
  grid-template-columns: repeat(auto-fill, minmax(clamp(46px, 11vw, 88px), 1fr));
  gap: clamp(6px, 1.4vw, 12px);
}

.picker-emoji {
  aspect-ratio: 1;
  min-height: clamp(46px, 11vw, 88px);   /* keeps the tap target thumb-sized */
  border: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  font-size: clamp(26px, 6.5vw, 52px);   /* glyph scales with page width */
  line-height: 1;
  cursor: pointer;
  transition: transform .1s ease, background .15s ease;
}
.picker-emoji:active {
  transform: scale(0.9);
  background: rgba(255, 255, 255, 0.13);
}

.picker-size-1 .picker-grid { grid-template-columns: repeat(auto-fill, minmax(28px, 1fr)); gap: 4px; }
.picker-size-1 .picker-emoji { min-height: 28px; font-size: 16px; border-radius: 8px; }
.picker-size-2 .picker-grid { grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 4px; }
.picker-size-2 .picker-emoji { min-height: 34px; font-size: 20px; border-radius: 10px; }
.picker-size-3 .picker-grid { grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 5px; }
.picker-size-3 .picker-emoji { min-height: 40px; font-size: 23px; border-radius: 12px; }
.picker-size-5 .picker-grid { grid-template-columns: repeat(auto-fill, minmax(clamp(56px, 14vw, 100px), 1fr)); gap: clamp(7px, 1.6vw, 14px); }
.picker-size-5 .picker-emoji { min-height: clamp(56px, 14vw, 100px); font-size: clamp(32px, 8vw, 62px); }
.picker-size-6 .picker-grid { grid-template-columns: repeat(auto-fill, minmax(clamp(66px, 17vw, 112px), 1fr)); gap: clamp(8px, 1.8vw, 16px); }
.picker-size-6 .picker-emoji { min-height: clamp(66px, 17vw, 112px); font-size: clamp(38px, 9.5vw, 72px); }
.picker-size-7 .picker-grid { grid-template-columns: repeat(auto-fill, minmax(clamp(78px, 20vw, 124px), 1fr)); gap: clamp(9px, 2vw, 18px); }
.picker-size-7 .picker-emoji { min-height: clamp(78px, 20vw, 124px); font-size: clamp(44px, 11vw, 82px); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(20px);
  z-index: 130;   /* above the Easter-egg screen (120) so its messages are visible */
  background: var(--text);
  color: var(--bg-deep);
  font-weight: 800;
  font-size: 14px;
  padding: 12px 20px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}
.toast.is-shown { opacity: 1; transform: translateX(-50%) translateY(0); }

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

/* ---------- Install-to-Home-Screen prompt ---------- */
.install-pill {
  margin-top: 18px;
  padding: 11px 20px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-family: "Nunito", sans-serif;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
}
.install-pill[hidden] { display: none; }
.install-pill.is-new { animation: installPulse 1.8s ease-in-out infinite; border-color: var(--yellow); }
@keyframes installPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 210, 63, 0.55); }
  50%      { box-shadow: 0 0 0 10px rgba(255, 210, 63, 0); }
}
.install-modal {
  width: 100%; max-width: 340px; margin: 0 16px; padding: 22px 20px;
  max-height: 94dvh; overflow-y: auto;
  border-radius: 28px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  animation: pop .35s cubic-bezier(.2, 1.3, .4, 1);
  text-align: center;
}
.install-modal .share-title { font-size: 19px; margin-bottom: 14px; }

/* The little looping phone demo: 9s = 3 scenes of 3s */
.demo {
  --tx1: 96px; --ty1: 276px;            /* finger target, step 1 */
  position: relative; width: 200px; height: 270px; margin: 0 auto 14px;
  border-radius: 26px; overflow: hidden;
  background: #0f0a1d; border: 3px solid #4a3b78;
  --loop: 9s;
}
.install-modal[data-os="android"] .demo { --tx1: 168px; --ty1: 8px; }
.demo-page {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  font: 700 13px "Fredoka", sans-serif; color: var(--text);
}
.demo-page img { width: 70px; height: 70px; border-radius: 50%; object-fit: cover; object-position: 50% 28%; }
.demo-bar {
  position: absolute; left: 0; right: 0; height: 40px; display: flex;
  align-items: center; justify-content: center; background: rgba(255,255,255,.12); color: #6fb3ff;
}
.demo-bar-ios { bottom: 0; }
.demo-bar-android { top: 0; justify-content: flex-end; padding-right: 14px; color: #fff; }
.demo-dots { font-size: 22px; font-weight: 900; }
.install-modal[data-os="ios"] .demo-bar-android,
.install-modal[data-os="android"] .demo-bar-ios { display: none; }
.demo-share, .demo-dots { animation: demoTap1 var(--loop) infinite; }
@keyframes demoTap1 {
  0%, 12% { transform: scale(1); } 15% { transform: scale(1.5); color: var(--yellow); }
  19%, 100% { transform: scale(1); }
}
.demo-sheet {
  position: absolute; left: 8px; right: 8px; bottom: 6px; padding: 6px;
  border-radius: 16px; background: #2d2547; font: 700 12px "Nunito", sans-serif; text-align: left;
  transform: translateY(110%); animation: demoSheet var(--loop) infinite;
}
.install-modal[data-os="android"] .demo-sheet { bottom: auto; top: 40px; left: auto; width: 150px; transform: translateY(-130%); animation-name: demoMenu; }
@keyframes demoSheet {
  0%, 31% { transform: translateY(110%); } 37%, 62% { transform: translateY(0); } 67%, 100% { transform: translateY(110%); }
}
@keyframes demoMenu {
  0%, 31% { transform: translateY(-130%); } 37%, 62% { transform: translateY(0); } 67%, 100% { transform: translateY(-130%); }
}
.demo-row { padding: 9px 10px; border-radius: 10px; color: #e9e3ff; }
.demo-row + .demo-row { border-top: 1px solid rgba(255,255,255,.08); }
.demo-row-hit { animation: demoRow var(--loop) infinite; }
@keyframes demoRow {
  0%, 44% { background: transparent; color: #e9e3ff; } 48%, 62% { background: var(--yellow); color: #3A2A00; } 100% { background: transparent; }
}
.demo-home {
  position: absolute; inset: 0; padding: 40px 18px; opacity: 0;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px 10px; align-content: start; justify-items: center;
  background: linear-gradient(160deg, #3a1d6b, #12334d);
  animation: demoHome var(--loop) infinite;
}
@keyframes demoHome { 0%, 63% { opacity: 0; } 68%, 95% { opacity: 1; } 100% { opacity: 0; } }
.demo-ghost { width: 40px; height: 40px; border-radius: 10px; background: rgba(255,255,255,.18); }
.demo-icon { position: relative; width: 40px; height: 40px; animation: demoIcon var(--loop) infinite; }
.demo-icon img { width: 100%; height: 100%; border-radius: 10px; display: block; box-shadow: 0 0 0 2px var(--yellow), 0 6px 14px rgba(0,0,0,.4); }
.demo-icon i { position: absolute; top: -10px; right: -10px; font-style: normal; font-size: 16px; }
@keyframes demoIcon {
  0%, 69% { transform: scale(0); } 74% { transform: scale(1.4); } 78%, 100% { transform: scale(1); }
}
.demo-finger {
  position: absolute; left: 0; top: 0; font-size: 34px; line-height: 1; opacity: 0;
  transform-origin: 50% 20%; animation: demoFinger var(--loop) infinite;
}
.install-modal[data-os="ios"] .demo-finger,
.install-modal[data-os="android"] .demo-finger { animation-name: demoFinger; }
@keyframes demoFinger {
  0%   { opacity: 0; left: calc(var(--tx1) + 30px); top: calc(var(--ty1) + 50px); transform: scale(1); }
  8%   { opacity: 1; left: calc(var(--tx1) - 4px);  top: calc(var(--ty1) + 8px);  transform: scale(1); }
  13%  { opacity: 1; left: calc(var(--tx1) - 4px);  top: calc(var(--ty1) + 8px);  transform: scale(.8); }
  18%  { opacity: 1; left: calc(var(--tx1) - 4px);  top: calc(var(--ty1) + 8px);  transform: scale(1); }
  24%  { opacity: 0; left: calc(var(--tx1) - 4px);  top: calc(var(--ty1) + 30px); }
  35%  { opacity: 0; left: 140px; top: 270px; transform: scale(1); }
  41%  { opacity: 1; left: 60px;  top: 205px; transform: scale(1); }
  46%  { opacity: 1; left: 60px;  top: 205px; transform: scale(.8); }
  51%  { opacity: 1; left: 60px;  top: 205px; transform: scale(1); }
  58%, 100% { opacity: 0; left: 60px; top: 230px; }
}
.install-steps { list-style: none; margin: 0 0 14px; padding: 0; text-align: left; display: grid; gap: 6px; }
.install-steps li {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px;
  font-weight: 800; font-size: 14px; color: var(--muted); opacity: .6;
}
.install-steps b {
  flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); color: var(--text); font-size: 13px;
}
.install-steps .st1 { animation: stepA 9s infinite; }
.install-steps .st2 { animation: stepB 9s infinite; }
.install-steps .st3 { animation: stepC 9s infinite; }
@keyframes stepA { 0%, 30% { opacity: 1; color: var(--text); background: rgba(255,210,63,.16); } 33%, 100% { opacity: .6; color: var(--muted); background: transparent; } }
@keyframes stepB { 0%, 30% { opacity: .6; background: transparent; } 33%, 64% { opacity: 1; color: var(--text); background: rgba(255,210,63,.16); } 67%, 100% { opacity: .6; color: var(--muted); background: transparent; } }
@keyframes stepC { 0%, 64% { opacity: .6; background: transparent; } 67%, 97% { opacity: 1; color: var(--text); background: rgba(255,210,63,.16); } 100% { opacity: .6; background: transparent; } }
.install-native { display: block; width: 100%; margin-bottom: 10px; padding: 14px 10px; }
.install-native[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) {
  .demo *, .install-steps li, .install-pill { animation: none !important; }
  .demo-sheet { transform: translateY(0) !important; }
  .demo-finger { opacity: 0 !important; }
}

/* The install tutorial opens from the intro splash (z-index 100), so sit above it. */
#installBackdrop { z-index: 110; }

/* ---------- iPhone-accurate install demo (12s loop, 4 scenes) ---------- */
.install-modal[data-os="ios"] .demo-android, .install-modal[data-os="android"] .demo-ios,
.install-modal[data-os="ios"] .install-steps-android, .install-modal[data-os="android"] .install-steps-ios { display: none; }
.demo-ios { --loop: 12s; width: 210px; height: 300px; background: #000; }
.i-page {
  position: absolute; left: 0; right: 0; top: 0; bottom: 44px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(180deg, #2a1b4a, var(--bg-deep)); font: 700 13px "Fredoka", sans-serif; color: var(--text);
}
.i-page img { width: 70px; height: 70px; border-radius: 50%; object-fit: cover; object-position: 50% 28%; }
.i-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 44px; padding: 0 8px; display: flex; align-items: center; gap: 6px; background: #000; color: #fff; }
.i-circle { flex: none; width: 28px; height: 28px; border-radius: 50%; background: #2b2b2e; display: grid; place-items: center; font-size: 15px; }
.i-pill { flex: 1; height: 28px; border-radius: 14px; background: #2b2b2e; display: flex; align-items: center; gap: 8px; padding: 0 9px; font: 600 11px "Nunito", sans-serif; }
.i-pill em { font-style: normal; flex: 1; text-align: center; padding-right: 22px; }
.i-menu { animation: iTap var(--loop) infinite; }
@keyframes iTap { 0%, 6% { transform: scale(1); color: #fff; } 9% { transform: scale(1.6); color: var(--yellow); } 13%, 100% { transform: scale(1); color: #fff; } }
.i-menu-pop {
  position: absolute; left: 30px; bottom: 50px; width: 150px; padding: 4px; border-radius: 16px;
  background: #3a3a3e; font: 700 11px "Nunito", sans-serif; text-align: left; color: #fff;
  transform-origin: 20% 100%; opacity: 0; transform: scale(.5); animation: iPop var(--loop) infinite;
}
@keyframes iPop { 0%, 20% { opacity: 0; transform: scale(.5); } 25%, 37% { opacity: 1; transform: scale(1); } 41%, 100% { opacity: 0; transform: scale(.9); } }
.i-mrow { display: flex; justify-content: space-between; align-items: center; padding: 7px 8px; border-radius: 10px; }
.i-mrow + .i-mrow { border-top: 1px solid rgba(255,255,255,.1); }
.i-mrow-share { animation: iRow1 var(--loop) infinite; }
@keyframes iRow1 { 0%, 30% { background: transparent; color: #fff; } 32%, 38% { background: var(--yellow); color: #3A2A00; } 41%, 100% { background: transparent; color: #fff; } }
.i-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; height: 142px; padding: 8px 8px 0; overflow: hidden; border-radius: 16px 16px 0 0;
  background: #1c1c1e; color: #fff; font: 700 11px "Nunito", sans-serif; text-align: left;
  transform: translateY(105%); animation: iSheet var(--loop) infinite;
}
.i-sheet { animation: iSheet var(--loop) infinite, iGrow var(--loop) infinite; }
@keyframes iSheet { 0%, 40% { transform: translateY(105%); } 45%, 77% { transform: translateY(0); } 81%, 100% { transform: translateY(105%); } }
@keyframes iGrow { 0%, 55% { height: 142px; } 59%, 100% { height: 232px; } }
.i-acts { display: flex; justify-content: space-around; height: 48px; padding-top: 2px; }
.i-acts span { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 8px; color: #ddd; width: 44px; text-align: center; }
.i-acts u { text-decoration: none; width: 28px; height: 28px; border-radius: 50%; background: #3a3a3e; display: grid; place-items: center; font-size: 13px; }
.i-more u { animation: iRow2 var(--loop) infinite; }
@keyframes iRow2 { 0%, 51% { background: #3a3a3e; color: #fff; } 53%, 58% { background: var(--yellow); color: #3A2A00; } 61%, 100% { background: #3a3a3e; color: #fff; } }
.i-head { display: flex; align-items: center; gap: 8px; height: 36px; }
.i-head img { width: 30px; height: 30px; border-radius: 8px; }
.i-head div { flex: 1; line-height: 1.15; } .i-head b { display: block; font-size: 12px; } .i-head small { color: #9a9aa0; font-size: 10px; }
.i-x { width: 20px; height: 20px; border-radius: 50%; background: #3a3a3e; display: grid; place-items: center; font-size: 9px; }
.i-apps { display: flex; justify-content: space-around; padding: 5px 0; height: 44px; }
.i-apps i { width: 34px; height: 34px; border-radius: 10px; }
.i-list { border-radius: 12px; background: #3a3a3e; }
.i-list div { height: 30px; padding: 8px 10px; display: flex; justify-content: space-between; border-radius: 12px; }
.i-list div + div { border-top: 1px solid rgba(255,255,255,.1); border-radius: 0 0 12px 12px; }
.i-add { animation: iRow3 var(--loop) infinite; }
@keyframes iRow3 { 0%, 71% { background: transparent; color: #fff; } 73%, 78% { background: var(--yellow); color: #3A2A00; } 81%, 100% { background: transparent; color: #fff; } }
.i-home {
  position: absolute; inset: 0; padding: 40px 18px; opacity: 0;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px 10px; align-content: start; justify-items: center;
  background: linear-gradient(160deg, #3a1d6b, #12334d); animation: iHome var(--loop) infinite;
}
@keyframes iHome { 0%, 79% { opacity: 0; } 83%, 96% { opacity: 1; } 100% { opacity: 0; } }
.i-icon { animation: iIcon var(--loop) infinite; }
@keyframes iIcon { 0%, 84% { transform: scale(0); } 88% { transform: scale(1.4); } 92%, 100% { transform: scale(1); } }
.i-finger { position: absolute; left: 0; top: 0; font-size: 30px; line-height: 1; opacity: 0; animation: iFinger var(--loop) infinite; }
@keyframes iFinger {
  0%   { opacity: 0; left: 50px;  top: 330px; transform: scale(1); }
  4%   { opacity: 1; left: 38px;  top: 266px; }
  7%   { opacity: 1; left: 38px;  top: 266px; transform: scale(.8); }
  10%  { opacity: 1; left: 38px;  top: 266px; transform: scale(1); }
  14%  { opacity: 0; left: 38px;  top: 285px; }
  24%  { opacity: 0; left: 90px;  top: 220px; }
  27%  { opacity: 1; left: 66px;  top: 150px; transform: scale(1); }
  30%  { opacity: 1; left: 66px;  top: 150px; transform: scale(1); }
  32%  { opacity: 1; left: 66px;  top: 150px; transform: scale(.8); }
  34%  { opacity: 1; left: 66px;  top: 150px; transform: scale(1); }
  38%  { opacity: 0; left: 66px;  top: 165px; }
  44%  { opacity: 0; left: 150px; top: 330px; }
  48%  { opacity: 1; left: 163px; top: 262px; transform: scale(1); }
  51%  { opacity: 1; left: 163px; top: 262px; transform: scale(1); }
  53%  { opacity: 1; left: 163px; top: 262px; transform: scale(.8); }
  55%  { opacity: 1; left: 163px; top: 262px; transform: scale(1); }
  58%  { opacity: 0; left: 163px; top: 275px; }
  62%  { opacity: 0; left: 110px; top: 330px; }
  65%  { opacity: 1; left: 65px;  top: 276px; transform: scale(1); }
  70%  { opacity: 1; left: 65px;  top: 276px; transform: scale(1); }
  72%  { opacity: 1; left: 65px;  top: 276px; transform: scale(.8); }
  75%  { opacity: 1; left: 65px;  top: 276px; transform: scale(1); }
  79%, 100% { opacity: 0; left: 65px; top: 292px; }
}
.install-steps-ios li { padding: 5px 10px; font-size: 13px; }
.install-steps-ios .i1 { animation: iStep1 12s infinite; }
.install-steps-ios .i2 { animation: iStep2 12s infinite; }
.install-steps-ios .i3 { animation: iStep3 12s infinite; }
.install-steps-ios .i4 { animation: iStep4 12s infinite; }
.install-steps-ios .i5 { animation: iStep5 12s infinite; }
@keyframes iStep1 { 0%, 19% { opacity: 1; color: var(--text); background: rgba(255,210,63,.16); } 21%, 100% { opacity: .6; color: var(--muted); background: transparent; } }
@keyframes iStep2 { 0%, 19% { opacity: .6; color: var(--muted); background: transparent; } 21%, 39% { opacity: 1; color: var(--text); background: rgba(255,210,63,.16); } 41%, 100% { opacity: .6; color: var(--muted); background: transparent; } }
@keyframes iStep3 { 0%, 39% { opacity: .6; color: var(--muted); background: transparent; } 41%, 59% { opacity: 1; color: var(--text); background: rgba(255,210,63,.16); } 61%, 100% { opacity: .6; color: var(--muted); background: transparent; } }
@keyframes iStep4 { 0%, 59% { opacity: .6; color: var(--muted); background: transparent; } 61%, 79% { opacity: 1; color: var(--text); background: rgba(255,210,63,.16); } 81%, 100% { opacity: .6; color: var(--muted); background: transparent; } }
@keyframes iStep5 { 0%, 79% { opacity: .6; color: var(--muted); background: transparent; } 81%, 99% { opacity: 1; color: var(--text); background: rgba(255,210,63,.16); } 100% { opacity: .6; color: var(--muted); background: transparent; } }
@media (prefers-reduced-motion: reduce) {
  .demo-ios *, .install-steps-ios li { animation: none !important; }
  .i-sheet { transform: translateY(0) !important; } .i-finger { opacity: 0 !important; }
}

/* ---------- Account ---------- */
.account-btn {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: 12px;
  z-index: 30;
  width: 34px; height: 34px; padding: 0;
  display: grid; place-items: center; overflow: hidden;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  opacity: 0.7;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.account-btn.is-in { opacity: 1; border-color: var(--yellow); }
.account-btn:active { transform: scale(0.9); }
.account-avatar { width: 100%; height: 100%; object-fit: cover; display: block; }
.account-avatar[hidden], .account-icon[hidden] { display: none; }
.account-icon { display: block; }
.account-modal { max-width: 330px; }
.account-note { color: var(--muted); font-weight: 700; font-size: 14px; line-height: 1.4; margin: 0 0 18px; }
.account-gbtn { display: flex; justify-content: center; min-height: 44px; }
.account-error { color: var(--danger); font-weight: 700; font-size: 13px; margin: 12px 0 0; }
.account-error[hidden], #accountGuest[hidden], #accountUser[hidden] { display: none; }
.account-big { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; border: 3px solid rgba(255,255,255,.18); margin-bottom: 10px; }
.account-out { display: block; width: 100%; margin-top: 4px; padding: 13px 10px; }
.account-modal .share-close { margin-top: 10px; }

/* ---------- Sign-in gate ---------- */
.gate-title { margin-top: 0; }
.gate-lead { margin-top: 12px; }
.gate-list { list-style: none; margin: 22px 0 26px; padding: 0; display: grid; gap: 10px; text-align: left; }
.gate-list li { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 16px; color: var(--text); }
.gate-list span { font-size: 22px; width: 30px; text-align: center; }
.gate-guest {
  margin-top: 16px; padding: 14px 34px; border-radius: 16px; cursor: pointer;
  border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.08); color: var(--text);
  font-family: "Fredoka", sans-serif; font-weight: 600; font-size: 18px;
}
.gate-guest:active { transform: scale(.97); }
.gate-fine { color: var(--muted); font-size: 12px; font-weight: 700; line-height: 1.4; margin: 14px 0 0; max-width: 270px; }

.account-admin { display: block; width: 100%; margin: 0 0 10px; padding: 13px 10px; text-decoration: none; text-align: center; }
.account-admin[hidden] { display: none; }

/* ---------- Feedback (footer button + form) ---------- */
.tab-feedback:active .tab-glyph { transform: scale(0.9); }
.fb-modal { max-width: 360px; text-align: left; }
.fb-modal .share-title { text-align: center; font-size: 20px; margin-bottom: 14px; }
.fb-types { display: flex; gap: 8px; margin-bottom: 14px; }
.fb-type {
  flex: 1; padding: 10px 6px; border-radius: 14px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); color: var(--muted);
  font-family: "Nunito", sans-serif; font-weight: 800; font-size: 14px;
}
.fb-type.is-on { background: var(--yellow); border-color: transparent; color: #3A2A00; }
.fb-label { display: block; margin: 0 0 6px; font-weight: 800; font-size: 14px; color: var(--text); }
.fb-label small { color: var(--muted); font-weight: 700; }
.fb-modal textarea, .fb-modal input[type="email"] {
  width: 100%; padding: 12px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--bg-deep); color: var(--text); font-family: "Nunito", sans-serif; font-weight: 700;
  font-size: 16px;                       /* 16px stops iPhone Safari zooming in on focus */
  user-select: text; -webkit-user-select: text;
}
.fb-modal textarea { resize: none; display: block; }
.fb-modal textarea:focus, .fb-modal input[type="email"]:focus { outline: 2px solid var(--violet); outline-offset: 1px; }
.fb-count { text-align: right; color: var(--muted); font-size: 12px; font-weight: 700; margin: 4px 2px 12px; }
.fb-signed { color: var(--muted); font-weight: 700; font-size: 13px; margin: 0 0 12px; }
.fb-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }   /* hidden trap field for bots */
.fb-actions { display: flex; gap: 10px; margin-top: 14px; }
.fb-actions .btn { padding: 14px 10px; font-size: 15px; }
.fb-actions .btn:disabled { opacity: .55; }
.fb-done { text-align: center; }
.fb-done-emoji { font-size: 54px; line-height: 1; margin-bottom: 8px; }
#fbForm[hidden], #fbDone[hidden], #fbContactRow[hidden] { display: none; }
