:root {
  --accent: #3ff2c9;
  --accent-dim: rgba(63, 242, 201, 0.25);
  --target: #ffd166;
  --wrong: #ff5c7a;
  --panel: rgba(10, 14, 18, 0.72);
  --text: #e9f3f0;
  --muted: #8aa39c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: #000; color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; }

#stage { position: fixed; inset: 0; }
#video { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
#cam, #overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
#cam { filter: saturate(0.85) brightness(0.8); }
.vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.65)); }

.panel {
  position: absolute;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  backdrop-filter: blur(8px);
  padding: 14px 16px;
}
#legend { top: 14px; left: 14px; width: 250px; font-size: 12.5px; }
#legend h1 { font-size: 20px; letter-spacing: 0.02em; margin-bottom: 10px; }
.legend-block { margin-bottom: 10px; }
.legend-block h3 { font-size: 10.5px; letter-spacing: 0.12em; color: var(--accent); margin-bottom: 6px; }
.legend-block ul { list-style: none; display: grid; gap: 3px; }
.legend-block li { display: flex; gap: 8px; align-items: center; }
.legend-block li .ic { width: 22px; text-align: center; font-weight: 800; }
.legend-block li b { min-width: 34px; }
.hint { color: var(--muted); font-size: 11px; margin-top: 4px; }
.swap { display: flex; gap: 6px; align-items: center; font-size: 11px; color: var(--muted); cursor: pointer; }

#stepsPanel { top: 14px; right: 14px; width: 270px; max-height: calc(100% - 250px); display: flex; flex-direction: column; }
#stepsPanel h3 { font-size: 14px; margin-bottom: 8px; }
#stepList { overflow-y: auto; padding-left: 0; list-style: none; display: grid; gap: 4px; scrollbar-width: thin; }
#stepList li { font-size: 12.5px; padding: 6px 8px; border-radius: 8px; display: flex; gap: 8px; align-items: center; color: var(--muted); }
#stepList li .n { width: 22px; text-align: right; opacity: 0.6; font-variant-numeric: tabular-nums; }
#stepList li .g { flex: 1; }
#stepList li .nt { font-weight: 700; }
#stepList li.done { opacity: 0.4; }
#stepList li.current { background: rgba(255, 209, 102, 0.15); color: var(--text); outline: 1px solid rgba(255, 209, 102, 0.5); }
#stepList li.current .nt { color: var(--target); }

#center { position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%); text-align: center; pointer-events: none; }
#bigNote { font-size: clamp(64px, 12vw, 140px); font-weight: 900; color: var(--accent); text-shadow: 0 0 30px rgba(63, 242, 201, 0.6); line-height: 1; transition: transform 0.12s; }
#bigNote.hit { transform: scale(1.12); }
#bigNote.ok { color: #7dffb0; }
#bigNote.bad { color: var(--wrong); text-shadow: 0 0 30px rgba(255, 92, 122, 0.6); }
#subNote { margin-top: 6px; color: var(--muted); font-size: 14px; }

#guide { position: absolute; left: 50%; bottom: 178px; transform: translateX(-50%); width: min(760px, calc(100% - 28px)); display: grid; gap: 8px; }
#nowBox {
  background: rgba(20, 16, 4, 0.78);
  border: 1px solid rgba(255, 209, 102, 0.55);
  border-radius: 14px;
  padding: 12px 16px;
  display: flex; gap: 12px; align-items: center;
  font-size: 18px;
  box-shadow: 0 0 30px rgba(255, 209, 102, 0.12);
}
#nowBox .label { font-size: 10.5px; letter-spacing: 0.15em; color: var(--target); }
#nowText b { color: var(--target); }
#nowText .rest { color: var(--wrong); font-weight: 700; }
#nextBox { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
#nextBox .chip { background: var(--panel); border-radius: 999px; padding: 4px 10px; font-size: 12.5px; color: var(--muted); border: 1px solid rgba(255, 255, 255, 0.08); }

#keys { position: absolute; left: 50%; bottom: 74px; transform: translateX(-50%); display: flex; gap: 8px; }
.key {
  width: 74px; height: 92px;
  border-radius: 12px;
  background: rgba(20, 26, 30, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  transition: transform 0.08s, background 0.15s, border-color 0.15s;
  position: relative;
}
.key .k-name { font-size: 20px; font-weight: 800; }
.key .k-ic { font-size: 20px; font-weight: 900; height: 26px; }
.key .k-txt { font-size: 9.5px; color: var(--muted); text-align: center; padding: 0 3px; line-height: 1.1; }
.key.target { border-color: var(--target); box-shadow: 0 0 18px rgba(255, 209, 102, 0.35); }
.key.target .k-name { color: var(--target); }
.key.active { background: var(--accent-dim); border-color: var(--accent); transform: translateY(-4px); }
.key.active .k-name { color: var(--accent); }
.key .badge { position: absolute; top: 4px; right: 6px; font-size: 11px; font-weight: 800; color: var(--target); }

#wave { position: absolute; left: 0; right: 0; bottom: 52px; width: 100%; height: 30px; pointer-events: none; }

#bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 52px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  background: rgba(6, 9, 11, 0.85);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
select, button, input, textarea { font: inherit; color: inherit; }
select { background: #11181c; border: 1px solid #2a3a3a; border-radius: 8px; padding: 6px 10px; max-width: 260px; }
button { background: var(--accent); color: #032019; border: 0; border-radius: 8px; padding: 7px 14px; font-weight: 700; cursor: pointer; }
button.ghost { background: transparent; color: var(--text); border: 1px solid #355; font-weight: 500; }
button.danger { color: var(--wrong); border-color: var(--wrong); }
button:disabled { opacity: 0.5; cursor: wait; }
#progress { flex: 1; height: 6px; background: #1c2a2a; border-radius: 99px; overflow: hidden; }
#progressFill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--target)); transition: width 0.25s; }
#progressText { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; min-width: 60px; text-align: right; }

#intro { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.82); z-index: 20; padding: 20px; }
#intro.hidden { display: none; }
.card, dialog form { max-width: 460px; background: #0c1215; border: 1px solid rgba(63, 242, 201, 0.3); border-radius: 16px; padding: 26px; box-shadow: 0 0 60px rgba(63, 242, 201, 0.1); }
.card h1 { font-size: 30px; color: var(--accent); margin-bottom: 8px; }
.card p { color: #b9cbc6; margin-bottom: 14px; }
.buttons { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.small { font-size: 12px; color: var(--muted) !important; margin-top: 10px; }
.status { color: var(--target) !important; min-height: 1em; }
code { background: #1a2626; padding: 0 4px; border-radius: 4px; }

dialog { margin: auto; background: transparent; border: 0; color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, 0.7); }
dialog h2 { margin-bottom: 12px; color: var(--accent); }
dialog label { display: grid; gap: 4px; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
dialog input, dialog textarea { background: #11181c; border: 1px solid #2a3a3a; border-radius: 8px; padding: 8px 10px; color: var(--text); width: 100%; }
dialog textarea { resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

@media (max-width: 900px) {
  #legend, #stepsPanel { display: none; }
  .key { width: 42px; height: 72px; }
  .key .k-txt { display: none; }
  #guide { bottom: 150px; }
}

#extract { border: 1px solid rgba(63, 242, 201, 0.3); border-radius: 12px; padding: 10px 12px 12px; margin-bottom: 12px; }
#extract legend { padding: 0 6px; font-size: 13px; color: var(--accent); }
.filebtn { display: inline-block; background: var(--accent); color: #032019; border-radius: 8px; padding: 7px 14px; font-weight: 700; cursor: pointer; margin: 0; }
.range { display: flex; gap: 12px; margin: 10px 0 0; }
.range label { margin: 0; flex: 1; }
dialog form { max-height: 92vh; overflow-y: auto; width: min(520px, 94vw); }
