* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  background: #070a16; color: #eef1ff;
  display: flex; align-items: center; justify-content: center;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
#wrap { position: relative; width: 100%; height: 100%; max-width: 520px; max-height: 100%; }
#game { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }

.hidden { display: none !important; }

/* HUD */
#hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: calc(10px + env(safe-area-inset-top)) 14px 0;
  pointer-events: none; z-index: 5;
}
.hud-left #hud-level { font-size: 11px; letter-spacing: 2px; color: #8f9bd8; font-weight: 700; }
.hud-left #hud-score { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; text-shadow: 0 0 18px rgba(120,140,255,.55); }
.hud-right { text-align: right; }
#hud-balls { font-size: 15px; letter-spacing: 2px; min-height: 22px; }
#hud-orange { font-size: 13px; color: #ffb066; font-weight: 700; margin-top: 4px; }
#hud-mult {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  font-size: 26px; font-weight: 900; color: #ffe45e;
  text-shadow: 0 0 16px rgba(255,200,60,.8);
  animation: pop .25s ease-out;
}
@keyframes pop { from { transform: translateX(-50%) scale(.4); } to { transform: translateX(-50%) scale(1); } }

/* Overlays */
.overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(7,10,22,.82); backdrop-filter: blur(6px);
  padding: 24px; text-align: center;
}
.title {
  font-size: 64px; font-weight: 900; letter-spacing: 6px;
  background: linear-gradient(180deg, #ffe45e, #ff7a3d 55%, #c86bff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 26px rgba(255,140,60,.45));
  margin-bottom: 6px;
}
.tagline { color: #a9b3e0; font-size: 15px; margin-bottom: 26px; }
#level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 22px; width: 100%; max-width: 380px; }
.lvl-btn {
  aspect-ratio: 1; border-radius: 14px; border: 1px solid #2c3763;
  background: #141a33; color: #dfe5ff; font-size: 20px; font-weight: 800;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 56px;
}
.lvl-btn small { font-size: 9px; font-weight: 600; color: #8f9bd8; }
.lvl-btn:active { transform: scale(.94); background: #1b2342; }
.hint { color: #7c86b8; font-size: 13px; max-width: 300px; line-height: 1.5; margin-bottom: 18px; }
.ghost-btn { background: none; border: 1px solid #2c3763; color: #8f9bd8; border-radius: 999px; padding: 8px 18px; font-size: 13px; }

#result-title {
  font-size: 52px; font-weight: 900; letter-spacing: 3px; margin-bottom: 8px;
  background: linear-gradient(180deg, #fff7ae, #ffb03d 50%, #ff5e7a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 30px rgba(255,170,60,.6));
  animation: feverPulse .6s ease-in-out infinite alternate;
}
@keyframes feverPulse { from { transform: scale(1); } to { transform: scale(1.06); } }
#result.lost #result-title {
  background: linear-gradient(180deg, #aab4e8, #5c669e);
  -webkit-background-clip: text; background-clip: text;
  animation: none; filter: none;
}
#result-sub { color: #a9b3e0; font-size: 15px; margin-bottom: 14px; max-width: 320px; line-height: 1.5; }
#result-score { font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; margin-bottom: 4px; }
#result-best { color: #8f9bd8; font-size: 14px; margin-bottom: 26px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.big-btn {
  border: 1px solid #2c3763; background: #141a33; color: #eef1ff;
  font-size: 16px; font-weight: 700; border-radius: 14px; padding: 14px 22px; min-height: 52px;
}
.big-btn.primary { background: linear-gradient(180deg, #ff9a3d, #ff5e7a); border: none; box-shadow: 0 4px 24px rgba(255,110,80,.4); }
.big-btn:active { transform: scale(.95); }
#result.lost #btn-next { display: none; }
