* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0d0b1a;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

#wrap {
  position: relative;
  box-shadow: 0 0 60px rgba(120, 90, 255, 0.25);
}

#game {
  display: block;
  touch-action: none;
  outline: none;
}

#ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -46%);
  width: max-content;
  min-width: 26em;
  max-width: 92%;
  max-height: 94%;
  overflow-y: auto;
  padding: 1.2em 2.2em;
  border-radius: 1.2em;
  background: rgba(22, 16, 44, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 1em 3em rgba(0, 0, 0, 0.45);
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s, transform 0.25s, visibility 0.25s;
}

.panel.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%);
  pointer-events: auto;
}

h1 {
  font-size: 2.6em;
  letter-spacing: 0.05em;
  background: linear-gradient(90deg, #ff7eb3, #ffd36e, #7ef0c5);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

h2 {
  font-size: 1.4em;
  margin: 0.2em 0 0.6em;
  color: #e9e3ff;
}

.howto {
  list-style: none;
  text-align: left;
  margin: 0.3em auto 0.6em;
  display: inline-block;
  line-height: 1.75;
  font-size: 0.95em;
  color: #d6d0f0;
}

.howto li::before {
  content: "♪";
  color: #ff7eb3;
  margin-right: 0.6em;
}

.howto b { color: #ffd36e; }

.btns {
  display: flex;
  gap: 0.7em;
  justify-content: center;
  flex-wrap: wrap;
  margin: 0.8em 0;
}

button {
  font: inherit;
  font-size: 1em;
  padding: 0.65em 1.4em;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  transition: transform 0.12s, background 0.2s, box-shadow 0.2s;
}

button:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.16);
}

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

button.primary {
  border: none;
  background: linear-gradient(135deg, #ff6b9d, #ff9f5a);
  box-shadow: 0 0.4em 1.2em rgba(255, 107, 157, 0.4);
  font-weight: 600;
}

button.primary:hover {
  box-shadow: 0 0.5em 1.6em rgba(255, 107, 157, 0.6);
}

.slider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7em;
  font-size: 0.9em;
  color: #cfc8ef;
  margin: 0.4em 0;
}

.slider input { width: 12em; accent-color: #ff7eb3; }
.sensVal { min-width: 3em; text-align: left; color: #ffd36e; }

.tip {
  font-size: 0.78em;
  color: #9d95c4;
  margin-top: 0.6em;
}

.err {
  font-size: 0.85em;
  color: #ff8a8a;
  min-height: 1em;
  margin-top: 0.4em;
}

.best {
  font-size: 0.9em;
  color: #cfc8ef;
  margin-top: 0.4em;
}

.best b { color: #ffd36e; }

.score {
  font-size: 1.4em;
  margin: 0.2em 0;
}

.score b {
  font-size: 2.6em;
  color: #ffd36e;
  text-shadow: 0 0 0.4em rgba(255, 211, 110, 0.5);
}

.bar {
  width: 16em;
  height: 0.7em;
  margin: 1em auto 0.3em;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #7ef0c5, #ffd36e);
  transition: width 0.05s linear;
}

button:focus-visible,
.slider input:focus-visible,
button.is-keyed {
  outline: 2px solid #ffd36e;
  outline-offset: 3px;
}

button:disabled {
  opacity: 0.55;
  cursor: progress;
  transform: none;
}

button[hidden] { display: none !important; }

.kicker {
  margin-bottom: 0.35em;
  font-size: 0.75em;
  letter-spacing: 0.22em;
  color: #ffd36e;
}

.lead {
  max-width: 28em;
  margin: 0 auto;
  line-height: 1.65;
  font-size: 0.92em;
  color: #d6d0f0;
}

.panel-calib {
  width: min(34em, 92%);
  min-width: min(26em, 92%);
}

.panel-calib.is-hot { border-color: rgba(255, 138, 138, 0.55); }
.panel-calib.is-done { border-color: rgba(126, 240, 197, 0.55); }

.meter-block { margin-top: 0.95em; }

.meter-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1em;
  margin-bottom: 0.35em;
  font-size: 0.82em;
  color: #cfc8ef;
}

.meter-head span:last-child {
  color: #ffd36e;
  font-variant-numeric: tabular-nums;
}

#calibLevelLabel.is-talk { color: #ffd36e; }
#calibLevelLabel.is-warn,
#calibStatus.is-warn { color: #ff8a8a; }
#calibStatus.is-done,
#calibLevelLabel.is-quiet { color: #7ef0c5; }

.panel-calib .bar {
  width: 100%;
  height: 0.85em;
  margin: 0;
}

#calibLive,
#calibLive.is-quiet { background: linear-gradient(90deg, #7ef0c5, #9d95c4); }
#calibLive.is-talk { background: linear-gradient(90deg, #7ef0c5, #ffd36e); }
#calibLive.is-loud { background: linear-gradient(90deg, #ff6b9d, #ff9f5a); }
#calibBar.is-paused { background: #ff8a8a; }
#calibBar.is-done { background: linear-gradient(90deg, #7ef0c5, #ffd36e); }

.ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 0.35em;
  font-size: 0.72em;
  color: #9d95c4;
}

.panel-calib .tip { text-align: left; }

@media (prefers-reduced-motion: reduce) {
  .panel,
  .bar > span,
  button {
    transition: none;
  }
}
