:root { color-scheme: dark; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex;
  flex-direction: column;
  background: radial-gradient(60% 60% at 85% 0%, rgba(123, 60, 246, 0.35), transparent 70%),
    radial-gradient(50% 60% at 0% 100%, rgba(18, 194, 240, 0.22), transparent 70%), #0b0f3a;
  color: #fff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 10px max(16px, env(safe-area-inset-left)) 10px max(16px, env(safe-area-inset-right));
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(11, 15, 58, 0.85);
}
.back, .link {
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 999px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}
.back:hover, .link:hover { background: #fff; color: #0b0f3a; }
.back:focus-visible, .link:focus-visible, .btn:focus-visible { outline: 3px solid #9fdcff; outline-offset: 2px; }
.title { margin: 0; font-size: 1.15rem; letter-spacing: -0.01em; }
.actions { display: flex; align-items: center; gap: 8px; }
.btn {
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  background: linear-gradient(90deg, #7b3cf6, #1f4bff);
  border: 0;
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.1); }
.stage { position: relative; flex: 1; min-height: 0; }
.game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #0e1823;
}
.loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-weight: 600;
}
.loading.done { display: none; }
.spinner {
  width: 38px;
  height: 38px;
  border: 4px solid rgba(255, 255, 255, 0.25);
  border-top-color: #9fdcff;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.nojs { position: absolute; inset: 0; margin: 0; display: grid; place-items: center; background: #0b0f3a; }
/* Phones: keep the bar to one slim row so the game gets the screen. */
@media (max-width: 640px) {
  .bar { flex-wrap: nowrap; padding-top: 6px; padding-bottom: 6px; gap: 8px; }
  .title, .link { display: none; }
  .back { font-size: 0.85rem; padding: 7px 12px; }
  .btn { font-size: 0.85rem; padding: 8px 12px; white-space: nowrap; }
}
/* Short landscape screens (phones on their side, small Chromebooks). */
@media (max-height: 520px) {
  .bar { padding-top: 4px; padding-bottom: 4px; }
  .title { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
}
