:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #03050b;
  color: #f6f8ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
}

body {
  min-height: 100svh;
  background:
    radial-gradient(circle at 50% 48%, rgba(108, 128, 255, 0.08), transparent 42%),
    linear-gradient(180deg, #03040a 0%, #06101f 100%);
}

button {
  font: inherit;
}

.shell {
  position: relative;
  width: 100vw;
  height: 100svh;
  min-height: 520px;
  overflow: hidden;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.hud {
  position: fixed;
  top: max(20px, env(safe-area-inset-top));
  left: 50%;
  z-index: 4;
  display: grid;
  width: min(300px, calc(100vw - 148px));
  gap: 9px;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
}

.score span {
  display: inline-block;
  font-size: clamp(34px, 8vw, 64px);
  font-weight: 650;
  line-height: 1;
  letter-spacing: 0;
  color: rgba(248, 251, 255, 0.94);
  text-shadow: 0 0 28px rgba(137, 154, 255, 0.24);
}

.score.is-counting span {
  animation: score-settle 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes score-settle {
  0% {
    opacity: 0.76;
    transform: scale(0.96);
  }

  58% {
    opacity: 1;
    transform: scale(1.035);
    text-shadow: 0 0 34px rgba(154, 171, 255, 0.42);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.stats {
  display: grid;
  grid-template-columns: 0.78fr 0.92fr 1.2fr;
  gap: 8px;
  width: 100%;
  color: rgba(222, 230, 255, 0.58);
  font-size: clamp(11px, 2.8vw, 13px);
  font-weight: 620;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
}

.debug-status {
  justify-self: center;
  margin-top: -1px;
  color: rgba(184, 204, 255, 0.46);
  font-size: 9px;
  font-weight: 650;
  line-height: 1;
  letter-spacing: 0.14em;
}

.controls {
  position: fixed;
  top: max(20px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  z-index: 8;
  display: flex;
  gap: 10px;
}

.control {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(212, 222, 255, 0.14);
  border-radius: 50%;
  color: #eef4ff;
  background: rgba(11, 17, 31, 0.34);
  backdrop-filter: blur(14px);
  cursor: pointer;
  transition:
    border-color 180ms ease,
    background 180ms ease,
    opacity 180ms ease;
}

.control:hover {
  border-color: rgba(226, 233, 255, 0.26);
  background: rgba(18, 27, 47, 0.5);
}

.help-button span {
  font-size: 18px;
  font-weight: 560;
  line-height: 1;
}

.beginner[aria-pressed="true"] {
  border-color: rgba(202, 216, 255, 0.4);
  background: rgba(132, 154, 255, 0.16);
  box-shadow: 0 0 24px rgba(120, 146, 255, 0.12);
}

.guide-icon {
  position: relative;
  width: 18px;
  height: 18px;
  border: 1.5px solid rgba(247, 251, 255, 0.82);
  border-radius: 50%;
}

.guide-icon::before {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #f7fbff;
  box-shadow: 0 0 8px rgba(150, 170, 255, 0.72);
  content: "";
  transform: translate(-50%, -50%);
}

.guide-icon::after {
  position: absolute;
  top: 50%;
  left: -4px;
  width: 24px;
  height: 1px;
  background: linear-gradient(90deg, transparent 0 13%, rgba(247, 251, 255, 0.72) 13% 38%, transparent 38% 62%, rgba(247, 251, 255, 0.72) 62% 87%, transparent 87%);
  content: "";
  transform: translateY(-50%);
}

.sound-on {
  position: relative;
  width: 16px;
  height: 16px;
  border-radius: 2px 8px 8px 2px;
  background: linear-gradient(90deg, #f7fbff 0 42%, transparent 42%);
}

.sound-on::before,
.sound-on::after {
  position: absolute;
  top: 50%;
  left: 7px;
  content: "";
  border: 1.5px solid rgba(247, 251, 255, 0.86);
  border-left: 0;
  border-bottom-color: transparent;
  border-top-color: transparent;
  border-radius: 0 20px 20px 0;
  transform: translateY(-50%);
}

.sound-on::before {
  width: 8px;
  height: 10px;
}

.sound-on::after {
  width: 14px;
  height: 16px;
  opacity: 0.66;
}

.volume[data-level="2"] .sound-on::after {
  opacity: 0.24;
}

.volume[data-level="1"] .sound-on::after {
  display: none;
}

.volume[data-level="1"] .sound-on::before {
  opacity: 0.62;
}

.volume[data-level="0"] .sound-on::before,
.volume[data-level="0"] .sound-on::after {
  display: none;
}

.volume[data-level="0"] .sound-on {
  opacity: 0.62;
}

.volume[data-level="0"] .sound-on::before {
  display: block;
  top: 7px;
  left: 0;
  width: 20px;
  height: 2px;
  border: 0;
  border-radius: 2px;
  background: #f7fbff;
  transform: rotate(-42deg);
}

.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow: auto;
  padding: max(20px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  background: rgba(3, 6, 14, 0.91);
  backdrop-filter: blur(18px);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
}

.help-overlay.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.help-inner {
  width: min(620px, 100%);
  margin: 0 auto;
  padding-bottom: 28px;
}

.help-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: clamp(32px, 7vh, 64px);
}

.language-tabs {
  display: flex;
  padding: 3px;
  border: 1px solid rgba(220, 229, 255, 0.13);
  border-radius: 999px;
  background: rgba(238, 243, 255, 0.05);
}

.language-tabs button {
  min-width: 54px;
  height: 32px;
  padding: 0 13px;
  border: 0;
  border-radius: 999px;
  color: rgba(227, 234, 255, 0.56);
  background: transparent;
  cursor: pointer;
}

.language-tabs button[aria-selected="true"] {
  color: #f9fbff;
  background: rgba(235, 241, 255, 0.12);
}

.close-help {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  padding: 0;
  border: 0;
  color: rgba(245, 248, 255, 0.82);
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
  background: transparent;
  cursor: pointer;
}

.help-copy h2 {
  margin: 0;
  color: #fbfdff;
  font-size: 28px;
  font-weight: 650;
  letter-spacing: 0;
}

.help-lead {
  margin: 10px 0 34px;
  color: rgba(224, 232, 255, 0.58);
  font-size: 15px;
  line-height: 1.6;
}

.help-rule {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 18px;
  padding: 19px 0;
  border-top: 1px solid rgba(218, 227, 255, 0.1);
}

.help-rule strong {
  color: rgba(243, 247, 255, 0.88);
  font-size: 13px;
  font-weight: 650;
}

.help-rule p {
  margin: 0;
  color: rgba(220, 228, 250, 0.66);
  font-size: 14px;
  line-height: 1.65;
}

.hint {
  position: fixed;
  left: 50%;
  bottom: max(44px, calc(env(safe-area-inset-bottom) + 28px));
  z-index: 4;
  padding: 0;
  color: rgba(231, 237, 255, 0.58);
  font-size: 15px;
  font-weight: 520;
  letter-spacing: 0;
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
  transition:
    opacity 420ms ease,
    transform 420ms ease;
}

.hint.is-hidden {
  opacity: 0;
  transform: translate(-50%, 8px);
}

.game-over {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 6;
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
  width: min(390px, calc(100vw - 48px));
  padding: 26px 28px 28px;
  border: 1px solid rgba(222, 230, 255, 0.13);
  border-radius: 8px;
  background: rgba(6, 10, 20, 0.62);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(18px);
  opacity: 0;
  transform: translate(-50%, -45%) scale(0.98);
  pointer-events: none;
  transition:
    opacity 260ms ease,
    transform 260ms ease;
}

.game-over.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.game-over.is-clear {
  transition-duration: 900ms;
}

.result-group,
.best-group {
  display: grid;
  gap: 16px;
}

.result-group h2,
.best-group h2 {
  margin: 0;
  color: rgba(220, 229, 255, 0.52);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-align: left;
  text-transform: uppercase;
}

.game-over.is-clear .result-group h2 {
  color: rgba(208, 236, 255, 0.88);
  text-shadow: 0 0 18px rgba(132, 168, 255, 0.28);
}

.clear-message {
  margin: -6px 0 0;
  color: rgba(224, 234, 255, 0.64);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0;
}

.result-grid,
.best-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(88px, 1fr));
  gap: 18px 20px;
}

.best-group {
  padding-top: 20px;
  border-top: 1px solid rgba(222, 230, 255, 0.11);
}

.final-score,
.best-score,
.best-combo-score,
.time-score,
.gate-score,
.max-combo-score {
  display: grid;
  gap: 7px;
  text-align: center;
}

.final-score span,
.best-score span,
.best-combo-score span,
.time-score span,
.gate-score span,
.max-combo-score span {
  color: rgba(220, 229, 255, 0.56);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.final-score strong,
.best-score strong,
.best-combo-score strong,
.time-score strong,
.gate-score strong,
.max-combo-score strong {
  color: #fbfdff;
  font-size: clamp(26px, 8vw, 36px);
  line-height: 1;
}

#again {
  height: 46px;
  border: 1px solid rgba(231, 237, 255, 0.18);
  border-radius: 999px;
  color: #f9fbff;
  background: rgba(238, 243, 255, 0.1);
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

#again:hover {
  border-color: rgba(241, 246, 255, 0.34);
  background: rgba(238, 243, 255, 0.16);
}

#again:active {
  transform: scale(0.985);
}

@media (max-height: 560px) {
  .shell {
    min-height: 420px;
  }

  .hint {
    bottom: max(24px, calc(env(safe-area-inset-bottom) + 16px));
  }
}

@media (max-width: 520px) {
  .controls {
    flex-direction: column;
  }

  .help-rule {
    grid-template-columns: 72px 1fr;
    gap: 12px;
  }
}
