:root {
  --cyan: #19e6ff;
  --magenta: #ff3df2;
  --purple: #8a4dff;
  --dim: #7d86a8;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: #000;
  color: #fff;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
}
body { display: flex; align-items: center; justify-content: center; }
#stage {
  position: relative;
  height: 100vh;
  height: 100dvh;
  max-width: 100vw;
  aspect-ratio: 9 / 16;
  background: #000;
  overflow: hidden;
}
@media (max-aspect-ratio: 9/16) {
  #stage { height: auto; width: 100vw; max-height: 100dvh; }
}
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  background: rgba(0, 0, 0, 0.88);
  padding: 24px;
  pointer-events: none; /* タップは画面全体で受ける */
}
.screen[hidden] { display: none; }
#over { background: rgba(0, 0, 0, 0.62); } /* ぶつかった壁が見えるようにする */
.screen button { pointer-events: auto; }
h1 {
  margin: 0;
  font-size: clamp(56px, 22vmin, 96px);
  letter-spacing: 0.12em;
  color: var(--cyan);
  text-shadow: 0 0 14px var(--cyan);
}
h2 { margin: 0; font-size: 34px; letter-spacing: 0.08em; color: var(--magenta); }
.tag { margin: -10px 0 14px; letter-spacing: 0.3em; color: var(--purple); font-weight: 700; }
.best, .final { margin: 0; color: var(--dim); font-size: 16px; letter-spacing: 0.08em; }
.best strong { color: #fff; font-size: 20px; }
.final { font-size: 18px; }
.final strong { color: #fff; font-size: 44px; display: block; line-height: 1.1; }
.new-best {
  margin: 0;
  color: var(--magenta);
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.15em;
  text-shadow: 0 0 10px var(--magenta);
  animation: best-pulse 1.4s ease-in-out infinite; /* ゆっくり脈打つだけ。速い点滅はしない */
}
@keyframes best-pulse { 0%, 100% { opacity: 0.75; transform: scale(1); } 50% { opacity: 1; transform: scale(1.08); } }
@media (prefers-reduced-motion: reduce) { .new-best { animation: none; } }
.help { margin: 8px 0 0; color: var(--dim); font-size: 14px; line-height: 1.7; }
button {
  font: inherit;
  color: #fff;
  background: transparent;
  border: 2px solid var(--purple);
  border-radius: 999px;
  padding: 10px 28px;
  letter-spacing: 0.1em;
  cursor: pointer;
}
button.primary {
  min-width: 180px;
  font-size: 24px;
  font-weight: 800;
  padding: 14px 32px;
  border-color: var(--cyan);
  color: var(--cyan);
}
button:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.retry-btn {
  display: inline-block;
  min-width: 180px;
  font-size: 24px;
  font-weight: 800;
  padding: 14px 32px;
  border: 2px solid var(--cyan);
  border-radius: 999px;
  color: var(--cyan);
  margin-top: 8px;
}
.retry-hint { margin: 0; color: var(--dim); font-size: 13px; opacity: 0.35; transition: opacity 0.2s; }
.retry-hint.ready { opacity: 1; }
