
    @font-face { font-family:'Nunito'; src:url('fonts/Nunito.ttf') format('truetype'); font-weight:200 1000; font-display:swap; }

    :root {
      color-scheme: light dark;
      --bg: #f3f8fb;
      --bg-deep: #dcecf3;
      --surface: rgba(255,255,255,.84);
      --surface-solid: #ffffff;
      --text: #17333d;
      --muted: #54707a;
      --line: rgba(30,79,93,.17);
      --tube: rgba(255,255,255,.52);
      --tube-line: rgba(26,67,79,.48);
      --accent: #f05f44;
      --accent-2: #d84531;
      --teal: #168b91;
      --teal-dark: #0e6870;
      --gold: #f2b93f;
      --shadow: 0 18px 50px rgba(32,76,89,.14);
      --soft-shadow: 0 8px 20px rgba(32,76,89,.11);
      --focus: #113fa5;
      --glass-highlight: rgba(255,255,255,.74);
      --bubble: rgba(22,139,145,.10);
      --spark: rgba(255,255,255,.7);
      --pink: #ef7d9b;
      --sky: #75c9e8;
      --cheek: rgba(240,95,68,.34);
    }
    @media (prefers-color-scheme: dark) {
      :root {
        --bg: #10262e;
        --bg-deep: #0a1c22;
        --surface: rgba(27,55,64,.88);
        --surface-solid: #1a353e;
        --text: #edf8f8;
        --muted: #aac5ca;
        --line: rgba(207,239,241,.17);
        --tube: rgba(228,252,255,.08);
        --tube-line: rgba(221,249,251,.5);
        --accent: #ff775f;
        --accent-2: #f25d48;
        --teal: #41c1c3;
        --teal-dark: #9ee5e1;
        --gold: #ffd269;
        --shadow: 0 18px 50px rgba(0,0,0,.26);
        --soft-shadow: 0 8px 22px rgba(0,0,0,.2);
        --focus: #9dc4ff;
        --glass-highlight: rgba(235,253,255,.42);
        --bubble: rgba(65,193,195,.09);
        --spark: rgba(235,253,255,.74);
        --pink: #ff91ad;
        --sky: #76d7ee;
        --cheek: rgba(255,119,95,.36);
      }
    }
    * { box-sizing: border-box; }
    [hidden] { display: none !important; }
    html, body { min-height: 100%; }
    body {
      margin: 0;
      overflow-x: hidden;
      background:
        radial-gradient(circle at 12% 14%, rgba(22,139,145,.12), transparent 27rem),
        radial-gradient(circle at 90% 88%, rgba(240,95,68,.10), transparent 24rem),
        var(--bg);
      color: var(--text);
      font-family: 'Nunito', ui-rounded, system-ui, sans-serif;
      -webkit-tap-highlight-color: transparent;
    }
    button { font: inherit; color: inherit; }
    button:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
    /* ---- Ad banner: fixed bottom slot; layout reserves space so ads never cover gameplay ---- */
    .ad-banner { position: fixed; left: 0; right: 0; bottom: 0; height: 56px; display: flex; align-items: center; justify-content: center; z-index: 40; pointer-events: none; }
    .ad-banner[hidden] { display: none; }
    body.has-ads .app { padding-bottom: 64px; }
    .app {
      width: min(1060px, 100%);
      min-height: 100vh;
      margin: 0 auto;
      padding: max(18px, env(safe-area-inset-top)) clamp(14px, 3vw, 34px) max(22px, env(safe-area-inset-bottom));
      display: grid;
      grid-template-rows: auto auto 1fr auto;
      gap: 14px;
    }
    .topbar {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      align-items: center;
      gap: 12px;
    }
    .level-block { min-width: 0; }
    .level-label {
      display: flex;
      align-items: baseline;
      flex-wrap: wrap;
      gap: 9px;
    }
    .level-label strong {
      font-family: 'Baloo 2', ui-rounded, sans-serif;
      font-size: clamp(28px, 5vw, 42px);
      line-height: .95;
      letter-spacing: -.03em;
    }
    .level-label span { color: var(--muted); font-weight: 800; font-size: 13px; }
    .progress-track {
      width: min(330px, 100%);
      height: 7px;
      background: var(--line);
      border-radius: 10px;
      overflow: hidden;
      margin-top: 8px;
    }
    .progress-fill { height: 100%; width: 2.5%; background: var(--teal); border-radius: inherit; transition: width .35s ease; }
    .icon-actions { display: flex; gap: 8px; }
    .icon-btn, .tool-btn, .primary-btn, .secondary-btn, .level-chip {
      border: 0;
      cursor: pointer;
      transition: transform .14s ease, background .14s ease, opacity .14s ease;
    }
    .icon-btn:active, .tool-btn:active, .primary-btn:active, .secondary-btn:active, .level-chip:active { transform: translateY(2px); }
    .icon-btn {
      width: 45px; height: 45px;
      display: grid; place-items: center;
      border-radius: 50%;
      background: var(--surface);
      box-shadow: var(--soft-shadow);
      border: 1px solid var(--line);
    }
    .icon-btn svg, .tool-btn svg { width: 21px; height: 21px; stroke-width: 2.4; }
    .status-card {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      background: var(--surface);
      border: 1px solid var(--line);
      border-radius: 18px;
      box-shadow: var(--soft-shadow);
      overflow: hidden;
    }
    .stat { padding: 11px 14px; text-align: center; position: relative; }
    .stat + .stat::before { content: ''; position: absolute; left: 0; top: 25%; bottom: 25%; width: 1px; background: var(--line); }
    .stat b { display: block; font-family: 'Baloo 2', sans-serif; font-size: 23px; line-height: 1; }
    .stat small { color: var(--muted); font-weight: 800; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
    .stat.score b { color: var(--teal-dark); }
    .stat.score.bump b { animation: scoreBump .34s cubic-bezier(.2,1.8,.4,1); }
    @keyframes scoreBump { 50% { transform: scale(1.28) rotate(-3deg); } }

    .game-shell {
      min-height: 410px;
      display: grid;
      place-items: center;
      padding: clamp(16px, 4vw, 34px) 4px;
      position: relative;
      isolation: isolate;
    }
    .game-shell::before, .game-shell::after {
      content: '';
      position: absolute;
      z-index: -1;
      border-radius: 50%;
      border: 1px solid var(--bubble);
      box-shadow: inset 0 0 22px var(--bubble);
      pointer-events: none;
    }
    .game-shell::before { width: 94px; height: 94px; left: 3%; top: 12%; }
    .game-shell::after { width: 52px; height: 52px; right: 8%; bottom: 13%; }
    .sea-doodles { position:absolute; inset:0; z-index:-1; pointer-events:none; overflow:hidden; }
    .sea-doodles i { position:absolute; display:block; border:2px solid var(--bubble); border-radius:50%; }
    .sea-doodles i:nth-child(1){width:18px;height:18px;left:15%;bottom:14%;animation:bobble 3.2s ease-in-out infinite alternate;}
    .sea-doodles i:nth-child(2){width:10px;height:10px;left:20%;bottom:20%;animation:bobble 2.4s .3s ease-in-out infinite alternate;}
    .sea-doodles i:nth-child(3){width:24px;height:24px;right:19%;top:15%;animation:bobble 3.8s .7s ease-in-out infinite alternate;}
    .sea-doodles i:nth-child(4){width:8px;height:8px;right:15%;top:24%;animation:bobble 2.1s .15s ease-in-out infinite alternate;}
    @keyframes bobble { to { transform:translateY(-9px) scale(.92); opacity:.45; } }
    .board-fx { position:absolute; inset:0; pointer-events:none; overflow:visible; z-index:8; }
    .pour-stream {
      position: fixed;
      z-index: 25;
      height: 10px;
      border-radius: 999px;
      transform-origin: 0 50%;
      background: linear-gradient(180deg, color-mix(in srgb, var(--c) 72%, white), var(--c) 48%, color-mix(in srgb, var(--c) 78%, black));
      box-shadow: 0 2px 6px color-mix(in srgb, var(--c) 45%, transparent), inset 0 2px 2px rgba(255,255,255,.5);
      animation: streamIn .66s ease both;
      pointer-events:none;
    }
    .pour-drop { position:fixed; z-index:26; width:12px; height:12px; border-radius:50% 50% 50% 8%; background:var(--c); transform:rotate(-45deg); animation:dropPop .46s ease both; pointer-events:none; }
    @keyframes streamIn { 0%,100%{opacity:0;clip-path:inset(0 100% 0 0)} 18%,78%{opacity:1;clip-path:inset(0 0 0 0)} }
    @keyframes dropPop { 0%,100%{opacity:0;transform:translateY(-9px) rotate(-45deg) scale(.5)} 40%{opacity:1;transform:translateY(3px) rotate(-45deg) scale(1)} }
    .combo-pop { position:fixed; z-index:27; color:var(--teal-dark); font-family:'Baloo 2',sans-serif; font-size:24px; font-weight:800; text-shadow:0 2px 0 var(--surface-solid); pointer-events:none; animation:comboFloat .7s ease-out forwards; }
    @keyframes comboFloat { to { transform:translateY(-42px) scale(1.12); opacity:0; } }
    .board {
      width: 100%;
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      align-content: center;
      gap: clamp(18px, 4vw, 38px) clamp(14px, 3.2vw, 30px);
      perspective: 900px;
    }
    .tube-wrap {
      width: clamp(54px, 9vw, 76px);
      height: clamp(178px, 25vw, 224px);
      display: grid;
      place-items: end center;
      border: 0;
      background: transparent;
      padding: 0;
      position: relative;
      cursor: pointer;
      touch-action: manipulation;
      --lift: 0px;
      transform: translateY(var(--lift));
      transition: transform .18s cubic-bezier(.2,.8,.2,1), filter .18s ease;
    }
    .tube-wrap:hover { filter: brightness(1.04); }
    .tube-wrap.selected { --lift: -15px; filter: drop-shadow(0 12px 10px rgba(22,139,145,.18)); }
    .tube-wrap.pouring { animation: tipTube .68s cubic-bezier(.3,.7,.25,1); z-index: 12; transform-origin:var(--pivot-x, 70%) 82%; }
    .tube-wrap.pouring .liquid { animation: liquidSwish .68s ease; }
    .tube-wrap.invalid { animation: shake .32s ease; }
    .tube-wrap.celebrate { animation: happy .6s ease; }
    @keyframes shake { 25%{transform:translateX(-7px)} 50%{transform:translateX(7px)} 75%{transform:translateX(-4px)} }
    @keyframes happy { 40%{transform:translateY(-18px) rotate(-3deg)} 70%{transform:translateY(-7px) rotate(2deg)} }
    @keyframes tipTube {
      0%{transform:translateY(-15px) translateX(0) rotate(0)}
      28%,72%{transform:translateY(-30px) translateX(var(--pour-shift, 0px)) rotate(var(--tip, 58deg))}
      100%{transform:translateY(-15px) translateX(0) rotate(0)}
    }
    @keyframes liquidSwish { 35%{filter:saturate(1.12) brightness(1.08)} 72%{filter:saturate(1.18)} }
    .tube {
      width: 100%;
      height: calc(100% - 10px);
      border: 4px solid var(--tube-line);
      border-top: 0;
      border-radius: 7px 7px 28px 28px;
      background: linear-gradient(90deg, var(--glass-highlight), var(--tube) 24%, var(--tube) 72%, rgba(8,37,44,.08));
      box-shadow: inset 8px 0 12px rgba(255,255,255,.2), inset -7px 0 12px rgba(8,37,44,.08), 0 12px 18px rgba(10,52,61,.14), 0 2px 0 var(--glass-highlight);
      overflow: hidden;
      display: flex;
      flex-direction: column-reverse;
      position: relative;
    }
    .tube::before, .tube::after {
      content: '';
      position: absolute;
      top: -1px;
      height: 4px;
      width: 11px;
      background: var(--tube-line);
      z-index: 6;
    }
    .tube::before { left: -2px; border-radius: 4px 0 0 4px; }
    .tube::after { right: -2px; border-radius: 0 4px 4px 0; }
    .shine { position: absolute; z-index: 5; left: 8px; top: 13px; bottom: 25px; width: 5px; border-radius: 8px; background: linear-gradient(rgba(255,255,255,.5), rgba(255,255,255,.08)); pointer-events: none; }
    .glass-bubbles { position:absolute; inset:8px 4px 12px; z-index:5; overflow:hidden; pointer-events:none; }
    .glass-bubbles i { position:absolute; bottom:-12px; border:1.5px solid rgba(255,255,255,.58); border-radius:50%; opacity:0; animation:tinyBubble 3.4s ease-in infinite; }
    .glass-bubbles i:nth-child(1){width:7px;height:7px;left:24%;animation-delay:.4s;}
    .glass-bubbles i:nth-child(2){width:4px;height:4px;right:26%;animation-delay:1.8s;animation-duration:2.7s;}
    @keyframes tinyBubble { 8%{opacity:.68} 80%{opacity:.4} 100%{transform:translateY(-118px) translateX(6px);opacity:0} }
    .tube-face { position:absolute; z-index:7; left:50%; bottom:29px; width:27px; height:17px; transform:translateX(-50%); opacity:0; transition:opacity .2s ease, transform .2s ease; pointer-events:none; }
    .tube-wrap.complete .tube-face { opacity:.92; transform:translateX(-50%) scale(1); }
    .tube-face::before, .tube-face::after { content:''; position:absolute; top:1px; width:5px; height:7px; border-radius:50%; background:rgba(18,57,65,.76); box-shadow:0 0 0 2px rgba(255,255,255,.2); }
    .tube-face::before { left:3px; } .tube-face::after { right:3px; }
    .tube-face i { position:absolute; left:50%; bottom:0; width:9px; height:5px; transform:translateX(-50%); border-bottom:2px solid rgba(18,57,65,.76); border-radius:0 0 9px 9px; }
    .tube-face i::before, .tube-face i::after { content:''; position:absolute; bottom:3px; width:5px; height:3px; border-radius:50%; background:var(--cheek); }
    .tube-face i::before { right:10px; } .tube-face i::after { left:10px; }
    .liquid {
      height: 25%;
      flex: 0 0 25%;
      background: linear-gradient(90deg, color-mix(in srgb, var(--c) 84%, white), var(--c) 42%, color-mix(in srgb, var(--c) 84%, black));
      position: relative;
      box-shadow: inset 0 4px 0 rgba(255,255,255,.2), inset 0 -3px 0 rgba(0,0,0,.08);
      transition: transform .25s ease, height .25s ease;
    }
    .liquid::before { content:''; position:absolute; left:8%; right:8%; top:3px; height:4px; border-radius:50%; background:rgba(255,255,255,.27); }
    .liquid::after { content:''; position:absolute; width:5px; height:5px; right:16%; top:30%; border:1px solid rgba(255,255,255,.42); border-radius:50%; }
    .liquid:last-of-type { border-radius: 9px 9px 0 0; animation:surfaceRipple 2.4s ease-in-out infinite alternate; }
    @keyframes surfaceRipple { to { border-radius: 38% 62% 0 0; } }
    .tube-index {
      position: absolute;
      bottom: -21px;
      color: var(--muted);
      font-weight: 800;
      font-size: 11px;
      opacity: .72;
    }
    .hint-ring::after {
      content: '';
      position: absolute;
      inset: -8px -7px -8px -7px;
      border: 3px dashed var(--gold);
      border-radius: 20px 20px 35px 35px;
      animation: hintPulse .85s ease-in-out infinite alternate;
    }
    @keyframes hintPulse { to { transform: scale(1.05); opacity: .55; } }

    .tools {
      display: flex;
      justify-content: center;
      flex-wrap: wrap;
      gap: 9px;
    }
    .tool-btn {
      min-height: 46px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      padding: 0 17px;
      border-radius: 14px;
      background: var(--surface);
      border: 1px solid var(--line);
      box-shadow: var(--soft-shadow);
      font-weight: 800;
    }
    .tool-btn:disabled { opacity: .42; cursor: default; transform: none; }
    .tool-btn.primary-tool { background: var(--teal); color: #fff; border-color: transparent; }
    @media (prefers-color-scheme: dark) { .tool-btn.primary-tool { color: #072d31; } }

    .scrim {
      position: fixed;
      inset: 0;
      z-index: 20;
      display: grid;
      place-items: center;
      padding: 20px;
      background: rgba(7,26,31,.62);
      backdrop-filter: blur(7px);
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
      transition: opacity .18s ease, visibility 0s linear .18s;
    }
    .scrim.open { opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s; }
    .modal {
      width: min(470px, 100%);
      max-height: min(760px, 88vh);
      overflow: auto;
      background: var(--surface-solid);
      border-radius: 26px;
      padding: clamp(22px, 5vw, 34px);
      box-shadow: 0 25px 70px rgba(0,0,0,.3);
      transform: translateY(12px) scale(.98);
      transition: transform .18s ease;
    }
    .scrim.open .modal { transform: none; }
    .modal h2 { font-family: 'Baloo 2', sans-serif; margin: 0; font-size: 34px; line-height: 1; letter-spacing: -.02em; }
    .modal p { color: var(--muted); line-height: 1.55; margin: 8px 0 22px; }
    .modal-actions { display: grid; gap: 10px; margin-top: 22px; }
    .primary-btn, .secondary-btn {
      min-height: 52px;
      border-radius: 15px;
      font-weight: 900;
      font-size: 16px;
      padding: 0 20px;
    }
    .primary-btn { color: #fff; background: var(--accent); box-shadow: 0 9px 0 var(--accent-2); margin-bottom: 7px; }
    .primary-btn:active { transform: translateY(5px); box-shadow: 0 4px 0 var(--accent-2); }
    .secondary-btn { background: var(--bg-deep); border: 1px solid var(--line); }
    .stars { display: flex; justify-content: center; gap: 8px; margin: 8px 0 14px; }
    .star { width: 50px; color: var(--line); transform: rotate(-7deg); }
    .star:nth-child(2) { width: 63px; transform: translateY(-8px); }
    .star:nth-child(3) { transform: rotate(7deg); }
    .star.earned { color: var(--gold); filter: drop-shadow(0 5px 4px rgba(172,112,0,.18)); animation: pop .45s cubic-bezier(.2,1.8,.4,1) backwards; }
    .star.earned:nth-child(2) { animation-delay: .12s; }
    .star.earned:nth-child(3) { animation-delay: .24s; }
    @keyframes pop { from { opacity:0; transform:scale(.2) rotate(-20deg); } }
    .win-stats { display: flex; justify-content: center; gap: 28px; text-align: center; }
    .win-stats b { font-family:'Baloo 2',sans-serif; font-size: 25px; display:block; line-height:1; }
    .win-stats small { color:var(--muted); font-weight:800; }
    .level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 9px; margin-top: 20px; }
    .level-chip { aspect-ratio: 1; border-radius: 13px; background: var(--bg-deep); border: 1px solid var(--line); font-weight: 900; position: relative; }
    .level-chip.active { background: var(--teal); color: #fff; border-color: transparent; }
    .level-chip .mini-star { position:absolute; right:3px; bottom:2px; color:var(--gold); font-size:10px; }
    .modal-head { display:flex; justify-content:space-between; align-items:center; gap:15px; }
    .modal-head .icon-btn { box-shadow:none; flex:0 0 auto; }
    .how-list { padding: 0; margin: 18px 0 0; list-style: none; display: grid; gap: 14px; }
    .how-list li { display:grid; grid-template-columns: 36px 1fr; gap:12px; align-items:start; line-height:1.42; }
    .how-list b { width:34px; height:34px; display:grid; place-items:center; border-radius:50%; background:var(--bg-deep); color:var(--teal-dark); font-family:'Baloo 2'; }
    .toast {
      position: fixed;
      z-index: 30;
      left: 50%; bottom: max(22px, env(safe-area-inset-bottom));
      transform: translate(-50%, 18px);
      background: var(--text); color: var(--bg);
      padding: 10px 16px;
      border-radius: 99px;
      font-weight: 800;
      opacity: 0; pointer-events:none;
      transition: opacity .2s ease, transform .2s ease;
      text-align:center;
      max-width: calc(100% - 30px);
    }
    .toast.show { opacity:1; transform:translate(-50%,0); }
    .confetti { position:fixed; inset:0; z-index:19; pointer-events:none; overflow:hidden; }
    .confetti i { position:absolute; top:-18px; width:10px; height:18px; background:var(--c); animation: fall var(--d) linear forwards; transform:rotate(var(--r)); }
    @keyframes fall { to { transform:translate(var(--x),110vh) rotate(720deg); } }

    @media (max-width: 580px) {
      .app { gap: 11px; }
      .stat { padding: 9px 6px; }
      .stat b { font-size: 20px; }
      .stat small { font-size: 9px; letter-spacing: .05em; }
      .game-shell { min-height: 390px; padding: 12px 0 20px; }
      .board { gap: 23px 15px; }
      .tube-wrap { width: min(15vw, 62px); height: min(42vw, 190px); }
      .tools { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); }
      .tool-btn { padding:0 9px; font-size:13px; }
      .level-grid { grid-template-columns:repeat(5,1fr); gap:7px; }
    }
    @media (max-width: 370px) {
      .tool-btn span { display:none; }
      .tube-wrap { width: 15vw; height: 43vw; }
      .board { column-gap: 12px; }
    }
    @media (prefers-reduced-motion: reduce) {
      *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
    }
  
