:root {
  --ink: #eef2ff;
  --dim: #b9c4e6;
  --edge: rgba(180, 200, 255, 0.5);
  --panel: rgba(10, 16, 36, 0.72);
  --warm: #ffd79a;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0a1024;
  color: var(--ink);
  font: 1rem/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}
body {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
button { touch-action: manipulation; }
#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
#sky:focus-visible { outline: 2px solid var(--warm); outline-offset: -4px; }
.hud {
  position: fixed;
  inset: 0;
  padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right))
    max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.hud::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 152px;
  background: linear-gradient(180deg, rgba(6, 10, 24, 0.94), rgba(6, 10, 24, 0.8) 42%, rgba(6, 10, 24, 0.42) 72%, rgba(6, 10, 24, 0));
  pointer-events: none;
  z-index: 0;
}
.hud > * { position: relative; z-index: 1; }
.restart {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  min-width: 44px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--edge);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  pointer-events: auto;
  touch-action: manipulation;
  cursor: pointer;
  text-shadow: 0 1px 4px rgba(4, 8, 20, 0.9);
}
.restart:hover { border-color: var(--warm); }
.restart:focus-visible { outline: 2px solid var(--warm); outline-offset: 2px; }
.bar { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.level, .goal, .hint, .note { margin: 0; font-size: 1rem; }
.level { color: var(--ink); font-weight: 600; text-shadow: 0 1px 4px rgba(4, 8, 20, 0.9); }
.goal { color: var(--dim); text-align: right; text-shadow: 0 1px 4px rgba(4, 8, 20, 0.9); }
.hint { color: var(--ink); text-shadow: 0 1px 6px rgba(4, 8, 22, 0.9); }
.meter {
  height: 6px;
  border-radius: 3px;
  background: rgba(160, 180, 230, 0.28);
  border: 1px solid var(--edge);
  overflow: hidden;
  width: min(100%, 420px);
}
.meter span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #8fb6ff, var(--warm));
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.18s ease-out;
}
.banner {
  margin-top: auto;
  align-self: center;
  pointer-events: auto;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  min-width: 232px;
  backdrop-filter: blur(6px);
}
.banner[hidden] { display: none; }
.banner-text { margin: 0; font-size: 1.06rem; text-align: center; }
button.primary {
  font: inherit;
  min-height: 44px;
  min-width: 44px;
  padding: 8px 18px;
  border-radius: 10px;
  border: 1px solid var(--edge);
  background: rgba(255, 215, 154, 0.16);
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
}
button.primary:hover, button.primary:focus-visible {
  background: rgba(255, 215, 154, 0.32);
  outline: none;
}
.note {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
@media (max-width: 560px) {
  /* keep the end-of-sky banner clear of the fixed Restart button */
  .banner { margin-bottom: 56px; }
}
@media (prefers-reduced-motion: reduce) {
  .meter span { transition: none; }
  * { scroll-behavior: auto; }
}
