html, body { margin: 0; padding: 0; width: 100%; height: 100%; background: #000; overflow: hidden; touch-action: none; overscroll-behavior: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#hud { position: fixed; top: 8px; left: 8px; color: #9aa; font: 12px/1.5 monospace; pointer-events: none; white-space: pre; text-shadow: 0 1px 2px #000; z-index: 2; }
#err { position: fixed; bottom: 0; left: 0; right: 0; color: #f66; background: rgba(0,0,0,.85); font: 12px/1.4 monospace; padding: 6px 8px; white-space: pre-wrap; display: none; z-index: 3; }
#hint { position: fixed; left: 50%; top: 38%; transform: translate(-50%, -50%); width: max-content; max-width: 90vw; z-index: 2; pointer-events: none; text-align: center; white-space: pre-line; color: #fff; font: bold 22px/1.5 system-ui, sans-serif; text-shadow: 0 2px 8px rgba(0,0,0,.8); opacity: 0; transition: opacity 0.4s; }
#hint.visible { opacity: 1; }
#hintHand { width: 88px; height: 99px; display: block; margin: 0 auto 10px; overflow: visible; filter: drop-shadow(0 4px 8px rgba(0,0,0,.7)); animation: hint-drag 2.2s ease-in-out infinite; }
#hintHandShape { fill: #fff; }
#hintRing { fill: none; stroke: #ffd94a; stroke-width: 3; animation: hint-ring 1.1s ease-out infinite; }
@keyframes hint-drag { 0%, 100% { transform: translateX(-46px); } 50% { transform: translateX(46px); } }
@keyframes hint-ring { 0% { r: 6; opacity: 0.95; } 100% { r: 16; opacity: 0; } }
/* ---- lose screen ---- */
#lose { position: fixed; inset: 0; z-index: 5; display: none; align-items: center; justify-content: center; background: rgba(12, 4, 20, 0.55); font-family: system-ui, sans-serif; }
#lose.visible { display: flex; }
.lose-panel { position: relative; width: min(330px, 86vw); padding: 26px 20px 30px; border-radius: 26px; text-align: center;
  background:
    url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='90'%20height='90'%3E%3Cg%20fill='none'%20stroke='%23ffffff'%20stroke-width='2'%20opacity='.05'%20stroke-linecap='round'%3E%3Ccircle%20cx='18'%20cy='20'%20r='7'/%3E%3Cpath%20d='M60%2012%20l10%2010%20M70%2012%20l-10%2010'/%3E%3Cpath%20d='M14%2066%20q8%20-10%2016%200%20t16%200'/%3E%3Ccircle%20cx='70'%20cy='64'%20r='4'/%3E%3C/g%3E%3C/svg%3E"),
    linear-gradient(160deg, #4b2158 0%, #6d2260 55%, #a02455 100%);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  animation: lose-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes lose-pop { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.lose-stars { display: flex; justify-content: center; align-items: flex-end; gap: 6px; margin-top: -56px; }
.lose-star { width: 58px; height: 58px; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.45)); }
.lose-star-big { width: 76px; height: 76px; margin-bottom: 10px; }
.lose-ribbon { position: relative; width: 78%; margin: -14px auto 0; z-index: 1; }
.lose-ribbon::before, .lose-ribbon::after { content: ''; position: absolute; top: 9px; width: 34px; height: 82%; background: #b3271b; z-index: -1; }
.lose-ribbon::before { left: -20px; clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 12px 50%); border-radius: 6px 0 0 6px; }
.lose-ribbon::after { right: -20px; clip-path: polygon(0 0, 100% 0, calc(100% - 12px) 50%, 100% 100%, 0 100%); border-radius: 0 6px 6px 0; }
.lose-ribbon span { display: block; padding: 10px 6px 12px; border-radius: 12px; background: linear-gradient(#f8604a, #dd3526);
  color: #fff; font-size: 23px; font-weight: 800; letter-spacing: 0.5px; text-shadow: 0 2px 3px rgba(120, 15, 5, 0.6);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.lose-score-label { margin-top: 20px; color: #fff; font-size: 19px; font-weight: 700; text-shadow: 0 2px 3px rgba(0, 0, 0, 0.4); }
.lose-score { margin-top: 2px; color: #f9b234; font-size: 30px; font-weight: 800; text-shadow: 0 2px 0 #7c4a08, 0 4px 6px rgba(0, 0, 0, 0.4); }
.lose-ball { position: relative; width: 130px; height: 132px; margin: 22px auto 0; }
.lose-ball-shadow { position: absolute; left: 26px; top: 14px; width: 118px; height: 118px; border-radius: 50%; background: rgba(30, 6, 40, 0.45); filter: blur(2px); }
.lose-ball-img { position: absolute; inset: 0; background: url('Img/balls.png') no-repeat; background-size: 310px 339.4px; background-position: -170.2px -10.3px; }
.lose-btn { display: block; margin: 30px auto 0; min-width: 140px; padding: 12px 30px; border: 0; border-radius: 999px; cursor: pointer;
  background: linear-gradient(#9be93d, #58bb18); box-shadow: 0 5px 0 #3d8c0c, 0 9px 14px rgba(0, 0, 0, 0.4), inset 0 2px 0 rgba(255, 255, 255, 0.45);
  color: #fff; font-family: inherit; font-size: 21px; font-weight: 800; letter-spacing: 0.5px; text-shadow: 0 2px 2px rgba(35, 90, 5, 0.6); }
.lose-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #3d8c0c, 0 4px 8px rgba(0, 0, 0, 0.4), inset 0 2px 0 rgba(255, 255, 255, 0.45); }

#tuneToggle { position: fixed; top: 8px; right: 8px; z-index: 4; font: 12px monospace; color: #9aa; background: rgba(0,0,0,.5); border: 1px solid #445; border-radius: 4px; padding: 4px 10px; cursor: pointer; touch-action: auto; }
#tunePanel { position: fixed; top: 36px; right: 8px; bottom: 8px; width: 240px; max-width: 80vw; overflow-y: auto; z-index: 4; display: none; background: rgba(10,10,18,.88); border: 1px solid #445; border-radius: 6px; padding: 8px; font: 11px/1.4 monospace; color: #cde; touch-action: auto; }
#tunePanel .tune-section { color: #8ac; font-weight: bold; margin: 10px 0 2px; text-transform: uppercase; }
#tunePanel .tune-row { margin-bottom: 6px; }
#tunePanel .tune-row label { display: flex; justify-content: space-between; color: #9ab; }
#tunePanel .tune-row label span { color: #fff; }
#tunePanel .tune-row input[type=range] { width: 100%; margin: 0; }
#tunePanel .tune-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
#tunePanel .tune-actions button { font: 11px monospace; color: #cde; background: #223; border: 1px solid #556; border-radius: 4px; padding: 4px 8px; cursor: pointer; }
#tunePanel .tune-export { width: 100%; height: 180px; margin-top: 8px; font: 10px/1.3 monospace; color: #cfc; background: #111; border: 1px solid #445; }
