:root{--blue:#2563eb;--blue2:#1d4ed8;--bg:#f3f6fb;--card:#fff;--text:#172033;--muted:#64748b;--line:#dbe3ef;--shadow:0 10px 28px rgba(30,64,175,.08)}
*{box-sizing:border-box}body{margin:0;font-family:system-ui,-apple-system,"Segoe UI",Roboto,"Noto Sans KR",sans-serif;background:var(--bg);color:var(--text)}
header{position:sticky;top:0;z-index:4;background:#fff;border-bottom:1px solid var(--line);padding:12px 16px;display:flex;justify-content:space-between;align-items:center;gap:10px}.brand{font-weight:900;font-size:19px}.brand span{color:var(--blue)}.headlink{font-size:12px;color:var(--blue);font-weight:800;text-decoration:none;white-space:nowrap}
main{max-width:780px;margin:auto;padding:16px 12px 30px}.intro{text-align:center;margin:8px 0 16px}.intro h1{font-size:clamp(25px,5vw,32px);margin:0;letter-spacing:-1px}.intro p{font-size:14px;color:var(--muted);margin:8px 0}
.stats{display:grid;grid-template-columns:repeat(4,1fr);gap:8px;margin-bottom:12px}.stat{background:#fff;border:1px solid var(--line);border-radius:14px;padding:10px 4px;text-align:center;box-shadow:var(--shadow)}.stat small{display:block;color:var(--muted);font-size:11px;margin-bottom:4px}.stat strong{font-size:clamp(16px,4vw,21px)}
.game{background:#fff;border:1px solid var(--line);border-radius:21px;padding:16px 10px;box-shadow:var(--shadow)}.msg{text-align:center;font-weight:800;min-height:24px;margin:0 0 5px}.sub{text-align:center;color:var(--muted);font-size:12px;min-height:18px;margin:0 0 12px}
.board{display:flex;justify-content:center;align-items:flex-end;gap:clamp(6px,2vw,14px);flex-wrap:wrap;min-height:220px;padding:8px 2px 16px}
.tube{width:clamp(42px,10.5vw,60px);height:clamp(165px,42vw,210px);max-height:210px;border:3px solid #b9c8dc;border-top:0;border-radius:0 0 18px 18px;background:linear-gradient(#eff6ff99,#dbeafe55);display:flex;flex-direction:column-reverse;align-items:center;justify-content:flex-start;padding:7px 4px 5px;gap:3px;cursor:pointer;position:relative;transition:.15s}.tube:before{content:"";position:absolute;top:0;left:-4px;right:-4px;height:7px;border:3px solid #b9c8dc;border-radius:8px;background:#fff}.tube.selected{border-color:var(--blue);transform:translateY(-8px);box-shadow:0 0 0 4px #dbeafe}.tube.selected:before{border-color:var(--blue)}
.ball{width:100%;flex:1;max-height:43px;min-height:10px;border-radius:50%;box-shadow:inset 0 3px 5px #ffffff70,inset 0 -4px 6px #0002;animation:pop .13s ease-out}@keyframes pop{from{transform:scale(.7)}to{transform:scale(1)}}
.controls{display:grid;grid-template-columns:repeat(3,1fr);gap:7px;margin-top:7px}.controls button,.nav button,.win button{font:inherit;font-weight:800;border:0;border-radius:12px;min-height:44px;padding:10px 6px;cursor:pointer}.blue{background:var(--blue);color:#fff}.blue:hover{background:var(--blue2)}.soft{background:#eef4ff;color:#1e40af;border:1px solid #d5e4ff!important}.plain{background:#fff;color:#334155;border:1px solid var(--line)!important}.controls button{font-size:13px}.nav{display:flex;gap:8px;margin-top:9px}.nav button{flex:1}.nav button:disabled{opacity:.4;cursor:not-allowed}
.optimal{display:flex;align-items:center;justify-content:space-between;gap:8px;background:#eff6ff;border:1px solid #dbeafe;color:#1e40af;border-radius:13px;padding:11px 12px;margin:12px 0 4px;font-size:13px}.optimal strong{font-size:18px}.optimal .right{text-align:right}.win{display:none;text-align:center;background:#ecfdf5;border:1px solid #a7f3d0;color:#065f46;border-radius:14px;padding:12px;margin-top:12px;font-weight:800}.win.show{display:block}.win button{width:100%;margin-top:8px;background:#059669;color:#fff}
.note{text-align:center;color:var(--muted);font-size:12px;line-height:1.65;margin:13px 3px 0}footer{text-align:center;color:#94a3b8;font-size:12px;padding:20px}
@media(max-width:420px){main{padding:12px 8px 26px}.game{padding:14px 6px}.board{gap:5px}.tube{width:clamp(38px,10vw,47px);height:clamp(155px,41vw,185px);padding:6px 3px 4px}.stat{padding:9px 2px}.stat small{font-size:10px}.controls button{font-size:12px;padding:9px 2px}.optimal{font-size:12px}}


/* Mobile-first usability refinements */
html{width:100%;min-height:100%;-webkit-text-size-adjust:100%;text-size-adjust:100%;overscroll-behavior-y:contain}
body{width:100%;min-height:100dvh;padding-bottom:env(safe-area-inset-bottom);touch-action:pan-y}
button,.tube,a{-webkit-tap-highlight-color:transparent;touch-action:manipulation}
button{user-select:none;-webkit-user-select:none}
header{padding-top:max(10px,env(safe-area-inset-top));}
main{width:100%;min-width:0}
.game{min-width:0;overflow:hidden}
.board{width:100%;gap:clamp(5px,1.8vw,13px);align-items:flex-end}
.tube{flex:0 0 clamp(40px,9.8vw,60px);touch-action:manipulation}
.ball{pointer-events:none}
.controls button,.nav button{min-height:48px}
@media(max-width:600px){
  main{padding:10px 8px 24px}
  .intro{margin:5px 0 12px}
  .intro p{font-size:13px}
  .stats{gap:5px;margin-bottom:9px}
  .stat{border-radius:12px;padding:8px 2px}
  .stat small{font-size:10px}
  .game{border-radius:18px;padding:13px 6px}
  .msg{font-size:15px;margin-bottom:4px}
  .sub{font-size:11px;margin-bottom:7px}
  .board{min-height:0;padding:8px 1px 14px;gap:clamp(4px,1.4vw,8px)}
  .tube{flex-basis:clamp(37px,9.6vw,54px);height:clamp(148px,39vh,205px);max-height:205px;border-width:2.5px;border-radius:0 0 15px 15px;padding:6px 3px 4px;gap:2px}
  .tube:before{left:-3px;right:-3px;border-width:2.5px;height:7px}
  .tube.selected{transform:translateY(-5px);box-shadow:0 0 0 3px #dbeafe}
  .ball{max-height:42px;min-height:9px}
  .optimal{padding:9px 10px;margin:9px 0 4px}
  .optimal strong{font-size:17px}
  .controls{gap:5px;margin-top:7px}
  .controls button{min-height:47px;font-size:12px;line-height:1.15}
  .nav{gap:5px;margin-top:7px}
  .nav button{min-height:48px;font-size:13px}
  .note{font-size:11px;margin-top:10px}
}
@media(max-width:360px){
  .brand{font-size:17px}
  .headlink{font-size:11px}
  .stats{grid-template-columns:repeat(2,1fr)}
  .stat strong{font-size:18px}
  .tube{flex-basis:clamp(36px,9.2vw,42px);height:150px}
  .controls{grid-template-columns:repeat(3,minmax(0,1fr))}
  .controls button{font-size:11px}
}
@media(orientation:landscape) and (max-height:520px) and (max-width:900px){
  header{padding:7px 12px}
  main{max-width:900px;padding:8px 10px 18px}
  .intro{margin:3px 0 8px}
  .intro h1{font-size:22px}
  .intro p{margin:4px 0;font-size:12px}
  .stats{margin-bottom:7px}
  .stat{padding:5px}
  .game{padding:9px}
  .msg{min-height:18px;font-size:13px}
  .sub{min-height:14px;font-size:10px;margin-bottom:4px}
  .board{min-height:0;padding:3px 0 8px;gap:8px}
  .tube{height:clamp(105px,42vh,170px);width:clamp(37px,7vw,52px);flex-basis:clamp(37px,7vw,52px)}
  .optimal{padding:6px 9px;margin:5px 0}
  .controls button,.nav button{min-height:38px;padding:7px}
  .note{margin-top:6px}
}


/* Shared fixed mini-game header matching the Baro 2048 reference */
.game-header{position:fixed!important;top:0;left:0;right:0;width:100%;height:84px;z-index:1000;background:rgba(255,255,255,.97);border-top:1px solid #f2dfe8;border-bottom:1px solid #e2e8f0;box-shadow:0 2px 10px rgba(15,23,42,.025);padding:0!important;display:block!important;backdrop-filter:blur(10px)}
.header-inner{height:100%;max-width:1180px;margin:0 auto;padding:0 22px;display:flex;align-items:center;justify-content:space-between;gap:16px}
.game-brand{display:flex;align-items:center;gap:12px;min-width:0}
.game-logo{width:51px;height:51px;flex:0 0 51px;border-radius:17px;background:linear-gradient(145deg,#6277ff,#4052e8);box-shadow:0 8px 18px rgba(69,87,235,.22);display:grid;grid-template-columns:repeat(2,1fr);grid-template-rows:repeat(2,1fr);place-items:center;padding:10px}
.game-logo span{display:block;width:9px;height:9px;border-radius:50%;background:#fff;box-shadow:0 0 0 2px rgba(255,255,255,.15)}
.brand-copy{min-width:0}.brand-title{font-size:21px;font-weight:900;letter-spacing:-.7px;line-height:1.15;white-space:nowrap;color:#182238}.brand-title strong{color:#4d63f5}.brand-subtitle{font-size:10px;font-weight:900;letter-spacing:1.7px;color:#94a3b8;margin-top:5px;white-space:nowrap}
.headlink{display:inline-flex;align-items:center;justify-content:center;min-height:47px;padding:0 16px;border-radius:14px;background:#eff4ff;border:1px solid #dce6ff;color:#3658e8;font-size:13px;font-weight:900;text-decoration:none;white-space:nowrap}
.headlink:hover{background:#e5edff}
body{padding-top:84px}
main{padding-top:16px}
@media(max-width:560px){
 .game-header{height:76px}
 .header-inner{padding:0 12px;gap:8px}
 .game-logo{width:44px;height:44px;flex-basis:44px;border-radius:14px;padding:8px}
 .game-logo span{width:8px;height:8px}
 .game-brand{gap:9px}
 .brand-title{font-size:17px;letter-spacing:-.5px}
 .brand-subtitle{font-size:8px;letter-spacing:1.15px;margin-top:4px}
 .headlink{min-height:42px;padding:0 10px;font-size:11px;border-radius:12px}
 body{padding-top:76px}
}
@media(max-width:360px){
 .header-inner{padding:0 8px}
 .game-logo{width:39px;height:39px;flex-basis:39px}
 .brand-title{font-size:15px}
 .brand-subtitle{font-size:7px;letter-spacing:.8px}
 .headlink{font-size:10px;padding:0 8px}
}
