@font-face { font-family: 'Cairo'; src: url('../fonts/cairo.woff2') format('woff2'); font-weight: 200 900; font-display: swap; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1d3a44; font-family: 'Cairo', system-ui, sans-serif; color: #fff; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
#app { position: fixed; inset: 0; max-width: 520px; margin: 0 auto; overflow: hidden; }
.screen { position: absolute; inset: 0; display: none; flex-direction: column; }
.screen.show { display: flex; }
.bg { position: absolute; inset: 0; background-size: cover; background-position: center; z-index: 0; }
.bg-home { background-image: linear-gradient(180deg, rgba(255,248,232,.30), rgba(250,236,208,.45)), url('../img/bg-home.webp'); }
.bg-game { background-image: linear-gradient(180deg, rgba(20,40,50,.18), rgba(30,22,10,.40)), url('../img/bg-game.webp'); }
.screen > *:not(.bg) { position: relative; z-index: 1; }

.glass {
  background: linear-gradient(180deg, rgba(255,255,255,.26) 0%, rgba(255,255,255,.06) 40%, rgba(255,255,255,0) 60%), rgba(52,30,10,.46);
  -webkit-backdrop-filter: blur(16px) saturate(1.4); backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid rgba(255,255,255,.38);
  box-shadow: inset 0 1.5px 0 rgba(255,255,255,.55), 0 8px 20px rgba(20,10,0,.30);
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
}

/* ---------- home ---------- */
.home-box { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; padding: 24px; }
.logo { text-align: center; }
.logo-jar { width: 92px; height: 92px; color: #fff3cf; filter: drop-shadow(0 4px 8px rgba(40,20,0,.45)); }
.logo h1 { margin: 2px 0 0; font-size: 46px; line-height: 1.05; font-weight: 900; color: #fff6dc; text-shadow: 0 3px 0 #8a5a14, 0 6px 14px rgba(40,20,0,.5); }
.logo p { margin: 8px 0 0; font-size: 17px; font-weight: 800; color: #3d2208; text-shadow: 0 1px 0 rgba(255,255,255,.6); }
.btn-play {
  display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 240px; height: 82px; border-radius: 26px; padding: 0 28px;
  font-size: 28px; font-weight: 900; line-height: 1.1; color: #fff; text-shadow: 0 2px 2px rgba(0,0,0,.35);
  border: 3px solid #ffe6a0; background: linear-gradient(180deg, #8fe87e, #3fae4c 60%, #2b8a37);
  box-shadow: 0 6px 0 #1d6a26, 0 14px 22px rgba(20,60,20,.35), inset 0 2px 0 rgba(255,255,255,.55);
}
.btn-play small { font-size: 15px; font-weight: 800; opacity: .92; }
.btn-play.small { height: 60px; min-width: 200px; font-size: 22px; }
.btn-play:active { transform: translateY(3px); box-shadow: 0 3px 0 #1d6a26, inset 0 2px 0 rgba(255,255,255,.55); }
.home-row { display: flex; gap: 12px; }
.pill-btn { display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 16px; border-radius: 18px; font-size: 16px; font-weight: 800; }
.pill-btn svg, .tool svg, .round-btn svg { width: 24px; height: 24px; }

/* ---------- game bar ---------- */
.bar { flex: none; display: flex; align-items: center; justify-content: space-between; padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 4px; }
.round-btn {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; color: #fff3cf;
  background: linear-gradient(180deg, #b1743a, #6b3c1a); border: 2px solid #e6b877;
  box-shadow: 0 3px 0 #3f2310, inset 0 2px 0 rgba(255,255,255,.35);
}
.round-btn.on { background: linear-gradient(180deg, #8fe87e, #2b8a37); border-color: #ffe6a0; color: #fff; }
.round-btn:active { transform: translateY(2px); }
.bar-title { text-align: center; display: flex; flex-direction: column; line-height: 1.1; }
.bar-title strong { font-size: 24px; font-weight: 900; text-shadow: 0 2px 2px rgba(0,0,0,.5); }
.bar-title small { font-size: 14px; font-weight: 700; color: #ffe9a8; text-shadow: 0 1px 2px rgba(0,0,0,.5); }

/* ---------- board ---------- */
#board { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: var(--rowgap, 22px); padding: 8px 10px; position: relative; }
.row { display: flex; justify-content: center; gap: var(--gap, 12px); }
.tube {
  position: relative; flex: none; width: var(--tw); height: calc(var(--sh) * 4 + 18px);
  border-radius: 10px 10px calc(var(--tw) / 2) calc(var(--tw) / 2);
  background: linear-gradient(90deg, rgba(255,255,255,.30) 0%, rgba(255,255,255,.08) 22%, rgba(255,255,255,.04) 70%, rgba(255,255,255,.18) 100%), rgba(215,240,245,.14);
  border: 2.5px solid rgba(255,255,255,.62); border-top-color: rgba(255,255,255,.4);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12), inset 0 -6px 10px rgba(0,0,0,.14), 0 8px 12px rgba(10,20,25,.30);
  transition: transform .18s ease; transform-origin: 50% 50%;
  display: flex; flex-direction: column-reverse; padding: 3px 3px 5px; overflow: visible;
}
.tube::before { /* gold rim */
  content: ''; position: absolute; left: -5px; right: -5px; top: -7px; height: 13px; border-radius: 7px;
  background: linear-gradient(180deg, #fff1bd, #f2c25a 55%, #b9801f); border: 1px solid #8a5a14; box-shadow: 0 2px 3px rgba(0,0,0,.35);
}
.tube::after { /* glass highlight */
  content: ''; position: absolute; left: 14%; top: 14px; bottom: 16px; width: 12%; border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,.55), rgba(255,255,255,.08)); pointer-events: none; z-index: 4;
}
.tube.sel { transform: translateY(-16px); }
.tube.done { box-shadow: inset 0 0 0 1px rgba(255,255,255,.12), 0 0 0 3px rgba(255,214,110,.85), 0 0 18px rgba(255,214,110,.7), 0 8px 12px rgba(10,20,25,.3); }
.tube.hint { animation: hintPulse .6s ease-in-out 3; }
@keyframes hintPulse { 50% { box-shadow: 0 0 0 4px #fff, 0 0 22px 6px rgba(255,255,255,.8); } }
.tube.moving { z-index: 20; transition: none; }
.seg {
  flex: 0 0 var(--sh); width: 100%; position: relative; overflow: hidden; border-radius: 3px; transition: flex-basis .28s ease;
  background-image: linear-gradient(90deg, rgba(255,255,255,.42) 0%, rgba(255,255,255,0) 32%, rgba(0,0,0,.22) 100%), linear-gradient(180deg, rgba(255,255,255,.18), rgba(0,0,0,0) 40%);
  background-color: var(--c);
}
.seg:first-child { border-radius: 3px 3px calc(var(--tw) / 2 - 4px) calc(var(--tw) / 2 - 4px); }
.seg.gone { flex-basis: 0; }
.seg.grow { flex-basis: 0; }
.seg.surf::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 22%; background: rgba(255,255,255,.28); }
.seg svg { position: absolute; left: 50%; top: 50%; width: 52%; height: 52%; transform: translate(-50%, -50%); color: rgba(255,255,255,.88); filter: drop-shadow(0 1px 1px rgba(0,0,0,.45)); display: none; }
#board.symbols .seg svg { display: block; }
.stream { position: absolute; width: 7px; border-radius: 4px; z-index: 30; pointer-events: none; transform-origin: 50% 0; }

/* ---------- tools ---------- */
.tools { flex: none; display: flex; gap: 8px; padding: 8px 10px calc(env(safe-area-inset-bottom, 0px) + 12px); }
.tool { position: relative; flex: 1; height: 68px; border-radius: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 14px; font-weight: 800; color: #fff; }
.tool:active { transform: translateY(2px); }
.tool[disabled] { opacity: .45; }
.tool b { position: absolute; top: -7px; right: -2px; min-width: 24px; height: 24px; border-radius: 12px; display: grid; place-items: center; font-size: 13px; line-height: 1; background: #d9532e; border: 2px solid #fff3d0; text-shadow: none; }

/* ---------- modals / misc ---------- */
.modal { position: absolute; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center; background: rgba(15,10,5,.45); padding: 24px; }
.modal.show { display: flex; }
.card { width: 100%; max-width: 360px; border-radius: 28px; padding: 24px 22px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.card h2 { margin: 0; font-size: 28px; font-weight: 900; }
.card p { margin: 0; font-size: 17px; font-weight: 700; color: #ffe9a8; }
.card ol { margin: 0; padding: 0 0 0 22px; text-align: start; font-size: 17px; font-weight: 700; line-height: 1.5; }
.stars { display: flex; gap: 8px; }
.stars svg { width: 52px; height: 52px; }
.link { font-size: 17px; font-weight: 800; color: #ffe9a8; padding: 8px 14px; }
.toast { position: absolute; left: 50%; top: 82px; transform: translate(-50%, -8px); padding: 10px 18px; border-radius: 16px; background: rgba(40,24,8,.92); border: 1px solid rgba(255,225,160,.5); font-size: 16px; font-weight: 800; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.fx { position: absolute; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.conf { position: absolute; width: 10px; height: 14px; border-radius: 2px; will-change: transform; }
