* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #0b1b33; --panel: #12294a; --panel2: #1b3a63;
  --ink: #eaf4ff; --gold: #ffd43b; --muted: rgba(234,244,255,.62);
  --tw: 52px; --th: 168px;            /* tube box, recomputed by JS */
}

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background-color: #0b1b33;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='104' height='104' viewBox='0 0 104 104'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.05' stroke-width='2'%3E%3Cpath d='M20 8c6 8 10 13 10 18a10 10 0 0 1-20 0c0-5 4-10 10-18z'/%3E%3Ccircle cx='78' cy='26' r='11'/%3E%3Crect x='62' y='62' width='20' height='30' rx='9'/%3E%3Cpath d='M26 62h16v22a8 8 0 0 1-16 0z'/%3E%3Ccircle cx='52' cy='46' r='4'/%3E%3Ccircle cx='96' cy='84' r='5'/%3E%3Ccircle cx='8' cy='92' r='4'/%3E%3C/g%3E%3C/svg%3E"),
    radial-gradient(circle at 50% 6%, #1b4d84, #0b1b33 66%);
  font-family: -apple-system, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  user-select: none; -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

.hidden { display: none !important; }
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 10; }
#game.screen { justify-content: flex-start; }
.panel { text-align: center; padding: 26px; width: min(400px, 94vw); animation: pin .3s ease; }
@keyframes pin { from { transform: translateY(16px) scale(.97); opacity: 0; } }

.logoK { font-size: 54px; }
h1 { font-size: 42px; font-weight: 900; letter-spacing: 1px; line-height: 1; }
h1 span {
  display: block; font-size: 23px; letter-spacing: 6px;
  background: linear-gradient(135deg, #8ce9ff, #4dabf7, #ffd43b);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
h2 { font-size: 30px; font-weight: 900; letter-spacing: 2px; margin-bottom: 8px; }
.tag { color: var(--muted); font-weight: 600; margin: 10px 0 18px; }

button.big {
  display: block; width: 100%; margin: 10px 0; padding: 15px 0;
  font-size: 18px; font-weight: 900; letter-spacing: 1px;
  color: #04243f; background: linear-gradient(135deg, #a5e8ff, #4dabf7);
  border: none; border-radius: 16px; cursor: pointer;
  box-shadow: 0 5px 0 #1971c2, 0 10px 24px rgba(0,0,0,.42);
}
button.big small { display: block; font-size: 11px; font-weight: 700; opacity: .75; margin-top: 2px; }
button.big:active { transform: translateY(3px); box-shadow: 0 2px 0 #1971c2; }
button.big.share { color: #4a2c00; background: linear-gradient(135deg, #ffe07a, #ffd43b); box-shadow: 0 5px 0 #c77e0a, 0 10px 24px rgba(0,0,0,.4); }
button.big.share:active { box-shadow: 0 2px 0 #c77e0a; }
.ghost { display: inline-block; background: none; border: none; color: var(--muted); font-size: 14px; font-weight: 700; margin-top: 8px; text-decoration: none; padding: 14px 12px; cursor: pointer; }
.best { color: var(--gold); font-weight: 800; margin-top: 14px; min-height: 20px; }
.hint { color: var(--muted); font-size: 13px; font-weight: 600; }
.lvlBadge {
  display: inline-block; margin-bottom: 10px; padding: 5px 18px;
  font-size: 14px; font-weight: 900; letter-spacing: 2px; color: var(--gold);
  background: rgba(255,212,59,.14); border: 1px solid rgba(255,212,59,.4); border-radius: 20px;
}
#lvlMap { display: flex; gap: 8px; justify-content: center; margin: 2px 0 6px; }
.lvlChip {
  width: 52px; padding: 6px 0 5px; border-radius: 12px; text-align: center;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12);
}
.lvlChip b { display: block; font-size: 15px; font-weight: 900; }
.lvlChip span { display: block; font-size: 12px; min-height: 16px; color: var(--muted); font-weight: 800; }
.lvlChip.done { opacity: .45; }
.lvlChip.done b { color: #8ce99a; }
.lvlChip.cur { background: rgba(255,212,59,.16); border-color: rgba(255,212,59,.55); box-shadow: 0 0 14px rgba(255,212,59,.2); }
.lvlChip.cur b { color: var(--gold); }
.nextHint { color: var(--muted); font-size: 12px; font-weight: 700; margin-bottom: 6px; }

/* ================= top bar ================= */
#topBar {
  width: 100%; max-width: 560px;
  display: flex; align-items: center; gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) 12px 6px;
}
.lvlTag { font-size: 12px; font-weight: 800; letter-spacing: 2px; color: var(--muted); }
.lvlTag b { display: block; font-size: 22px; letter-spacing: 0; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.05; }
.lvlTag em { display: block; font-style: normal; font-size: 10px; font-weight: 800; letter-spacing: 1px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lvlTag em.near { color: #8ce99a; }

.tierBadge {
  display: inline-block; margin-bottom: 6px; padding: 3px 14px;
  font-size: 11px; font-weight: 900; letter-spacing: 2px;
  border-radius: 20px; border: 1px solid currentColor;
}
.streakWin {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,138,31,.16); border: 1px solid rgba(255,138,31,.5);
  color: #ff8a1f; font-weight: 900; font-size: 15px;
  padding: 5px 16px; border-radius: 20px; margin-bottom: 8px;
}
button.big.resume { color: #04243f; background: linear-gradient(135deg, #8ce99a, #3ec1ae); box-shadow: 0 5px 0 #1b8a6e, 0 10px 24px rgba(0,0,0,.4); }
button.big.resume:active { box-shadow: 0 2px 0 #1b8a6e; }
#topBar .spacer { flex: 1; }
.ico {
  position: relative; width: 46px; height: 46px; border-radius: 14px; border: none;
  background: rgba(255,255,255,.11); color: var(--ink);
  font-size: 18px; font-weight: 800; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s, background .15s;
}
.ico:active { transform: scale(.9); background: rgba(255,255,255,.2); }
.ico[disabled] { opacity: .32; }
.ico b { position: absolute; right: -3px; top: -4px; min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 9px; background: var(--gold); color: #3d2c00; font-size: 11px; font-weight: 900;
  display: flex; align-items: center; justify-content: center; }
#hud { width: 100%; max-width: 320px; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 2px 14px 0; }
.movesLbl { font-size: 13px; font-weight: 900; letter-spacing: 2px; color: var(--muted); }
.movesLbl b { color: var(--ink); font-variant-numeric: tabular-nums; }
#parBar { width: 100%; height: 11px; border-radius: 8px; background: rgba(0,0,0,.34); border: 2px solid rgba(255,255,255,.85); overflow: hidden; }
#parFill { height: 100%; width: 100%; border-radius: 6px; background: linear-gradient(90deg, #ffd426, #ff8a1f); transition: width .3s ease; }
#parFill.low { background: linear-gradient(90deg, #ff8a1f, #ff3b5c); }
#stars { display: flex; gap: 6px; margin-top: -1px; }
#stars i {
  font-style: normal; font-size: 21px; line-height: 1;
  color: #3d4d6b; text-shadow: 0 1px 0 rgba(0,0,0,.4);
  transition: color .25s, transform .25s, text-shadow .25s;
}
#stars i.on { color: #ffd426; text-shadow: 0 0 10px rgba(255,212,38,.75), 0 2px 0 #c78a10; }
#stars i.pop { animation: starPop .4s cubic-bezier(.3,1.6,.5,1); }
@keyframes starPop { 40% { transform: scale(1.45) rotate(-12deg); } }

/* ================= board ================= */
/* min-height:0 is load-bearing: without it this flex item refuses to shrink below
   its content, the board overflows the screen and the sizing maths reads a height
   that does not exist. */
#boardWrap { flex: 1 1 auto; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; padding: 12px 10px 6px; }
#bottomBar {
  flex: 0 0 auto; width: 100%; max-width: 560px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 4px 14px max(8px, env(safe-area-inset-bottom));
}
#board {
  display: flex; flex-direction: column; align-items: center;
  gap: calc(var(--th) * .10);
}
.trow { display: flex; align-items: flex-end; justify-content: center; gap: calc(var(--tw) * .30); }

.tube {
  position: relative;
  width: var(--tw); height: var(--th);
  cursor: pointer;
  transform: translate3d(0,0,0);
  transition: transform .2s cubic-bezier(.34,1.5,.64,1);
  will-change: transform;
  filter: drop-shadow(0 8px 10px rgba(0,0,0,.55));
}

/* the open rim: a machined collar that overhangs the glass on both sides */
.tube .rim {
  position: absolute; left: calc(var(--tw) * -.08); right: calc(var(--tw) * -.08);
  top: 0; height: calc(var(--tw) * .155);
  border-radius: calc(var(--tw) * .078);
  background: linear-gradient(180deg, #c3ccd9 0%, #98a2b1 40%, #626b7a 76%, #808a99 100%);
  box-shadow: 0 1px 2px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.45);
  z-index: 6; pointer-events: none;
}

/* thin borosilicate wall, straight sides, hemispherical base */
.tube .glass {
  position: absolute; left: 0; right: 0;
  top: calc(var(--tw) * .105); bottom: 0;
  border: max(1px, calc(var(--tw) * .028)) solid rgba(226,240,255,.30);
  border-top: none;
  border-radius: 0 0 calc(var(--tw) * .5) calc(var(--tw) * .5);
  background: linear-gradient(100deg, rgba(226,240,255,.09), rgba(226,240,255,.02) 46%, rgba(226,240,255,.07));
  overflow: hidden;
}

/* liquid: flat, clean, faintly translucent — the glass does the work, not the fill */
.tube .fill { position: absolute; inset: 0; z-index: 1; }
.seg {
  position: absolute; left: 0; right: 0;
  will-change: height, bottom;
  box-shadow: inset 0 0 0 999px rgba(0,0,0,0);   /* own stacking, keeps ::after crisp */
}
.seg::before {   /* barrel shading: the column is a cylinder seen from the side */
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(94deg,
    rgba(0,0,0,.26) 0%, rgba(0,0,0,.06) 13%,
    rgba(255,255,255,.16) 34%, rgba(255,255,255,.02) 56%,
    rgba(0,0,0,.10) 82%, rgba(0,0,0,.28) 100%);
}
/* the surface of the topmost band reads as an ellipse, seen slightly from above */
.seg.topSeg::after {
  content: ''; position: absolute; left: 0; right: 0;
  top: calc(var(--tw) * -.082); height: calc(var(--tw) * .164);
  border-radius: 50%;
  background: inherit;
  filter: brightness(1.3) saturate(1.04);
  box-shadow: inset 0 calc(var(--tw) * .03) 0 rgba(255,255,255,.28);
}

/* faint graduation marks etched across the wall */
.tube .marks {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background-image: repeating-linear-gradient(180deg,
    rgba(255,255,255,.10) 0 1px, rgba(255,255,255,0) 1px 12.5%);
  mask-image: linear-gradient(90deg, transparent 0, #000 14%, #000 62%, transparent 78%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14%, #000 62%, transparent 78%);
}

/* one long specular running the height of the tube, brightest where it is empty */
.tube .sheen {
  position: absolute; left: 15%; top: 3%; width: 7%; height: 88%;
  border-radius: 999px; z-index: 3; pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,.62), rgba(255,255,255,.16) 42%, rgba(255,255,255,.30));
}
.tube .glass::after {   /* thin bright catch-light hugging the right wall */
  content: ''; position: absolute; right: 11%; top: 6%; width: 4%; height: 80%;
  border-radius: 999px; z-index: 3; pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,.22), rgba(255,255,255,.05));
}

.tube.sel { transform: translate3d(0, calc(var(--th) * -.12), 0) scale(1.04); z-index: 6;
  filter: drop-shadow(0 8px 10px rgba(0,0,0,.55)) drop-shadow(0 0 10px rgba(141,233,255,.85)); }
.tube.sel .glass { border-color: rgba(190,240,255,.75); }
.tube.pouring { transition: transform .24s cubic-bezier(.4,.05,.25,1); z-index: 30; }
.tube.back { transition: transform .24s cubic-bezier(.34,1.3,.64,1); z-index: 30; }
.tube.nope { animation: nope .34s ease; }
@keyframes nope { 20% { transform: translateX(-6px) rotate(-3deg); } 50% { transform: translateX(6px) rotate(3deg); } 80% { transform: translateX(-3px); } }
.tube.done .glass { border-color: rgba(255,226,138,.85); }
.tube.done { filter: drop-shadow(0 8px 10px rgba(0,0,0,.5)) drop-shadow(0 0 12px rgba(255,212,59,.85)); }
.tube.justDone { animation: doneHop .5s cubic-bezier(.3,1.5,.5,1); }
@keyframes doneHop { 35% { transform: translateY(-14px) scale(1.06); } 70% { transform: translateY(0) scale(.98); } }
.tube .cap {
  position: absolute; left: 50%; top: calc(var(--th) * -.14); transform: translateX(-50%) scale(0);
  font-size: calc(var(--tw) * .44); filter: drop-shadow(0 2px 4px rgba(0,0,0,.5));
  pointer-events: none; z-index: 7;
}
.tube.done .cap { animation: capPop .45s cubic-bezier(.3,1.6,.5,1) forwards; }
@keyframes capPop { to { transform: translateX(-50%) scale(1); } }
.tube.hintFrom .glass { border-color: var(--gold); }
.tube.hintFrom { animation: hintGlow .6s ease infinite alternate; }
.tube.hintTo .glass { border-color: #8ce99a; }
.tube.hintTo { animation: hintGlow2 .6s ease infinite alternate; }
@keyframes hintGlow {
  from { filter: drop-shadow(0 8px 10px rgba(0,0,0,.5)); }
  to   { filter: drop-shadow(0 8px 10px rgba(0,0,0,.5)) drop-shadow(0 0 14px var(--gold)); } }
@keyframes hintGlow2 {
  from { filter: drop-shadow(0 8px 10px rgba(0,0,0,.5)); }
  to   { filter: drop-shadow(0 8px 10px rgba(0,0,0,.5)) drop-shadow(0 0 14px #8ce99a); } }

/* pouring stream */
#streamLayer { position: fixed; inset: 0; pointer-events: none; z-index: 28; }
.stream {
  position: absolute; width: 9px; margin-left: -4.5px; border-radius: 5px;
  box-shadow: 0 0 8px rgba(255,255,255,.28);
  transform-origin: 50% 0;
}
.stream::after { content: ''; position: absolute; left: -2px; right: -2px; bottom: -3px; height: 8px; border-radius: 50%; background: inherit; opacity: .85; }

#bigMsg {
  position: fixed; top: 20%; left: 50%; transform: translate(-50%, -50%);
  width: max-content; max-width: 88vw;
  font-size: min(38px, 8.5vw); font-weight: 900; font-style: italic; text-align: center; line-height: 1.05;
  text-shadow: 0 6px 20px rgba(0,0,0,.6); pointer-events: none; opacity: 0; z-index: 34;
}
#bigMsg.show { animation: bigPop 1s ease; }
@keyframes bigPop { 0% { transform: translate(-50%,-50%) scale(.3); opacity: 0; } 25% { transform: translate(-50%,-50%) scale(1.14); opacity: 1; } 80% { opacity: 1; } 100% { transform: translate(-50%,-50%) scale(1); opacity: 0; } }

#btnHint {
  display: flex; align-items: center; gap: 7px; min-height: 48px; padding: 0 20px;
  font-size: 16px; font-weight: 900; letter-spacing: .5px; color: #04243f;
  background: linear-gradient(135deg, #ffe07a, #ffd43b); border: none; border-radius: 26px; cursor: pointer;
  box-shadow: 0 4px 0 #c77e0a, 0 8px 18px rgba(0,0,0,.4);
}
#btnHint:active { transform: translateY(3px); box-shadow: 0 1px 0 #c77e0a; }
#btnHint b { font-size: 13px; font-weight: 900; background: rgba(4,36,63,.18); padding: 1px 8px; border-radius: 11px; }
#moveTag { font-size: 12px; font-weight: 800; letter-spacing: 1px; color: var(--muted); }

/* short phones: claw back every pixel of chrome so the tubes stay big */
@media (max-height: 700px) {
  #topBar { padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: 2px; gap: 6px; }
  .ico { width: 42px; height: 42px; border-radius: 12px; font-size: 16px; }
  .lvlTag { font-size: 11px; }
  .lvlTag b { font-size: 19px; }
  #hud { gap: 3px; }
  .movesLbl { font-size: 11px; }
  #parBar { height: 9px; }
  #stars i { font-size: 17px; }
  #boardWrap { padding: 6px 8px 4px; }
  #btnHint { min-height: 42px; font-size: 14px; padding: 0 16px; }
}

.coinWin {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,212,59,.15); border: 1px solid rgba(255,212,59,.4);
  color: var(--gold); font-weight: 900; font-size: 18px;
  padding: 6px 18px; border-radius: 20px; margin-bottom: 12px;
}
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 50; }

/* power-up modal (shared shape with the other SKG games) */
.puOv { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(4,14,28,.76); backdrop-filter: blur(3px); animation: puFade .2s ease; }
@keyframes puFade { from { opacity: 0; } }
.puCard { width: min(360px, 92vw); padding: 26px 22px; border-radius: 20px; text-align: center;
  background: var(--panel); border: 1px solid rgba(255,255,255,.12); box-shadow: 0 20px 60px rgba(0,0,0,.6);
  animation: pin .28s ease; }
.puCard .logoK { font-size: 46px; }
.puCard h2 { font-size: 24px; font-weight: 900; letter-spacing: 1px; margin: 4px 0 4px; }
.puCard p { color: var(--muted); font-size: 14px; font-weight: 600; margin-bottom: 14px; }
