body.ball-page main { min-height: 100dvh; background: radial-gradient(circle at 8% 18%, #fff 0 3px, transparent 4px), linear-gradient(#bfeaf2 0 72%, #fff8e7 72%); }
body.ball-page, body.ball-page * { -webkit-user-select: none; user-select: none; -webkit-user-drag: none; -webkit-touch-callout: none; }
.ball-game { width: min(980px, calc(100% - 40px)); margin: 26px auto 42px; position: relative; z-index: 1; }
.ball-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; margin-bottom: 18px; }
.ball-heading > div:first-child > span { color: #2e7d87; font-size: 10px; letter-spacing: .16em; font-weight: 900; }
.ball-heading h1 { margin: 7px 0 7px; font-size: clamp(38px, 5vw, 60px); line-height: 1; letter-spacing: -.05em; }
.ball-heading p { margin: 0; color: #526575; font-size: 13px; }
.ball-score { flex: 0 0 auto; min-width: 112px; padding: 8px 12px; border: 3px solid var(--ink); border-radius: 17px; background: #e8dcff; box-shadow: 4px 4px 0 var(--ink); text-align: center; }
.ball-score b, .ball-score small { display: block; }
.ball-score b { color: #725ac6; font-size: 40px; line-height: 1; }
.ball-score small { margin-top: 3px; font-size: 9px; font-weight: 900; }
.ball-stage { position: relative; height: min(540px, 62vh); min-height: 390px; overflow: hidden; border: 3px solid var(--ink); border-radius: 28px; background: linear-gradient(#b9ebf5 0 82%, #dff5e5 82%); box-shadow: 9px 9px 0 var(--ink); touch-action: none; user-select: none; }
.ball-start-zone { position: absolute; z-index: 5; top: 12px; left: 50%; width: 152px; min-height: 82px; transform: translateX(-50%); border: 4px dashed #725ac6; border-radius: 28px; background: #f5efffcc; display: flex; align-items: center; justify-content: center; gap: 7px; color: #725ac6; pointer-events: none; transition: background .16s ease, transform .16s ease; }
.ball-start-zone span { font-size: 38px; }
.ball-start-zone b { font-size: 13px; }
.ball-start-zone.is-ready { background: #fff2bd; transform: translateX(-50%) scale(1.08); }
.ball-start-zone.is-running { opacity: .3; }
.ball-guide { position: absolute; z-index: 3; top: 31%; left: 50%; transform: translateX(-50%); display: grid; place-items: center; color: #497585; pointer-events: none; animation: ball-hint 1.5s ease-in-out infinite; }
.ball-guide span { font-size: 42px; }
.ball-guide b { margin-top: 3px; padding: 5px 10px; border-radius: 20px; background: #ffffffb8; font-size: 12px; }
.track-belt { position: absolute; z-index: 1; inset: 0 0 auto; width: 100%; contain: layout paint; will-change: transform; backface-visibility: hidden; transform: translateZ(0); pointer-events: none; }
.terrain-shape { --shape-color: #ff6b88; position: absolute; display: block; border: 3px solid var(--ink); background: repeating-linear-gradient(90deg, var(--shape-color) 0 24px, #fff 24px 36px); box-shadow: inset -9px 0 0 #25304716, 6px 6px 0 #25304725; }
.terrain-shape.type-pillar { border-radius: 18px 18px 7px 7px; }
.terrain-shape.type-pillar::before { content: ""; position: absolute; inset: -9px -7px auto; height: 18px; border: 3px solid var(--ink); border-radius: 50%; background: #fff2bd; box-shadow: 0 4px 0 #25304720; }
.terrain-shape.type-stick { border-radius: 999px; box-shadow: inset -7px -4px 0 #25304716, 5px 5px 0 #25304725; }
.terrain-shape.type-square { border-radius: 8px; }
.terrain-shape.type-triangle { border: 0; background: var(--ink); box-shadow: none; clip-path: polygon(50% 0, 100% 100%, 0 100%); filter: drop-shadow(5px 5px 0 #25304730); }
.terrain-shape.type-triangle::before { content: ""; position: absolute; inset: 5px; background: var(--shape-color); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.terrain-shape.is-dots { background: radial-gradient(circle, #fff 0 5px, transparent 6px) 0 0 / 27px 27px, var(--shape-color); }
.terrain-shape.is-solid { background: linear-gradient(90deg, var(--shape-color), #fff2bd, var(--shape-color)); }
.terrain-shape.is-checkers:not(.type-triangle) { background: repeating-linear-gradient(135deg, var(--shape-color) 0 18px, #fff 18px 36px, var(--yellow) 36px 54px); }
.terrain-shape.type-brick { border-radius: 7px; background-color: var(--shape-color); background-image: linear-gradient(var(--ink) 2px, transparent 2px), linear-gradient(90deg, var(--ink) 2px, transparent 2px), linear-gradient(90deg, transparent 20px, var(--ink) 20px 22px, transparent 22px); background-position: 0 0, 0 0, 0 22px; background-size: 100% 22px, 40px 44px, 40px 44px; box-shadow: inset -7px -6px 0 #25304718, 6px 6px 0 #25304725; }
.terrain-shape.type-brick.is-bricks-alt { background-position: 0 0, 20px 0, 0 22px; background-size: 100% 20px, 44px 40px, 44px 40px; }
.terrain-shape.type-rectangle { border-radius: 7px; background: linear-gradient(90deg, var(--shape-color), #fff2bd 48%, var(--shape-color)); }
.terrain-shape.type-circle { border-radius: 50%; background: radial-gradient(circle at 34% 28%, #fff 0 8%, transparent 9%), var(--shape-color); box-shadow: inset -9px -10px 0 #25304718, 6px 6px 0 #25304725; }
.terrain-shape.type-ellipse { border-radius: 50%; background: repeating-linear-gradient(145deg, var(--shape-color) 0 20px, #fff 20px 31px); }
.terrain-shape.type-star, .terrain-shape.type-heart, .terrain-shape.type-quadrilateral { border: 0; background: var(--ink); box-shadow: none; filter: drop-shadow(6px 6px 0 #25304730); }
.terrain-shape.type-star { clip-path: polygon(50% 0, 61% 34%, 98% 35%, 68% 56%, 79% 94%, 50% 71%, 21% 94%, 32% 56%, 2% 35%, 39% 34%); }
.terrain-shape.type-star::before { content: ""; position: absolute; inset: 5px; background: var(--shape-color); clip-path: polygon(50% 0, 61% 34%, 98% 35%, 68% 56%, 79% 94%, 50% 71%, 21% 94%, 32% 56%, 2% 35%, 39% 34%); }
.terrain-shape.type-heart { clip-path: polygon(50% 96%, 10% 60%, 3% 38%, 7% 20%, 20% 7%, 37% 8%, 50% 24%, 63% 8%, 80% 7%, 93% 20%, 97% 38%, 90% 60%); }
.terrain-shape.type-heart::before { content: ""; position: absolute; inset: 5px; background: var(--shape-color); clip-path: polygon(50% 96%, 10% 60%, 3% 38%, 7% 20%, 20% 7%, 37% 8%, 50% 24%, 63% 8%, 80% 7%, 93% 20%, 97% 38%, 90% 60%); }
.terrain-shape.type-quadrilateral { clip-path: polygon(13% 0, 100% 0, 86% 100%, 0 100%); }
.terrain-shape.type-quadrilateral::before { content: ""; position: absolute; inset: 5px; background: var(--shape-color); clip-path: polygon(13% 0, 100% 0, 86% 100%, 0 100%); }
.terrain-marker { position: absolute; z-index: 2; width: 42px; height: 42px; display: grid; place-items: center; border: 2px solid var(--ink); border-radius: 50%; background: #fff; box-shadow: 3px 3px 0 #25304735; font-family: "Apple Color Emoji","Segoe UI Emoji",sans-serif; font-size: 23px; }
.terrain-shape.is-spawning, .terrain-marker.is-spawning { animation: terrain-spawn .48s cubic-bezier(.22, 1.35, .42, 1) both; animation-delay: calc(var(--spawn-index, 0) * 28ms); transform-origin: center bottom; }
.drop-ball { --ball-color: #ff6b88; position: absolute; z-index: 7; left: 0; top: 0; width: 84px; height: 84px; padding: 0; border: 4px solid var(--ink); border-radius: 50%; background: radial-gradient(circle at 31% 25%, #fff 0 7%, transparent 8%), radial-gradient(circle at 35% 30%, #fff8 0 13%, transparent 14%), var(--ball-color); box-shadow: inset -12px -14px 0 #25304720, 6px 8px 0 #25304738; cursor: grab; touch-action: none; contain: layout paint style; will-change: transform; backface-visibility: hidden; }
.drop-ball:active, .drop-ball.is-dragging { cursor: grabbing; box-shadow: inset -9px -11px 0 #25304720, 3px 4px 0 #25304738; }
.drop-ball.is-dragging { transform-origin: center; }
.drop-ball.is-running { pointer-events: none; }
.drop-ball.is-finished { filter: saturate(1.08); }
.ball-ground { position: absolute; z-index: 2; inset: auto 0 0; height: 23%; border-top: 4px solid var(--ink); background: #8fd39e; display: flex; align-items: flex-start; justify-content: space-around; padding-top: 14px; pointer-events: none; }
.ball-ground i { width: 11px; height: 22px; border-radius: 100% 0; background: #4b9d67; transform: rotate(-25deg); }
.ball-actions { display: grid; grid-template-columns: 1.2fr 1fr; gap: 12px; margin-top: 18px; }
.ball-actions button { min-height: 56px; border: 3px solid var(--ink); border-radius: 16px; box-shadow: 4px 4px 0 var(--ink); font-size: 16px; font-weight: 900; cursor: pointer; }
#demoDrop { background: var(--yellow); }
#resetBall { background: var(--blue); }
.ball-actions button:active { transform: translate(2px,2px); box-shadow: 2px 2px 0 var(--ink); }
.ball-toast { position: fixed; z-index: 2000; top: max(14px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 28px); padding: 13px 22px; border: 3px solid var(--ink); border-radius: 16px; background: var(--pink); color: #fff; box-shadow: 5px 5px 0 var(--ink); font-weight: 900; text-align: center; animation: ball-toast-in .3s ease-out; }
.ball-page footer { padding-bottom: env(safe-area-inset-bottom); }
@keyframes ball-hint { 0%,100% { transform: translate(-50%, 5px); } 50% { transform: translate(-50%, -7px); } }
@keyframes ball-toast-in { from { opacity: 0; transform: translate(-50%,-15px); } to { opacity: 1; transform: translateX(-50%); } }
@keyframes terrain-spawn { 0% { opacity: 0; transform: translate3d(var(--spawn-x, 0), -42px, 0) rotate(var(--spawn-rotate, 0deg)) scale(.42); } 72% { opacity: 1; transform: translate3d(0, 5px, 0) rotate(-2deg) scale(1.08, .94); } 100% { opacity: 1; transform: none; } }

@media (max-width: 760px) {
  .ball-page .topbar { width: calc(100% - 22px); }
  .ball-game { width: calc(100% - 22px); margin: 14px auto 28px; }
  .ball-heading { align-items: center; gap: 8px; margin-bottom: 11px; }
  .ball-heading h1 { margin-block: 4px; font-size: 31px; }
  .ball-heading p { max-width: 230px; font-size: 10px; line-height: 1.4; }
  .ball-score { min-width: 86px; padding: 6px 8px; border-radius: 13px; box-shadow: 3px 3px 0 var(--ink); }
  .ball-score b { font-size: 28px; }
  .ball-stage { height: min(520px, 65dvh); min-height: 360px; border-radius: 21px; box-shadow: 6px 7px 0 var(--ink); }
  .drop-ball { width: 72px; height: 72px; border-width: 3px; }
  .ball-start-zone { width: 128px; min-height: 70px; }
  .ball-start-zone span { font-size: 32px; }
  .terrain-shape { border-width: 2px; box-shadow: inset -6px 0 0 #25304712, 3px 4px 0 #25304720; }
  .terrain-shape.type-pillar::before { border-width: 2px; }
  .ball-actions { gap: 8px; margin-top: 13px; }
  .ball-actions button { min-height: 50px; font-size: 13px; }
  .ball-page footer { width: calc(100% - 22px); min-height: 52px; }
}

@media (max-height: 700px) and (max-width: 760px) {
  .ball-heading > div:first-child > span, .ball-heading p { display: none; }
  .ball-heading h1 { font-size: 28px; }
  .ball-stage { height: 420px; min-height: 330px; }
  .ball-actions button { min-height: 46px; }
  .ball-page footer { min-height: 44px; font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  .ball-guide, .ball-toast, .terrain-shape.is-spawning, .terrain-marker.is-spawning { animation: none !important; }
}
