* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 10%, rgba(36, 174, 175, 0.18), transparent 26rem),
    linear-gradient(135deg, #15161d 0%, #25222c 48%, #171b20 100%);
  color: #f6f1e8;
  font-family: Arial, Helvetica, sans-serif;
  display: grid;
  place-items: center;
}

.game-shell {
  width: min(920px, calc(100vw - 32px));
  min-height: min(760px, calc(100vh - 32px));
  display: grid;
  grid-template-rows: auto auto auto auto 1fr auto;
  gap: 18px;
}

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

.hud > div {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.24);
  padding: 14px 16px;
}

.label {
  display: block;
  color: #b9c4c4;
  font-size: 12px;
  letter-spacing: 0;
  margin-bottom: 6px;
}

.hud strong {
  font-size: clamp(20px, 4vw, 38px);
  line-height: 1;
}

.difficulty,
.mode-select {
  display: grid;
  gap: 10px;
}

.difficulty {
  grid-template-columns: repeat(3, 1fr);
}

.mode-select {
  grid-template-columns: repeat(2, 1fr);
}

.difficulty label,
.mode-select label {
  position: relative;
  min-height: 44px;
}

.difficulty input,
.mode-select input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.difficulty span,
.mode-select span {
  width: 100%;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #dfe9e7;
  font-weight: 800;
  cursor: pointer;
}

.difficulty input:checked + span,
.mode-select input:checked + span {
  background: #53d8fb;
  border-color: #b8f0ff;
  color: #09131a;
}

.song-import {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) minmax(180px, auto);
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  padding: 10px 12px;
}

.song-import label {
  color: #dfe9e7;
  font-size: 13px;
  font-weight: 800;
}

.song-import input {
  width: 100%;
  min-width: 0;
  color: #dfe9e7;
  font: inherit;
}

.song-import input::file-selector-button {
  margin-right: 10px;
  border: 0;
  border-radius: 8px;
  background: #53d8fb;
  color: #09131a;
  padding: 9px 12px;
  font-weight: 800;
  cursor: pointer;
}

.song-import span {
  color: #b9c4c4;
  font-size: 12px;
  text-align: right;
}

.stage {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(var(--lane-count, 4), 1fr);
  gap: 10px;
  min-height: 520px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.08), transparent 34%),
    rgba(5, 7, 10, 0.68);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

.lane {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: auto;
  padding: 0;
  appearance: none;
  cursor: pointer;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  border-top: 0;
  border-bottom: 0;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.035);
  color: inherit;
  font: inherit;
}

.piano-mode {
  gap: 4px;
  background:
    linear-gradient(to bottom, rgba(117, 211, 255, 0.12), transparent 38%),
    repeating-linear-gradient(
      to right,
      rgba(255, 255, 255, 0.05) 0,
      rgba(255, 255, 255, 0.05) 1px,
      transparent 1px,
      transparent calc(100% / var(--lane-count, 8))
    ),
    rgba(5, 7, 10, 0.72);
}

.piano-mode .lane:nth-of-type(odd) {
  background: rgba(255, 255, 255, 0.055);
}

.piano-mode .lane:nth-of-type(even) {
  background: rgba(83, 216, 251, 0.055);
}

.lane span {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font-size: 26px;
  font-weight: 800;
}

.lane small {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  color: #c8d4d4;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.lane.active span {
  background: #f2c14e;
  color: #1d1a14;
  border-color: #fff6d4;
  transform: translateX(-50%) scale(1.06);
}

.hit-line {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 72px;
  height: 4px;
  z-index: 5;
  background: #f2c14e;
  box-shadow: 0 0 18px rgba(242, 193, 78, 0.9);
}

.note {
  position: absolute;
  left: 50%;
  top: -72px;
  z-index: 3;
  width: min(92px, 78%);
  height: 58px;
  display: grid;
  place-items: center;
  transform: translateX(-50%);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), transparent 36%),
    linear-gradient(180deg, #53d8fb, #2a9df4);
  border: 3px solid rgba(255, 255, 255, 0.78);
  box-shadow:
    0 7px 0 #1569a7,
    0 18px 30px rgba(42, 157, 244, 0.36);
  color: #08131b;
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
}

.note::after {
  content: attr(data-note);
  position: absolute;
  right: 8px;
  bottom: 6px;
  color: rgba(8, 19, 27, 0.34);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.classic-mode .note::after {
  content: attr(data-key);
}

.note.hit {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), transparent 36%),
    linear-gradient(180deg, #a6efae, #45c75a);
  border-color: #eaffec;
  box-shadow:
    0 7px 0 #26873a,
    0 0 28px rgba(116, 214, 128, 0.8);
}

.note.missed {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.64), transparent 36%),
    linear-gradient(180deg, #ff8a9b, #e85d75);
  border-color: #ffd7de;
  box-shadow:
    0 7px 0 #9e2e44,
    0 0 24px rgba(232, 93, 117, 0.7);
}

.controls {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.controls button {
  min-width: 130px;
  height: 46px;
  border: 0;
  border-radius: 8px;
  background: #f2c14e;
  color: #171717;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}

.controls button:hover {
  filter: brightness(1.08);
}

.controls button:active {
  transform: translateY(1px);
}

@media (max-width: 620px) {
  .game-shell {
    width: calc(100vw - 20px);
    min-height: calc(100vh - 20px);
    gap: 10px;
  }

  .hud {
    grid-template-columns: 1fr;
  }

  .difficulty,
  .mode-select {
    grid-template-columns: 1fr;
  }

  .song-import {
    grid-template-columns: 1fr;
  }

  .song-import span {
    text-align: left;
  }

  .hud > div {
    padding: 10px 12px;
  }

  .stage {
    min-height: 480px;
    gap: 4px;
  }

  .piano-mode {
    gap: 2px;
  }

  .lane span {
    width: min(44px, 82%);
    height: 44px;
    font-size: 20px;
  }

  .piano-mode .lane span {
    width: min(38px, 84%);
    height: 42px;
    font-size: 18px;
  }

  .lane small {
    font-size: 10px;
  }

  .note {
    width: min(68px, 82%);
    height: 50px;
    font-size: 24px;
  }

  .piano-mode .note {
    width: min(48px, 86%);
    font-size: 18px;
  }

  .controls button {
    min-width: 112px;
  }
}
