:root {
  color-scheme: dark;
  font-family: "Segoe UI", "Yu Gothic UI", "Hiragino Sans", sans-serif;
  background: #050816;
  color: #f7f7ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #050816;
}

button {
  font: inherit;
}

.game-shell {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 420px;
  overflow: hidden;
  user-select: none;
  touch-action: none;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.hud {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  width: 100%;
  padding: max(20px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) 0 max(22px, env(safe-area-inset-left));
  pointer-events: none;
}

.brand p,
.brand h1,
.meters span,
.meters strong {
  margin: 0;
}

.combo-display {
  position: absolute;
  z-index: 5;
  top: max(82px, calc(env(safe-area-inset-top) + 66px));
  right: max(22px, env(safe-area-inset-right));
  display: grid;
  justify-items: end;
  pointer-events: none;
}

.combo-display span {
  font-size: 9px;
  letter-spacing: 0.28em;
  opacity: 0.55;
}

.combo-display strong {
  font-size: clamp(32px, 5vw, 68px);
  font-weight: 200;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-shadow: 0 0 24px rgba(132, 190, 255, 0.42);
}

.brand-ja {
  font-size: clamp(11px, 1.2vw, 14px);
  font-weight: 600;
  letter-spacing: 0.28em;
  opacity: 0.75;
}

.brand h1 {
  margin-top: 5px;
  font-size: clamp(13px, 1.5vw, 19px);
  font-weight: 300;
  letter-spacing: 0.22em;
}

.meters {
  display: flex;
  gap: clamp(18px, 4vw, 56px);
  text-align: right;
}

.meters div {
  display: grid;
  gap: 3px;
}

.meters span,
.result-score span,
.result-score small {
  font-size: 9px;
  letter-spacing: 0.2em;
  opacity: 0.55;
}

.meters strong {
  font-size: clamp(15px, 2vw, 24px);
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}

.intro,
.result {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 32px;
  text-align: center;
}

.intro[hidden],
.result[hidden] {
  display: none;
}

.intro-copy {
  transform: translateY(4vh);
}

.eyebrow,
.result-heading p {
  margin: 0 0 16px;
  color: #d7ccff;
  font-size: 10px;
  letter-spacing: 0.36em;
}

.intro h2,
.result h2 {
  margin: 0;
  font-size: clamp(26px, 5.3vw, 64px);
  font-weight: 200;
  line-height: 1.45;
  letter-spacing: 0.06em;
  text-shadow: 0 0 28px rgba(173, 198, 255, 0.38);
}

.control {
  margin: 26px 0 28px;
  color: rgba(255, 255, 255, 0.62);
  font-size: clamp(11px, 1.4vw, 14px);
  letter-spacing: 0.12em;
}

.control span {
  margin: 0 8px;
  opacity: 0.4;
}

#startButton,
#restartButton {
  min-width: 190px;
  border: 1px solid rgba(227, 231, 255, 0.52);
  border-radius: 999px;
  padding: 14px 24px;
  background: rgba(7, 10, 31, 0.38);
  color: white;
  font-size: 12px;
  letter-spacing: 0.18em;
  cursor: pointer;
  backdrop-filter: blur(12px);
}

#startButton:hover,
#restartButton:hover {
  border-color: white;
  background: rgba(100, 120, 210, 0.2);
}

.result {
  align-content: center;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 0.6fr);
  gap: clamp(30px, 8vw, 120px);
  padding-inline: max(32px, 10vw);
  background: rgba(3, 5, 18, 0.2);
  backdrop-filter: blur(1.5px);
}

.result-heading {
  text-align: left;
}

.result-heading h2 {
  font-size: clamp(34px, 6vw, 78px);
}

.result-score {
  display: grid;
  justify-items: center;
}

.result-score strong {
  margin: 2px 0 8px;
  font-size: clamp(46px, 8vw, 96px);
  font-weight: 200;
  font-variant-numeric: tabular-nums;
}

#restartButton {
  grid-column: 1 / -1;
  justify-self: center;
}

.anchor-hint {
  position: absolute;
  z-index: 3;
  bottom: max(21px, env(safe-area-inset-bottom));
  left: 50%;
  margin: 0;
  transform: translateX(-50%);
  font-size: 9px;
  letter-spacing: 0.3em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 400ms ease;
}

.judgement {
  position: absolute;
  z-index: 6;
  top: 27%;
  left: 50%;
  margin: 0;
  transform: translate(-50%, 10px) scale(0.88);
  color: white;
  font-size: clamp(20px, 4vw, 46px);
  font-weight: 200;
  letter-spacing: 0.22em;
  opacity: 0;
  pointer-events: none;
}

.judgement.visible {
  transform: translate(-50%, 0) scale(1);
  opacity: 1;
  transition: opacity 120ms ease, transform 160ms ease;
}

.judgement.perfect {
  color: #fff0ae;
  text-shadow: 0 0 12px #fff, 0 0 34px #d69fff;
}

.judgement.good {
  color: #bcecff;
  text-shadow: 0 0 24px #5a9fff;
}

.judgement.miss {
  color: #d6b7de;
  text-shadow: 0 0 20px #7a315f;
}

.anchor-hint.visible {
  opacity: 0.52;
}

.sound-button {
  position: absolute;
  z-index: 5;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  border: 0;
  padding: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.45);
  font-size: 8px;
  letter-spacing: 0.18em;
  cursor: pointer;
}

@media (max-width: 680px) {
  .hud {
    padding-top: max(14px, env(safe-area-inset-top));
    padding-inline: 15px;
  }

  .brand-ja {
    font-size: 9px;
  }

  .brand h1 {
    font-size: 10px;
  }

  .meters {
    gap: 10px;
  }

  .meters span {
    font-size: 7px;
  }

  .meters strong {
    font-size: 12px;
  }

  .combo-display {
    top: max(61px, calc(env(safe-area-inset-top) + 50px));
    right: 15px;
  }

  .combo-display strong {
    font-size: 34px;
  }

  .intro {
    padding-inline: 18px;
  }

  .intro h2 {
    font-size: clamp(24px, 8vw, 38px);
  }

  .control {
    line-height: 1.8;
  }

  .result {
    grid-template-columns: 1fr;
    gap: 26px;
    padding: 86px 22px 64px;
  }

  .result-heading {
    text-align: center;
  }

  #restartButton {
    grid-column: 1;
  }

  .sound-button {
    right: 8px;
    bottom: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .anchor-hint {
    transition: none;
  }
}
