/* Kids Rainbow Universe storybook look, shared by the games (after assets/common.css).
   Start screen of floating world islands on the rainbow sky, round glass buttons, the cloud curtain between screens,
   the grown-ups sheet, hints and sparkles. Game screens add their own styles on top. */
[hidden] { display: none !important; }
body { background: #e6dcff; }

/* ---------- the sky ---------- */
.scene {
  position: fixed;
  inset: -2%;
  background: #e6dcff url(art/ui/start-bg.webp) center 35% / cover no-repeat;
  animation: drift 30s ease-in-out infinite alternate;
}
@media (orientation: landscape) { .scene { background-image: url(art/ui/start-bg-wide.webp); background-position: center; } }
/* during play the sky calms down so the game is the brightest thing on screen */
.scene::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 75% 60% at 50% 45%, rgba(255, 255, 255, .5), rgba(255, 255, 255, .15) 70%);
  opacity: 0;
  transition: opacity .4s;
}
body.in-game .scene::after { opacity: 1; }
@keyframes drift { from { transform: scale(1); } to { transform: scale(1.05) translateY(-1%); } }
.motes { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.mote {
  position: absolute;
  bottom: -40px;
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0 30%, rgba(255, 255, 255, 0) 70%);
  animation: rise var(--t) linear infinite;
  animation-delay: var(--d);
}
@keyframes rise {
  0% { translate: 0 0; opacity: 0; }
  12% { opacity: .95; }
  85% { opacity: .95; }
  100% { translate: var(--x) -115vh; opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .scene, .tile, .isle { animation: none !important; } .motes { display: none; } }

/* ---------- round glass buttons (home, undo, grown-ups...) ---------- */
.round-btn {
  position: relative;
  width: var(--b, clamp(52px, 7vmin, 68px));
  height: var(--b, clamp(52px, 7vmin, 68px));
  border-radius: 50%;
  background: rgba(255, 255, 255, .62);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 3px solid rgba(255, 255, 255, .95);
  box-shadow: 0 5px 0 rgba(124, 111, 208, .16), 0 10px 22px rgba(124, 111, 208, .18);
  display: grid;
  place-items: center;
  color: #8663c3;
  flex: none;
  transition: transform .15s, opacity .25s, background .2s;
}
.round-btn img { width: 72%; filter: drop-shadow(0 2px 2px rgba(59, 35, 82, .25)); pointer-events: none; }
.round-btn svg { width: 50%; height: 50%; pointer-events: none; }
.round-btn:active { transform: scale(.9); }
.round-btn.off { opacity: .4; }
.round-btn.armed { background: #ff7aa8; color: #fff; border-color: #fff; animation: kg-shake .45s; }
.corner { position: fixed; top: calc(var(--safe-t) + 10px); z-index: 20; }
.corner.left { left: calc(var(--safe-l) + 10px); }
.corner.right { right: calc(var(--safe-r) + 10px); }
/* hold-to-open: a ring fills while held (Shell.holdable sets --hold and --hold-on) */
.hold::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: conic-gradient(#8663c3 calc(var(--hold, 0) * 360deg), transparent 0);
  -webkit-mask: radial-gradient(circle, transparent 62%, #000 64%);
  mask: radial-gradient(circle, transparent 62%, #000 64%);
  opacity: var(--hold-on, 0);
  pointer-events: none;
}

/* ---------- start screen: logo and world islands ---------- */
.start {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(var(--safe-t) + 8px) calc(var(--safe-r) + 12px) calc(var(--safe-b) + 12px) calc(var(--safe-l) + 12px);
}
.logo {
  margin: 0;
  line-height: 0;
  animation: logo-in .9s cubic-bezier(.3, 1.6, .5, 1) both, bob 4s ease-in-out 1s infinite;
}
.logo svg { display: block; overflow: visible; }
/* the logo keeps clear of the round corner buttons (about 76 px each side) */
.logo .logo-wide { height: clamp(96px, 16vh, 200px); width: auto; max-width: min(94vw, calc(100vw - 2 * (var(--safe-r) + 78px))); }
.logo .logo-tall { display: none; }
@media (orientation: landscape) { .logo .logo-wide { height: clamp(60px, 17vh, 170px); } }
@media (orientation: portrait) and (min-height: 1000px) {
  .logo .logo-wide { display: none; }
  .logo .logo-tall { display: block; height: clamp(220px, 24vh, 330px); width: auto; }
}
@keyframes logo-in { from { transform: scale(.3) translateY(-40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes bob { 0%, 100% { translate: 0 0; rotate: -1deg; } 50% { translate: 0 -6px; rotate: 1deg; } }
.tiles {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: grid;
  place-content: center;
  gap: var(--gap);
  grid-template-columns: repeat(var(--cols), var(--tw));
}
/* each world is a floating island with its name on the sky: no cards, no pills */
.tile {
  position: relative;
  width: var(--tw);
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: tile-in .7s cubic-bezier(.3, 1.5, .5, 1) both;
  animation-delay: var(--d);
  transition: scale .35s cubic-bezier(.3, 1.6, .5, 1), filter .3s;
}
.tile .isle {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / .95;
  animation: float 5.5s ease-in-out infinite;
  animation-delay: calc(var(--d) * -6);
}
.tile .isle img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: 50% 100%;
  filter: drop-shadow(0 14px 12px rgba(90, 70, 170, .28));
}
.tile .isle::after {
  content: "";
  position: absolute;
  left: 20%;
  right: 20%;
  bottom: -8%;
  height: 12%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 255, 255, .9), rgba(255, 255, 255, 0));
  z-index: -1;
}
.tile:active { scale: .94; }
.tile.picked { scale: 1.1; filter: brightness(1.08); }
/* names on the sky: Nunito 900 in the world colour with the logo's thick white outline */
.tile .name, .sky-title {
  color: var(--c);
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  -webkit-text-stroke: .3em #fff;
  paint-order: stroke fill;
  filter: drop-shadow(0 3px 4px rgba(124, 111, 208, .35));
}
.tile .name {
  margin-top: .2em;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: clamp(18px, calc(var(--tw) * .15), 36px);
}
/* The whole cloud bank (about 4.6 : 1) is drawn with its fluffy top showing and the rest running off the bottom of the
   screen. (A box shorter than the picture would crop the fluffy top into a hard straight edge when sideways.) */
.clouds {
  --cloud-h: calc(112vw * 543 / 2492);   /* the cloud bank picture's shape (the retina export is 2492 x 543) */
  position: fixed;
  left: -6%;
  right: -6%;
  top: calc(100% - min(clamp(90px, 20vh, 240px), var(--cloud-h)));
  height: var(--cloud-h);
  background: url(art/ui/cloud-bank.webp) center top / 100% auto no-repeat;
  pointer-events: none;
  z-index: 0;
  animation: clouds-drift 14s ease-in-out infinite alternate;
}
@keyframes clouds-drift { from { translate: -1.5% 0; } to { translate: 1.5% 0; } }
.start > :not(.clouds):not(.corner) { position: relative; z-index: 1; }
.start.again .logo { animation: bob 4s ease-in-out infinite; }
.start.again .tile { animation: tile-back .45s ease-out backwards; animation-delay: calc(var(--d) * .5); }
@keyframes tile-back { from { opacity: 0; scale: .92; } to { opacity: 1; scale: 1; } }
@keyframes tile-in { from { transform: translateY(80px) scale(.4) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes float { 0%, 100% { translate: 0 0; rotate: -1.5deg; } 50% { translate: 0 -9px; rotate: 1.5deg; } }

/* ---------- the cloud curtain between screens (Shell.go): calm, about 2.5 s, never a fast wipe ----------
   Clouds drift together, the destination floats in the middle, the clouds part. */
.curtain {
  --close: 1s;
  --open: 1.1s;
  position: fixed;
  inset: 0;
  z-index: 90;
  overflow: hidden;
  pointer-events: none;
  visibility: hidden;
}
.curtain.on { visibility: visible; pointer-events: all; }
.curtain .sky {
  position: absolute;
  inset: 0;
  background: #f4f0ff;   /* before iOS 16.2 the color-mix() gradient below is skipped: the sky is then plain */
  background: radial-gradient(ellipse 70% 60% at 50% 50%, #fffdff, color-mix(in srgb, var(--c, #b58cff) 14%, #f1eeff) 70%, color-mix(in srgb, var(--c, #b58cff) 22%, #e4e0fb));
  opacity: 0;
  transition: opacity var(--open) ease;
}
.curtain .cl {
  position: absolute;
  left: 50%;
  height: 68vh;
  width: auto;
  max-width: none;
  translate: -50% 0;
  /* brighter and a touch softer than on the start screen, so a full screen of cloud feels airy, not grey */
  filter: brightness(1.12) saturate(.85);
  transition: transform var(--open) cubic-bezier(.45, 0, .2, 1);
}
.curtain .cl.low { bottom: -4vh; transform: translateY(110%); }
.curtain .cl.high { top: -4vh; transform: translateY(-110%) scale(-1, -1); }
/* rear layers: taller and shifted sideways, anchored at the screen edge like the front ones so their flat,
   cut-off side is always off-screen; only puffy edges ever show */
.curtain .cl.low.back { height: 82vh; bottom: -4vh; opacity: .8; margin-left: 18vw; }
.curtain .cl.high.back { height: 82vh; top: -4vh; opacity: .8; margin-left: -18vw; }
.curtain .pic {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(50vmin, 340px);
  translate: -50% -50%;
  opacity: 0;
  scale: .7;
  transition: opacity .5s ease, scale .8s cubic-bezier(.3, 1.4, .5, 1);
}
.curtain .pic > * { width: 100%; height: auto; display: block; overflow: visible; filter: drop-shadow(0 14px 16px rgba(90, 70, 170, .3)); animation: float 3s ease-in-out infinite; }
.curtain.closed .sky { opacity: 1; transition-duration: var(--close); }
.curtain.closed .cl.low { transform: translateY(0); transition-duration: var(--close); }
.curtain.closed .cl.high { transform: translateY(0) scale(-1, -1); transition-duration: var(--close); }
.curtain.closed .cl.back { transition-delay: .08s; }
.curtain.closed .pic { opacity: 1; scale: 1; transition-delay: calc(var(--close) * .55); }
/* opening: the picture floats up and away as the clouds part */
.curtain.opening .pic { opacity: 0; scale: 1.08; translate: -50% -70%; transition: opacity .45s ease, scale .6s ease, translate .6s ease; }
@media (prefers-reduced-motion: reduce) {
  .curtain { --close: .3s; --open: .3s; }
  .curtain .cl { display: none; }
}

/* ---------- effects ---------- */
.spark { position: fixed; width: 24px; height: 24px; margin: -12px 0 0 -12px; pointer-events: none; z-index: 60; }
.spark svg { width: 100%; height: 100%; display: block; }
.hint {
  position: fixed;
  z-index: 40;
  translate: -50% 0;
  padding: 8px 16px;
  border-radius: 999px;
  background: #fff;
  color: #8663c3;
  font-weight: 800;
  font-size: 15px;
  white-space: nowrap;
  box-shadow: 0 5px 0 rgba(124, 111, 208, .18), 0 10px 22px rgba(124, 111, 208, .2);
  pointer-events: none;
  animation: hint 2.4s ease forwards;
}
@keyframes hint { 0% { opacity: 0; scale: .8; } 10%, 85% { opacity: 1; scale: 1; } 100% { opacity: 0; } }

/* ---------- grown-ups sheet (the one place with small text for adults) ---------- */
.sheet-veil {
  position: fixed;
  inset: 0;
  z-index: 85;
  display: grid;
  place-items: center;
  padding: calc(var(--safe-t) + 16px) calc(var(--safe-r) + 16px) calc(var(--safe-b) + 16px) calc(var(--safe-l) + 16px);
  background: rgba(106, 75, 171, .28);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: veil .25s ease;
}
@keyframes veil { from { opacity: 0; } }
.sheet {
  position: relative;
  width: min(560px, 100%);
  max-height: 100%;
  overflow-y: auto;
  touch-action: pan-y;
  padding: 26px clamp(18px, 4vw, 30px) 24px;
  border-radius: 32px;
  background: linear-gradient(#fbfaff, #f1eeff);
  border: 4px solid #fff;
  box-shadow: 0 10px 0 rgba(124, 111, 208, .18), 0 30px 60px rgba(60, 40, 120, .3);
  color: #4a3a78;
  animation: sheet .4s cubic-bezier(.3, 1.5, .5, 1);
}
@keyframes sheet { from { opacity: 0; translate: 0 30px; scale: .95; } }
.sheet h2 { margin: 0 0 4px; font-size: 28px; font-weight: 900; color: #8663c3; }
.sheet .lead { margin: 0 0 12px; color: #6a5e96; font-weight: 600; font-size: 15px; }
.sheet .close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fff;
  color: #8663c3;
  font-size: 22px;
  font-weight: 900;
  box-shadow: 0 3px 0 rgba(124, 111, 208, .2);
}
.opt { display: flex; align-items: center; gap: 14px; padding: 12px 0; font-weight: 700; }
.opt + .opt { border-top: 2px dashed rgba(134, 99, 195, .15); }
.opt .txt { flex: 1; }
.opt .txt b { display: block; font-weight: 900; color: #6a4bab; font-size: 17px; }
.opt .txt span { font-size: 14px; color: #6a5e96; font-weight: 600; }
.switch { position: relative; width: 62px; height: 36px; border-radius: 999px; background: #d9d3ef; flex: none; transition: background .2s; }
.switch::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(60, 40, 120, .25);
  transition: translate .25s cubic-bezier(.3, 1.5, .5, 1);
}
.switch[aria-checked="true"] { background: #8663c3; }
.switch[aria-checked="true"]::after { translate: 26px 0; }
.sheet .pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  margin-top: 8px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 16px;
  color: #8663c3;
  background: #fff;
  box-shadow: 0 4px 0 rgba(124, 111, 208, .22);
}
.sheet .pill.done { background: #63bd89; color: #fff; box-shadow: 0 4px 0 #45996a; }
.sheet .note { margin: 14px 0 0; font-size: 13px; color: #6a5e96; font-weight: 600; }
.gate { margin-top: 10px; padding: 12px 14px; border-radius: 20px; background: #fff; box-shadow: 0 4px 0 rgba(124, 111, 208, .18); }
.gate p { margin: 0 0 10px; font-weight: 700; }
.gate .digits { display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px; }
.gate .digits button { aspect-ratio: 1; border-radius: 12px; background: #f1eeff; color: #6a4bab; font-weight: 900; font-size: 18px; }
