:root {
  --ink: #3b2f5c;
  --muted: #8a7fa8;
  --primary: #7c5cff;
  --primary-dark: #5b3fe0;
  --pink: #ff6fa8;
  --green: #22c07a;
  --red: #ff5e5e;
  --yellow: #ffc93c;
  --card: #fff;
  --c1: #7c5cff;
  --c2: #ff6fa8;
  --app-h: 100vh;
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html {
  background: linear-gradient(165deg, #fff1d6 0%, #ffe3ef 45%, #dff1ff 100%);
  min-height: 100%;
}

html, body { margin: 0; }

body {
  min-height: var(--app-h);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled { cursor: default; }

.screen {
  position: relative;
  min-height: var(--app-h);
  padding: var(--sat) var(--sar) var(--sab) var(--sal);
}

/* ---------- shared buttons ---------- */

.icon-btn {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 0 rgba(60, 40, 120, 0.12);
  font-size: 22px;
  line-height: 44px;
  text-align: center;
  transition: transform 0.12s;
}
.icon-btn.back { font-size: 34px; font-weight: 700; line-height: 40px; color: var(--primary); }
.icon-btn:active { transform: scale(0.9); }

.btn {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  background: #fff;
  color: var(--primary);
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 4px 0 rgba(60, 40, 120, 0.15);
  transition: transform 0.12s, box-shadow 0.12s;
  white-space: nowrap;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(60, 40, 120, 0.15); }
.btn.primary {
  background: linear-gradient(135deg, var(--c1), var(--c2));
  color: #fff;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18);
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  min-height: 60px;
}
.topbar .title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 20px;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.title-emoji { margin-right: 6px; }
.timer {
  flex: none;
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 3px 0 rgba(60, 40, 120, 0.12);
}
@media (max-width: 400px) {
  .topbar { gap: 8px; padding: 8px 10px; }
  .topbar .title { font-size: 18px; }
  .title-emoji { margin-right: 3px; }
  .timer { padding: 6px 9px; font-size: 15px; }
}

/* ---------- home ---------- */

.home {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.bg-deco { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.bg-deco i {
  position: absolute;
  border-radius: 50%;
  opacity: 0.35;
  animation: float 9s ease-in-out infinite;
}
.bg-deco i:nth-child(1) { width: 140px; height: 140px; background: #ffc93c; top: -30px; left: -40px; }
.bg-deco i:nth-child(2) { width: 90px; height: 90px; background: #ff6fa8; top: 18%; right: -20px; animation-delay: -2s; }
.bg-deco i:nth-child(3) { width: 60px; height: 60px; background: #38a3ff; bottom: 22%; left: 6%; animation-delay: -4s; }
.bg-deco i:nth-child(4) { width: 180px; height: 180px; background: #7c5cff; bottom: -70px; right: -50px; opacity: 0.2; animation-delay: -1s; }
.bg-deco i:nth-child(5) { width: 36px; height: 36px; background: #22c07a; top: 40%; left: 12%; animation-delay: -6s; }
.bg-deco i:nth-child(6) { width: 26px; height: 26px; background: #ff9f43; top: 12%; left: 45%; animation-delay: -3s; }

@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-18px) scale(1.06); }
}

.home-head {
  position: relative;
  width: 100%;
  max-width: 980px;
  text-align: center;
  padding: 20px 16px 8px;
}
.home-head .sound-toggle { position: absolute; right: 16px; top: 16px; }
.logo {
  font-size: 64px;
  line-height: 1;
  animation: bob 2.4s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-8px) rotate(4deg); }
}
.rainbow {
  margin: 6px 0 4px;
  font-size: clamp(32px, 8vw, 56px);
  font-weight: 900;
  letter-spacing: 2px;
}
.rainbow span {
  display: inline-block;
  color: hsl(calc(var(--i) * 55 + 330), 85%, 58%);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.08);
  animation: wave 2.8s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.12s);
}
@keyframes wave {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}
.tagline { margin: 0; color: var(--muted); font-size: 17px; font-weight: 700; }

.game-list {
  position: relative;
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 18px 16px;
}
@media (min-width: 700px) {
  .game-list { grid-template-columns: repeat(3, 1fr); gap: 20px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .home-head { padding-top: 8px; }
  .logo { font-size: 40px; }
  .rainbow { font-size: 30px; margin: 2px 0; }
  .game-list { grid-template-columns: repeat(3, 1fr); padding-top: 10px; }
}

.game-tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  border-radius: 28px;
  text-align: left;
  color: #fff;
  background: linear-gradient(135deg, var(--c1), var(--c2));
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.14), 0 14px 26px rgba(80, 40, 140, 0.18);
  transition: transform 0.14s, box-shadow 0.14s;
  overflow: hidden;
}
.game-tile::after {
  content: '';
  position: absolute;
  width: 160px;
  height: 160px;
  right: -50px;
  top: -60px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
}
.game-tile:active { transform: translateY(5px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.14); }
.tile-emoji {
  flex: none;
  width: 70px;
  height: 70px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.92);
  display: grid;
  place-items: center;
  font-size: 40px;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.06);
}
.tile-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.tile-title { font-size: 24px; font-weight: 900; }
.tile-desc { font-size: 15px; font-weight: 600; opacity: 0.92; }
.tile-best { display: flex; flex-direction: column; align-items: center; gap: 2px; z-index: 1; }
.tile-best-label { font-size: 11px; opacity: 0.85; }
.tile-stars { display: flex; gap: 2px; }
.tile-go { display: none; }

@media (min-width: 700px) {
  .game-tile { flex-direction: column; text-align: center; padding: 26px 18px 22px; min-height: 280px; justify-content: center; }
  .tile-emoji { width: 96px; height: 96px; font-size: 56px; border-radius: 30px; }
  .tile-title { font-size: 28px; }
  .tile-go {
    display: block;
    margin-top: 6px;
    padding: 8px 26px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--c2);
    font-size: 18px;
    font-weight: 900;
  }
}
@media (orientation: landscape) and (max-height: 500px) {
  .game-tile { flex-direction: column; text-align: center; min-height: 0; padding: 14px 12px; gap: 8px; }
  .tile-emoji { width: 60px; height: 60px; font-size: 34px; }
  .tile-title { font-size: 22px; }
  .tile-desc { font-size: 13px; }
  .tile-go, .tile-best-label { display: none; }
  .home-foot { padding-bottom: 12px; }
}

.home-foot {
  position: relative;
  padding: 4px 16px 24px;
  color: var(--muted);
  font-weight: 700;
  font-size: 15px;
  text-align: center;
}

/* ---------- stars ---------- */

.star { width: 20px; height: 20px; fill: rgba(255, 255, 255, 0.45); }
.star.on { fill: #ffd43b; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.15)); }
.star.small { width: 20px; height: 20px; }
.star.big { width: 64px; height: 64px; fill: #ece8f6; transition: fill 0.2s; }
.star.big.on { fill: #ffc93c; }
.star.big.pop { animation: starpop 0.55s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes starpop {
  0% { transform: scale(0.2) rotate(-40deg); }
  100% { transform: scale(1) rotate(0); }
}

/* ---------- setup ---------- */

.setup { display: flex; flex-direction: column; }
.setup-body {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 4px 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.setup-intro {
  margin: 0;
  padding: 14px 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.85);
  font-size: 16px;
  line-height: 1.6;
  font-weight: 600;
}
.opt-group h3 { margin: 0 0 10px; font-size: 18px; font-weight: 900; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  min-height: 50px;
  padding: 8px 18px;
  border-radius: 18px;
  background: #fff;
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 4px 0 rgba(60, 40, 120, 0.12);
  border: 3px solid transparent;
  transition: transform 0.12s;
}
.chip:active { transform: scale(0.95); }
.chip[aria-pressed="true"] {
  background: linear-gradient(135deg, var(--c1), var(--c2));
  color: #fff;
  border-color: rgba(255, 255, 255, 0.6);
}
.opt-group.big .chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (min-width: 600px), (orientation: landscape) {
  .opt-group.big .chips { grid-template-columns: repeat(9, 1fr); }
}
@media (min-width: 600px) and (orientation: portrait) {
  .opt-group.big .chips { grid-template-columns: repeat(5, 1fr); }
}
.opt-group.big .chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  aspect-ratio: 5 / 4;
  min-height: 0;
  padding: 4px;
  border-radius: 24px;
}
@media (min-width: 600px), (orientation: landscape) {
  .opt-group.big .chip { aspect-ratio: 1 / 1; }
}
.opt-group.big .chip-label { font-size: 40px; line-height: 1; font-weight: 900; }
.chip-hint { font-size: 12px; font-weight: 700; opacity: 0.7; margin-top: 4px; }
@media (orientation: landscape) and (max-height: 500px) {
  .opt-group.big .chip-label { font-size: 30px; }
  .chip-hint { display: none; }
}
.start-btn {
  position: sticky;
  bottom: calc(var(--sab) + 14px);
  z-index: 5;
  align-self: center;
  margin-top: 6px;
  min-width: 240px;
  min-height: 64px;
  padding: 0 32px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--c1), var(--c2));
  color: #fff;
  font-size: 24px;
  font-weight: 900;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.18);
  animation: breathe 2s ease-in-out infinite;
}
.start-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18); }
@keyframes breathe {
  0%, 100% { scale: 1; }
  50% { scale: 1.04; }
}

/* ---------- game layout ---------- */

.screen.game {
  height: var(--app-h);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.game .topbar { flex: none; }

.game-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 12px 10px;
}

.board {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress { flex: none; display: flex; align-items: center; gap: 10px; }
.progress-track {
  flex: 1;
  height: 12px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.8);
  overflow: hidden;
}
.progress-bar {
  width: 0;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--c1), var(--c2));
  transition: width 0.3s;
}
.progress-text { flex: none; font-size: 14px; font-weight: 800; color: var(--muted); }

.cards {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 10px;
  align-content: start;
  touch-action: pan-y;
}

.pager {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 44px;
}
.pager.single { visibility: hidden; }
.pg {
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: #fff;
  font-weight: 800;
  font-size: 15px;
  color: var(--primary);
  box-shadow: 0 3px 0 rgba(60, 40, 120, 0.12);
  white-space: nowrap;
  flex: none;
}
.pg:disabled { opacity: 0.35; }
.page-num { font-weight: 900; font-size: 16px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.dot {
  width: 26px;
  height: 26px;
  position: relative;
}
.dot::before {
  content: '';
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: #d9d1f5;
  transition: transform 0.2s;
}
.dot.done::before { background: var(--c1); }
.dot.current::before { background: var(--c2); transform: scale(1.5); }

.pad {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.pad-actions { display: flex; gap: 10px; width: max(var(--wheel), 260px); }
.pad-actions .btn { flex: 1; padding: 0 10px; }

@media (orientation: landscape) {
  .game-body { flex-direction: row; gap: 14px; }
  .pad { justify-content: center; }
  .pad-actions { width: max(var(--wheel), 230px); }
}

/* ---------- number wheel ---------- */

.pad { --wheel: min(62vw, calc(var(--app-h) * 0.33), 320px); }
@media (orientation: landscape) {
  .pad { --wheel: min(calc(var(--app-h) * 0.56), 38vw, 340px); }
}

.wheel {
  position: relative;
  width: var(--wheel);
  height: var(--wheel);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #fff 0 30%, transparent 30.5%),
    conic-gradient(from -18deg, #ffe0e9, #fff0c7, #dcf7e6, #dcefff, #e8e0ff, #ffe0e9);
  box-shadow: 0 8px 0 rgba(60, 40, 120, 0.1), inset 0 0 0 6px rgba(255, 255, 255, 0.8);
  flex: none;
}
.submitted .wheel { opacity: 0.45; pointer-events: none; }

.digit {
  --size: calc(var(--wheel) * 0.215);
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--size);
  height: var(--size);
  margin: calc(var(--size) / -2) 0 0 calc(var(--size) / -2);
  border-radius: 50%;
  background: hsl(calc(var(--i) * 36 + 340), 88%, 62%);
  color: #fff;
  font-size: calc(var(--size) * 0.52);
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.15);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18);
  transform: rotate(calc(var(--i) * 36deg)) translateY(calc(var(--wheel) * -0.365)) rotate(calc(var(--i) * -36deg));
}
.digit:active { filter: brightness(1.1); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18); margin-top: calc(var(--size) / -2 + 3px); }
.digit.pop { animation: digitpop 0.25s ease-out; }
@keyframes digitpop {
  50% { filter: brightness(1.25); }
}

.wheel-center {
  --size: calc(var(--wheel) * 0.34);
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--size);
  height: var(--size);
  margin: calc(var(--size) / -2) 0 0 calc(var(--size) / -2);
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  font-size: calc(var(--size) * 0.36);
  font-weight: 900;
  box-shadow: 0 4px 0 rgba(60, 40, 120, 0.15), inset 0 0 0 3px #eee8fb;
}
.wheel-center:active { transform: scale(0.92); }

.submit.ready { animation: ready 1.4s ease-in-out infinite; }
.submit.pulse { animation: pulse 0.5s ease-in-out 2; }
@keyframes ready {
  0%, 100% { box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18), 0 0 0 0 rgba(255, 111, 168, 0.5); }
  50% { box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18), 0 0 0 10px rgba(255, 111, 168, 0); }
}
@keyframes pulse {
  50% { transform: scale(1.1); }
}

/* ---------- question cards ---------- */

.card {
  position: relative;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px 6px 26px;
  border-radius: 20px;
  background: var(--card);
  border: 3px solid transparent;
  box-shadow: 0 4px 0 rgba(60, 40, 120, 0.08), 0 8px 16px rgba(60, 40, 120, 0.06);
  font-size: var(--fs, 24px);
  font-weight: 900;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
  overflow: hidden;
}
.card.active {
  border-color: var(--c1);
  box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.18), 0 8px 16px rgba(60, 40, 120, 0.08);
}
.card.filled:not(.active) .ans { border-style: solid; border-color: #d8d0f3; }
.card.right { border-color: var(--green); background: #effff6; }
.card.wrong { border-color: var(--red); background: #fff2f2; }
.card.shake { animation: shake 0.4s; }
@keyframes shake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.qno {
  position: absolute;
  left: 6px;
  top: 6px;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  border-radius: 10px;
  background: #f0ecff;
  color: var(--primary);
  font-size: 12px;
  line-height: 20px;
  text-align: center;
  font-weight: 800;
}

.card-main { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }

.eq { display: flex; align-items: center; justify-content: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
.eq .op { margin: 0 0.22em; color: var(--c2); }

.ans {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.1em;
  height: 1.45em;
  padding: 0 0.2em;
  border-radius: 0.35em;
  border: 3px dashed #cfc5f2;
  background: #faf8ff;
  color: var(--primary-dark);
  font-variant-numeric: tabular-nums;
}
.card.active .ans { border-style: solid; border-color: var(--c1); background: #fff; }
.card.active .ans:empty::after {
  content: '';
  width: 3px;
  height: 0.9em;
  border-radius: 2px;
  background: var(--c1);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.card.right .ans { border-color: var(--green); color: #129a5b; background: #fff; }
.card.wrong .ans { border-color: var(--red); color: var(--red); background: #fff; text-decoration: line-through; text-decoration-thickness: 2px; }

.feedback {
  position: absolute;
  right: 8px;
  bottom: 3px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}
.card.right .feedback { color: #129a5b; }
.card.wrong .feedback { color: var(--red); }
.feedback:empty { display: none; }
.card.right, .card.wrong { padding-bottom: 16px; }

/* ---------- line-segment cards ---------- */

.theme-lines .card { align-items: stretch; padding: 8px 10px; }
.theme-lines .card-main { flex-direction: column; gap: 4px; }
.segments { flex: 1; min-height: 0; width: 100%; }
.segments text { font-family: inherit; font-weight: 900; }
.seg-name { font-size: 15px; }
.seg-name.one, .seg-len.one { fill: #2f8ff0; }
.seg-name.two, .seg-len.two { fill: #f07a2b; }
.seg-len { font-size: 17px; }
.bar.one { fill: #6fb8ff; }
.bar.two { fill: #ffb074; }
.tick { stroke: rgba(255, 255, 255, 0.95); stroke-width: 1.6; }
.cap { stroke-width: 3; stroke-linecap: round; }
.cap.one { stroke: #2f8ff0; }
.cap.two { stroke: #f07a2b; }
.guide { stroke: #b3a9d6; stroke-width: 1.5; stroke-dasharray: 4 4; }
.bracket { fill: none; stroke: #e8457e; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.bracket-q { fill: #e8457e; font-size: 18px; text-anchor: middle; }

.sentence {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.3em;
  font-size: var(--fs, 20px);
  white-space: nowrap;
}
.choices { display: inline-flex; gap: 0.25em; }
.choice {
  min-width: 44px;
  min-height: 40px;
  padding: 0 0.45em;
  border-radius: 0.5em;
  background: #f3f0ff;
  color: var(--primary);
  font-weight: 900;
  border: 3px solid #e0d9fb;
}
.choice.selected { background: linear-gradient(135deg, var(--c1), var(--c2)); color: #fff; border-color: transparent; }
.theme-lines .card.right, .theme-lines .card.wrong { padding-bottom: 18px; }

/* ---------- toast ---------- */

.toast {
  position: absolute;
  left: 50%;
  top: calc(var(--sat) + 70px);
  z-index: 20;
  padding: 10px 20px;
  border-radius: 999px;
  background: rgba(59, 47, 92, 0.92);
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -10px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- result overlay ---------- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--sat) + 12px) calc(var(--sar) + 12px) calc(var(--sab) + 12px) calc(var(--sal) + 12px);
  background: rgba(59, 47, 92, 0.45);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: fadein 0.25s;
}
@keyframes fadein { from { opacity: 0; } }
.result-card {
  width: min(440px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 20px 20px 22px;
  border-radius: 32px;
  background: #fff;
  text-align: center;
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.1);
  animation: popin 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes popin { from { transform: scale(0.6); opacity: 0; } }
.mascot { font-size: 64px; line-height: 1; animation: bob 2s ease-in-out infinite; }
.result-stars { display: flex; justify-content: center; gap: 6px; margin: 8px 0 2px; }
.result-stars .star:nth-child(2) { transform: translateY(-12px); }
.result-stars .star:nth-child(2).pop { animation-name: starpop-mid; }
@keyframes starpop-mid {
  0% { transform: translateY(-12px) scale(0.2) rotate(-40deg); }
  100% { transform: translateY(-12px) scale(1) rotate(0); }
}
.result-card h2 { margin: 4px 0 2px; font-size: 30px; font-weight: 900; color: var(--c2); }
.result-card .sub { margin: 0; font-size: 17px; font-weight: 700; color: var(--muted); }
.stats { display: flex; justify-content: center; gap: 14px; margin: 14px 0 6px; }
.stats div {
  min-width: 110px;
  padding: 10px 12px;
  border-radius: 18px;
  background: #f6f3ff;
  display: flex;
  flex-direction: column;
}
.stats b { font-size: 26px; font-weight: 900; color: var(--primary-dark); font-variant-numeric: tabular-nums; }
.stats span { font-size: 13px; font-weight: 700; color: var(--muted); }
.tip { margin: 8px 0 0; font-size: 14px; font-weight: 700; color: #e08a00; }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 16px; }
.result-actions .btn { flex: 1 1 100px; }
.result-actions .btn:not(.primary) { background: #f3f0ff; box-shadow: 0 4px 0 rgba(60, 40, 120, 0.12); }

@media (orientation: landscape) and (max-height: 500px) {
  .result-card { width: min(560px, 100%); padding: 12px 18px 14px; }
  .mascot { display: none; }
  .star.big { width: 48px; height: 48px; }
  .result-card h2 { font-size: 24px; }
  .stats { margin: 8px 0 4px; }
  .result-actions { margin-top: 10px; }
}

/* ---------- confetti ---------- */

.confetti { position: absolute; inset: 0; z-index: 40; pointer-events: none; overflow: hidden; }
.confetti i {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 14px;
  border-radius: 3px;
  animation-name: fall;
  animation-timing-function: cubic-bezier(0.25, 0.6, 0.5, 1);
  animation-fill-mode: forwards;
}
@keyframes fall {
  to { transform: translate(var(--drift), calc(var(--app-h) + 40px)) rotate(var(--spin)); }
}

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