:root {
  --sky-1: #6c5ce7;
  --sky-2: #4facfe;
  --ink: #2d2a4a;
  --ink-soft: #6b6890;
  --card: #ffffff;
  --sun: #ffd23f;
  --sun-dark: #e0a800;
  --good: #2ecc71;
  --good-dark: #1e9e55;
  --try: #ff9f43;
  --radius: 28px;
  --font: 'Baloo Bhaijaan 2', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(165deg, var(--sky-1) 0%, #7f6cf0 40%, var(--sky-2) 100%) fixed;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
  /* Phone-app feel: no "Save image" pop-up on a long press, no double-tap zoom,
     no text growing when the phone turns */
  -webkit-touch-callout: none;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
/* Scrolling lists show no scroll bar, like an app */
* { scrollbar-width: none; }
*::-webkit-scrollbar { display: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
.ar { font-family: var(--font); direction: rtl; unicode-bidi: isolate; }

/* Twinkling background stars */
.sky { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.sky i {
  position: absolute; width: 6px; height: 6px; border-radius: 50%;
  background: #fff; opacity: .5; animation: twinkle 3s ease-in-out infinite;
}
.sky i:nth-child(1) { top: 8%; left: 12%; }
.sky i:nth-child(2) { top: 18%; left: 78%; animation-delay: .4s; width: 4px; height: 4px; }
.sky i:nth-child(3) { top: 42%; left: 6%; animation-delay: 1.2s; }
.sky i:nth-child(4) { top: 60%; left: 90%; animation-delay: .8s; width: 8px; height: 8px; }
.sky i:nth-child(5) { top: 80%; left: 20%; animation-delay: 2s; width: 4px; height: 4px; }
.sky i:nth-child(6) { top: 30%; left: 50%; animation-delay: 1.6s; width: 3px; height: 3px; }
.sky i:nth-child(7) { top: 92%; left: 70%; animation-delay: .2s; }
.sky i:nth-child(8) { top: 5%; left: 45%; animation-delay: 2.4s; width: 5px; height: 5px; }
@keyframes twinkle { 0%, 100% { opacity: .2; transform: scale(.7); } 50% { opacity: .9; transform: scale(1.2); } }

#app {
  position: relative; z-index: 1;
  max-width: 560px; margin: 0 auto;
  height: 100dvh;
  padding: max(12px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column;
}
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }
#world { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* ---------- Shared bits ---------- */
.bar { display: flex; align-items: center; gap: 8px; min-height: 52px; }
.bar .grow { flex: 1; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, .22); color: #fff;
  border-radius: 999px; padding: 6px 14px; font-weight: 800; font-size: 18px;
  backdrop-filter: blur(6px);
}
.icon-btn {
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center; font-size: 24px;
  background: rgba(255, 255, 255, .22); color: #fff; position: relative;
  backdrop-filter: blur(6px);
}
.icon-btn:active { transform: scale(.92); }
.chunky {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--sun); color: var(--ink); font-weight: 800; font-size: 22px;
  border-radius: 22px; padding: 14px 26px;
  box-shadow: 0 6px 0 var(--sun-dark), 0 10px 24px rgba(0, 0, 0, .18);
  transition: transform .08s, box-shadow .08s;
}
.chunky:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--sun-dark); }
.chunky.white { background: #fff; box-shadow: 0 6px 0 #d9d6f0, 0 10px 24px rgba(0, 0, 0, .14); }
.chunky.white:active { box-shadow: 0 2px 0 #d9d6f0; }
.screen-enter { animation: screenIn .35s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes screenIn { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }

/* Each screen sits in one box. Going deeper slides in from the right, going
   back slides in from the left, the next part of a round rises up. */
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.screen.push { animation: pushIn .34s cubic-bezier(.2, .8, .2, 1); }
.screen.pop { animation: popIn .34s cubic-bezier(.2, .8, .2, 1); }
.screen.rise { animation: screenIn .35s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes pushIn { from { opacity: 0; transform: translateX(22%); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: translateX(-22%); } to { opacity: 1; transform: none; } }
.icon-btn .ui-icon { width: 1em; height: 1em; }

/* ---------- Opening screen ----------
   Starts as the same purple as the phone's own splash, so the app seems to
   carry straight on from it: the icon bounces in, sound waves ripple out while
   a child shouts "Kalimati!", then it fades into home. */
.launch {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  background: linear-gradient(165deg, var(--sky-1) 0%, #7f6cf0 40%, var(--sky-2) 100%);
  /* the same space top and bottom, so the icon sits in the middle of the screen like the iPhone start picture */
  padding: max(env(safe-area-inset-top), env(safe-area-inset-bottom)) 16px;
}
.launch.still .launch-logo, .launch.still .launch-name { animation: none; }
.launch-logo { position: relative; width: 148px; height: 148px; animation: logoIn .7s cubic-bezier(.3, 1.6, .5, 1) both; }
.launch-logo img { position: relative; width: 100%; height: 100%; display: block; filter: drop-shadow(0 14px 22px rgba(30, 20, 90, .35)); -webkit-user-drag: none; }
.launch-logo i {
  position: absolute; inset: 0; border-radius: 34%;
  border: 6px solid rgba(255, 255, 255, .7); opacity: 0;
}
.launch.talk .launch-logo i { animation: wave 1.1s ease-out infinite; }
.launch.talk .launch-logo i:nth-child(2) { animation-delay: .3s; }
.launch.talk .launch-logo i:nth-child(3) { animation-delay: .6s; }
.launch.talk .launch-logo img { animation: shout .55s ease-in-out 2; }
.launch-name {
  color: #fff; font-size: 54px; font-weight: 800; line-height: 1;
  text-shadow: 0 4px 0 rgba(0, 0, 0, .15); animation: nameIn .55s .25s cubic-bezier(.3, 1.5, .5, 1) both;
}
.launch-play {
  /* below the name without pushing the icon and name up, so they stay where the iPhone start picture had them */
  position: absolute; top: calc(50% + 112px + 34px); left: calc(50% - 48px);
  width: 96px; height: 96px; border-radius: 50%;
  display: grid; place-items: center; background: var(--sun); color: var(--ink);
  box-shadow: 0 7px 0 var(--sun-dark), 0 12px 28px rgba(0, 0, 0, .2);
  animation: nameIn .4s cubic-bezier(.3, 1.5, .5, 1) both, breathe 1.6s .4s ease-in-out infinite;
}
.launch-play[hidden] { display: none; }
.launch-play svg { width: 44px; height: 44px; margin-left: 6px; fill: currentColor; }
.launch-play:active { transform: translateY(4px); box-shadow: 0 3px 0 var(--sun-dark); }
.launch.out { animation: launchOut .45s ease-in forwards; pointer-events: none; }
.launch.out .launch-logo { animation: logoOut .45s ease-in forwards; }
@keyframes logoIn { from { transform: scale(.2) rotate(-25deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes nameIn { from { transform: translateY(24px) scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes wave { from { transform: scale(1); opacity: .8; } to { transform: scale(1.9); opacity: 0; } }
@keyframes shout { 50% { transform: scale(1.1) rotate(-4deg); } }
@keyframes launchOut { to { opacity: 0; } }
@keyframes logoOut { to { transform: scale(1.6); opacity: 0; } }

/* ---------- Pictures ---------- */
.pic { display: inline-grid; place-items: center; line-height: 1; }
.pic .art { display: block; width: 1em; height: 1em; object-fit: contain; filter: drop-shadow(0 .03em .05em rgba(0, 0, 0, .18)); }
.pic .art { pointer-events: none; -webkit-user-drag: none; user-select: none; }
.pic .art.photo { width: 1.2em; height: 1em; filter: drop-shadow(0 .03em .06em rgba(0, 0, 0, .3)); }
/* Interface icons (icons.js). Rewards are gold or orange with a chunky edge, like the buttons. */
.ui-icon { display: inline-block; flex: none; width: 1.1em; height: 1.1em; fill: currentColor; vertical-align: -.2em; pointer-events: none; }
.ui-icon.gold { fill: var(--sun); filter: drop-shadow(0 .06em 0 var(--sun-dark)); }
.ui-icon.fire { fill: #ff8a3d; filter: drop-shadow(0 .06em 0 #c4511a); }
.ui-icon .core { fill: var(--sun); }
.ui-icon.ok { fill: var(--good); }
.ui-icon.tint { fill: var(--sky-1); }
.star-row { display: inline-flex; gap: .06em; vertical-align: -.2em; }
.star-row .ui-icon { vertical-align: 0; }
.emoji { font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif; }
.pic .emoji { font-size: 1em; }
.pic .swatch {
  width: .9em; height: .9em; border-radius: 50%;
  box-shadow: inset 0 -.08em 0 rgba(0, 0, 0, .15), 0 .04em .12em rgba(0, 0, 0, .2);
  border: .03em solid rgba(0, 0, 0, .08);
}
.pic .swatch.rainbow { background: conic-gradient(#ef4444, #f97316, #facc15, #22c55e, #3b82f6, #a855f7, #ef4444); }
.pic svg { width: .95em; height: .95em; overflow: visible; filter: drop-shadow(0 .04em .06em rgba(0, 0, 0, .2)); }
.pic .num { display: grid; place-items: center; gap: .04em; }
.pic .num b { font-size: .9em; font-weight: 800; color: #6c5ce7; line-height: 1; }

/* ---------- Home ---------- */
.brand { display: flex; align-items: baseline; gap: 10px; color: #fff; }
.brand .ar { font-size: 34px; font-weight: 800; text-shadow: 0 3px 0 rgba(0, 0, 0, .15); }
.level-chip { margin: 6px 0 12px; }
.topics {
  flex: 1; overflow-y: auto; padding: 4px 2px 24px; perspective: 900px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px;
  align-content: start;
  -webkit-overflow-scrolling: touch;
}
.topic {
  background: var(--card); border-radius: var(--radius);
  padding: 14px 10px 12px; text-align: center;
  box-shadow: 0 6px 0 var(--tc, #ccc), 0 12px 24px rgba(0, 0, 0, .15);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  position: relative; transform-style: preserve-3d;
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform .15s, box-shadow .1s;
  animation: topicIn .6s cubic-bezier(.2, .9, .3, 1.3) backwards;
  animation-delay: calc(var(--i, 0) * 50ms);
}
.topic:active { transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(4px) scale(.97); box-shadow: 0 2px 0 var(--tc, #ccc); }
@keyframes topicIn { from { transform: rotateX(-80deg) translateY(40px); opacity: 0; } }
.topic .pic { font-size: 60px; height: 70px; transform: translateZ(26px); }
.topic .ar { font-size: 24px; font-weight: 800; line-height: 1.3; }
.topic .en { font-size: 14px; color: var(--ink-soft); font-weight: 700; line-height: 1.1; }
.meter { width: 80%; height: 8px; border-radius: 99px; background: #eeeaff; margin-top: 8px; overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 99px; background: var(--tc, var(--good)); }
.topic .done-badge { position: absolute; top: 8px; right: 10px; font-size: 22px; line-height: 1; }

/* Install banner for the grown-up (home screen) */
#install-slot { flex: none; }
.install-banner {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
  background: rgba(255, 255, 255, .94); color: var(--ink); border-radius: 18px;
  padding: 8px 6px 8px 12px; box-shadow: 0 4px 0 rgba(45, 42, 74, .12), 0 8px 18px rgba(0, 0, 0, .12);
  animation: screenIn .35s;
}
.install-banner .ib-pic { flex: none; font-size: 28px; line-height: 1; color: var(--sky-1); }
.install-banner .ib-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.install-banner b { font-size: 15px; font-weight: 800; }
.install-banner small { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.install-banner .btn { flex: none; padding: 8px 14px; font-size: 15px; }
.ib-close { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-soft); }
.ib-close svg { width: 18px; height: 18px; }
.ib-close:active { background: #f1eeff; }
@media (max-width: 340px) { .install-banner .ib-pic { display: none; } }

/* Long-press parent button */
.hold { position: relative; }
.hold::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%;
  background: conic-gradient(var(--sun) calc(var(--p, 0) * 1%), transparent 0);
  -webkit-mask: radial-gradient(circle, transparent 60%, #000 61%);
  mask: radial-gradient(circle, transparent 60%, #000 61%);
  pointer-events: none;
}
.hold-tip {
  position: absolute; top: 56px; right: 0; white-space: nowrap;
  background: #fff; color: var(--ink); font-size: 14px; font-weight: 700;
  padding: 6px 12px; border-radius: 12px; box-shadow: 0 6px 16px rgba(0, 0, 0, .2);
  animation: screenIn .2s; z-index: 5;
}

/* A topic opened from a home screen shortcut, waiting for the first tap */
div.ready { flex: 1; display: flex; align-items: center; justify-content: center; perspective: 900px; }
.ready .topic { width: min(72vw, 280px); padding: 26px 16px 22px; gap: 6px; }
.ready .topic .pic { font-size: 120px; height: 140px; }
.ready .topic .ar { font-size: 36px; }
.ready .topic .en { font-size: 18px; }
.go-play {
  width: 64px; height: 64px; border-radius: 50%; margin-top: 8px;
  background: var(--sun); box-shadow: 0 5px 0 var(--sun-dark);
  display: grid; place-items: center; animation: breathe 1.6s ease-in-out infinite;
}
.go-play::before { content: ''; margin-left: 6px; border-style: solid; border-width: 14px 0 14px 22px; border-color: transparent transparent transparent #fff; }

/* ---------- Play ---------- */
.round-dots { display: flex; gap: 6px; justify-content: center; flex: 1; }
.round-dots i { width: 12px; height: 12px; border-radius: 50%; background: rgba(255, 255, 255, .3); transition: all .3s; }
.round-dots i.now { background: #fff; transform: scale(1.3); }
.round-dots i.won { background: var(--sun); }
.round-dots i.miss { background: rgba(255, 255, 255, .6); }
.jar { position: relative; }
.jar.bump { animation: bump .4s; }
@keyframes bump { 40% { transform: scale(1.35); } }

.stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; min-height: 0; }
/* The stage is a size container, so the picture is sized by the room it
   really has: on a short window it shrinks instead of running into the word. */
@supports (container-type: size) { .stage { container-type: size; } }
.card {
  width: min(78vw, 340px); aspect-ratio: 1 / 1.08;
  background: var(--card); border-radius: 40px;
  box-shadow: 0 10px 0 rgba(0, 0, 0, .12), 0 24px 50px rgba(0, 0, 0, .2);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative; padding: 16px;
  transition: transform .2s, box-shadow .3s;
}
.card .pic-slot { font-size: min(36vw, 160px); height: 1.1em; display: grid; place-items: center; }
.card .label { display: flex; flex-direction: column; align-items: center; }
.card .word { font-size: clamp(34px, 10vw, 48px); font-weight: 800; line-height: 1.25; margin-top: 6px; text-align: center; }
.card .meaning { font-size: 18px; font-weight: 700; color: var(--ink-soft); }
.card .replay {
  position: absolute; top: 12px; left: 12px; width: 48px; height: 48px; border-radius: 50%;
  background: #f1eeff; display: grid; place-items: center; font-size: 24px; color: var(--sky-1);
}
.card.pop { animation: cardPop .5s cubic-bezier(.2, .9, .3, 1.4); }
@keyframes cardPop { from { transform: scale(.3) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }
.card.speaking .pic-slot .pic { animation: wiggle .6s ease-in-out infinite; }
@keyframes wiggle { 25% { transform: rotate(-6deg) scale(1.05); } 75% { transform: rotate(6deg) scale(1.05); } }
.card.win { box-shadow: 0 10px 0 var(--good-dark), 0 0 0 8px var(--good), 0 24px 50px rgba(0, 0, 0, .2); animation: winJump .6s; }
@keyframes winJump { 30% { transform: translateY(-24px) scale(1.06); } 60% { transform: translateY(0) scale(.98); } }
.card.shake { animation: shake .5s; }
@keyframes shake { 20%, 60% { transform: translateX(-12px) rotate(-2deg); } 40%, 80% { transform: translateX(12px) rotate(2deg); } }
.card .stamp {
  display: inline-flex; align-items: center; gap: 4px;
  position: absolute; bottom: -22px; left: 50%; transform: translateX(-50%);
  background: var(--good); color: #fff; font-weight: 800; font-size: 22px;
  padding: 6px 20px; border-radius: 99px; white-space: nowrap;
  box-shadow: 0 4px 0 var(--good-dark); animation: cardPop .4s;
}
.card .stamp.soft { background: var(--try); box-shadow: 0 4px 0 #d9822b; }

.heard { min-height: 22px; color: rgba(255, 255, 255, .85); font-size: 15px; font-weight: 700; text-align: center; }

.mic-row { display: flex; align-items: center; justify-content: center; gap: 18px; padding-bottom: 8px; }
.mic {
  width: 112px; height: 112px; border-radius: 50%;
  background: #fff; display: grid; place-items: center; font-size: 50px; color: var(--sky-1);
  box-shadow: 0 8px 0 #d9d6f0, 0 16px 30px rgba(0, 0, 0, .2);
  position: relative; transition: transform .1s, background .2s;
}
.mic:active { transform: translateY(4px); box-shadow: 0 3px 0 #d9d6f0; }
.mic.ready { animation: breathe 1.4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.08); } }
.mic.listening { background: #ff5e7e; box-shadow: 0 8px 0 #c93a58, 0 0 0 calc(10px + var(--lvl, 0) * 40px) rgba(255, 94, 126, .25); }
.mic.listening::before, .mic.listening::after {
  content: ''; position: absolute; inset: -10px; border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, .7); animation: ripple 1.4s ease-out infinite;
}
.mic.listening::after { animation-delay: .7s; }
@keyframes ripple { from { transform: scale(.9); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
.mic.busy { opacity: .6; }
.mic .glyph { display: grid; }
.mic .bars { display: none; gap: 5px; align-items: center; height: 50px; }
.mic.listening .bars { display: flex; }
.mic.listening .glyph { display: none; }
.mic .bars i { width: 8px; border-radius: 4px; background: #fff; height: 30%; transition: height .08s; }
.mic.heard-sound .bars i { animation: eq .5s ease-in-out infinite; }
.mic.heard-sound .bars i:nth-child(2) { animation-delay: .1s; }
.mic.heard-sound .bars i:nth-child(3) { animation-delay: .2s; }
.mic.heard-sound .bars i:nth-child(4) { animation-delay: .3s; }
@keyframes eq { 50% { height: 95%; } }
.side-btn { width: 64px; height: 64px; font-size: 28px; }
.hint { color: #fff; font-weight: 800; font-size: 20px; text-align: center; min-height: 30px; text-shadow: 0 2px 0 rgba(0, 0, 0, .12); }

.combo {
  display: flex; align-items: center; gap: 10px;
  position: fixed; top: 22%; left: 50%; transform: translateX(-50%);
  font-size: 44px; font-weight: 800; color: var(--sun);
  text-shadow: 0 4px 0 #b3551b, 0 0 30px rgba(255, 210, 63, .8);
  animation: comboIn 1.2s forwards; z-index: 40; pointer-events: none; white-space: nowrap;
}
@keyframes comboIn {
  0% { transform: translateX(-50%) scale(.2); opacity: 0; }
  25% { transform: translateX(-50%) scale(1.25); opacity: 1; }
  70% { transform: translateX(-50%) scale(1); opacity: 1; }
  100% { transform: translateX(-50%) translateY(-40px); opacity: 0; }
}
.flyer { position: fixed; z-index: 45; font-size: 44px; pointer-events: none; }
.flyer .ui-icon { display: block; width: 1em; height: 1em; }

/* ---------- End of round ---------- */
.end { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; color: #fff; text-align: center; }
.end h1 { margin: 0; font-size: 40px; line-height: 1.1; text-shadow: 0 4px 0 rgba(0, 0, 0, .15); }
.end .big-stars { font-size: 64px; font-weight: 800; display: flex; align-items: center; gap: 12px; line-height: 1; }
.end .big-stars .ui-icon { vertical-align: 0; }
.gift {
  font-size: 120px; line-height: 1; animation: giftWobble 1.2s ease-in-out infinite;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, .25));
}
@keyframes giftWobble { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-10deg) scale(1.05); } 40% { transform: rotate(10deg) scale(1.05); } 60% { transform: rotate(0); } }
.gift.open { animation: giftOpen .6s forwards; }
@keyframes giftOpen { to { transform: scale(1.8); opacity: 0; } }
.treasure-reveal { font-size: 130px; line-height: 1; display: grid; place-items: center; width: 1.2em; height: 1.2em; animation: reveal .8s cubic-bezier(.2, .9, .3, 1.5); filter: drop-shadow(0 0 30px rgba(255, 230, 120, .9)); }
@keyframes reveal { from { transform: scale(0) rotate(-180deg); } to { transform: none; } }
.end-actions { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.end .sub { font-size: 20px; font-weight: 700; opacity: .9; }
.streak-note { background: rgba(255, 255, 255, .2); border-radius: 18px; padding: 8px 16px; font-weight: 800; font-size: 18px; }

/* ---------- Collection ---------- */
.sheet {
  flex: 1; overflow-y: auto; background: #fff; border-radius: 32px 32px 0 0;
  margin: 0 -16px calc(-1 * max(16px, env(safe-area-inset-bottom)));
  padding: 20px 16px 40px; -webkit-overflow-scrolling: touch;
}
.sheet h2 { margin: 6px 0 10px; font-size: 22px; display: flex; align-items: center; gap: 8px; }
.sheet h2 .ar { font-size: 22px; }
.sheet h2 small { color: var(--ink-soft); font-size: 15px; margin-left: auto; }
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; margin-bottom: 18px; }
.sticker { background: #f5f3ff; border-radius: 18px; aspect-ratio: 1; display: grid; place-items: center; position: relative; }
.sticker .pic { font-size: 36px; }
.sticker.locked .pic { filter: grayscale(1) brightness(1.2); opacity: .3; }
.sticker .s { position: absolute; bottom: 3px; display: flex; font-size: 11px; }
.sticker.treasure { font-size: 38px; background: #fff7d6; }
.empty-note { color: var(--ink-soft); font-weight: 700; }

/* ---------- Parent settings ----------
   Like a phone's own Settings app: white groups of rows on a soft grey,
   a small heading above each group and a note under it. */
.sheet.settings { background: #f2f1f8; padding-top: 4px; }
.settings section { margin: 0; }
.settings p.note { margin: 6px 0 0; color: var(--ink-soft); font-size: 14px; line-height: 1.35; font-weight: 500; }
.group-h { margin: 24px 16px 7px; font-size: 15px; font-weight: 800; color: var(--ink-soft); }
.group { background: #fff; border-radius: 18px; overflow: hidden; box-shadow: 0 1px 2px rgba(45, 42, 74, .06); }
.group-f { margin: 7px 16px 0; font-size: 13.5px; line-height: 1.4; color: var(--ink-soft); font-weight: 500; }
.group-f.credits { margin-top: 28px; text-align: center; }
.group-f a { color: var(--sky-1); font-weight: 700; text-decoration: none; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 10px 16px;
  position: relative; text-align: left; font-size: 16px; font-weight: 700; line-height: 1.3; color: var(--ink);
  transition: background .15s;
}
.row + .row::before { content: ''; position: absolute; top: 0; left: 16px; right: 0; border-top: 1px solid #ebe9f3; }
button.row:active, .row.pick:active { background: #efedf7; }
.row-label { flex: 1; min-width: 0; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row small { font-size: 14px; font-weight: 500; color: var(--ink-soft); }
.row-value { color: var(--ink-soft); font-weight: 600; text-align: right; }
.row.text { font-weight: 500; font-size: 15px; color: var(--ink-soft); }
/* A picker row: the phone's own list opens from an invisible <select> over it */
.row.pick { cursor: pointer; }
.row.pick .row-chev { width: 15px; height: 15px; fill: #b3b0c8; margin-left: -6px; }
.row.pick select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; font-size: 16px; cursor: pointer; appearance: none; -webkit-appearance: none; border: 0; }
.row.pick:has(select:disabled) { opacity: .5; }
.row.action { color: var(--sky-1); }
.row.action .ui-icon { width: 22px; height: 22px; }
.row.action.danger { color: #e0413a; }
.row.action:disabled { opacity: .5; }
/* The level list: a tick moves to the chosen row */
.row.radio .row-tick { width: 20px; height: 20px; fill: var(--sky-1); opacity: 0; transform: scale(.4); transition: opacity .15s, transform .25s cubic-bezier(.3, 1.6, .5, 1); }
.row.radio.on .row-tick { opacity: 1; transform: none; }
/* Segmented control with a white thumb that slides to the choice */
.seg { position: relative; display: grid; grid-template-columns: repeat(var(--n), 1fr); background: #e5e3ef; border-radius: 13px; padding: 3px; }
.seg-thumb {
  position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc((100% - 6px) / var(--n)); border-radius: 10px; background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 3px 1px rgba(0, 0, 0, .04); transform: translateX(calc(100% * var(--i)));
  transition: transform .32s cubic-bezier(.3, .7, .2, 1);
}
.seg button { position: relative; z-index: 1; padding: 9px 0; font-size: 17px; font-weight: 700; color: var(--ink-soft); transition: color .2s; }
.seg button.on { color: var(--ink); font-weight: 800; }
/* Filter chips: a tick and full colour when shown, grey outline when hidden */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips .chip {
  display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 13px 0 11px; border-radius: 11px;
  font-weight: 700; font-size: 15px; background: #fff; color: var(--ink-soft); box-shadow: inset 0 0 0 1.5px #d9d6e8;
  transition: background .2s, color .2s, box-shadow .2s;
}
.chips .chip .pic { font-size: 18px; filter: grayscale(1); opacity: .5; transition: filter .2s, opacity .2s; }
.chips .chip .chip-tick { width: 0; height: 15px; margin-right: -6px; fill: var(--sky-1); opacity: 0; transition: width .2s, margin .2s, opacity .2s; }
.chips .chip.on { background: #e9e5ff; color: var(--ink); box-shadow: none; }
.chips .chip.on .pic { filter: none; opacity: 1; }
.chips .chip.on .chip-tick { width: 15px; margin-right: 0; opacity: 1; }
.chips .chip:active { transform: scale(.96); }
.chips .chip.nope { animation: nope .35s; }
@keyframes nope { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
/* Switches with a phone's proportions; the knob stretches while pressed */
.switch { width: 51px; height: 31px; border-radius: 99px; background: #e2e0ec; position: relative; flex: none; transition: background .25s; }
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 99px; background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .15), 0 1px 1px rgba(0, 0, 0, .16); transition: transform .25s cubic-bezier(.3, .7, .3, 1.15), width .2s;
}
.switch.on { background: var(--good); }
.switch.on::after { transform: translateX(20px); }
.switch:active::after { width: 33px; }
.switch.on:active::after { transform: translateX(14px); }
.switch:disabled { opacity: .5; }
/* Action sheet: slides up from the bottom for choices that can't be undone */
.as-wrap {
  position: fixed; inset: 0; z-index: 70; display: flex; align-items: flex-end; justify-content: center;
  padding: 0 10px calc(10px + env(safe-area-inset-bottom)); background: rgba(25, 18, 60, .45); animation: asFade .2s;
}
.action-sheet { width: 100%; max-width: 440px; display: grid; gap: 8px; animation: asUp .34s cubic-bezier(.2, .9, .3, 1); }
.as-group { background: #fff; border-radius: 16px; overflow: hidden; }
.as-head { padding: 14px 18px 12px; text-align: center; display: grid; gap: 3px; color: var(--ink-soft); }
.as-head b { font-size: 15px; }
.as-head small { font-size: 14px; font-weight: 500; line-height: 1.35; }
.as-btn { display: block; width: 100%; min-height: 56px; font-size: 19px; font-weight: 700; color: var(--sky-1); background: #fff; }
.as-group .as-btn { border-top: 1px solid #e7e5f0; }
.as-btn.danger { color: #e0413a; }
.as-btn.cancel { border-radius: 16px; font-weight: 800; }
.as-btn:active { background: #ecebf2; }
.as-wrap.out { animation: asFade .25s reverse forwards; }
.as-wrap.out .action-sheet { animation: asDown .25s ease-in forwards; }
@keyframes asFade { from { opacity: 0; } }
@keyframes asUp { from { transform: translateY(110%); } }
@keyframes asDown { to { transform: translateY(110%); } }
.field { width: 100%; font: inherit; font-size: 16px; padding: 12px 14px; border-radius: 14px; border: 2px solid #dcd7f5; background: #fbfaff; margin-top: 6px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.btn { background: var(--sky-1); color: #fff; font-weight: 800; padding: 10px 16px; border-radius: 14px; font-size: 16px; }
.btn .ui-icon { margin-right: 2px; }
.btn.ghost { background: #f1eeff; color: var(--ink); }
.btn.danger { background: #ffe3e3; color: #c0392b; }
.btn:disabled { opacity: .5; }
.progress-line { height: 10px; border-radius: 99px; background: #eeeaff; overflow: hidden; margin-top: 10px; }
.progress-line i { display: block; height: 100%; background: var(--good); transition: width .2s; }
.banner { display: flex; gap: 10px; align-items: flex-start; background: #fff4e0; color: #8a4b00; border-radius: 16px; padding: 12px 14px; font-weight: 700; font-size: 15px; margin: 12px 0 0; line-height: 1.35; }
.banner > .ui-icon { width: 20px; height: 20px; margin-top: 1px; }
.title-white { color: #fff; font-weight: 800; font-size: 24px; }

/* Moving progress: the code to type on the other phone */
.move-code { margin: 6px 0 4px; padding: 14px 10px; border-radius: 18px; background: #f1eeff; color: var(--sky-1); text-align: center; font-size: 46px; font-weight: 800; letter-spacing: .12em; line-height: 1.1; user-select: all; -webkit-user-select: all; }
.move-code.gone { opacity: .35; text-decoration: line-through; }
.move-input { font-size: 30px; font-weight: 800; text-align: center; letter-spacing: .12em; text-transform: uppercase; user-select: text; -webkit-user-select: text; }
.move-input::placeholder { color: #c9c3ea; }
.move-err { color: #c0392b !important; margin-top: 8px !important; }
/* The sticker picture, before it's shared */
.share-pic { display: block; width: 100%; border-radius: 16px; margin: 8px 0 2px; box-shadow: 0 6px 18px rgba(30, 20, 90, .18); }
a.btn { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }

/* iPhone install guide: Safari's own steps, with an arrow toward the first button */
.guide {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  padding: 20px 20px calc(70px + env(safe-area-inset-bottom)); background: rgba(30, 22, 80, .6); animation: screenIn .2s;
}
.guide-card {
  width: 100%; max-width: 380px; max-height: 100%; overflow-y: auto; background: #fff; color: var(--ink);
  border-radius: 24px; padding: 20px; box-shadow: 0 20px 50px rgba(0, 0, 0, .3);
}
.guide-card h3 { margin: 0 0 6px; font-size: 21px; }
.guide-card .note { margin: 0 0 10px; color: var(--ink-soft); font-size: 15px; line-height: 1.35; font-weight: 500; }
.guide-steps { list-style: none; margin: 12px 0 4px; padding: 0; display: grid; gap: 14px; counter-reset: step; }
.guide-steps li { display: flex; align-items: center; gap: 14px; font-size: 16px; font-weight: 500; line-height: 1.3; counter-increment: step; }
.guide-steps .gi { flex: none; position: relative; width: 46px; height: 46px; border-radius: 13px; background: #f2f2f7; color: #0a84ff; display: grid; place-items: center; }
.guide-steps .gi svg { width: 26px; height: 26px; }
.guide-steps .gi::before {
  content: counter(step); position: absolute; top: -6px; left: -6px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--sky-1); color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center;
}
.guide-link { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 8px 8px 8px 12px; border-radius: 14px; background: #f2f2f7; }
.guide-link span { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 14px; font-weight: 600; user-select: all; -webkit-user-select: all; }
.guide-link .btn { flex: none; }
.guide-arrow { position: fixed; width: 40px; height: 56px; color: var(--sun); filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .35)); animation: guidePoint 1s ease-in-out infinite; }
.guide-arrow svg { width: 100%; height: 100%; display: block; }
.guide-arrow.bottom { bottom: calc(6px + env(safe-area-inset-bottom)); left: calc(50% - 20px); }
.guide-arrow.bottom-right { bottom: calc(6px + env(safe-area-inset-bottom)); right: 12px; }
.guide-arrow.top { top: calc(6px + env(safe-area-inset-top)); right: 24px; }
.guide-arrow.top svg { transform: rotate(180deg); }
@keyframes guidePoint { 50% { transform: translateY(8px); } }
.guide-arrow.top { animation-name: guidePointUp; }
@keyframes guidePointUp { 50% { transform: translateY(-8px); } }

/* ---------- 3D (three.js draws the pictures behind the page) ---------- */
.has-3d .pic-slot .pic, .has-3d .gift .pic { visibility: hidden; }
.has-3d .pic-slot { touch-action: none; cursor: grab; }
.has-3d .card { background: none; box-shadow: none; aspect-ratio: auto; padding: 8px 0 0; }
.has-3d .card.pop, .has-3d .card.win, .has-3d .card.shake { animation: none; }
.has-3d .card .pic-slot { font-size: min(46vw, 210px); height: 1.12em; width: 100%; }
@container (min-height: 1px) { .has-3d .card .pic-slot { font-size: min(50cqw, 210px, 40cqh); } }
.has-3d .card .label {
  background: #fff; border-radius: 26px; padding: 6px 26px 10px; margin-top: 14px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, .12), 0 16px 30px rgba(0, 0, 0, .18);
  transition: box-shadow .3s;
}
/* Room above the word for stacked marks (shadda with a damma), so they never poke out of the white box */
.has-3d .card .word { line-height: 1.5; margin-top: 0; }
.has-3d .card.pop .label { animation: cardPop .5s cubic-bezier(.2, .9, .3, 1.4) .15s backwards; }
.has-3d .card.win .label { box-shadow: 0 6px 0 var(--good-dark), 0 0 0 6px var(--good); }
.has-3d .card .replay { background: rgba(255, 255, 255, .92); box-shadow: 0 4px 12px rgba(0, 0, 0, .15); }
.has-3d .card .stamp { bottom: -26px; }
.has-3d .gift { font-size: 150px; animation: none; filter: none; }
.has-3d .gift.open { animation: none; }
.has-3d .treasure-reveal { font-size: 150px; animation: none; filter: none; }

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