:root {
  color-scheme: dark;
  --ink: #fffaf0;
  --muted: #b8bfca;
  --line: rgba(255, 255, 255, 0.16);
  --panel: rgba(9, 10, 13, 0.72);
  --orange: #ff9f1c;
  --green: #40d47e;
  --blue: #50a7ff;
  --pink: #ff5b8f;
  --violet: #8f7cff;
  --lane-width: 25%;
  --hit-y: 78%;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: #c9d7df;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button {
  font: inherit;
}

.shell {
  min-height: 100svh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 18% 20%, rgba(255, 185, 92, 0.34), transparent 32%),
    radial-gradient(circle at 82% 18%, rgba(123, 189, 236, 0.42), transparent 35%),
    linear-gradient(140deg, #d7e7ee 0%, #aebdc7 54%, #d9e1e6 100%);
}

.game {
  position: relative;
  width: 100%;
  min-height: 100svh;
  overflow: hidden;
}

#visualizer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.04;
  z-index: 1;
}

.stage-video {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 0;
  width: auto;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
  opacity: 0;
  transform: translate(-50%, -50%);
  transition: opacity 300ms ease;
}

.stage-video.is-visible {
  opacity: 0.9;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  overflow: hidden;
}

.screen.is-active {
  display: block;
}

.screen-content {
  position: relative;
  z-index: 3;
}

.screen-op,
.screen-menu,
.screen-result {
  display: none;
  place-items: center;
  padding: 24px;
}

.screen-op.is-active,
.screen-menu.is-active,
.screen-result.is-active {
  display: grid;
}

.op-movie,
.op-fallback,
.stage-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.op-movie {
  z-index: 1;
  opacity: 0.72;
}

.op-fallback {
  z-index: 0;
  background:
    linear-gradient(120deg, rgba(255, 185, 92, 0.22), transparent 42%),
    linear-gradient(230deg, rgba(90, 160, 210, 0.22), transparent 46%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.18) 0 2px, transparent 2px 42px),
    #bdd0d9;
}

.stage-art {
  z-index: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(38, 47, 56, 0.48)),
    var(--stage-image, linear-gradient(135deg, #cbdde7, #a9bac6 52%, #d7e1e6));
  background-size: cover;
  background-position: center;
  opacity: 0.88;
}

.title-content,
.menu-content,
.result-content {
  width: min(760px, 100%);
  text-align: center;
  text-shadow: 0 4px 28px rgba(0, 0, 0, 0.55);
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 0.95;
  font-weight: 900;
}

h1 {
  font-size: 82px;
}

h2 {
  font-size: 62px;
}

.title-hint {
  margin: 18px 0 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
}

.primary-button,
.result-content button,
.difficulty button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
}

.primary-button {
  margin-top: 30px;
  min-width: 190px;
  padding: 0 26px;
  color: #130d04;
  background: var(--orange);
  border-color: rgba(255, 159, 28, 0.72);
  font-weight: 900;
  box-shadow: 0 0 34px rgba(255, 159, 28, 0.24);
}

.local-song {
  margin-top: 20px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 850;
}

.local-song[hidden],
.title-adjust[hidden] {
  display: none;
}

.local-song p {
  margin: 0 0 10px;
}

.local-song small {
  color: rgba(245, 250, 252, 0.78);
  font-size: 12px;
  font-weight: 800;
}

.local-song input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.local-song-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.14);
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
}

.local-difficulty {
  display: inline-grid;
  grid-template-columns: auto 54px;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  margin-left: 8px;
  padding: 0 8px 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.local-difficulty span {
  color: var(--ink);
  font-size: 11px;
  font-weight: 900;
}

.local-difficulty input {
  position: static;
  width: 42px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.12);
  opacity: 1;
  pointer-events: auto;
  font-size: 17px;
  font-weight: 900;
  text-align: center;
}

.stage-select {
  display: grid;
  grid-template-columns: repeat(5, 48px);
  justify-content: center;
  gap: 8px;
  margin: 0 auto;
}

.stage-select-panel {
  margin-top: 28px;
}

.stage-select-panel[hidden] {
  display: none;
}

.stage-select-label {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

.stage-select button {
  width: 48px;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  color: var(--ink);
  background-color: rgba(255, 255, 255, 0.12);
  background-position: center;
  background-size: cover;
  box-shadow: 0 0 18px rgba(92, 202, 255, 0.14);
  cursor: pointer;
  font-weight: 900;
  overflow: hidden;
  text-indent: -999px;
}

.stage-select button:hover,
.stage-select button:focus-visible {
  border-color: rgba(255, 159, 28, 0.76);
  background-color: rgba(255, 159, 28, 0.38);
  color: #130d04;
}

.all-songs-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-top: 22px;
  padding: 0 24px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.24);
  box-shadow: 0 0 24px rgba(92, 202, 255, 0.14);
  font-size: 14px;
  font-weight: 900;
  text-decoration: none;
}

.all-songs-link:hover,
.all-songs-link:focus-visible {
  background: rgba(255, 255, 255, 0.34);
}

.title-adjust {
  display: inline-grid;
  grid-template-columns: auto 78px;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
  padding: 8px 10px 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.title-adjust label {
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.title-adjust input {
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.12);
  font-size: 18px;
  font-weight: 900;
  text-align: center;
}

.difficulty {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: min(420px, 100%);
  margin: 24px auto 0;
}

.stage-meta {
  margin: 14px 0 0;
  color: rgba(245, 250, 252, 0.88);
  font-size: 20px;
  font-weight: 850;
}

.difficulty button {
  font-weight: 850;
}

.difficulty button.is-selected {
  background: var(--green);
  color: #04110a;
  border-color: rgba(64, 212, 126, 0.7);
}

.asset-note {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.countdown {
  margin: 20px 0 0;
  color: var(--orange);
  font-size: 22px;
  font-weight: 900;
}

.screen-play {
  padding: 14px;
}

.hud {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: min(620px, 100%);
  margin: 0 auto;
}

.hud div {
  min-height: 44px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.hud span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.hud strong {
  display: block;
  margin-top: 3px;
  font-size: 21px;
  line-height: 1;
}

.track-wrap {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  height: calc(100svh - 218px);
  min-height: 360px;
  padding: 8px 0;
}

.track {
  position: relative;
  width: min(560px, 100%);
  height: min(620px, 100%);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  overflow: hidden;
  border-inline: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 250, 240, 0.08), rgba(255, 250, 240, 0.01)),
    rgba(0, 0, 0, 0.36);
}

.track::before {
  content: "";
  position: absolute;
  left: 4%;
  right: 4%;
  top: var(--hit-y);
  z-index: 2;
  height: 2px;
  transform: translateY(-50%);
  background: linear-gradient(90deg, transparent, rgba(92, 202, 255, 0.78), rgba(117, 255, 232, 0.9), rgba(92, 202, 255, 0.78), transparent);
  box-shadow: 0 0 18px rgba(92, 202, 255, 0.62);
}

.lane {
  position: relative;
  border-left: 1px solid rgba(255, 255, 255, 0.045);
}

.lane:first-child {
  border-left: 0;
}

.lane span {
  display: none;
}

.lane.active span {
  display: none;
}

.lane span::before {
  content: attr(data-key);
  transform: rotate(-45deg);
  font-size: 12px;
}

.lane[data-lane="0"] {
  --lane-color: #5ccaff;
}

.lane[data-lane="1"] {
  --lane-color: #5df2bd;
}

.lane[data-lane="2"] {
  --lane-color: #a88cff;
}

.lane[data-lane="3"] {
  --lane-color: #ff6fb1;
}

.judgement-line {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--hit-y);
  z-index: 4;
  height: 1px;
  transform: translateY(-50%);
  pointer-events: none;
}

.judge-diamond {
  position: absolute;
  top: 50%;
  left: calc(var(--lane-index) * 25% + 12.5%);
  width: 76px;
  aspect-ratio: 1;
  transform: translate(-50%, -50%) rotate(45deg);
  border: 2px solid var(--judge-color);
  border-radius: 2px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.14), transparent 42%),
    rgba(255, 255, 255, 0.01);
  box-shadow:
    0 0 20px color-mix(in srgb, var(--judge-color) 64%, transparent),
    inset 0 0 18px color-mix(in srgb, var(--judge-color) 38%, transparent);
}

.judge-diamond::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid color-mix(in srgb, var(--judge-color) 72%, white);
  opacity: 0.78;
}

.judge-diamond[data-lane="0"] {
  --lane-index: 0;
  --judge-color: #5ccaff;
}

.judge-diamond[data-lane="1"] {
  --lane-index: 1;
  --judge-color: #5df2bd;
}

.judge-diamond[data-lane="2"] {
  --lane-index: 2;
  --judge-color: #a88cff;
}

.judge-diamond[data-lane="3"] {
  --lane-index: 3;
  --judge-color: #ff6fb1;
}

.judge-diamond.active {
  animation: judge-flash 180ms ease;
}

@keyframes judge-flash {
  0%,
  100% {
    transform: translate(-50%, -50%) rotate(45deg) scale(1);
  }
  50% {
    transform: translate(-50%, -50%) rotate(45deg) scale(1.18);
    box-shadow:
      0 0 34px color-mix(in srgb, var(--judge-color) 86%, transparent),
      0 0 80px color-mix(in srgb, var(--judge-color) 48%, transparent),
      inset 0 0 24px color-mix(in srgb, var(--judge-color) 54%, transparent);
  }
}

.notes-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.note {
  position: absolute;
  left: calc(var(--lane) * var(--lane-width) + 12.5%);
  top: var(--y);
  width: 42px;
  aspect-ratio: 1;
  transform: translate(-50%, -50%) rotate(45deg);
  border: 2px solid var(--note-color, var(--orange));
  border-radius: 2px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0.05)),
    color-mix(in srgb, var(--note-color, var(--orange)) 44%, transparent);
  box-shadow:
    0 0 20px color-mix(in srgb, var(--note-color, var(--orange)) 76%, transparent),
    0 0 48px color-mix(in srgb, var(--note-color, var(--orange)) 34%, transparent),
    inset 0 0 14px rgba(255, 255, 255, 0.32);
}

.note.hit {
  transform: translate(-50%, -50%) rotate(45deg) scale(1.45);
  opacity: 0;
  transition: transform 140ms ease, opacity 140ms ease;
}

.hit-text {
  position: absolute;
  left: 50%;
  bottom: 132px;
  z-index: 5;
  min-width: 190px;
  transform: translateX(-50%);
  text-align: center;
  font-size: 54px;
  font-weight: 950;
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 0 30px currentColor;
}

.hit-text.has-image {
  width: 260px;
  height: 92px;
  min-width: 0;
  color: transparent;
  text-shadow: none;
}

.hit-text.has-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.combo-burst {
  position: absolute;
  left: 50%;
  top: 18%;
  z-index: 5;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  min-width: 220px;
  transform: translateX(-50%) scale(0.72);
  color: rgba(255, 250, 240, 0.96);
  font-family: Georgia, "Times New Roman", serif;
  text-shadow: 0 4px 28px rgba(0, 0, 0, 0.62);
  opacity: 0;
  pointer-events: none;
}

.combo-burst .digit-strip {
  font-size: 128px;
  line-height: 0.9;
}

.combo-burst.use-sprite .digit-strip {
  display: flex;
  gap: 2px;
}

.digit {
  display: inline-block;
}

.combo-burst.use-sprite .digit {
  width: 84px;
  height: 116px;
  background-image: url("assets/ui/digits.png");
  background-repeat: no-repeat;
  background-size: 840px 116px;
  background-position-x: calc(var(--digit) * -84px);
  background-position-y: 0;
  color: transparent;
}

.combo-burst.use-combo-image small {
  width: 118px;
  height: 38px;
  background-image: url("assets/ui/combo.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  color: transparent;
}

.combo-burst small {
  font-size: 30px;
  letter-spacing: 0;
}

.combo-burst.is-visible {
  opacity: 1;
}

.combo-burst.bump .digit-strip {
  animation: combo-bounce 260ms cubic-bezier(0.2, 1.35, 0.35, 1);
}

@keyframes combo-bounce {
  0% {
    transform: scale(0.68);
  }
  55% {
    transform: scale(1.16);
  }
  100% {
    transform: scale(1);
  }
}

.hit-text.perfect {
  color: var(--orange);
}

.hit-text.good {
  color: var(--green);
}

.hit-text.miss {
  color: var(--blue);
}

.hit-text.show {
  animation: pop 260ms ease;
}

@keyframes pop {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(10px) scale(0.8);
  }
  25%,
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-14px) scale(1.06);
  }
}

.touch-pads {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: min(780px, 100%);
  margin: -2px auto 18px;
}

.touch-pads button {
  height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.1);
  font-size: 24px;
  font-weight: 900;
  touch-action: manipulation;
}

.touch-pads button:active {
  background: var(--green);
  color: #06120a;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  width: min(680px, 100%);
  margin: 28px auto 0;
}

.result-stats div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.result-stats dt {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.result-stats dd {
  margin: 6px 0 0;
  font-size: 28px;
  font-weight: 900;
}

.result-content button {
  min-width: 150px;
  margin: 28px 5px 0;
  padding: 0 22px;
  font-weight: 900;
}

.result-content .primary-button {
  color: var(--ink);
}

.music-cta {
  display: grid;
  place-items: center;
  width: min(360px, 100%);
  min-height: 50px;
  margin: 18px auto 0;
  border: 1px solid rgba(255, 159, 28, 0.72);
  border-radius: 8px;
  color: #130d04;
  background: var(--orange);
  box-shadow: 0 0 34px rgba(255, 159, 28, 0.26);
  font-weight: 950;
  text-decoration: none;
}

@media (max-width: 720px) {
  .screen-op,
  .screen-menu,
  .screen-result {
    padding: 18px;
  }

  h1 {
    font-size: 48px;
  }

  h2 {
    font-size: 34px;
  }

  .stage-meta {
    font-size: 16px;
  }

  .stage-select {
    grid-template-columns: repeat(5, 42px);
  }

  .stage-select button {
    width: 42px;
  }

  .title-hint {
    font-size: 15px;
  }

  .title-adjust {
    margin-top: 18px;
    grid-template-columns: auto 68px;
  }

  .local-difficulty {
    display: grid;
    width: fit-content;
    margin: 10px auto 0;
  }

  .hud {
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
  }

  .hud div {
    min-height: 40px;
    padding: 6px 8px;
  }

  .hud strong {
    font-size: 18px;
  }

  .result-stats {
    grid-template-columns: repeat(2, 1fr);
    width: min(420px, 100%);
  }

  .track-wrap {
    height: calc(100svh - 188px);
    min-height: 300px;
  }

  .track {
    height: 100%;
    --hit-y: 72%;
  }

  .hit-text {
    font-size: 34px;
  }

  .combo-burst {
    top: 18%;
    min-width: 170px;
  }

  .combo-burst .digit-strip {
    font-size: 96px;
  }

  .combo-burst.use-sprite .digit {
    width: 64px;
    height: 88px;
    background-size: 640px 88px;
    background-position-x: calc(var(--digit) * -64px);
  }

  .combo-burst small {
    font-size: 22px;
  }

  .touch-pads button {
    height: 78px;
  }

  .touch-pads {
    margin-top: -26px;
  }
}
