:root {
  --ink: #f5fbff;
  --ink-dim: #a9b6d5;
  --navy-950: #070b1d;
  --navy-900: #0c1129;
  --navy-800: #121a38;
  --navy-700: #1b264a;
  --navy-600: #28365e;
  --mint: #76f3c7;
  --mint-soft: #b7ffe8;
  --coral: #ff7180;
  --yellow: #ffd76e;
  --violet: #9b8dff;
  --line: rgba(236, 246, 255, 0.16);
  --line-strong: rgba(236, 246, 255, 0.28);
  --shadow: 0 24px 70px rgba(3, 6, 20, 0.46);
  --app-width: 412px;
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--navy-950);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 16% 12%, rgba(118, 243, 199, 0.09), transparent 28%),
    radial-gradient(circle at 88% 84%, rgba(255, 113, 128, 0.11), transparent 27%),
    linear-gradient(145deg, #080c20 0%, #0d1430 46%, #080b1c 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

#app {
  position: relative;
  display: flex;
  width: min(var(--app-width), calc(100vw - 32px));
  min-height: min(812px, calc(100vh - 32px));
  margin: 16px auto;
  overflow: hidden;
  isolation: isolate;
  flex-direction: column;
  border: 1px solid rgba(229, 244, 255, 0.16);
  border-radius: 32px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, rgba(118, 243, 199, 0.014) 0 1px, transparent 1px 6px),
    radial-gradient(circle at 10% 0%, rgba(118, 243, 199, 0.11), transparent 27%),
    radial-gradient(circle at 98% 100%, rgba(255, 113, 128, 0.13), transparent 32%),
    linear-gradient(165deg, var(--navy-800), var(--navy-950) 76%);
}

#app::before,
#app::after {
  position: absolute;
  z-index: -1;
  pointer-events: none;
  content: "";
}

#app::before {
  top: -150px;
  right: -130px;
  width: 320px;
  height: 320px;
  border: 1px solid rgba(118, 243, 199, 0.12);
  border-radius: 50%;
  box-shadow: 0 0 0 20px rgba(118, 243, 199, 0.025), 0 0 0 42px rgba(118, 243, 199, 0.018);
}

#app::after {
  bottom: -125px;
  left: -130px;
  width: 285px;
  height: 285px;
  border: 1px solid rgba(255, 113, 128, 0.12);
  border-radius: 50%;
  box-shadow: 0 0 0 24px rgba(255, 113, 128, 0.026);
}

.screen {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  padding: 28px 22px 22px;
}

.eyebrow,
.section-kicker,
.hud-label,
.stage-kicker,
.result-kicker {
  margin: 0;
  color: var(--mint);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  line-height: 1.2;
  text-transform: uppercase;
}

.title-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(118, 243, 199, 0.36);
  border-radius: 15px 15px 15px 4px;
  color: var(--navy-950);
  font-size: 1.18rem;
  font-weight: 950;
  letter-spacing: -0.1em;
  background: var(--mint);
  box-shadow: 8px 8px 0 rgba(255, 113, 128, 0.26);
  transform: rotate(-4deg);
}

.brand-mark span {
  transform: rotate(4deg);
}

.title-copy {
  max-width: 286px;
}

#title-screen h1 {
  margin: 16px 0 0;
  color: var(--ink);
  font-size: clamp(2.45rem, 10vw, 3.7rem);
  font-weight: 950;
  letter-spacing: -0.09em;
  line-height: 0.9;
}

#title-screen h1 em {
  display: block;
  color: var(--coral);
  font-style: normal;
}

.title-subtitle {
  max-width: 260px;
  margin: 20px 0 0;
  color: var(--ink-dim);
  font-size: 0.92rem;
  line-height: 1.6;
}

.title-orbit {
  position: relative;
  width: min(100%, 340px);
  height: 158px;
  margin: auto auto 26px;
  overflow: hidden;
  border: 1px solid rgba(236, 246, 255, 0.13);
  border-radius: 22px;
  background:
    linear-gradient(90deg, transparent 49.7%, rgba(118, 243, 199, 0.14) 50%, transparent 50.3%),
    linear-gradient(0deg, transparent 49.7%, rgba(255, 215, 110, 0.12) 50%, transparent 50.3%),
    radial-gradient(circle at 50% 50%, rgba(118, 243, 199, 0.2), transparent 16%),
    var(--navy-900);
}

.title-orbit::before,
.title-orbit::after {
  position: absolute;
  inset: 22px 18%;
  border: 1px solid rgba(118, 243, 199, 0.2);
  border-radius: 50%;
  content: "";
  transform: rotate(-17deg) scaleY(0.46);
}

.title-orbit::after {
  inset: 35px 8%;
  border-color: rgba(255, 113, 128, 0.2);
  transform: rotate(21deg) scaleY(0.39);
}

.orbit-orb {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  border: 5px solid var(--navy-950);
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 6px rgba(118, 243, 199, 0.16), 0 0 28px rgba(118, 243, 199, 0.72);
  transform: translate(-50%, -50%);
}

.orbit-note {
  position: absolute;
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid rgba(7, 11, 29, 0.62);
  border-radius: 8px 8px 8px 2px;
  color: var(--navy-950);
  font-size: 0.72rem;
  font-weight: 950;
  background: var(--yellow);
  transform: rotate(8deg);
}

.orbit-note--one {
  top: 28px;
  left: 15%;
}

.orbit-note--two {
  right: 16%;
  bottom: 26px;
  color: #fff;
  background: var(--coral);
  transform: rotate(-9deg);
}

.title-actions {
  display: grid;
  gap: 10px;
}

.primary-button,
.ghost-button,
.stage-card,
.result-dismiss {
  min-height: 48px;
  border: 0;
  cursor: pointer;
}

#start-button,
#back-button {
  -webkit-tap-highlight-color: transparent;
}

#back-button {
  flex: 0 0 auto;
}

.primary-button {
  position: relative;
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 17px;
  overflow: hidden;
  border-radius: 15px;
  color: var(--navy-950);
  font-size: 0.98rem;
  font-weight: 900;
  text-align: left;
  background: var(--mint);
  box-shadow: 0 8px 0 rgba(118, 243, 199, 0.22);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-button::after {
  position: absolute;
  top: 0;
  right: -36px;
  width: 105px;
  height: 100%;
  content: "";
  background: rgba(255, 255, 255, 0.18);
  transform: skewX(-24deg);
}

.primary-button span:last-child {
  font-size: 1.25rem;
  line-height: 1;
}

.primary-button:hover {
  background: var(--mint-soft);
  transform: translateY(-2px);
  box-shadow: 0 10px 0 rgba(118, 243, 199, 0.22);
}

.primary-button:active {
  transform: translateY(3px);
  box-shadow: 0 4px 0 rgba(118, 243, 199, 0.22);
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink-dim);
  font-size: 0.8rem;
  font-weight: 800;
  background: rgba(12, 17, 41, 0.58);
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.ghost-button:hover {
  border-color: var(--mint);
  color: var(--mint-soft);
  background: rgba(118, 243, 199, 0.08);
}

#stage-select {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 16px;
  padding-top: 24px;
}

.stage-select-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.stage-select-heading h2 {
  margin: 6px 0 0;
  font-size: 1.42rem;
  letter-spacing: -0.04em;
}

.stage-select-heading p:last-child {
  max-width: 100px;
  margin: 0;
  color: var(--ink-dim);
  font-size: 0.72rem;
  line-height: 1.35;
  text-align: right;
}

#stage-buttons {
  display: grid;
  min-height: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  overflow-y: auto;
  padding: 2px 2px 7px;
  scrollbar-color: var(--navy-600) transparent;
  scrollbar-width: thin;
}

.stage-card {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 148px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  text-align: left;
  background:
    linear-gradient(135deg, rgba(118, 243, 199, 0.11), transparent 44%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.04), transparent 55%),
    var(--navy-900);
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.stage-card::after {
  position: absolute;
  right: -17px;
  bottom: -23px;
  width: 78px;
  height: 78px;
  border: 1px solid rgba(118, 243, 199, 0.28);
  border-radius: 50%;
  content: "";
  box-shadow: 0 0 0 11px rgba(118, 243, 199, 0.04), 0 0 0 22px rgba(118, 243, 199, 0.025);
}

.stage-card:hover,
.stage-card[aria-current="true"] {
  border-color: var(--mint);
  background:
    linear-gradient(135deg, rgba(118, 243, 199, 0.2), transparent 48%),
    var(--navy-800);
  transform: translateY(-3px);
}

.stage-card:nth-child(3n + 2) {
  background:
    linear-gradient(135deg, rgba(255, 113, 128, 0.13), transparent 48%),
    var(--navy-900);
}

.stage-card:nth-child(3n) {
  background:
    linear-gradient(135deg, rgba(255, 215, 110, 0.14), transparent 48%),
    var(--navy-900);
}

.stage-card:nth-child(3n + 2)::after {
  border-color: rgba(255, 113, 128, 0.28);
}

.stage-card:nth-child(3n)::after {
  border-color: rgba(255, 215, 110, 0.28);
}

.stage-card__topline {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stage-card__index {
  color: var(--yellow);
  font-size: 0.72rem;
  font-weight: 900;
}

.stage-card__title {
  max-width: 100%;
  margin-top: 14px;
  overflow: hidden;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-card__meta {
  max-width: 100%;
  overflow: hidden;
  color: var(--ink-dim);
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-screen {
  gap: 12px;
  padding-top: 20px;
}

.game-topbar,
.game-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.game-topbar__title {
  min-width: 0;
}

.game-topbar__title h2 {
  margin: 4px 0 0;
  overflow: hidden;
  font-size: 1.22rem;
  letter-spacing: -0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-topbar__stage {
  flex: 0 0 auto;
  padding: 7px 9px;
  border: 1px solid rgba(255, 215, 110, 0.4);
  border-radius: 10px;
  color: var(--yellow);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.game-instruction {
  max-width: 315px;
  margin: 0;
  color: var(--ink-dim);
  font-size: 0.78rem;
  line-height: 1.45;
}

.hud-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.hud-card {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(12, 17, 41, 0.64);
}

.hud-card--accent {
  border-color: rgba(118, 243, 199, 0.26);
  background: rgba(118, 243, 199, 0.07);
}

.hud-value {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--ink);
  font-size: 1.16rem;
  font-weight: 950;
  letter-spacing: -0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-card--accent .hud-value {
  color: var(--mint);
}

#beat-lane {
  --pulse-strength: 0;
  position: relative;
  display: block;
  min-height: 0;
  flex: 1;
  overflow: hidden;
  border: 1px solid rgba(236, 246, 255, 0.16);
  border-radius: 22px;
  background:
    linear-gradient(90deg, transparent 24.8%, rgba(236, 246, 255, 0.07) 25%, transparent 25.2%, transparent 49.8%, rgba(236, 246, 255, 0.1) 50%, transparent 50.2%, transparent 74.8%, rgba(236, 246, 255, 0.07) 75%, transparent 75.2%),
    linear-gradient(0deg, rgba(118, 243, 199, calc(0.04 + var(--pulse-strength) * 0.1)), transparent 36%),
    repeating-linear-gradient(0deg, rgba(236, 246, 255, 0.05) 0 1px, transparent 1px 42px),
    linear-gradient(155deg, #111a3a, #0a1028 78%);
  box-shadow: inset 0 0 52px rgba(118, 243, 199, calc(0.04 + var(--pulse-strength) * 0.08));
  transition: box-shadow 160ms ease, background-color 160ms ease;
}

#beat-lane::before,
#beat-lane::after {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  content: "";
  background: linear-gradient(180deg, transparent, rgba(118, 243, 199, 0.52) 26%, rgba(118, 243, 199, 0.08) 74%, transparent);
}

#beat-lane::before {
  left: 9px;
}

#beat-lane::after {
  right: 9px;
}

#beat-lane.is-pulsing {
  box-shadow: inset 0 0 70px rgba(118, 243, 199, calc(0.1 + var(--pulse-strength) * 0.16)), 0 0 0 1px rgba(118, 243, 199, calc(0.1 + var(--pulse-strength) * 0.16));
}

#hit-line {
  position: absolute;
  right: 15px;
  bottom: 72px;
  left: 15px;
  height: 2px;
  border-radius: 99px;
  background: linear-gradient(90deg, transparent, var(--yellow) 12%, var(--yellow) 88%, transparent);
  box-shadow: 0 0 12px rgba(255, 215, 110, 0.76);
}

#hit-line::before,
#hit-line::after {
  position: absolute;
  top: 50%;
  width: 7px;
  height: 7px;
  border: 2px solid var(--yellow);
  border-radius: 50%;
  content: "";
  background: var(--navy-900);
  transform: translateY(-50%);
}

#hit-line::before {
  left: -1px;
}

#hit-line::after {
  right: -1px;
}

#player-orb {
  --orb-x: 50;
  --orb-y: 18;
  position: absolute;
  z-index: 2;
  bottom: calc(72px + (var(--orb-y) * 1%));
  left: calc(var(--orb-x) * 1%);
  width: 32px;
  height: 32px;
  border: 6px solid var(--navy-950);
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 5px rgba(118, 243, 199, 0.2), 0 0 26px rgba(118, 243, 199, 0.78);
  transform: translate(-50%, 50%);
  transition: left 180ms ease, bottom 180ms ease, box-shadow 180ms ease;
}

#player-orb::before {
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(7, 11, 29, 0.45);
  border-radius: 50%;
  content: "";
}

#player-orb.is-hit {
  box-shadow: 0 0 0 8px rgba(118, 243, 199, 0.22), 0 0 38px rgba(255, 215, 110, 0.9);
}

.beat-marker {
  position: absolute;
  z-index: 1;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 2px solid var(--coral);
  border-radius: 7px 7px 7px 2px;
  color: var(--navy-950);
  font-size: 0.62rem;
  font-weight: 950;
  background: var(--coral);
  box-shadow: 0 0 16px rgba(255, 113, 128, 0.52);
  transform: translate(-50%, 50%) rotate(-8deg);
}

.beat-marker[data-kind="perfect"] {
  border-color: var(--yellow);
  background: var(--yellow);
}

.beat-marker[data-active="true"] {
  border-color: var(--mint);
  background: var(--mint);
}

#feedback {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 4;
  max-width: calc(100% - 48px);
  padding: 9px 14px;
  border: 1px solid var(--mint);
  border-radius: 999px;
  color: var(--navy-950);
  font-size: 0.79rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  opacity: 0;
  pointer-events: none;
  text-align: center;
  text-transform: uppercase;
  background: var(--mint);
  box-shadow: 0 8px 24px rgba(118, 243, 199, 0.28);
  transform: translate(-50%, -50%) scale(0.84) rotate(-4deg);
}

#feedback.is-visible {
  animation: feedback-pop 700ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

#feedback[data-kind="good"] {
  border-color: var(--yellow);
  background: var(--yellow);
}

#feedback[data-kind="miss"] {
  border-color: var(--coral);
  color: #fff;
  background: var(--coral);
}

#feedback[data-kind="perfect"] {
  border-color: var(--mint);
  background: var(--mint);
}

.game-footer {
  min-height: 39px;
}

.progress-wrap {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: 10px;
}

.progress-caption {
  flex: 0 0 auto;
  color: var(--ink-dim);
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

#progress {
  --progress: 0%;
  position: relative;
  display: block;
  width: 100%;
  height: 8px;
  overflow: hidden;
  border: 0;
  border-radius: 99px;
  appearance: none;
  background: rgba(236, 246, 255, 0.11);
}

#progress::after {
  display: block;
  width: var(--progress);
  height: 100%;
  border-radius: inherit;
  content: "";
  background: linear-gradient(90deg, var(--mint), var(--yellow));
  box-shadow: 0 0 10px rgba(118, 243, 199, 0.58);
}

#progress[data-native="true"]::after {
  display: none;
}

#progress::-webkit-progress-bar {
  border-radius: 99px;
  background: rgba(236, 246, 255, 0.11);
}

#progress::-webkit-progress-value {
  border-radius: 99px;
  background: linear-gradient(90deg, var(--mint), var(--yellow));
}

#progress::-moz-progress-bar {
  border-radius: 99px;
  background: linear-gradient(90deg, var(--mint), var(--yellow));
}

.result-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(7, 11, 29, 0.78);
  backdrop-filter: blur(6px);
}

.result-card {
  width: min(100%, 320px);
  padding: 24px 20px 20px;
  border: 1px solid rgba(118, 243, 199, 0.42);
  border-radius: 22px;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 4px),
    linear-gradient(155deg, rgba(27, 38, 74, 0.98), rgba(12, 17, 41, 0.98));
  box-shadow: 0 20px 58px rgba(0, 0, 0, 0.38), 0 0 0 8px rgba(118, 243, 199, 0.05);
  animation: result-in 360ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.result-card h2 {
  margin: 7px 0 0;
  font-size: 1.72rem;
  letter-spacing: -0.06em;
}

.result-score {
  margin: 20px 0 16px;
  color: var(--mint);
  font-size: 3rem;
  font-weight: 950;
  letter-spacing: -0.1em;
  line-height: 0.9;
}

.result-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.result-detail {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(7, 11, 29, 0.32);
}

.result-detail span {
  display: block;
  color: var(--ink-dim);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.result-detail strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 1rem;
}

.result-message {
  min-height: 20px;
  margin: 0 0 18px;
  color: var(--ink-dim);
  font-size: 0.8rem;
  line-height: 1.45;
}

.result-dismiss {
  width: 100%;
}

@keyframes feedback-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.84) rotate(-4deg);
  }
  18%,
  76% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(2deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.96) rotate(0deg);
  }
}

@keyframes result-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 430px) {
  #app {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }
}

@media (max-height: 680px) {
  #app {
    min-height: 100vh;
  }

  .screen {
    padding-top: 20px;
    padding-bottom: 16px;
  }

  .title-orbit {
    height: 112px;
    margin-bottom: 16px;
  }

  #title-screen h1 {
    margin-top: 10px;
    font-size: 2.65rem;
  }

  .title-subtitle {
    margin-top: 12px;
  }

  .stage-card {
    min-height: 128px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
