:root {
  color-scheme: dark;
  --bg: #07080d;
  --panel: #10141c;
  --panel-strong: #151b25;
  --line: #2a3242;
  --line-bright: #4b5a73;
  --text: #eef5ff;
  --muted: #9aa9bd;
  --dim: #667386;
  --cyan: #4fd0ff;
  --green: #35d69b;
  --gold: #f4c84b;
  --rose: #ff6b8b;
  --violet: #9d8cff;
  --shadow: rgba(0, 0, 0, 0.32);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

select {
  font: inherit;
  color: var(--text);
}

button {
  border: 1px solid var(--line);
  color: var(--text);
  background: #18202c;
  cursor: pointer;
}

button:disabled {
  color: var(--dim);
  cursor: not-allowed;
  opacity: 0.62;
}

button:not(:disabled):hover,
.upload-button:hover,
.song-item:hover {
  border-color: var(--line-bright);
  background: #1f2938;
}

.app-shell {
  position: relative;
  width: 100%;
  height: 100%;
}

.game-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #05070a;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.ui-toggle-button {
  position: absolute;
  z-index: 6;
  top: 18px;
  left: 18px;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 0;
  background: rgba(9, 13, 20, 0.78);
  color: var(--text);
  font-weight: 900;
  box-shadow: 0 10px 24px var(--shadow);
  backdrop-filter: blur(10px);
}

.ui-toggle-button[aria-pressed="true"] {
  border-color: rgba(79, 208, 255, 0.65);
  color: var(--cyan);
}

.command-bar {
  position: absolute;
  z-index: 4;
  top: 18px;
  left: 70px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.command-bar button,
.toolbar button,
.upload-button,
#playButton {
  display: inline-grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 0 14px;
  background: rgba(9, 13, 20, 0.78);
  color: var(--text);
  font-weight: 800;
  box-shadow: 0 10px 24px var(--shadow);
  backdrop-filter: blur(10px);
  cursor: pointer;
}

.command-bar button:hover,
.ui-toggle-button:hover,
.upload-button:hover,
.song-item:hover {
  border-color: var(--line-bright);
  background: rgba(31, 41, 56, 0.9);
}

.game-stage.ui-hidden .command-bar,
.game-stage.ui-hidden .hud {
  display: none;
}

.music-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(2, 4, 8, 0.74);
  backdrop-filter: blur(12px);
}

.music-overlay[hidden] {
  display: none;
}

.music-panel {
  display: grid;
  grid-template-rows: auto auto auto minmax(250px, 0.92fr) auto minmax(150px, 1fr) auto;
  width: min(1040px, 100%);
  height: min(820px, 100%);
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(70, 95, 140, 0.18), transparent 34%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    #0d121c;
  background-size: auto, 44px 44px, 44px 44px, auto;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 20px 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.1;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  font-weight: 800;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
  padding: 10px 20px;
}

.toolbar button {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
}

.toolbar button[hidden] {
  display: none;
}

#songUpload {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.search-row {
  padding: 0 20px 14px;
}

#searchInput {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: #0b1018;
  outline: none;
}

#searchInput:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(79, 208, 255, 0.14);
}

.selected-record {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 4px 20px 96px;
  overflow: hidden;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background:
    linear-gradient(180deg, rgba(6, 10, 18, 0.18), rgba(2, 3, 7, 0.28)),
    linear-gradient(90deg, transparent 0 8%, rgba(79, 208, 255, 0.08) 49%, transparent 92%);
}

.selected-record::before,
.selected-record::after {
  content: "";
  position: absolute;
  top: 42px;
  width: 156px;
  height: 156px;
  border: 1px solid rgba(150, 180, 255, 0.18);
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #080b11 0 14%, transparent 15%),
    repeating-radial-gradient(circle at center, #263246 0 3px, #121923 4px 7px),
    conic-gradient(from 24deg, rgba(80, 120, 200, 0.82), rgba(80, 220, 170, 0.76), rgba(220, 180, 80, 0.82), rgba(80, 120, 200, 0.82));
  box-shadow: 0 24px 34px rgba(0, 0, 0, 0.42);
  opacity: 0.62;
  transform: perspective(560px) rotateX(58deg) scale(0.94);
}

.selected-record::before {
  left: max(24px, 12%);
}

.selected-record::after {
  right: max(24px, 12%);
}

.record-art {
  position: relative;
  display: grid;
  place-items: center;
  z-index: 2;
  width: min(238px, 42vw);
  height: min(238px, 42vw);
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #090b10 0 13%, transparent 14%),
    repeating-radial-gradient(circle at center, #1e2836 0 4px, #121923 5px 8px),
    conic-gradient(from 12deg, var(--rose), var(--gold), var(--green), var(--cyan), var(--violet), var(--rose));
  box-shadow: 0 28px 50px rgba(0, 0, 0, 0.52), 0 0 0 10px rgba(255, 255, 255, 0.035);
  transform: perspective(700px) rotateX(9deg);
}

.record-art::after {
  content: "";
  position: absolute;
  inset: 16%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  box-shadow: inset 0 0 0 18px rgba(0, 0, 0, 0.18);
}

.record-art span {
  position: relative;
  z-index: 1;
  font-size: clamp(2rem, 7vw, 3.4rem);
  font-weight: 900;
}

.record-meta {
  position: absolute;
  right: 20px;
  bottom: 16px;
  left: 20px;
  z-index: 3;
  min-height: 74px;
  min-width: 0;
  border: 1px solid rgba(110, 140, 200, 0.34);
  border-radius: 8px;
  padding: 14px 16px;
  background: rgba(9, 13, 22, 0.84);
  box-shadow: 0 18px 32px rgba(0, 0, 0, 0.32);
  text-align: center;
}

.record-meta p {
  margin: 0 0 6px;
  overflow: hidden;
  color: #f0f5ff;
  font-weight: 950;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-meta span {
  color: #9fb8df;
  font-size: 0.88rem;
  font-weight: 760;
}

.model-settings {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 0 20px 16px;
}

.model-settings-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.model-select-row {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.model-select-row span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 760;
}

.model-select-row select {
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #0b1018;
  outline: none;
}

.model-select-row select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(79, 208, 255, 0.14);
}

.song-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 6px;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 14px 12px;
  background: rgba(0, 0, 0, 0.12);
}

.song-item {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 52px;
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 8px;
  text-align: left;
  background: rgba(10, 14, 22, 0.52);
}

.song-item.active {
  border-color: rgba(244, 200, 75, 0.76);
  background: rgba(244, 200, 75, 0.1);
}

.song-dot {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background:
    radial-gradient(circle at center, #071018 0 18%, transparent 19%),
    conic-gradient(from 30deg, var(--cyan), var(--green) 48%, var(--gold), var(--violet), var(--cyan));
  color: #061018;
  font-weight: 900;
}

.song-name {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-weight: 780;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.song-type {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.model-strip {
  border-top: 1px solid var(--line);
  padding: 12px 20px 16px;
  background: rgba(0, 0, 0, 0.12);
}

#transformerStatus {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 0.82rem;
}

.model-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.model-chip {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.74rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud {
  position: absolute;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(9, 13, 20, 0.78);
  box-shadow: 0 10px 24px var(--shadow);
  backdrop-filter: blur(10px);
}

.top-hud {
  top: 18px;
  left: 300px;
  right: 18px;
  justify-content: space-between;
  min-height: 58px;
  padding: 10px 14px;
}

.top-hud > div {
  min-width: 0;
}

.hud-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hud strong {
  display: block;
  max-width: 44vw;
  overflow: hidden;
  font-size: 0.98rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bottom-hud {
  right: 18px;
  bottom: 18px;
  left: 18px;
  min-height: 64px;
  padding: 10px 12px;
}

#playButton {
  min-width: 96px;
}

.time-readout {
  display: grid;
  grid-template-columns: 48px minmax(80px, 1fr) 48px;
  gap: 10px;
  align-items: center;
  width: 100%;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.time-readout span:last-child {
  text-align: right;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

#progressFill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--cyan), var(--gold));
}

.loading-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: rgba(5, 7, 10, 0.72);
}

.loading-layer[hidden] {
  display: none;
}

.loader {
  width: min(360px, calc(100vw - 48px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel-strong);
  box-shadow: 0 20px 40px var(--shadow);
}

#loadingText {
  display: block;
  margin-bottom: 12px;
  font-weight: 850;
}

.loader-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

#loaderFill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--rose), var(--gold), var(--green));
}

@media (max-width: 820px) {
  html,
  body {
    overflow: hidden;
  }

  .app-shell {
    width: 100%;
    height: 100%;
  }

  .command-bar {
    top: 10px;
    left: 62px;
    right: 10px;
  }

  .ui-toggle-button {
    top: 10px;
    left: 10px;
  }

  .command-bar button {
    min-width: 0;
    padding: 0 11px;
  }

  .music-overlay {
    padding: 10px;
    align-items: stretch;
  }

  .music-panel {
    width: 100%;
    height: 100%;
  }

  .toolbar,
  .model-settings {
    grid-template-columns: 1fr;
  }

  .music-panel {
    grid-template-rows: auto auto auto minmax(210px, 0.72fr) auto minmax(140px, 1fr) auto;
  }

  .selected-record {
    min-height: 220px;
    padding-bottom: 88px;
  }

  .selected-record::before,
  .selected-record::after {
    top: 48px;
    width: 104px;
    height: 104px;
  }

  .record-art {
    width: min(172px, 54vw);
    height: min(172px, 54vw);
  }

  .song-list {
    grid-template-columns: 1fr;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .song-item {
    margin: 0;
  }

  .top-hud {
    top: 66px;
    right: 10px;
    left: 10px;
  }

  .bottom-hud {
    right: 10px;
    bottom: 10px;
    left: 10px;
  }
}
