:root {
  color-scheme: dark;
  --bg: #12090c;
  --ink: #f6f1ea;
  --muted: rgba(246, 241, 234, 0.68);
  --line: rgba(246, 241, 234, 0.16);
  --left: #5ce1ff;
  --right: #ffb03a;
  --hot: #ff2f86;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, sans-serif;
}

button, input { font: inherit; color: inherit; }

button {
  background: #f4efe8;
  color: #140c10;
  border: 0;
  padding: 14px 16px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 750;
  cursor: pointer;
}

button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--left);
  outline-offset: 2px;
}

button.ghost {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

button:disabled { opacity: 0.55; cursor: default; }

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: block;
}

#cam {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  pointer-events: none;
  z-index: 0;
}

[hidden] { display: none !important; }

.panel {
  position: fixed;
  z-index: 4;
  left: 22px;
  top: 22px;
  bottom: 22px;
  width: min(440px, calc(100vw - 28px));
  overflow: auto;
  padding: 26px 22px 20px;
  background: rgba(10, 6, 8, 0.82);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.eyebrow {
  margin: 0 0 8px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-family: Impact, "Arial Narrow", sans-serif;
  font-size: 78px;
  font-weight: 400;
  letter-spacing: 0.06em;
  line-height: 0.8;
  text-shadow: 4px 0 var(--hot), -4px 0 var(--left);
}

.lede { font-size: 17px; line-height: 1.4; }

.how {
  margin: 0 0 16px;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.45;
}

.how strong { color: var(--ink); font-weight: 650; }

#songs { margin: 14px 0; }

.song {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  width: 100%;
  margin: 0 0 8px;
  padding: 11px 12px;
  text-align: left;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 650;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.03);
  border-left: 4px solid var(--c, var(--ink));
  box-shadow: none;
}

.song small {
  grid-column: 1 / -1;
  font-weight: 500;
  color: var(--muted);
}

.song .meta { color: var(--muted); font-size: 13px; letter-spacing: 0.04em; }

.song.on { background: rgba(255, 255, 255, 0.09); }

.row { display: flex; gap: 8px; }
.row button { flex: 1; }

.vol, .lag {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  color: var(--muted);
  font-size: 14px;
}

.vol input, .lag input { flex: 1; }

.keys, .fine, #cam-status {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

#cam-status { min-height: 2.8em; }

details { margin-top: 8px; color: var(--muted); }
summary { cursor: pointer; }

#topbar {
  position: fixed;
  z-index: 3;
  top: calc(10px + env(safe-area-inset-top));
  left: calc(12px + env(safe-area-inset-left));
  right: calc(12px + env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

#topbar button { pointer-events: auto; padding: 10px 12px; }

#song-name {
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 13px;
  text-align: center;
}

#score {
  font-family: Impact, "Arial Narrow", sans-serif;
  font-size: 34px;
  letter-spacing: 0.04em;
  min-width: 4ch;
  text-align: right;
}

#groove {
  position: fixed;
  z-index: 3;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
}

#groove span {
  display: block;
  height: 100%;
  width: 62%;
  background: linear-gradient(90deg, var(--hot), var(--right), var(--left));
}

#readout {
  position: fixed;
  z-index: 2;
  top: calc(72px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(640px, 92vw);
  text-align: center;
  pointer-events: none;
}

#cue-kicker {
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 13px;
  color: var(--muted);
}

#cue-move {
  font-family: Impact, "Arial Narrow", sans-serif;
  font-size: clamp(52px, 9vw, 92px);
  letter-spacing: 0.04em;
  line-height: 0.86;
}

#cue-bar {
  width: min(220px, 50vw);
  height: 6px;
  margin: 10px auto 0;
  background: rgba(255, 255, 255, 0.16);
}

#cue-fill { display: block; height: 100%; width: 0; }

#queue {
  margin-top: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 13px;
  color: var(--muted);
  min-height: 1.2em;
}

#judge {
  position: fixed;
  z-index: 2;
  top: 46%;
  right: calc(28px + env(safe-area-inset-right));
  margin: 0;
  font-family: Impact, "Arial Narrow", sans-serif;
  font-size: clamp(28px, 5vw, 44px);
  letter-spacing: 0.08em;
  min-height: 1em;
  text-align: right;
}

#combo {
  position: fixed;
  z-index: 2;
  left: calc(18px + env(safe-area-inset-left));
  bottom: calc(22px + env(safe-area-inset-bottom));
  font-family: Impact, "Arial Narrow", sans-serif;
  font-size: clamp(54px, 8vw, 84px);
  line-height: 0.8;
  pointer-events: none;
}

#count {
  position: fixed;
  z-index: 2;
  top: 28%;
  left: calc(28px + env(safe-area-inset-left));
  font-family: Impact, "Arial Narrow", sans-serif;
  font-size: min(16vw, 120px);
  line-height: 0.8;
  pointer-events: none;
  text-shadow: 4px 0 var(--hot), -4px 0 var(--left);
}

#feet-warn {
  position: fixed;
  z-index: 3;
  left: 50%;
  bottom: calc(12vh + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--hot);
  color: white;
  padding: 10px 14px;
  font-weight: 750;
  text-align: center;
}

#pause-screen {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
}

.card {
  width: min(420px, calc(100vw - 28px));
  padding: 22px;
  background: #1a1014;
  border: 1px solid var(--line);
}

.card h2 {
  font-family: Impact, "Arial Narrow", sans-serif;
  font-size: 64px;
  font-weight: 400;
  margin: 0 0 8px;
  letter-spacing: 0.04em;
}

#results {
  left: 50%;
  top: 50%;
  bottom: auto;
  transform: translate(-50%, -50%);
  width: min(520px, calc(100vw - 20px));
  max-height: calc(100vh - 20px);
}

#rank {
  margin: 0;
  font-family: Impact, "Arial Narrow", sans-serif;
  font-size: clamp(96px, 16vw, 148px);
  line-height: 0.75;
  letter-spacing: 0.02em;
  text-shadow: 5px 0 var(--hot), -5px 0 var(--left);
}

#result-title { margin: 8px 0; font-size: 28px; }

#stats {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
}

#stats li { border-top: 1px solid var(--line); padding-top: 6px; }
#stats b { display: block; font-size: 20px; }

#save-form { display: flex; gap: 8px; margin: 12px 0; }
#player-name {
  flex: 1;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 10px 4px;
}

#board { margin: 0 0 14px; padding-left: 18px; color: var(--muted); }
#board b { color: var(--ink); }

#toast {
  position: fixed;
  z-index: 6;
  left: 50%;
  top: calc(14px + env(safe-area-inset-top));
  transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 24px));
  background: #f4efe8;
  color: #140c10;
  padding: 10px 14px;
  font-weight: 650;
}

@media (max-width: 800px) {
  .panel {
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: auto;
    max-height: 54vh;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }

  #results {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    transform: none;
    width: auto;
    max-height: 88vh;
  }

  h1 { font-size: 76px; }
}
