/* Color Sort Lab – UI. Font: Fredoka (OFL), icons: Lucide (ISC). See CREDITS.md */
@font-face{font-family:"Fredoka";font-weight:500;font-display:swap;src:url("../assets/fonts/fredoka-latin-500-normal.woff2") format("woff2");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
@font-face{font-family:"Fredoka";font-weight:500;font-display:swap;src:url("../assets/fonts/fredoka-latin-ext-500-normal.woff2") format("woff2");unicode-range:U+0100-02AF,U+0304,U+0308,U+0329,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}
@font-face{font-family:"Fredoka";font-weight:600;font-display:swap;src:url("../assets/fonts/fredoka-latin-600-normal.woff2") format("woff2");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
@font-face{font-family:"Fredoka";font-weight:600;font-display:swap;src:url("../assets/fonts/fredoka-latin-ext-600-normal.woff2") format("woff2");unicode-range:U+0100-02AF,U+0304,U+0308,U+0329,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}
@font-face{font-family:"Fredoka";font-weight:700;font-display:swap;src:url("../assets/fonts/fredoka-latin-700-normal.woff2") format("woff2");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
@font-face{font-family:"Fredoka";font-weight:700;font-display:swap;src:url("../assets/fonts/fredoka-latin-ext-700-normal.woff2") format("woff2");unicode-range:U+0100-02AF,U+0304,U+0308,U+0329,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}

*{box-sizing:border-box;margin:0;padding:0;-webkit-tap-highlight-color:transparent}
html,body{height:100%;overflow:hidden;overscroll-behavior:none}
body{font-family:"Fredoka","Segoe UI",system-ui,sans-serif;font-weight:500;color:#fff;user-select:none;-webkit-user-select:none;touch-action:manipulation;background:var(--bg);transition:background .5s}
button{font:inherit;color:inherit;border:0;background:none;cursor:pointer}
.ic{width:24px;height:24px;flex:none}

/* ---------- palette ---------- */
:root{
  --green:#3fd27a;--green-d:#1f9e52;--blue:#3fa9ff;--blue-d:#1f6fd1;--yellow:#ffc93c;--yellow-d:#d99412;
  --orange:#ff8a3d;--orange-d:#d1561a;--purple:#9b6bff;--purple-d:#6a3fd1;--pink:#ff5d8f;--pink-d:#cc2d63;
  --ink:#24305e;--card:#f4f7ff;--card-2:#dfe7fb;
}
/* ---------- themes ---------- */
.theme-lab{--bg:radial-gradient(130% 75% at 50% 0%,#3a63c9 0%,#1f3a86 45%,#121f4d 100%);--glass:rgba(255,255,255,.14);--accent:#5fd0ff}
.theme-midnight{--bg:radial-gradient(130% 75% at 50% 0%,#5a3bb0 0%,#2b1a66 50%,#120a30 100%);--glass:rgba(255,255,255,.12);--accent:#c3a2ff}
.theme-mint{--bg:radial-gradient(130% 75% at 50% 0%,#38b9a4 0%,#17706a 50%,#0b3a3c 100%);--glass:rgba(255,255,255,.15);--accent:#8bffd9}
.theme-sunset{--bg:radial-gradient(130% 75% at 50% 0%,#ff9a62 0%,#c2456b 50%,#4a1640 100%);--glass:rgba(255,255,255,.16);--accent:#ffd36b}
.theme-space{--bg:radial-gradient(1px 1px at 20% 30%,#fff9,transparent),radial-gradient(1px 1px at 70% 60%,#fff8,transparent),radial-gradient(1.5px 1.5px at 40% 80%,#fffa,transparent),radial-gradient(1px 1px at 85% 15%,#fff9,transparent),radial-gradient(130% 75% at 50% 0%,#2a3c7a 0%,#0e1430 60%,#04050f 100%);--glass:rgba(255,255,255,.1);--accent:#8fb3ff}
.theme-clean{--bg:linear-gradient(180deg,#e9f2ff 0%,#c9dbf7 100%);--glass:rgba(36,48,94,.1);--accent:#2f7cf6;color:var(--ink)}

/* floating background bubbles */
.bg-bubbles{position:fixed;inset:0;pointer-events:none;overflow:hidden;z-index:0}
.bg-bubbles i{position:absolute;bottom:-60px;border-radius:50%;background:radial-gradient(circle at 30% 30%,rgba(255,255,255,.35),rgba(255,255,255,.05) 60%,transparent 70%);border:1px solid rgba(255,255,255,.12);animation:rise linear infinite}
.bg-bubbles i:nth-child(1){left:6%;width:26px;height:26px;animation-duration:14s}
.bg-bubbles i:nth-child(2){left:22%;width:12px;height:12px;animation-duration:10s;animation-delay:-4s}
.bg-bubbles i:nth-child(3){left:38%;width:40px;height:40px;animation-duration:18s;animation-delay:-9s}
.bg-bubbles i:nth-child(4){left:55%;width:16px;height:16px;animation-duration:12s;animation-delay:-2s}
.bg-bubbles i:nth-child(5){left:70%;width:30px;height:30px;animation-duration:16s;animation-delay:-11s}
.bg-bubbles i:nth-child(6){left:84%;width:10px;height:10px;animation-duration:9s;animation-delay:-6s}
.bg-bubbles i:nth-child(7){left:92%;width:22px;height:22px;animation-duration:15s;animation-delay:-13s}
.bg-bubbles i:nth-child(8){left:48%;width:8px;height:8px;animation-duration:8s;animation-delay:-1s}
@keyframes rise{to{transform:translateY(-115vh) translateX(20px)}}
.theme-clean .bg-bubbles i{background:radial-gradient(circle at 30% 30%,rgba(255,255,255,.9),rgba(255,255,255,.2) 60%,transparent 70%);border-color:rgba(47,124,246,.15)}

#app{position:relative;z-index:1;height:100%;max-width:560px;margin:0 auto;display:flex;flex-direction:column}
.screen{position:absolute;inset:0;display:none;flex-direction:column;padding:env(safe-area-inset-top) 0 env(safe-area-inset-bottom)}
.screen.active{display:flex;animation:screenIn .28s ease-out}
@keyframes screenIn{from{opacity:0;transform:translateY(10px)}}

/* ---------- shared pieces ---------- */
.topbar{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:14px 14px 6px}
.round-btn{width:48px;height:48px;border-radius:50%;display:grid;place-items:center;color:var(--ink);
  background:linear-gradient(180deg,#fff 0%,#dfe8fb 100%);box-shadow:0 4px 0 #9fb0d8,0 8px 18px rgba(0,0,0,.25);transition:transform .18s cubic-bezier(.34,1.56,.64,1)}
.round-btn:active{transform:translateY(3px) scale(.94);box-shadow:0 1px 0 #9fb0d8,0 4px 10px rgba(0,0,0,.25);transition-duration:.05s}
.coin-pill{display:flex;align-items:center;gap:8px;padding:5px 16px 5px 5px;border-radius:999px;font-weight:700;font-size:19px;
  background:rgba(0,0,0,.28);box-shadow:inset 0 2px 4px rgba(0,0,0,.25),0 1px 0 rgba(255,255,255,.15);color:#fff}
.coin-pill.dark{background:var(--ink)}
.theme-clean .coin-pill{background:var(--ink)}
.coin-ico{width:30px;height:30px;border-radius:50%;display:inline-block;position:relative;flex:none;
  background:radial-gradient(circle at 35% 30%,#fff7c9 0 14%,#ffd84d 38%,#f2a50c 100%);box-shadow:inset 0 0 0 2.5px #c77d00,inset 0 -3px 0 rgba(160,90,0,.35)}
.coin-ico::after{content:"";position:absolute;inset:7px;border-radius:50%;border:2px solid rgba(199,125,0,.55)}
.coin-ico.big{width:44px;height:44px}.coin-ico.big::after{inset:10px}
.bump{animation:bump .35s}
@keyframes bump{40%{transform:scale(1.18)}}

/* candy buttons */
.candy-btn{--c:var(--green);--d:var(--green-d);display:flex;align-items:center;justify-content:center;gap:10px;padding:14px 22px;border-radius:22px;
  font-weight:700;font-size:21px;color:#fff;text-shadow:0 2px 0 rgba(0,0,0,.18);position:relative;
  background:linear-gradient(180deg,color-mix(in srgb,var(--c) 70%,#fff) 0%,var(--c) 45%,var(--c) 100%);
  box-shadow:0 6px 0 var(--d),0 12px 22px rgba(0,0,0,.25),inset 0 2px 0 rgba(255,255,255,.45);transition:transform .18s cubic-bezier(.34,1.56,.64,1)}
.candy-btn::before{content:"";position:absolute;left:12px;right:12px;top:5px;height:38%;border-radius:16px;background:linear-gradient(rgba(255,255,255,.45),rgba(255,255,255,0));pointer-events:none}
.candy-btn:active{transform:translateY(5px);box-shadow:0 1px 0 var(--d),0 4px 10px rgba(0,0,0,.25),inset 0 2px 0 rgba(255,255,255,.45);transition-duration:.05s}
.candy-btn.yellow{--c:var(--yellow);--d:var(--yellow-d)}.candy-btn.blue{--c:var(--blue);--d:var(--blue-d)}.candy-btn.purple{--c:var(--purple);--d:var(--purple-d)}
.candy-btn.wide{width:100%;margin-top:14px}
.candy-btn .ic{width:26px;height:26px;stroke-width:2.6}
.candy-btn[disabled]{filter:grayscale(.6);opacity:.55}
.ad-tag{display:inline-block;font-style:normal;font-size:11px;font-weight:700;line-height:1;padding:4px 6px;border-radius:7px;background:#fff;color:#c77d00;text-shadow:none;letter-spacing:.5px}

/* ---------- home ---------- */
.logo{margin:4vh auto 0;text-align:center}
.logo h1{display:flex;flex-direction:column;align-items:center;line-height:.95;font-weight:700}
.logo h1 span{font-size:40px;letter-spacing:.5px;text-shadow:0 3px 0 rgba(0,0,0,.25)}
.logo h1 b{font-size:64px;letter-spacing:6px;color:var(--yellow);-webkit-text-stroke:2px #b86e00;paint-order:stroke fill;text-shadow:0 5px 0 #8a4f00,0 10px 20px rgba(0,0,0,.35)}
.logo p{margin-top:8px;display:inline-block;padding:4px 14px;border-radius:999px;background:rgba(0,0,0,.22);font-size:15px;font-weight:600;letter-spacing:4px;text-transform:uppercase}
.theme-clean .logo h1 span{color:var(--ink);text-shadow:none}.theme-clean .logo p{background:var(--ink);color:#fff}
.logo-tubes{display:flex;gap:12px;justify-content:center;align-items:flex-end;margin-bottom:18px}
.logo-tubes i{width:32px;height:104px;border:3px solid rgba(255,255,255,.85);border-top:0;border-radius:0 0 16px 16px;position:relative;overflow:hidden;
  background:rgba(255,255,255,.1);box-shadow:inset 6px 0 0 rgba(255,255,255,.18);animation:bob 3s ease-in-out infinite}
.logo-tubes i::before{content:"";position:absolute;left:-6px;right:-6px;top:0;height:6px;border-radius:3px;background:#fff;z-index:1}
.logo-tubes i:nth-child(2){animation-delay:-.75s;height:116px}.logo-tubes i:nth-child(3){animation-delay:-1.5s;height:116px}.logo-tubes i:nth-child(4){animation-delay:-2.25s}
.logo-tubes i::after{content:"";position:absolute;inset:auto 0 0;height:76%;background:linear-gradient(#ff4d6d 0 25%,#ffc93c 0 50%,#3fa9ff 0 75%,#3fd27a 0)}
.logo-tubes i:nth-child(2)::after{background:linear-gradient(#9b6bff 0 25%,#3fd27a 0 50%,#ff4d6d 0 75%,#ffc93c 0)}
.logo-tubes i:nth-child(3)::after{background:linear-gradient(#3fa9ff 0 25%,#ff8a3d 0 50%,#9b6bff 0 75%,#ff5d8f 0)}
.logo-tubes i:nth-child(4)::after{background:linear-gradient(#ffc93c 0 25%,#ff5d8f 0 50%,#3fd27a 0 75%,#3fa9ff 0)}
@keyframes bob{50%{transform:translateY(-7px) rotate(-2deg)}}
.play-btn{margin:5vh auto 0;width:min(80%,320px);padding:16px 22px;border-radius:28px;font-size:30px;animation:breathe 2.4s ease-in-out infinite}
.play-btn .ic{width:34px;height:34px;fill:#fff}
.play-text{display:flex;flex-direction:column;align-items:flex-start;line-height:1}
.play-text small{font-size:15px;font-weight:600;opacity:.92;margin-top:3px}
@keyframes breathe{50%{transform:scale(1.04)}}
.play-btn:active{animation:none}
.home-tiles{display:flex;gap:14px;justify-content:center;margin-top:26px}
.tile{width:132px;padding:14px 8px 12px;border-radius:22px;display:flex;flex-direction:column;align-items:center;gap:8px;font-weight:600;font-size:16px;
  background:var(--glass);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 8px 20px rgba(0,0,0,.18);backdrop-filter:blur(8px);transition:transform .18s cubic-bezier(.34,1.56,.64,1)}
.tile:active{transform:scale(.93);transition-duration:.05s}
.tile-ic,.tool-ic,.t-ic{--c:var(--blue);--d:var(--blue-d);display:grid;place-items:center;position:relative;color:#fff;border-radius:18px;
  background:linear-gradient(180deg,color-mix(in srgb,var(--c) 65%,#fff),var(--c) 55%);box-shadow:0 4px 0 var(--d),inset 0 2px 0 rgba(255,255,255,.45)}
.tile-ic{width:58px;height:58px}.tile-ic .ic{width:30px;height:30px;stroke-width:2.4}
.orange{--c:var(--orange);--d:var(--orange-d)}.yellow{--c:var(--yellow);--d:var(--yellow-d)}.green{--c:var(--green);--d:var(--green-d)}.purple{--c:var(--purple);--d:var(--purple-d)}.blue{--c:var(--blue);--d:var(--blue-d)}
.brand{margin-top:auto;text-align:center;opacity:.5;font-size:12px;font-weight:600;padding:16px;letter-spacing:4px}

/* ---------- game ---------- */
.level-pill{flex:1;max-width:210px;text-align:center;padding:6px 12px 7px;border-radius:20px;background:rgba(0,0,0,.25);box-shadow:inset 0 2px 4px rgba(0,0,0,.25),0 1px 0 rgba(255,255,255,.15);color:#fff}
.theme-clean .level-pill{background:var(--ink)}
.level-line{display:flex;align-items:center;justify-content:center;gap:6px;font-size:20px;font-weight:700;line-height:1.1}
.level-line b{font-size:22px}
.level-pill small{display:block;font-size:13px;font-weight:600;opacity:.75}
#board{flex:1;width:100%;min-height:0;display:block}
.toolbar{display:flex;justify-content:space-around;padding:6px 10px 18px}
.tool{display:flex;flex-direction:column;align-items:center;gap:7px;width:76px;font-size:13px;font-weight:600;transition:transform .18s cubic-bezier(.34,1.56,.64,1)}
.tool-ic{width:60px;height:60px;border-radius:20px}
.tool-ic .ic{width:30px;height:30px;stroke-width:2.6}
.tool:active{transform:translateY(3px) scale(.94);transition-duration:.05s}
.tool:active .tool-ic{box-shadow:0 1px 0 var(--d),inset 0 2px 0 rgba(255,255,255,.45)}
.tool em{position:absolute;top:-8px;right:-8px;min-width:24px;height:24px;padding:0 6px;border-radius:12px;font-style:normal;font-size:13px;font-weight:700;
  display:grid;place-items:center;background:var(--pink);color:#fff;box-shadow:0 2px 0 var(--pink-d),0 0 0 2px #fff}
.tool em.ad-tag{background:#fff;color:#c77d00;box-shadow:0 2px 0 #c9d3ee;height:20px;font-size:10px;top:-7px}
.tool.disabled{opacity:.45;filter:grayscale(.7)}
.badge{display:none;font-size:11px;font-weight:700;padding:3px 7px;border-radius:8px;letter-spacing:1px}
.badge.hard{display:inline-block;background:var(--pink);box-shadow:0 2px 0 var(--pink-d);animation:pulse 1.4s ease-in-out infinite}
.badge.easy{display:inline-block;background:var(--green);box-shadow:0 2px 0 var(--green-d)}
@keyframes pulse{50%{transform:scale(1.12)}}
#hud-moves.bump{animation:bump .3s}
.hud-sub{display:flex;gap:10px;justify-content:center;align-items:center}
.hud-time{font-variant-numeric:tabular-nums;font-weight:700}
.hud-time:empty{display:none}
.hud-time.warn{color:#ff4d6d;animation:pulse 1s ease-in-out infinite}
.timeup-card{display:flex;flex-direction:column;gap:10px;text-align:center}

/* ---------- overlays / cards ---------- */
.overlay{position:absolute;inset:0;display:none;align-items:center;justify-content:center;background:rgba(8,14,36,.62);backdrop-filter:blur(5px);z-index:10;padding:22px}
.overlay.show{display:flex;animation:fadeIn .2s}
@keyframes fadeIn{from{opacity:0}}
.card{position:relative;width:100%;max-width:390px;padding:44px 20px 20px;border-radius:30px;color:var(--ink);
  background:linear-gradient(180deg,var(--card) 0%,var(--card-2) 100%);box-shadow:0 8px 0 #a9b8de,0 26px 60px rgba(0,0,0,.45),inset 0 2px 0 #fff}
.overlay.show .card{animation:cardIn .4s cubic-bezier(.34,1.56,.64,1)}
@keyframes cardIn{from{transform:translateY(40px) scale(.85);opacity:0}}
.ribbon{--c:var(--green);--d:var(--green-d);position:absolute;left:50%;top:-24px;transform:translateX(-50%);min-width:230px;max-width:92%;padding:12px 26px;text-align:center;
  font-size:23px;font-weight:700;color:#fff;text-shadow:0 2px 0 rgba(0,0,0,.2);border-radius:18px;white-space:nowrap;
  background:linear-gradient(180deg,color-mix(in srgb,var(--c) 70%,#fff),var(--c) 55%);box-shadow:0 5px 0 var(--d),0 10px 18px rgba(0,0,0,.25),inset 0 2px 0 rgba(255,255,255,.45)}
.ribbon.blue{--c:var(--blue);--d:var(--blue-d)}.ribbon.purple{--c:var(--purple);--d:var(--purple-d)}
.close-btn{position:absolute;right:-10px;top:-14px;width:44px;height:44px;border-radius:50%;display:grid;place-items:center;color:#fff;z-index:2;
  background:linear-gradient(180deg,#ff8aa8,var(--pink) 55%);box-shadow:0 4px 0 var(--pink-d),0 6px 14px rgba(0,0,0,.3),inset 0 2px 0 rgba(255,255,255,.45)}
.close-btn .ic{stroke-width:3}
.close-btn:active{transform:translateY(3px);box-shadow:0 1px 0 var(--pink-d)}
.muted{opacity:.65;font-size:14px;text-align:center;margin-top:6px}
.win-card{text-align:center}
.stars{display:flex;justify-content:center;align-items:flex-end;gap:6px;margin:6px 0 4px}
.stars i{width:58px;height:58px;background:linear-gradient(180deg,#ffe36b,#ffb300);filter:drop-shadow(0 3px 0 #c77d00);
  clip-path:polygon(50% 0,61% 35%,98% 35%,68% 57%,79% 91%,50% 70%,21% 91%,32% 57%,2% 35%,39% 35%);animation:pop .5s cubic-bezier(.34,1.56,.64,1) backwards}
.stars i:nth-child(2){width:78px;height:78px;animation-delay:.15s;margin-bottom:12px}.stars i:nth-child(3){animation-delay:.3s}
.stars i.off{background:#c3cde6;filter:drop-shadow(0 3px 0 #9fb0d8)}
@keyframes pop{from{transform:scale(0) rotate(-120deg)}}
.reward{display:flex;align-items:center;justify-content:center;gap:10px;margin:12px auto 0;padding:8px 22px 8px 10px;width:max-content;border-radius:999px;background:var(--ink);color:#fff;font-size:30px;font-weight:700}
.shop-head{display:flex;justify-content:center;margin-bottom:10px}
.tabs{display:flex;gap:8px;margin-bottom:12px;padding:5px;border-radius:18px;background:#d3ddf5}
.tab{flex:1;display:flex;align-items:center;justify-content:center;gap:6px;padding:10px;border-radius:14px;font-weight:600;color:#5a6aa0}
.tab .ic{width:20px;height:20px}
.tab.active{background:#fff;color:var(--ink);box-shadow:0 3px 0 #b7c4e6}
.shop-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;max-height:44vh;overflow:auto;padding:10px 6px 8px}
.item{position:relative;border-radius:18px;background:#fff;padding:8px 6px 10px;text-align:center;font-size:13px;font-weight:600;color:var(--ink);
  box-shadow:0 4px 0 #c3cde6;border:3px solid transparent;transition:transform .18s cubic-bezier(.34,1.56,.64,1)}
.item:active{transform:scale(.94);transition-duration:.05s}
.item canvas{width:100%;height:84px;display:block;border-radius:12px;background:linear-gradient(180deg,#2a4590,#16244a)}
.swatch{height:84px;border-radius:12px;background:var(--bg)}
.item.equipped{border-color:var(--green);box-shadow:0 4px 0 var(--green-d)}
.item.equipped::after{content:"\2713";position:absolute;top:-9px;right:-9px;width:24px;height:24px;border-radius:50%;background:var(--green);color:#fff;font-size:14px;display:grid;place-items:center;box-shadow:0 2px 0 var(--green-d)}
.item .price{display:flex;align-items:center;justify-content:center;gap:4px;margin-top:6px;font-size:13px}
.item .price .coin-ico{width:16px;height:16px}.item .price .coin-ico::after{display:none}
.item.locked .price{color:#c77d00;font-weight:700}
.item.locked:not(.affordable) canvas,.item.locked:not(.affordable) .swatch{filter:grayscale(.5) brightness(.85)}
.item.affordable{box-shadow:0 4px 0 #e0b24a}
.item.bump{animation:nope .3s}
@keyframes nope{25%{transform:translateX(-5px)}75%{transform:translateX(5px)}}
.toggle{display:flex;align-items:center;gap:12px;padding:10px 4px;font-size:18px;font-weight:600;border-bottom:2px solid #d3ddf5;cursor:pointer}
.toggle>span:nth-of-type(2){flex:1}
.t-ic{width:40px;height:40px;border-radius:13px}.t-ic .ic{width:22px;height:22px}
.toggle input{display:none}
.toggle i{width:56px;height:32px;border-radius:16px;background:#c3cde6;position:relative;transition:.2s;box-shadow:inset 0 2px 4px rgba(0,0,0,.15)}
.toggle i::after{content:"";position:absolute;left:3px;top:3px;width:26px;height:26px;border-radius:50%;background:#fff;box-shadow:0 2px 3px rgba(0,0,0,.25);transition:.2s cubic-bezier(.34,1.56,.64,1)}
.toggle input:checked+i{background:var(--green)}.toggle input:checked+i::after{left:27px}
.lang-row{display:flex;align-items:center;gap:8px;margin:16px 0 4px;color:#5a6aa0}
.lang-row button{flex:1;padding:10px;border-radius:14px;background:#d3ddf5;font-weight:600;color:#5a6aa0}
.lang-row button.active{background:var(--blue);color:#fff;box-shadow:0 3px 0 var(--blue-d)}
.ad-bar{height:10px;border-radius:5px;background:#d3ddf5;margin-top:16px;overflow:hidden}.ad-bar i{display:block;height:100%;width:0;background:var(--yellow)}
#overlay-ad.show .ad-bar i{animation:adbar 1.2s linear forwards}@keyframes adbar{to{width:100%}}
#toast{position:absolute;left:50%;bottom:118px;transform:translateX(-50%) translateY(20px);padding:11px 20px;border-radius:16px;z-index:20;white-space:nowrap;
  background:var(--ink);color:#fff;font-weight:600;font-size:15px;box-shadow:0 4px 0 #111a3a,0 10px 24px rgba(0,0,0,.3);opacity:0;pointer-events:none;transition:.25s cubic-bezier(.34,1.56,.64,1)}
#toast.show{opacity:1;transform:translateX(-50%)}
@media (max-height:640px){.logo-tubes{display:none}.play-btn{margin-top:3vh}}
@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}

/* ---------- colour mixing ---------- */
.badge.mix{display:inline-block;background:var(--purple);box-shadow:0 2px 0 var(--purple-d)}
.mix-legend{display:flex;justify-content:center;flex-wrap:wrap;gap:8px;margin:4px 14px 0}
.mix-legend[hidden]{display:none}
.recipe{display:inline-flex;align-items:center;gap:4px;padding:4px 10px;border-radius:999px;background:rgba(0,0,0,.25);font-weight:700;font-size:14px;color:#fff}
.recipe b{opacity:.8}
.dot{width:16px;height:16px;border-radius:50%;display:inline-block;background:radial-gradient(circle at 32% 28%,rgba(255,255,255,.85) 0 12%,var(--c) 40%);box-shadow:0 0 0 2px rgba(255,255,255,.75)}
.mix-card{text-align:center}
.mix-flask{width:72px;height:72px;margin:4px auto 10px;border-radius:24px;display:grid;place-items:center;color:#fff;
  background:linear-gradient(135deg,#ff4d6d,#9b6bff 50%,#3fc1ff);box-shadow:0 5px 0 var(--purple-d),inset 0 2px 0 rgba(255,255,255,.45);animation:bob 2.4s ease-in-out infinite}
.mix-flask .ic{width:40px;height:40px;stroke-width:2.2}
.mix-body{font-size:16px;font-weight:600;line-height:1.35}
.mix-recipes{display:flex;flex-direction:column;align-items:center;gap:8px;margin:14px 0 4px}
.mix-recipes .recipe{background:var(--ink);font-size:18px;padding:7px 16px;gap:8px}
.mix-recipes .dot{width:24px;height:24px}
.recipe .ic{width:16px;height:16px;stroke-width:2.4;opacity:.9}
.mix-recipes .recipe .ic{width:22px;height:22px}

/* ---------- Prof. Fizz (mascot) ---------- */
.prof{position:absolute;z-index:6;pointer-events:none}
.prof .prof-svg{display:block;width:100%;height:auto;pointer-events:auto;cursor:pointer;filter:drop-shadow(0 6px 10px rgba(0,0,0,.3));
  animation:profBob 3.2s ease-in-out infinite;transform-origin:50% 100%}
@keyframes profBob{50%{transform:translateY(-3px) rotate(-1.5deg)}}
.prof .lids rect{transform-box:fill-box;transform-origin:50% 0;transform:scaleY(0);animation:blink 4.6s infinite}
@keyframes blink{0%,94%,100%{transform:scaleY(0)}96%{transform:scaleY(1)}}
.prof .mouth-open{display:none}
.prof.talking .mouth-open{display:block;transform-box:fill-box;transform-origin:50% 50%;animation:talk .16s ease-in-out infinite alternate}
.prof.talking .mouth-closed{display:none}
@keyframes talk{from{transform:scaleY(.35)}to{transform:scaleY(1)}}
.prof.speaking .prof-svg{animation:profTalk .5s ease-in-out infinite}
@keyframes profTalk{50%{transform:translateY(-4px) rotate(2deg)}}
.prof .pupils{transition:transform .3s}
.prof.speaking .pupils{transform:translateX(1.5px)}
.prof .bubble{position:absolute;left:calc(100% + 6px);top:4px;min-width:150px;max-width:min(240px,62vw);padding:10px 14px;border-radius:18px 18px 18px 6px;
  background:#fff;color:var(--ink);font-size:15px;font-weight:600;line-height:1.3;box-shadow:0 4px 0 #b7c4e6,0 10px 24px rgba(0,0,0,.28);
  opacity:0;transform:translateY(6px) scale(.85);transform-origin:0 100%;transition:.22s cubic-bezier(.34,1.56,.64,1);pointer-events:none}
.prof .bubble::before{content:"";position:absolute;left:-8px;top:16px;border:8px solid transparent;border-right-color:#fff;border-left:0}
.prof.speaking .bubble{opacity:1;transform:none}
.prof-game{left:6px;top:calc(env(safe-area-inset-top) + 92px);width:62px}
.prof-home{left:12px;bottom:calc(env(safe-area-inset-bottom) + 40px);width:96px}
.prof-home .bubble{top:-6px}
@media (max-height:700px){.prof-home{width:74px}}

/* ---------- pause menu ---------- */
.pause-card{text-align:center}
.pause-level{font-size:20px;font-weight:700;margin-bottom:12px}
.quick-toggles{display:flex;justify-content:center;gap:12px;margin-bottom:6px}
.qt{display:flex;flex-direction:column;align-items:center;gap:6px;width:84px;padding:10px 4px;border-radius:18px;background:#fff;font-size:13px;font-weight:600;color:var(--ink);box-shadow:0 4px 0 #c3cde6;position:relative;transition:transform .18s cubic-bezier(.34,1.56,.64,1)}
.qt:active{transform:scale(.92)}
.qt.off .t-ic{filter:grayscale(1);opacity:.45}
.qt.off::after{content:"";position:absolute;left:24px;right:24px;top:30px;height:3px;border-radius:2px;background:var(--pink);transform:rotate(-35deg)}
.pause-row{display:flex;gap:12px;margin-top:14px}
.pause-row .candy-btn{flex:1;font-size:17px;padding:12px 10px}
.pause-row .candy-btn .ic{width:22px;height:22px}
.link-btn{display:flex;align-items:center;justify-content:center;gap:6px;margin:16px auto 0;font-weight:600;color:#5a6aa0;font-size:15px}
.link-btn .ic{width:20px;height:20px}

/* ---------- Prof. Fizz – illustrated version (overrides the old SVG rules) ---------- */
.prof .prof-img{display:block;width:100%;height:auto;pointer-events:auto;cursor:pointer;user-select:none;-webkit-user-drag:none;
  filter:drop-shadow(0 6px 10px rgba(0,0,0,.35));transform-origin:50% 100%;animation:profBob 3.2s ease-in-out infinite}
.prof.talking .prof-img{animation:profJabber .22s ease-in-out infinite alternate}
@keyframes profJabber{from{transform:rotate(-2.5deg) scale(1,1)}to{transform:rotate(2deg) scale(1.03,.97)}}
.prof .prof-img.pop{animation:profPop .35s cubic-bezier(.34,1.56,.64,1)}
@keyframes profPop{from{transform:scale(.8) rotate(-6deg)}}
.prof-game{width:78px;top:calc(env(safe-area-inset-top) + 86px)}
.prof-game .bubble{top:10px}
.prof-home{width:138px;left:2px;bottom:calc(env(safe-area-inset-bottom) + 46px)}
.prof-home .bubble{top:14px}
@media (max-height:700px){.prof-home{width:92px}}
.prof-game{width:auto}
.prof-game .prof-img{height:88px;width:auto}
.prof-home{width:auto}
.prof-home .prof-img{height:170px;width:auto}
@media (max-height:700px){.prof-home .prof-img{height:130px}}

/* ======================================================================
   Prof. Fizz – integrated layout (overrides the earlier floating version)
   ====================================================================== */
/* --- game: comic panel under the HUD; he leans in from the left, head above the panel --- */
.prof-panel{position:relative;flex:none;height:78px;margin:22px 12px 0}
.prof-game{position:absolute;inset:0;width:auto;top:auto;left:0;right:0;height:100%;display:flex;align-items:flex-end;pointer-events:none}
.prof-game .prof-img{height:122px;width:auto;flex:none;margin:0 -10px -4px -6px;position:relative;z-index:2;pointer-events:auto}
.prof-game .bubble{position:relative;left:auto;top:auto;flex:1;min-width:0;max-width:none;height:100%;margin:0;
  display:flex;align-items:center;padding:8px 14px 8px 18px;opacity:1;transform:none;
  background:linear-gradient(180deg,#fffef8,#f3f0e2);color:#1b2240;border:3px solid #1b2240;border-radius:20px;
  box-shadow:4px 5px 0 #1b2240;font-size:15px;line-height:1.25;pointer-events:none}
.prof-game .bubble::before{content:"";position:absolute;left:-11px;top:50%;width:16px;height:16px;margin-top:-8px;border:0;
  background:#fbf9ee;border-left:3px solid #1b2240;border-bottom:3px solid #1b2240;transform:rotate(45deg);border-radius:0 0 0 4px}
.prof-game .bubble-text{display:block;width:100%}
.prof-game.speaking .bubble{animation:panelPop .3s cubic-bezier(.34,1.56,.64,1)}
@keyframes panelPop{from{transform:scale(.94)}}
.prof-game .goal-title{display:block;font-weight:700;font-size:15px}
.prof-game .recipe{display:inline-flex;margin:5px 6px 0 0;font-size:14px;padding:4px 10px;background:#1b2240}
.prof-game .recipe .dot{width:17px;height:17px}
.theme-clean .prof-game .bubble{box-shadow:4px 5px 0 #1b2240}
@media (max-height:700px){.prof-panel{height:66px;margin-top:16px}.prof-game .prof-img{height:100px}.prof-game .bubble{font-size:14px}}

/* --- home: he stands on the stage below the menu, with a floor shadow --- */
.prof-stage{position:relative;flex:1;min-height:150px;margin:6px 10px 0}
.prof-stage::after{content:"";position:absolute;left:30px;bottom:4px;width:150px;height:18px;border-radius:50%;background:radial-gradient(rgba(0,0,0,.45),transparent 70%)}
.prof-home{position:absolute;left:4px;bottom:8px;top:auto;width:auto;height:100%;max-height:250px;display:block;z-index:2}
.prof-home .prof-img{height:100%;width:auto}
.prof-home .bubble{left:auto;right:auto;position:absolute;top:6px;left:calc(100% - 26px);min-width:170px;max-width:min(220px,52vw);
  background:linear-gradient(180deg,#fffef8,#f3f0e2);color:#1b2240;border:3px solid #1b2240;box-shadow:4px 5px 0 #1b2240;border-radius:20px 20px 20px 6px}
.prof-home .bubble::before{display:none}
.brand{position:relative;z-index:3;padding-top:6px}

/* --- cards: he leans over the card edge --- */
.card-prof{position:absolute;z-index:4;pointer-events:none;filter:drop-shadow(0 8px 12px rgba(0,0,0,.35))}
.card-prof-left{left:-34px;top:-78px;height:118px;transform:rotate(-6deg)}
.card-prof-right{right:-22px;top:-132px;height:122px;transform:rotate(5deg)}
.overlay.show .card-prof{animation:profPeek .55s .15s cubic-bezier(.34,1.56,.64,1) backwards}
@keyframes profPeek{from{opacity:0;transform:translateY(30px) scale(.7)}}
.mix-prof{display:block;height:130px;width:auto;margin:-4px auto 6px;filter:drop-shadow(0 6px 10px rgba(0,0,0,.25))}
/* home: give the stage to Prof. Fizz – tighter logo block */
.logo{margin-top:1.5vh}
.logo-tubes{margin-bottom:10px;gap:9px}
.logo-tubes i{width:24px;height:70px;border-radius:0 0 12px 12px}
.logo-tubes i:nth-child(2),.logo-tubes i:nth-child(3){height:80px}
.logo h1 span{font-size:34px}.logo h1 b{font-size:54px}
.play-btn{margin-top:3vh}
.home-tiles{margin-top:16px}
.prof-stage{min-height:190px}
.prof-home{max-height:300px}
.prof-home .bubble{top:18px}

/* ---------- new coin asset (assets/coin.svg) ---------- */
.coin-ico{background:url("../assets/coin.svg") center/contain no-repeat;box-shadow:none;border-radius:0;filter:drop-shadow(0 2px 1px rgba(0,0,0,.25))}
.coin-ico::after{display:none}
.item .price .coin-ico{width:18px;height:18px}

/* ---------- pause menu: four quick toggles incl. language ---------- */
.quick-toggles{display:grid;grid-template-columns:repeat(4,1fr);gap:8px}
.qt{width:auto;min-width:0;padding:10px 2px;font-size:12px}
.qt span:last-child{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.flag-ic{width:40px;height:40px;border-radius:13px;display:grid;place-items:center;background:#fff;box-shadow:0 4px 0 #c3cde6,inset 0 0 0 2px #e3e9f8}
.flag{width:30px;height:20px;display:block;filter:drop-shadow(0 1px 1px rgba(0,0,0,.25))}
.qt-lang.bump .flag,.lang-cycle.bump .flag{animation:flagFlip .35s}
@keyframes flagFlip{50%{transform:rotateY(90deg) scale(1.15)}}
.lang-cycle{display:flex;align-items:center;gap:10px;width:100%;margin:14px 0 4px;padding:8px 12px;border-radius:16px;background:#fff;color:var(--ink);font-weight:700;font-size:17px;box-shadow:0 4px 0 #c3cde6}
.lang-cycle .lang-name{flex:1;text-align:left}
.lang-cycle .ic{color:#5a6aa0}
.lang-cycle:active{transform:translateY(3px);box-shadow:0 1px 0 #c3cde6}

/* ---------- keep Prof inside the screen on small phones ---------- */
.prof-home{left:0;right:0;width:100%}
.prof-home .prof-img{position:absolute;left:4px;bottom:0;height:100%}
.prof-home .bubble{left:auto;right:6px;top:10px;min-width:0;max-width:min(58%,230px)}
.card-prof-left{left:-12px}
.card-prof-right{right:-8px}
@media (max-width:360px){.card-prof-right{right:-2px;height:104px;top:-116px}.card-prof-left{left:-4px;height:100px;top:-66px}.prof-home .bubble{max-width:62%;font-size:14px}}

/* ======================================================================
   Illustrated lab backgrounds, bench and paper texture (assets/bg/)
   ====================================================================== */
.theme-lab{--art:url("../assets/bg/lab.jpg")}
.theme-clean{--art:url("../assets/bg/clean.jpg")}
.theme-mint{--art:url("../assets/bg/mint.jpg")}
.theme-midnight{--art:url("../assets/bg/midnight.jpg")}
.theme-sunset{--art:url("../assets/bg/sunset.jpg")}
.theme-space{--art:url("../assets/bg/space.jpg")}
/* the illustration fills the screen; a soft tint on top keeps tubes and text readable */
body::before{content:"";position:fixed;inset:0;z-index:0;pointer-events:none;
  background:linear-gradient(180deg,rgba(8,14,36,.55) 0%,rgba(8,14,36,.18) 22%,rgba(8,14,36,.12) 55%,rgba(8,14,36,.55) 100%),var(--art) center/cover no-repeat;
  transition:opacity .4s}
.theme-clean body::before,body.theme-clean::before{background:linear-gradient(180deg,rgba(255,255,255,.55) 0%,rgba(255,255,255,.2) 25%,rgba(255,255,255,.18) 60%,rgba(255,255,255,.55) 100%),var(--art) center/cover no-repeat}
.bg-bubbles{z-index:0;opacity:.6}
/* shop: theme previews show the real illustration */
.swatch{background:var(--art) center/cover no-repeat,var(--bg)}

/* paper grain on the comic panel, bubbles and cards */
.prof-game .bubble,.prof-home .bubble{background:linear-gradient(180deg,rgba(255,254,248,.92),rgba(243,240,226,.92)),url("../assets/bg/paper.jpg") center/256px repeat}
.card{background:linear-gradient(180deg,rgba(244,247,255,.93) 0%,rgba(223,231,251,.93) 100%),url("../assets/bg/paper.jpg") center/320px repeat}

/* overlays (pause, win, shop, settings…) cover the whole viewport, not just the 560 px game column –
   otherwise on wide screens only the middle got dimmed/blurred */
.overlay{position:fixed;inset:0}
#toast{position:fixed}

/* ---------- shop: Items tab (undo / hint / extra tube packs) ---------- */
.tabs .tab{padding:9px 4px;font-size:14px;gap:5px}
.item-pack{display:flex;flex-direction:column;align-items:center;gap:3px;padding:10px 4px 10px}
.item-pack .pack-ic{width:62px;height:62px;border-radius:20px;margin:2px auto 4px}
.item-pack .pack-ic .ic{width:32px;height:32px;stroke-width:2.6}
.item-pack .pack-ic em{position:absolute;top:-8px;right:-10px;min-width:30px;height:24px;padding:0 6px;border-radius:12px;font-style:normal;font-size:13px;font-weight:700;
  display:grid;place-items:center;background:var(--pink);color:#fff;box-shadow:0 2px 0 var(--pink-d),0 0 0 2px #fff}
.item-pack .owned{font-size:11px;font-weight:600;opacity:.65}

/* ---------- Settings: Prof toggle icon, colour-blind symbols in HTML dots ---------- */
.prof-mini{overflow:hidden}
.prof-mini img{width:44px;height:44px;object-fit:cover;object-position:50% 18%;margin-top:6px}
.dot{position:relative;display:inline-grid;place-items:center}
.dot .sym{width:72%;height:72%}
/* Prof. Fizz switched off: hide him everywhere, keep the goal panel as a plain banner */
.no-prof .prof-img,.no-prof .card-prof,.no-prof .mix-prof,.no-prof .prof-stage{display:none!important}
.no-prof .prof-panel{height:auto;min-height:52px;margin-top:10px}
.no-prof .prof-game{position:relative;height:auto}
.no-prof .prof-game .bubble{min-height:52px}
.no-prof .prof-game .bubble::before{display:none}

/* goal text slides away after RULES.ui.goalSeconds; speech or a tap on the prof brings the bubble back */
.prof-game .bubble{transition:opacity .35s ease,transform .35s ease}
.prof-game.idle-hidden:not(.speaking) .bubble{opacity:0;transform:translateX(-14px) scale(.92);pointer-events:none}

.credits{max-height:52vh;overflow:auto;text-align:left;font-size:14px;line-height:1.35}
.credits h3{font-size:16px;margin:10px 0 2px;color:var(--purple-d)}
.credits p{margin:2px 0}
#btn-credits{justify-content:center}
