#loader {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 28px;
  padding: 24px; box-sizing: border-box;
  background: radial-gradient(ellipse at 50% 40%, #1d2a4a 0%, #0a0e1a 70%);
  color: #e8ecf5; font-family: system-ui, -apple-system, sans-serif;
  transition: opacity .6s ease;
}
#loader.done { opacity: 0; pointer-events: none; }

#loader .logo {
  width: clamp(96px, 26vmin, 160px); height: auto;
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, .5));
  animation: bob 1.6s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-8px) rotate(4deg); }
}

#loader h1 {
  margin: 0; font-size: clamp(28px, 7vw, 44px); font-weight: 800;
  letter-spacing: .02em; text-align: center;
}
#loader h1 span { color: #ff9b2f; }

#loader .panel { width: min(360px, 100%); }
#loader .row {
  display: flex; justify-content: space-between; margin-bottom: 8px;
  font-size: 14px; color: #b7c0d6;
}
#loader .pct { font-variant-numeric: tabular-nums; }
#loader .track {
  height: 8px; border-radius: 4px; overflow: hidden;
  background: rgba(255, 255, 255, .1);
}
#loader .fill {
  height: 100%; width: 0; border-radius: 4px;
  background: linear-gradient(90deg, #ff7a1a, #ffc24a);
  transition: width .3s ease;
}
#loader .hint {
  margin: 14px 0 0; font-size: 12px; color: #7d879e; text-align: center;
  line-height: 1.5;
}
#loader.error .fill { background: #e5484d; }
#loader.error .stage { color: #ff8b8f; }

/* iPhone "Add to Home Screen" tip (fullscreen.js); above the loader. */
#fs-tip {
  position: fixed; z-index: 20; left: 50%; top: max(12px, env(safe-area-inset-top));
  transform: translateX(-50%); width: min(420px, calc(100% - 32px));
  box-sizing: border-box; padding: 10px 36px 10px 14px; border-radius: 10px;
  background: rgba(20, 26, 44, .92); color: #e8ecf5;
  font: 13px/1.4 system-ui, -apple-system, sans-serif;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .4);
}
#fs-tip span { position: absolute; right: 12px; top: 9px; color: #7d879e; }

/* Phones in portrait: the game is landscape-only. */
#rotate { display: none; }
@media (orientation: portrait) and (pointer: coarse) {
  #rotate {
    position: fixed; inset: 0; z-index: 30;
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 16px; padding: 24px;
    background: #0a0e1a; color: #e8ecf5; text-align: center;
    font: 600 18px system-ui, -apple-system, sans-serif;
  }
  #rotate img { width: 96px; animation: turn 2s ease-in-out infinite; }
}
@keyframes turn {
  0%, 30% { transform: rotate(0); }
  60%, 100% { transform: rotate(-90deg); }
}
