:root {
  --ink: #282243;
  --muted: #756e8e;
  --paper: #fbf9ff;
  --cream: #fff9e9;
  --purple: #6d5ce8;
  --purple-dark: #5040c4;
  --purple-soft: #e8e3ff;
  --coral: #ff806f;
  --aqua: #50d5c2;
  --sun: #ffd259;
  --lilac: #9c83ef;
  --berry: #d766a8;
  --mint: #77d896;
  --shadow: 0 18px 45px rgba(65, 48, 130, 0.16);
  --soft-shadow: 0 8px 22px rgba(65, 48, 130, 0.12);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Avenir Next", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: #332b65;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 50% -10%, #766be1 0, #332b65 56%, #272150 100%);
}

button { font: inherit; }
button, [role="button"] { touch-action: manipulation; }
button:focus-visible { outline: 4px solid rgba(255, 210, 89, 0.88); outline-offset: 3px; }

#app {
  width: min(100%, 500px);
  min-height: 100dvh;
  margin-inline: auto;
  background: var(--paper);
  box-shadow: 0 0 80px rgba(14, 9, 43, 0.4);
}

.screen {
  position: relative;
  min-height: 100dvh;
  padding: max(14px, env(safe-area-inset-top)) 20px max(18px, env(safe-area-inset-bottom));
  overflow: hidden;
}

.boot-screen {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  color: var(--muted);
  background: linear-gradient(160deg, #fbf9ff, #ede8ff);
}

.boot-screen .brand-mark { animation: breathe 1.2s ease-in-out infinite alternate; }

.top-actions {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
}

.top-title {
  min-width: 0;
  flex: 1;
  text-align: center;
  font-size: 0.86rem;
  font-weight: 850;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-transform: uppercase;
}

.icon-spacer { width: 42px; }

.icon-button {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 15px;
  color: var(--ink);
  background: rgba(255,255,255,0.72);
  box-shadow: 0 5px 14px rgba(55, 44, 108, 0.08);
  cursor: pointer;
}

.ui-icon {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-mark {
  position: relative;
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  border-radius: 22px;
  background: linear-gradient(145deg, #8b7bf7, #5c4bd4);
  box-shadow: 0 10px 24px rgba(85, 68, 200, 0.28), inset 0 1px rgba(255,255,255,0.35);
  transform: rotate(-4deg);
}

.brand-mark::before {
  content: "";
  position: absolute;
  inset: 13px;
  border-radius: 13px 13px 17px 13px;
  background: #fff9e9;
}

.brand-mark span {
  position: absolute;
  z-index: 1;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  top: 25px;
}
.brand-mark span:nth-child(1) { left: 12px; background: var(--coral); }
.brand-mark span:nth-child(2) { left: 26px; background: var(--aqua); }
.brand-mark span:nth-child(3) { left: 40px; background: var(--sun); }

.primary-button,
.secondary-button,
.text-button {
  border: 0;
  cursor: pointer;
}

.primary-button {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 13px 22px;
  border-radius: 20px;
  color: white;
  background: linear-gradient(145deg, #7968ef, #5a49ce);
  box-shadow: 0 12px 25px rgba(83, 64, 196, 0.3), inset 0 2px rgba(255,255,255,0.2);
  font-size: 1.05rem;
  font-weight: 900;
}

.primary-button:active { transform: translateY(2px); box-shadow: 0 7px 15px rgba(83, 64, 196, 0.25); }
.primary-button b { font-size: 1.5rem; font-weight: 500; line-height: 1; }

.secondary-button {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: 18px;
  color: var(--purple-dark);
  background: #ece8ff;
  font-weight: 850;
}

.text-button {
  color: var(--muted);
  background: transparent;
  padding: 12px 18px;
  font-weight: 800;
}

.eyebrow {
  display: block;
  margin-bottom: 7px;
  color: var(--purple);
  font-size: 0.78rem;
  font-weight: 950;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Home */
.home-screen {
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 15% 15%, rgba(255,255,255,0.9) 0 4%, transparent 4.3%),
    radial-gradient(circle at 92% 27%, rgba(255,255,255,0.65) 0 5%, transparent 5.3%),
    linear-gradient(165deg, #fdfbff 0%, #eee9ff 56%, #e6e0ff 100%);
}

.home-copy { padding: 14px 5px 5px; }
.logo-row { display: flex; align-items: center; justify-content: center; gap: 15px; }
.home-copy h1 { margin: 0; font-size: clamp(2.35rem, 12vw, 3.35rem); line-height: 1; letter-spacing: -0.06em; }
.home-copy p { margin: 10px 0 0; text-align: center; color: var(--muted); font-weight: 750; }

.island-card {
  position: relative;
  min-height: 288px;
  flex: 1 1 310px;
  max-height: 380px;
  margin: 8px -10px 0;
  overflow: hidden;
}

.sky-orb { position: absolute; border-radius: 50%; filter: blur(0.2px); }
.orb-one { width: 56px; height: 56px; left: 20px; top: 40px; background: rgba(255, 210, 89, 0.4); }
.orb-two { width: 34px; height: 34px; right: 28px; top: 78px; background: rgba(80, 213, 194, 0.34); }
.floating-star { position: absolute; color: white; text-shadow: 0 5px 12px rgba(88,70,190,.25); animation: float 2.6s ease-in-out infinite alternate; }
.star-a { top: 36px; right: 74px; font-size: 1.3rem; }
.star-b { top: 114px; left: 40px; font-size: 0.85rem; animation-delay: -1.1s; }
.extra-treasures {
  position: absolute;
  z-index: 9;
  right: 18px;
  bottom: 13px;
  padding: 7px 10px;
  border: 1px solid rgba(109,92,232,.12);
  border-radius: 999px;
  color: #6552c7;
  background: rgba(255,255,255,.84);
  box-shadow: 0 7px 17px rgba(78,59,150,.12);
  font-size: .68rem;
  font-weight: 850;
}

.island {
  position: absolute;
  left: 50%;
  top: 52%;
  width: 310px;
  height: 205px;
  transform: translate(-50%, -50%);
  animation: islandFloat 3s ease-in-out infinite alternate;
}

.island-top {
  position: absolute;
  z-index: 2;
  left: 12px;
  top: 40px;
  width: 286px;
  height: 104px;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 20%, #b8f1c8 0, #7edfa1 54%, #5fc684 100%);
  box-shadow: inset 0 8px rgba(255,255,255,.25), 0 18px 24px rgba(83,65,166,.15);
}

.island-base {
  position: absolute;
  z-index: 1;
  left: 41px;
  top: 91px;
  width: 228px;
  height: 107px;
  clip-path: polygon(0 0, 100% 0, 78% 78%, 58% 100%, 33% 87%, 12% 58%);
  border-radius: 0 0 45% 45%;
  background: linear-gradient(160deg, #b99076, #8065b0 68%, #65509c);
}

.island-friend {
  position: absolute;
  z-index: 5;
  left: 119px;
  top: 52px;
  width: 72px;
  height: 72px;
  border-radius: 52% 48% 45% 55%;
  background: linear-gradient(145deg, #ff9585, #ff756b);
  box-shadow: inset 0 5px rgba(255,255,255,.25), 0 10px 16px rgba(86,47,98,.18);
}
.island-friend .eye { position: absolute; top: 29px; width: 6px; height: 8px; border-radius: 50%; background: #3d3250; }
.island-friend .eye:first-child { left: 23px; }
.island-friend .eye:nth-child(2) { right: 23px; }
.island-friend .smile { position: absolute; left: 28px; top: 39px; width: 17px; height: 9px; border: 3px solid #3d3250; border-top: 0; border-radius: 0 0 12px 12px; }

.decor { position: absolute; z-index: 6; display: grid; place-items: center; filter: drop-shadow(0 5px 5px rgba(52,38,98,.16)); }
.decor-flower { color: #fff7a2; font-size: 31px; text-shadow: 0 0 0 #ff806f; }
.decor-crystal { color: #8d77ed; font-size: 28px; }
.decor-tree { width: 34px; height: 47px; border-radius: 55% 45% 47% 53%; background: #3ebc83; }
.decor-tree::after { content: ""; position: absolute; width: 8px; height: 20px; left: 13px; bottom: -12px; border-radius: 5px; background: #93694e; }
.decor-mushroom { width: 31px; height: 18px; border-radius: 19px 19px 7px 7px; background: #d766a8; }
.decor-mushroom::after { content: ""; position: absolute; width: 10px; height: 18px; left: 10px; top: 14px; border-radius: 3px 3px 6px 6px; background: #fff3d5; }
.decor-crown { color: #ffd259; font-size: 33px; }
.d1 { left: 62px; top: 88px; }.d2 { right: 66px; top: 91px; }.d3 { left: 57px; top: 48px; }
.d4 { right: 49px; top: 64px; }.d5 { left: 94px; top: 116px; }.d6 { right: 102px; top: 46px; }
.d7 { right: 70px; top: 32px; }.d8 { left: 37px; top: 111px; }.d9 { right: 36px; top: 112px; }.d10 { left: 139px; top: 20px; }

.home-progress {
  display: grid;
  grid-template-columns: auto minmax(80px, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin: -8px 2px 15px;
  padding: 11px 15px;
  border: 1px solid rgba(109,92,232,.08);
  border-radius: 18px;
  background: rgba(255,255,255,.67);
}
.home-progress > div:not(.progress-track) { display: grid; text-align: center; }
.home-progress strong { font-size: 1.08rem; }
.home-progress span { color: var(--muted); font-size: .68rem; font-weight: 750; }
.progress-track { height: 9px; overflow: hidden; border-radius: 9px; background: #ddd7f5; }
.progress-track span { display: block; height: 100%; min-width: 3px; border-radius: inherit; background: linear-gradient(90deg, var(--aqua), var(--purple)); }
.home-buttons { display: grid; gap: 10px; }
.settings-link { margin: 11px auto 0; padding: 9px 12px; display: flex; align-items: center; gap: 7px; border: 0; color: var(--muted); background: transparent; font-size: .76rem; font-weight: 750; cursor: pointer; }
.settings-link .ui-icon { width: 16px; }

/* Map */
.map-screen { background: linear-gradient(180deg, #f9f7ff, #eee9ff); overflow: visible; }
.map-heading { padding: 20px 6px 16px; }
.map-heading h1 { margin: 0; font-size: 2.1rem; letter-spacing: -.045em; }
.world-list { display: grid; gap: 18px; padding-bottom: 18px; }
.world-card { position: relative; padding: 20px 17px 22px; overflow: hidden; border-radius: 28px; box-shadow: var(--soft-shadow); }
.world-card::before { content: ""; position: absolute; width: 160px; height: 160px; right: -65px; top: -80px; border-radius: 50%; background: rgba(255,255,255,.23); }
.world-bubbles { background: linear-gradient(145deg, #d9f8f2, #c9e8f8); }
.world-forest { background: linear-gradient(145deg, #dcf5d6, #c9ecd9); }
.world-stars { background: linear-gradient(145deg, #e6dfff, #dfd4f7); }
.world-header { position: relative; z-index: 1; display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.world-header span { color: var(--muted); font-size: .69rem; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.world-header h2 { margin: 3px 0 2px; font-size: 1.33rem; }
.world-header p { margin: 0; color: var(--muted); font-size: .78rem; font-weight: 650; }
.world-score { min-width: 62px; display: flex; align-items: center; justify-content: center; gap: 4px; padding: 8px 10px; border-radius: 13px; background: rgba(255,255,255,.55); font-size: .75rem; font-weight: 900; }
.world-score .ui-icon { width: 14px; height: 14px; fill: var(--sun); stroke: #d5a521; }
.level-path { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px 12px; margin-top: 22px; }
.level-path::before { content: ""; position: absolute; z-index: -1; inset: 23px 15px auto; height: 47px; border: 3px dotted rgba(83,66,140,.16); border-left-color: transparent; border-right-color: transparent; border-radius: 50%; }
.level-node { position: relative; width: 47px; height: 47px; margin: auto; display: grid; place-items: center; border: 0; border-radius: 17px; color: var(--ink); background: rgba(255,255,255,.76); box-shadow: 0 7px 13px rgba(66,48,105,.12), inset 0 -3px rgba(69,50,115,.05); font-weight: 950; cursor: pointer; }
.level-node:nth-child(even) { transform: translateY(8px); }
.level-node.done { color: white; background: linear-gradient(145deg, #8472f2, #6554d6); }
.level-node.current { outline: 4px solid rgba(255,255,255,.65); animation: nodePulse 1.5s ease-in-out infinite alternate; }
.level-node:disabled { cursor: default; color: #a9a3b8; background: rgba(255,255,255,.35); box-shadow: none; }
.level-node .ui-icon { width: 17px; height: 17px; }
.level-node b { position: absolute; right: -5px; top: -7px; display: grid; place-items: center; width: 19px; height: 19px; border-radius: 50%; color: #9b7213; background: var(--sun); font-size: .65rem; box-shadow: 0 3px 7px rgba(84,60,110,.18); }

/* Settings */
.settings-screen { background: linear-gradient(165deg, #faf8ff, #eee9ff); }
.settings-card { margin-top: 22px; padding: 20px; border-radius: 28px; background: rgba(255,255,255,.75); box-shadow: var(--shadow); }
.settings-hero { display: flex; align-items: center; gap: 14px; padding-bottom: 20px; border-bottom: 1px solid #e9e5f4; }
.settings-hero .brand-mark { width: 53px; height: 53px; flex-basis: 53px; border-radius: 18px; transform: rotate(-3deg) scale(.83); transform-origin: center; }
.settings-hero h1 { margin: 0 0 3px; }
.settings-hero p { margin: 0; color: var(--muted); font-size: .78rem; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 19px 2px; border-bottom: 1px solid #ebe7f4; }
.setting-row div { display: grid; gap: 4px; }
.setting-row strong { font-size: .94rem; }
.setting-row span { color: var(--muted); font-size: .74rem; line-height: 1.35; }
.toggle { position: relative; width: 52px; height: 31px; flex: 0 0 52px; border: 0; border-radius: 20px; background: #d7d2e2; cursor: pointer; transition: .2s ease; }
.toggle i { position: absolute; left: 4px; top: 4px; width: 23px; height: 23px; border-radius: 50%; background: white; box-shadow: 0 3px 6px rgba(50,42,75,.18); transition: .2s ease; }
.toggle.on { background: var(--purple); }
.toggle.on i { transform: translateX(21px); }
.privacy-note { display: flex; gap: 13px; margin-top: 20px; padding: 15px; border-radius: 18px; color: #3c6558; background: #e3f6ed; }
.privacy-note > span { font-size: 1.5rem; }
.privacy-note p { margin: 0; font-size: .76rem; line-height: 1.5; }
.reset-zone { margin-top: 30px; text-align: center; }
.reset-zone p { margin: 0 auto 10px; max-width: 260px; color: var(--muted); font-size: .7rem; line-height: 1.4; }
.hold-button { position: relative; width: 100%; min-height: 48px; overflow: hidden; border: 1px solid #f0c4c0; border-radius: 16px; color: #a64e48; background: #fff2f0; font-weight: 850; cursor: pointer; }
.hold-button span { position: relative; z-index: 2; }
.hold-button i { position: absolute; z-index: 1; inset: 0 100% 0 0; background: #ffd5d0; }
.hold-button.holding i { right: 0; transition: right 2s linear; }

/* Game shell */
.game-screen { display: flex; flex-direction: column; background: linear-gradient(180deg, #f9f7ff 0%, #eee9ff 100%); }
.game-screen.world-bubbles { background: linear-gradient(180deg, #f8fbff 0%, #e1f5f5 100%); }
.game-screen.world-forest { background: linear-gradient(180deg, #fcfff9 0%, #e5f4e0 100%); }
.game-screen.world-stars { background: linear-gradient(180deg, #fbf9ff 0%, #ebe3ff 100%); }
.level-meter { height: 6px; margin: 8px 4px 18px; overflow: hidden; border-radius: 5px; background: rgba(80,61,138,.1); }
.level-meter span { display: block; height: 100%; min-width: 3px; border-radius: inherit; background: linear-gradient(90deg, var(--aqua), var(--purple)); }
.game-heading { display: flex; align-items: center; justify-content: center; gap: 13px; text-align: left; }
.game-heading h1 { margin: 0; font-size: 1.42rem; letter-spacing: -.025em; }
.game-heading p { margin: 3px 0 0; color: var(--muted); font-size: .75rem; font-weight: 700; }
.puzzle-kind { width: 47px; height: 47px; display: grid; place-items: center; border-radius: 16px; background: rgba(255,255,255,.78); box-shadow: var(--soft-shadow); }
.mini-shape { width: 34px; }
.mini-tube { width: 29px; height: 35px; display: flex; flex-direction: column-reverse; align-items: center; gap: 2px; padding: 5px 5px 3px; border: 3px solid #7669a8; border-top: 0; border-radius: 0 0 9px 9px; }
.mini-tube b { width: 15px; height: 6px; border-radius: 5px; }
.mini-tube b:nth-child(1) { background: var(--coral); }.mini-tube b:nth-child(2) { background: var(--aqua); }.mini-tube b:nth-child(3) { background: var(--sun); }
.mini-pattern { display: flex; align-items: center; gap: 3px; }
.mini-pattern b { width: 8px; height: 8px; border-radius: 50%; background: var(--purple); }
.mini-pattern b:nth-child(2) { width: 12px; height: 12px; background: var(--coral); }
.game-board { flex: 1 1 auto; min-height: 430px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 18px 0 8px; }
.game-footer { display: flex; justify-content: space-between; align-items: center; padding: 8px 6px 2px; color: var(--muted); font-size: .68rem; font-weight: 800; }
.footer-dot { display: inline-block; width: 7px; height: 7px; margin-left: 5px; border-radius: 50%; background: #c9c2df; }
.footer-dot.active { width: 19px; border-radius: 8px; background: var(--purple); }

/* Tube puzzle */
.tube-help { display: flex; align-items: center; gap: 9px; margin-bottom: 21px; color: #8379a2; }
.tube-help span { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 9px; background: rgba(255,255,255,.72); font-size: .72rem; font-weight: 900; }
.tube-help i { font-style: normal; }
.tubes { width: 100%; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: center; gap: 20px 13px; padding: 0 4px; }
.tube { position: relative; width: 56px; height: calc(38px + var(--capacity) * 43px); padding: 0; border: 0; background: transparent; cursor: pointer; transition: transform .18s ease; }
.tube.selected { transform: translateY(-14px); }
.tube-rim { position: absolute; z-index: 3; left: 4px; right: 4px; top: 2px; height: 12px; border: 4px solid rgba(90,78,139,.54); border-radius: 50%; background: rgba(255,255,255,.52); }
.tube-glass { position: absolute; inset: 8px 7px 0; overflow: hidden; border: 4px solid rgba(100,86,151,.38); border-top: 0; border-radius: 0 0 20px 20px; background: linear-gradient(90deg, rgba(255,255,255,.55), rgba(255,255,255,.22)); box-shadow: inset 8px 0 rgba(255,255,255,.18), 0 9px 15px rgba(64,50,112,.08); }
.tube-stack { position: absolute; inset: auto 4px 5px; display: flex; flex-direction: column-reverse; gap: 3px; }
.ball { position: relative; display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%; box-shadow: inset 0 5px rgba(255,255,255,.25), inset 0 -4px rgba(48,37,83,.12), 0 3px 5px rgba(44,34,80,.13); animation: ballDrop .22s ease-out both; }
.ball::after { color: rgba(255,255,255,.86); font-size: 14px; font-style: normal; font-weight: 950; line-height: 1; }
.ball.color-coral::after { content: "•"; font-size: 26px; }.ball.color-aqua::after { content: "="; }.ball.color-sun::after { content: "+"; }.ball.color-lilac::after { content: "×"; }.ball.color-berry::after { content: "◆"; font-size: 10px; }.ball.color-mint::after { content: "○"; }
.move-count { min-height: 21px; margin: 22px 0 0; color: var(--muted); font-size: .74rem; font-weight: 720; text-align: center; }

/* Shared colors and shapes */
.color-coral { --token: var(--coral); background-color: var(--coral); }.color-aqua { --token: var(--aqua); background-color: var(--aqua); }
.color-sun { --token: var(--sun); background-color: var(--sun); }.color-lilac { --token: var(--lilac); background-color: var(--lilac); }
.color-berry { --token: var(--berry); background-color: var(--berry); }.color-mint { --token: var(--mint); background-color: var(--mint); }
.shape-svg { width: 58px; height: 58px; overflow: visible; background: none !important; transform: scale(var(--token-scale, 1)); transform-origin: center; filter: drop-shadow(0 5px 4px rgba(51,40,87,.16)); }
.shape-svg > g { fill: var(--token); stroke: rgba(63,48,96,.12); stroke-width: 2; stroke-linecap: round; }
.shape-svg .shape-shine { fill: none; stroke: rgba(255,255,255,.62); stroke-width: 7; stroke-linecap: round; }

/* Sort puzzle */
.sort-board { justify-content: space-evenly; }
.sort-bins { width: 100%; display: grid; grid-template-columns: repeat(var(--bin-count), minmax(54px, 1fr)); gap: 8px; align-items: end; }
.sort-bin { position: relative; min-width: 0; min-height: 108px; display: grid; place-items: center; padding: 13px 3px 9px; overflow: visible; border: 0; border-radius: 16px 16px 23px 23px; background: rgba(255,255,255,.62); box-shadow: inset 0 -7px rgba(74,55,120,.07), var(--soft-shadow); cursor: pointer; }
.sort-bin::after { content: ""; position: absolute; inset: 8px 7px 7px; border: 2px dashed rgba(85,68,130,.14); border-radius: 12px 12px 18px 18px; }
.bin-lid { position: absolute; z-index: 2; left: -3px; right: -3px; top: 0; height: 10px; border-radius: 8px; background: #7467a6; box-shadow: 0 3px 4px rgba(54,43,84,.14); }
.bin-symbol { z-index: 1; width: clamp(34px, 10vw, 48px); opacity: .92; }
.sort-bin.color .bin-symbol { border: 6px solid rgba(255,255,255,.7); border-radius: 50%; }
.bin-count { position: absolute; z-index: 3; right: 5px; bottom: 5px; min-width: 20px; min-height: 20px; display: grid; place-items: center; border-radius: 10px; color: var(--purple-dark); background: white; font-size: .67rem; font-weight: 950; }
.sort-tray { width: 100%; min-height: 180px; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 10px; margin-top: 27px; padding: 18px 12px; border-radius: 30px; background: rgba(255,255,255,.55); box-shadow: inset 0 0 0 2px rgba(255,255,255,.5); }
.sort-item { width: 67px; height: 67px; display: grid; place-items: center; border: 0; border-radius: 23px; background: #fff; box-shadow: 0 7px 13px rgba(58,43,98,.12), inset 0 -4px rgba(75,54,110,.04); cursor: pointer; transition: .16s ease; }
.sort-item.selected { transform: translateY(-8px) rotate(-3deg); outline: 4px solid rgba(109,92,232,.22); box-shadow: 0 13px 20px rgba(58,43,98,.18); }
.item-symbol { width: 51px; }
.empty-tray { align-self: center; color: var(--muted); font-size: .9rem; font-weight: 850; }

/* Pattern puzzle */
.pattern-board { justify-content: center; }
.round-pips { display: flex; gap: 7px; margin-bottom: 24px; }
.round-pips i { width: 25px; height: 7px; border-radius: 7px; background: #d8d2ea; }
.round-pips i.active { background: var(--purple); }
.pattern-strip { width: 100%; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 19px 12px; border-radius: 28px; background: rgba(255,255,255,.66); box-shadow: var(--soft-shadow); }
.pattern-cell { width: clamp(48px, 13vw, 61px); height: clamp(61px, 16vw, 72px); display: grid; place-items: center; border-radius: 19px; background: rgba(244,241,253,.76); }
.pattern-cell.missing { border: 3px dashed #b2a8d2; color: #8d83aa; background: transparent; }
.pattern-cell.missing b { font-size: 1.6rem; }
.pattern-token { width: clamp(42px, 11vw, 53px); }
.pattern-options { display: flex; justify-content: center; gap: 16px; margin-top: 37px; }
.pattern-option { width: 91px; height: 91px; display: grid; place-items: center; border: 0; border-radius: 29px; background: white; box-shadow: 0 12px 24px rgba(62,44,107,.14), inset 0 -6px rgba(77,58,115,.05); cursor: pointer; }
.pattern-option:active { transform: translateY(3px); }
.option-token { width: 68px; }

/* Success and particles */
.success-overlay { position: absolute; z-index: 50; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(48,37,91,.36); backdrop-filter: blur(7px); animation: fadeIn .22s ease-out; }
.success-card { width: min(100%, 355px); padding: 27px 25px 21px; border-radius: 32px; text-align: center; background: #fffdf8; box-shadow: 0 25px 65px rgba(32,23,72,.3); animation: successIn .48s cubic-bezier(.22,1.3,.42,1) both; }
.success-card h2 { margin: 7px 0 7px; font-size: 1.75rem; letter-spacing: -.04em; }
.success-card p { margin: 0 auto 22px; max-width: 250px; color: var(--muted); font-size: .82rem; line-height: 1.45; }
.success-card .primary-button { width: 100%; }
.success-star { position: relative; width: 102px; height: 102px; margin: -9px auto 14px; display: grid; place-items: center; }
.success-star span { position: relative; z-index: 2; width: 78px; height: 78px; display: grid; place-items: center; border-radius: 50%; color: #9b6b10; background: linear-gradient(145deg, #ffe880, #ffc947); box-shadow: 0 11px 22px rgba(167,118,20,.25), inset 0 5px rgba(255,255,255,.43); font-size: 2.6rem; animation: starSpin .65s cubic-bezier(.2,1.4,.5,1) both; }
.success-star i { position: absolute; width: 10px; height: 10px; border-radius: 50%; background: var(--coral); }
.success-star i:nth-child(2) { left: 2px; top: 25px; }.success-star i:nth-child(3) { right: 3px; top: 12px; background: var(--aqua); }.success-star i:nth-child(4) { right: 8px; bottom: 15px; background: var(--lilac); }
#celebration { position: fixed; z-index: 100; inset: 0; pointer-events: none; overflow: hidden; }
.confetti-piece { position: absolute; top: -20px; width: 9px; height: 15px; border-radius: 3px; animation: confettiFall 1.85s var(--delay) cubic-bezier(.3,.72,.45,1) both; }
.mini-burst { position: fixed; width: 8px; height: 8px; border-radius: 50%; background: var(--token); animation: miniBurst .62s ease-out both; }

.nudge { animation: nudge .3s ease-in-out !important; }

/* Motion */
@keyframes breathe { to { transform: scale(1.06) rotate(2deg); } }
@keyframes float { to { transform: translateY(10px) rotate(12deg); } }
@keyframes islandFloat { to { transform: translate(-50%, calc(-50% + 8px)); } }
@keyframes nodePulse { to { transform: translateY(-3px) scale(1.04); } }
@keyframes ballDrop { from { transform: translateY(-12px) scale(.88); opacity: .45; } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes successIn { from { opacity: 0; transform: translateY(35px) scale(.83); } }
@keyframes starSpin { from { opacity: 0; transform: rotate(-140deg) scale(.2); } }
@keyframes nudge { 25% { transform: translateX(-7px) rotate(-2deg); } 65% { transform: translateX(6px) rotate(2deg); } }
@keyframes confettiFall { 0% { opacity: 0; transform: translate3d(0,-20px,0) rotate(0); } 12% { opacity: 1; } 100% { opacity: 0; transform: translate3d(var(--drift),105vh,0) rotate(var(--spin)); } }
@keyframes miniBurst { to { opacity: 0; transform: rotate(var(--angle)) translateX(60px) scale(.2); } }

.calm-motion *,
.calm-motion *::before,
.calm-motion *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }

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

@media (max-width: 380px) {
  .screen { padding-inline: 15px; }
  .home-copy h1 { font-size: 2.45rem; }
  .island { transform: translate(-50%, -50%) scale(.9); }
  .level-path { gap-inline: 7px; }
  .level-node { width: 43px; height: 43px; border-radius: 15px; }
  .tubes { gap-inline: 8px; }
  .tube { width: 51px; }
  .pattern-option { width: 82px; height: 82px; border-radius: 25px; }
  .sort-item { width: 60px; height: 60px; }
}

@media (min-height: 880px) {
  .home-screen { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
  .island-card { min-height: 340px; }
  .game-board { min-height: 510px; }
}
