:root {
  --ink: #3c2a55;
  --muted: #5c4d78;
  --card: rgba(255, 255, 255, 0.94);
  --line: #efe4ff;
  --pink: #ff7eb3;
  --orange: #ff9f43;
  --gold: #ffc53d;
  --green: #2ecf8b;
  --blue: #4d94ff;
  --shadow: 0 10px 0 rgba(90, 60, 140, 0.06), 0 16px 36px rgba(70, 120, 180, 0.16);
  --radius: 28px;
  color: var(--ink);
  font-family: "Arial Rounded MT Bold", "Chalkboard SE", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  min-height: 100dvh;
  overflow: hidden;
  color: var(--ink);
  background: linear-gradient(#8fd3ff, #e7f7ff 58%, #d9f8d8);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}
button, input { font-family: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
input { user-select: text; -webkit-user-select: text; }
#app { position: relative; height: 100dvh; z-index: 1; }

.sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.sky-sun {
  position: absolute; top: 10px; right: 108px; width: 68px; height: 68px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff7c8, #ffd15c 55%, #ffb703);
  box-shadow: 0 0 0 12px rgba(255, 209, 92, 0.28);
}
.cloud { position: absolute; height: 28px; background: #fff; border-radius: 40px; opacity: 0.9; animation: drift 28s linear infinite; }
.cloud:before, .cloud:after { content: ""; position: absolute; background: #fff; border-radius: 50%; }
.cloud:before { width: 34px; height: 34px; top: -18px; left: 16px; }
.cloud:after { width: 24px; height: 24px; top: -12px; left: 42px; }
.c1 { width: 92px; top: 46px; left: 18%; }
.c2 { width: 120px; top: 86px; left: 62%; animation-duration: 36s; }
.c3 { width: 70px; top: 28px; left: 78%; animation-duration: 24s; }
.hills {
  position: absolute; left: -10%; right: -10%; bottom: -30px; height: 120px; border-radius: 50% 50% 0 0;
  background: #b6ef9e;
}

.screen { height: 100%; display: flex; flex-direction: column; padding: 14px 18px 16px; gap: 12px; min-height: 0; overflow: hidden; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1, .pick h1, .modal h3, .sheet h3 { margin: 0; }
.brand h1 { font-size: 32px; letter-spacing: 0.02em; }
.brand p, .muted { margin: 2px 0 0; color: var(--muted); font-size: 16px; text-shadow: 0 1px 0 #fff; }
.logo, .mark {
  width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center;
  background: linear-gradient(180deg, #fff, #ffe38a); color: #ef7b00; font-size: 22px; font-weight: 800;
  box-shadow: 0 6px 0 #f0c14a;
}

.icon-btn, .nav-btn, .text-btn {
  min-width: 64px; min-height: 64px; border-radius: 20px; background: #fff;
  box-shadow: var(--shadow); font-size: 28px; display: grid; place-items: center;
}
.text-btn { min-width: 88px; font-size: 20px; padding: 0 14px; color: #6d5a8d; }
.icon-btn svg { width: 32px; height: 32px; fill: #6d5a8d; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 4px solid #fff;
}
.home-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 14px; }
.pet-card, .cal-card { min-height: 0; display: flex; }
.pet-card { flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 8px 18px 12px; overflow: hidden; }
.pet-copy { width: min(100%, 420px); text-align: center; }
.pet-copy h2 { margin: 0; font-size: 32px; }
.level-pill {
  display: inline-block; margin: 6px 0; padding: 4px 12px; border-radius: 999px;
  background: #efe4ff; color: #6a4db5; font-size: 16px;
}
.xp { height: 18px; border-radius: 999px; background: #e3d8f6; overflow: hidden; border: 2px solid #d5c6ef; }
.xp > div { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #ffd15c, #ff9f43); }
.xp-text { margin: 6px 0 0; font-size: 15px; color: var(--muted); }
.speech {
  margin: 8px 0 0; padding: 8px 14px; border-radius: 18px; background: #fff7fb;
  border: 3px solid #ffd0e4; font-size: 18px;
}

.buddy { flex: 1 1 auto; width: min(100%, 420px); height: auto; min-height: 0; max-height: 380px; filter: drop-shadow(0 10px 0 rgba(255,255,255,.28)); }
.buddy.mini { flex: none; width: 210px; height: 230px; }
.buddy.pick { flex: none; width: 100%; height: 100%; }
.buddy.hero { flex: none; width: min(360px, 46vw); height: min(46dvh, 360px); }
.pet-svg { width: 100%; height: 100%; overflow: visible; }
.buddy-bob, .buddy-live { height: 100%; width: 100%; }
.buddy-bob { animation: bob 2.6s ease-in-out infinite; }
.egg-bob { height: 100%; animation: eggwob 2.3s ease-in-out infinite; transform-origin: 50% 80%; }
.egg-hot { animation-duration: 0.7s; }
.mood-happy .buddy-bob, .mood-happy .buddy-live, .mood-happy .egg-bob { animation: hop 0.55s ease; }
.mood-sad .buddy-bob, .mood-sad .buddy-live, .mood-sad .egg-bob { animation: sulk 0.45s ease; }

.pet-stage {
  position: relative; width: 100%; height: 100%;
  display: grid; place-items: center;
}
.pet-stage::after {
  content: ""; position: absolute; left: 12%; right: 12%; bottom: 6%; height: 12%;
  border-radius: 50%; pointer-events: none; z-index: 0;
}
.pet-stage.land::after { background: radial-gradient(ellipse at center, #8fe388 0%, rgba(143, 227, 136, 0.2) 70%, transparent 100%); }
.pet-stage.sea::after {
  background:
    radial-gradient(ellipse at center, #d9f7ff 0%, rgba(143, 220, 255, 0.85) 45%, transparent 75%);
}
.pet-sprite {
  position: relative; z-index: 1;
  width: 78%; height: 78%; max-width: 260px; max-height: 240px;
  object-fit: contain; object-position: center bottom; image-rendering: auto;
  pointer-events: none; user-select: none;
  filter: drop-shadow(0 8px 0 rgba(70, 50, 110, 0.08));
}
.buddy.mini .pet-sprite { width: 82%; height: 82%; }
.buddy.pick .pet-sprite { width: 78%; height: 78%; }
.buddy.preview .pet-sprite { width: 72%; height: 72%; max-width: 120px; max-height: 110px; }
.buddy.thumb .pet-sprite { width: 70%; height: 70%; max-width: 56px; max-height: 48px; filter: none; }
.pet-sprite.egg-sprite {
  width: 72%; height: 72%; max-width: 260px; max-height: 260px;
}
.buddy.thumb .pet-stage::after, .buddy.preview .pet-stage::after { bottom: 2%; height: 10%; opacity: 0.7; }

.cal-card { flex-direction: column; padding: 12px 14px 10px; overflow: hidden; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cal-head h2 { margin: 0; font-size: 24px; }
.cal-actions { display: flex; gap: 8px; }
.nav-btn { min-width: 52px; min-height: 52px; font-size: 26px; }
.weekdays, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; width: 100%; }
.weekdays { margin-top: 8px; color: var(--muted); font-size: 14px; text-align: center; }
.cal-grid { flex: 1; min-height: 0; grid-template-rows: repeat(6, 1fr); margin-top: 4px; }
.day, .day-empty {
  border-radius: 14px; min-width: 0; width: 100%; min-height: 0; background: #f7f3ff; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font-size: 16px; color: var(--ink);
}
.day.sun { color: #e25b8a; }
.day.sat { color: #3d7de0; }
.day.today { box-shadow: inset 0 0 0 3px #4d94ff; }
.day.future { opacity: 0.38; }
.day .dn { font-weight: 800; line-height: 1; font-size: 15px; }
.day .badge { font-size: 13px; line-height: 1; color: #c98400; font-weight: 800; white-space: nowrap; }
.day .badge.fix { color: #7a4ec8; }
.day .cal-stars {
  display: flex; align-items: center; justify-content: center; gap: 1px;
  width: 100%; padding: 0 2px; line-height: 1; position: relative;
}
.day .cal-stars i {
  flex: 0 0 auto; width: 0.92em; height: 0.92em; font-size: 15px;
  background: #e8dfc8; clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.day .cal-stars i.on {
  background: linear-gradient(180deg, #ffe566, #ffb700);
  filter: drop-shadow(0 1px 0 #e09a00);
}
.day .cal-stars em {
  position: absolute; right: 2px; top: -2px;
  min-width: 14px; height: 14px; padding: 0 3px; border-radius: 999px;
  background: #7a4ec8; color: #fff; font-size: 10px; font-style: normal; font-weight: 800;
  display: grid; place-items: center; line-height: 1;
}
.day.has { background: #fff6d8; }
.day.made { background: #efe4ff; }
@media (min-height: 820px) {
  .day .cal-stars i { font-size: 17px; }
}

.home-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.diff { margin: 0; font-size: 18px; font-weight: 800; }
.today-line { margin: 4px 0 0; color: var(--muted); }
.go, .primary, .ok-btn {
  border-radius: 24px; background: linear-gradient(#49e39b, #14b86e); color: #fff;
  font-size: 32px; font-weight: 800; min-height: 76px; padding: 0 42px;
  box-shadow: 0 8px 0 #0d8f56;
}
.go:active, .primary:active, .ok-btn:active, .key:active, .choice:active, .preset:active {
  transform: translateY(4px); box-shadow: 0 3px 0 rgba(40, 20, 60, 0.18);
}
.go { min-width: 280px; animation: pulse 2.4s ease-in-out infinite; }

.pick { height: 100%; display: grid; grid-template-rows: auto 1fr auto; gap: 10px; padding: 16px 20px 18px; }
.pick h1 { font-size: 36px; }
.pick-grid { min-height: 0; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 10px; }
.choice {
  min-height: 0; border-radius: 24px; background: #fff; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; padding: 6px 6px 8px; border: 4px solid transparent;
}
.choice.on { border-color: #ff9f43; background: #fff8ee; }
.choice .pick-art { flex: 1; min-height: 0; width: 100%; }
.choice b { font-size: 20px; }
.pick-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pick-foot p { margin: 0; font-size: 20px; }

.quiz { height: 100%; display: grid; grid-template-rows: auto 1fr auto; gap: 8px; padding: 12px 18px 14px; }
.quiz-top { display: flex; align-items: center; gap: 12px; }
.dots { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: #e5def2; display: block; }
.dot.now { box-shadow: 0 0 0 3px #fff, 0 0 0 6px #8b7cff; }
.dot.good { background: #2ecf8b; }
.dot.fixed { background: #4d94ff; }
.dot.miss { background: #ff9f43; }
.phase { font-size: 20px; font-weight: 800; white-space: nowrap; background: rgba(255,255,255,.9); padding: 8px 14px; border-radius: 999px; }
.quiz-main { min-height: 0; display: grid; grid-template-columns: 230px 1fr; gap: 8px; align-items: center; }
.q-card {
  position: relative; background: var(--card); border-radius: 32px; box-shadow: var(--shadow);
  min-height: 0; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  border: 4px solid #fff;
}
.q-stack { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.q-notes {
  min-height: 32px; display: flex; align-items: flex-end; justify-content: center;
  text-align: center;
}
.hint { margin: 0; background: #fff4cc; color: #8a5a00; border-radius: 999px; padding: 4px 14px; font-size: 16px; }
.retry-tag { margin: 0; color: #7a4ec8; font-weight: 800; font-size: 16px; }
.expr { margin: 0; font-size: clamp(36px, 4.6vw, 76px); font-weight: 800; letter-spacing: 0.03em; }
.expr .op { color: #ff7eb3; margin: 0 0.12em; }
.expr .eq { color: #8b7cff; margin: 0 0.12em; }
.expr .qmark { color: #ff9f43; }
.answer {
  min-width: 200px; min-height: 78px; padding: 0 22px; border-radius: 22px; background: #fff;
  border: 4px solid #eadfff; display: flex; align-items: center; justify-content: center;
  font-size: 60px; font-weight: 800; letter-spacing: 0.04em;
}
.answer.empty { color: #d9d0e8; }
.flash-good .answer { background: #e5fff3; border-color: #2ecf8b; }
.flash-bad .answer { background: #ffe8ee; border-color: #ff7eb3; animation: shake 0.4s linear; }
.flash-empty .answer { animation: shake 0.35s linear; }
.stamp {
  position: absolute; top: 18px; right: 22px; font-size: 28px; font-weight: 800;
  transform: rotate(8deg); padding: 4px 10px; border-radius: 14px; border: 4px solid currentColor;
}
.stamp.ok { color: #12a866; background: #e9fff5; }
.stamp.no { color: #e25b8a; background: #fff0f5; }

.pad { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.keys { width: min(560px, 100%); display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.key {
  min-height: 62px; border-radius: 18px; font-size: 36px; font-weight: 800; color: #fff;
  box-shadow: 0 6px 0 rgba(40, 20, 60, 0.16);
}
.key[data-d="1"] { background: #ff6b6b; }
.key[data-d="2"] { background: #ff9f43; }
.key[data-d="3"] { background: #ffd15c; color: #6b4e00; }
.key[data-d="4"] { background: #3ddc97; color: #085041; }
.key[data-d="5"] { background: #2ec8d6; color: #08484f; }
.key[data-d="6"] { background: #4d8dff; }
.key[data-d="7"] { background: #8b7cff; }
.key[data-d="8"] { background: #ff7eb3; }
.key[data-d="9"] { background: #ff8ad4; }
.key[data-d="0"] { background: #748ffc; }
.key.erase { background: #ffe8a3; color: #6b4e00; font-size: 24px; }
.ok-btn { width: min(560px, 100%); letter-spacing: 0.08em; }
button:disabled { filter: grayscale(0.3); opacity: 0.7; }

.result, .evolve, .settings { height: 100%; display: grid; gap: 10px; padding: 14px 18px 16px; }
.result { grid-template-rows: minmax(280px, 32vh) minmax(0, 1fr) auto; }
.result-top {
  min-height: 280px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 22px 16px 18px; text-align: center; border-radius: 32px; border: 4px solid #fff;
  background:
    radial-gradient(circle at 12% 28%, #ffe7a3 0 18px, transparent 19px),
    radial-gradient(circle at 88% 22%, #ffd0e6 0 16px, transparent 17px),
    radial-gradient(circle at 78% 78%, #c9f1ff 0 14px, transparent 15px),
    linear-gradient(180deg, #fff8e4 0%, #fff 70%);
  box-shadow: var(--shadow);
}
.result-body { min-height: 0; display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.result-side {
  min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto auto auto; justify-items: center; align-items: center; gap: 8px;
  background: var(--card); border-radius: 28px; box-shadow: var(--shadow); padding: 12px 12px 14px; text-align: center;
}
.result-side .xp { width: min(100%, 300px); height: 26px; }
.buddy.result { width: 100%; height: 100%; min-height: 0; max-width: none; max-height: none; }
.buddy.result .buddy-bob, .buddy.result .egg-bob, .buddy.result .pet-stage { width: 100%; height: 100%; }
.buddy.result .pet-sprite { width: 100%; height: 100%; max-width: none; max-height: none; }
.xp-now { margin: 0; font-size: 20px; font-weight: 800; color: #5b3d9a; }
.evolve-card { text-align: center; }
.stars { display: flex; justify-content: center; align-items: flex-end; gap: 16px; }
.star { font-size: 58px; color: #e6ddf2; line-height: 1; }
.star.toon {
  width: 150px; height: 150px; display: block; flex: 0 0 auto;
  filter: drop-shadow(0 8px 0 #e4d3ee);
}
.star.toon svg { width: 100%; height: 100%; overflow: visible; display: block; }
.star.toon .body { fill: #f6eefe; stroke: #fff; stroke-width: 8; stroke-linejoin: round; }
.star.toon .shine { fill: #fff; opacity: 0.35; }
.star.toon .asleep, .star.toon .awake { fill: none; stroke: #cbb6e4; stroke-width: 4; stroke-linecap: round; }
.star.toon .awake { display: none; }
.star.toon.on {
  filter: drop-shadow(0 8px 0 #e09400);
  animation: pop 0.45s both;
  animation-delay: calc(var(--d) * 0.12s);
}
.star.toon.on .body { fill: #ffcc33; stroke: #fff7d2; }
.star.toon.on .shine { opacity: 0.95; }
.star.toon.on .asleep { display: none; }
.star.toon.on .awake { display: block; stroke: none; }
.star.toon.on .awake ellipse { fill: #5c3b16; }
.star.toon.on .awake circle { fill: #fff; }
.star.toon.on .awake .cheek { fill: #ff8fb8; }
.star.toon.on .awake .smile { fill: none; stroke: #5c3b16; stroke-width: 4; stroke-linecap: round; }
.phrase { margin: 2px 0 0; font-size: 36px; font-weight: 800; }
.xp-note { margin: 0; font-size: 16px; color: #6a4db5; line-height: 1.4; }
.scroll { min-height: 0; overflow: auto; background: var(--card); border-radius: 24px; padding: 8px 12px 12px; box-shadow: var(--shadow); }
.qhead, .qrow { display: grid; grid-template-columns: 1.6fr 0.6fr 0.7fr 0.7fr; gap: 8px; align-items: center; padding: 8px 6px; }
.qhead { color: var(--muted); font-size: 14px; position: sticky; top: 0; background: #fff; z-index: 1; }
.qrow { border-top: 2px solid #f4effb; font-size: 20px; }
.qrow.no {
  background: #ffd0dc; color: #9d123c; font-weight: 800;
  box-shadow: inset 8px 0 0 #e11d48;
}
.qrow.no span:nth-child(2) {
  justify-self: start; padding: 2px 10px; border-radius: 999px; background: #e11d48; color: #fff; font-size: 16px;
}
.actions { display: flex; justify-content: flex-end; gap: 10px; }
.ghost {
  min-height: 64px; padding: 0 22px; border-radius: 20px; background: #fff; font-size: 22px; font-weight: 800;
  box-shadow: var(--shadow);
}
.danger {
  min-height: 64px; padding: 0 22px; border-radius: 20px; background: #ffe4ec; color: #9d123c;
  font-size: 22px; font-weight: 800; box-shadow: 0 6px 0 #e7a0b6;
}
.danger:active { transform: translateY(4px); box-shadow: 0 2px 0 #e7a0b6; }

.evolve { place-items: center; }
.evolve-card {
  width: min(760px, 100%); background: var(--card); border-radius: 36px; padding: 18px 20px 22px; box-shadow: var(--shadow);
}
.evolve-card h2 { margin: 8px 0; font-size: 40px; }
.pop-in { animation: pop 0.6s both; }

.settings { grid-template-rows: auto 1fr; }
.settings .topbar { justify-content: flex-start; gap: 14px; }
.lock { height: 100%; display: grid; grid-template-rows: auto 1fr; padding: 16px 20px; }
.lock-card { margin: auto; width: min(460px, 100%); text-align: center; }
.pin-dots { display: flex; justify-content: center; gap: 12px; margin: 12px 0; }
.pin-dots i { width: 18px; height: 18px; border-radius: 50%; background: #eadfff; display: block; }
.pin-dots i.on { background: #8b7cff; }
.shake { animation: shake 0.4s linear; }
.set-grid { min-height: 0; overflow: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-content: start; padding-bottom: 8px; }
.set-card { background: var(--card); border-radius: 24px; padding: 14px 16px 16px; box-shadow: var(--shadow); }
.set-card h3 { margin: 0 0 6px; font-size: 22px; }
.set-card p { margin: 0 0 10px; color: var(--muted); font-size: 15px; line-height: 1.45; }
.set-card.wide { grid-column: 1 / -1; }
.pet-edit-body { display: grid; grid-template-columns: 200px 1fr; gap: 12px; align-items: start; }
.pet-preview {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 4px;
  background: linear-gradient(#fff, #f3f8ff); border: 3px solid #efe4ff; border-radius: 22px; padding: 8px 8px 10px;
  min-width: 0;
}
.pet-preview b { font-size: 18px; text-align: center; line-height: 1.2; }
.pet-preview .stage { color: var(--muted); font-size: 12px; text-align: center; }
.pet-preview .row { justify-content: center; gap: 6px; }
.pet-preview .preset { min-height: 40px; padding: 0 10px; font-size: 15px; }
.pet-preview .stepper b { min-width: 48px; font-size: 22px; }
.pet-preview .stepper button { min-height: 40px; padding: 0 12px; font-size: 18px; }
.buddy.preview { flex: none; width: 132px; height: 112px; max-height: 112px; overflow: hidden; }
.pet-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; align-content: start; }
.pet-choice {
  min-width: 0; border-radius: 14px; background: #f7f3ff; border: 3px solid transparent;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 4px 6px; font-size: 14px;
}
.pet-choice-art {
  width: 100%; height: 52px; display: grid; place-items: center; overflow: hidden;
}
.pet-choice b { font-size: 14px; line-height: 1.15; text-align: center; }
.pet-choice.on { border-color: #ff9f43; background: #fff8ea; }
.pet-choice small { color: var(--muted); font-size: 11px; font-weight: 700; }
.buddy.thumb { flex: none; width: 72px; height: 52px; max-height: 52px; overflow: hidden; }
.stepper { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stepper b { min-width: 72px; text-align: center; font-size: 28px; }
.stepper button, .preset, .file-btn {
  min-height: 52px; padding: 0 14px; border-radius: 16px; background: #f4efff; font-size: 20px; font-weight: 800;
}
.preset.on, .tab.on { background: #ffe08a; }
.presets, .tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
input[type="date"] {
  min-height: 52px; border-radius: 16px; border: 3px solid #eadfff; padding: 0 12px; font-size: 18px; background: #fff;
}
.status-line { margin: 0; font-size: 16px; }

.mask, .sheet-mask {
  position: absolute; inset: 0; background: rgba(70, 90, 140, 0.28);
  display: flex; align-items: center; justify-content: center; padding: 18px; z-index: 40;
}
.mask { z-index: 50; }
.modal, .sheet {
  width: min(920px, 100%); max-height: 100%; background: #fff; border-radius: 28px;
  box-shadow: var(--shadow); padding: 18px 18px 16px; display: flex; flex-direction: column; gap: 8px;
}
.modal { width: min(520px, 100%); }
.modal p, .sheet p { margin: 0; font-size: 18px; line-height: 1.5; }
.sheet .scroll { box-shadow: none; padding: 0; }
.toast {
  position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #3c2a55; color: #fff; border-radius: 999px; padding: 12px 18px; z-index: 70; font-size: 18px;
}
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i {
  position: absolute; left: calc(6% * var(--i)); top: -12px; width: 12px; height: 18px; background: var(--c);
  border-radius: 3px; animation: fall 1.1s ease-in both; animation-delay: calc(var(--i) * 0.03s);
}

#rotate {
  display: none; position: fixed; inset: 0; z-index: 80; background: linear-gradient(#8fd3ff, #ffe9f4);
  align-items: center; justify-content: center; text-align: center; flex-direction: column; gap: 8px;
}
#rotate h2 { margin: 0; font-size: 40px; }
#rotate p { margin: 0; font-size: 22px; color: #6d5a8d; }
.ipad-art { width: 140px; height: 90px; border: 8px solid #3c2a55; border-radius: 16px; animation: turn 1.6s ease-in-out infinite; background: #fff; }

@media (orientation: portrait) {
  #rotate { display: flex; }
}
@media (max-height: 820px) {
  .brand h1 { font-size: 26px; }
  .buddy { max-height: 280px; }
  .go, .primary, .ok-btn { min-height: 64px; font-size: 28px; }
  .key { min-height: 54px; font-size: 32px; }
  .expr { font-size: clamp(30px, 4.2vw, 60px); }
  .answer { min-height: 64px; font-size: 48px; }
  .result { grid-template-rows: minmax(188px, auto) minmax(0, 1fr) auto; }
  .result-top { min-height: 188px; padding: 12px 12px 10px; }
  .star.toon { width: 108px; height: 108px; }
  .phrase { font-size: 28px; }
  .speech { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, .buddy-bob, .buddy-live, .egg-bob, .go { animation: none !important; }
}

@keyframes bob { 50% { transform: translateY(-8px); } }
@keyframes eggwob {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg) translateY(2px); }
}
@keyframes hop {
  0% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-18px) scale(1.04); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes sulk {
  0%, 100% { transform: rotate(0); }
  40% { transform: rotate(-6deg); }
  70% { transform: rotate(5deg); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}
@keyframes pop {
  0% { transform: scale(0.2) rotate(-12deg); }
  70% { transform: scale(1.15) rotate(4deg); }
  100% { transform: scale(1) rotate(0); }
}
@keyframes pulse {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}
@keyframes drift { from { transform: translateX(0); } to { transform: translateX(40px); } }
@keyframes fall { to { transform: translateY(70dvh) rotate(180deg); opacity: 0.2; } }
@keyframes turn { 50% { transform: rotate(-90deg); } }
