:root {
  color-scheme: dark;
  --ink: #f7f3e9;
  --muted: #c0c6d8;
  --soft-text: #d8dce7;
  --dim-text: #aab3c9;
  --cyan: #63f7e5;
  --yellow: #ffe77a;
  --danger: #ff507c;
  --bg: #070817;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  overscroll-behavior: none;
}

body {
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  user-select: none;
}

button { font: inherit; }

.game-shell {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 44%, rgba(46, 47, 108, .22), transparent 48%),
    linear-gradient(160deg, #0a0b21 0%, #050610 72%);
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hud {
  position: absolute;
  z-index: 2;
  top: max(20px, env(safe-area-inset-top));
  left: max(20px, env(safe-area-inset-left));
  right: max(20px, env(safe-area-inset-right));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity .35s, transform .35s;
}

.hud.is-visible { opacity: 1; transform: translateY(0); }
.best-block { text-align: right; }
.combo-block { text-align: center; min-width: 80px; }
.score-block strong, .best-block strong, .combo-block strong {
  display: block;
  margin-top: 1px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: clamp(20px, 5.4vw, 30px);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -.05em;
}
.best-block strong { color: var(--muted); }
.combo-block strong { color: var(--yellow); transition: transform .15s; }
.combo-block.pulse strong { transform: scale(1.25); }
.hud-label {
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  letter-spacing: .18em;
}

.sound-button {
  display: none;
  position: absolute;
  z-index: 8;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 50%;
  color: var(--muted);
  background: rgba(7,8,23,.45);
  backdrop-filter: blur(10px);
  cursor: pointer;
}
.sound-button.is-muted { opacity: .45; }
.sound-button.is-muted::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 1px;
  top: 20px;
  left: 9px;
  background: currentColor;
  transform: rotate(-45deg);
}

.screen {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 24px max(54px, env(safe-area-inset-bottom));
  text-align: center;
  background: linear-gradient(to bottom, rgba(7,8,23,.16), rgba(7,8,23,.42));
  opacity: 0;
  visibility: hidden;
  transform: scale(1.025);
  transition: opacity .45s, transform .45s, visibility .45s;
}
.screen.is-visible { opacity: 1; visibility: visible; transform: scale(1); }
.eyebrow {
  color: var(--cyan);
  font: 500 11px/1 "SFMono-Regular", Consolas, monospace;
  letter-spacing: .26em;
  text-transform: uppercase;
}
.wordmark {
  display: flex;
  width: 100%;
  align-items: baseline;
  justify-content: center;
  margin: 17px 0 0;
  max-width: 100%;
  color: var(--ink);
  font-family: "Segoe UI Variable Display", "Avenir Next", "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(40px, 11.2vw, 68px);
  font-kerning: normal;
  font-optical-sizing: auto;
  font-feature-settings: "kern" 1, "liga" 1;
  line-height: .84;
  white-space: nowrap;
  text-shadow: 0 0 24px rgba(255,255,255,.035);
}
.wordmark-hoshi {
  color: var(--yellow);
  font-weight: 720;
  letter-spacing: -.065em;
}
.wordmark-watari {
  margin-left: .075em;
  font-weight: 280;
  letter-spacing: -.045em;
}
.subtitle {
  display: flex;
  width: 164px;
  align-items: center;
  gap: 12px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .38em;
  white-space: nowrap;
}
.subtitle::before, .subtitle::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(192,198,216,.48));
}
.subtitle::after { transform: scaleX(-1); }
.subtitle span { padding-left: .38em; }
.mini-orbit { position: relative; width: 132px; height: 72px; margin: 38px 0 24px; }
.mini-orbit::before, .mini-orbit::after {
  content: "";
  position: absolute;
  inset: 8px 14px;
  border: 1px solid rgba(99,247,229,.25);
  border-radius: 50%;
  transform: rotate(-14deg);
}
.mini-orbit::after { inset: 20px 35px; border-color: rgba(255,255,255,.16); }
.mini-orbit i, .mini-orbit b, .mini-orbit em { position: absolute; display: block; border-radius: 50%; }
.mini-orbit i { width: 9px; height: 9px; left: 21px; top: 16px; background: var(--yellow); box-shadow: 0 0 14px var(--yellow); }
.mini-orbit b { width: 13px; height: 13px; left: 59px; top: 29px; background: var(--cyan); box-shadow: 0 0 20px var(--cyan); }
.mini-orbit em { width: 5px; height: 5px; right: 23px; bottom: 15px; background: var(--danger); }
.instruction { margin: 0 0 29px; color: var(--soft-text); font-size: 15px; line-height: 2; letter-spacing: .04em; }
.instruction strong { color: var(--ink); font-weight: 800; }
.noise-key { display: flex; gap: 17px; margin: -14px 0 24px; color: var(--dim-text); font-size: 11px; }
.noise-key span { display: flex; align-items: center; gap: 5px; }
.noise-key i { width: 6px; height: 6px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 7px var(--danger); }
.noise-key .fast i { background: #b86cff; box-shadow: 0 0 7px #b86cff; }
.noise-key .slow i { background: #ff9d57; box-shadow: 0 0 7px #ff9d57; }
.main-button {
  position: relative;
  display: flex;
  width: min(260px, 74vw);
  min-height: 66px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  overflow: hidden;
  border: 1px solid rgba(99,247,229,.45);
  border-radius: 3px;
  color: #071816;
  background: var(--cyan);
  box-shadow: 0 0 28px rgba(99,247,229,.14);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.main-button::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(7,24,22,.14);
  pointer-events: none;
}
.main-button:active { transform: scale(.97); box-shadow: 0 0 45px rgba(99,247,229,.3); }
.main-button:disabled { opacity: .48; pointer-events: none; }
.main-button span { font-size: 17px; font-weight: 800; }
.main-button small { font: 500 10px/1 "SFMono-Regular", Consolas, monospace; letter-spacing: .12em; opacity: .72; }
.hint { margin: 18px 0 0; color: var(--dim-text); font-size: 11px; letter-spacing: .08em; }

.result-screen h2 { margin: 15px 0 25px; font-size: 24px; letter-spacing: .12em; }
.result-score span { display: block; color: var(--muted); font-size: 13px; }
.result-score strong {
  display: block;
  margin-top: 5px;
  color: var(--yellow);
  font: 500 clamp(54px, 18vw, 88px)/1 "SFMono-Regular", Consolas, monospace;
  letter-spacing: -.08em;
}
.new-best {
  height: 22px;
  color: var(--cyan);
  font: 500 12px/22px "SFMono-Regular", Consolas, monospace;
  letter-spacing: .2em;
  opacity: 0;
}
.new-best.is-visible { opacity: 1; animation: blink 1s steps(2) infinite; }
.result-stats {
  display: flex;
  width: min(280px, 76vw);
  margin: 18px 0 28px;
  padding: 15px 0;
  border-top: 1px solid rgba(255,255,255,.09);
  border-bottom: 1px solid rgba(255,255,255,.09);
}
.result-stats div { flex: 1; }
.result-stats div + div { border-left: 1px solid rgba(255,255,255,.09); }
.result-stats dt { color: var(--muted); font-size: 11px; }
.result-stats dd { margin: 4px 0 0; font: 500 20px/1 "SFMono-Regular", Consolas, monospace; }

.tap-guide {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: max(66px, calc(env(safe-area-inset-bottom) + 45px));
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
}
.tap-guide.is-visible { animation: guide 2.3s ease both; }
.tap-guide p { margin: 8px 0 0; color: var(--soft-text); font-size: 12px; letter-spacing: .08em; }
.tap-icon { position: relative; width: 34px; height: 34px; border: 1px solid rgba(255,255,255,.22); border-radius: 50%; }
.tap-icon span { position: absolute; inset: 10px; border: 1px solid var(--cyan); border-radius: 50%; }

@keyframes guide { 0% { opacity: 0; transform: translate(-50%, 8px); } 15%, 70% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }
@keyframes blink { 50% { opacity: .35; } }

@media (min-width: 800px) {
  .game-shell { left: 50%; width: min(100%, 720px); transform: translateX(-50%); box-shadow: 0 0 100px #000; }
  body { background: #02030a; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
