:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-tertiary: #1e1e2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent: #00d4ff;
  --accent-secondary: #00ff88;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --radius-md: 12px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 600px; height: 600px; overflow: hidden;
  background: #000;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
#app { width: 100%; height: 100%; position: relative; }
.screen { width: 100%; height: 100%; position: absolute; top: 0; left: 0; display: flex; flex-direction: column; }
.screen.hidden { display: none; }
.focusable { transition: all 0.15s ease; border: 2px solid transparent; cursor: pointer; outline: none; }
.focusable:focus { border-color: var(--focus-ring); box-shadow: 0 0 20px var(--focus-glow); }
.hidden { display: none !important; }

/* ---------- Flash overlay ---------- */
.flash {
  position: absolute; inset: 0;
  background: var(--accent);
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  transition: opacity 0.16s ease-out;
}
.flash.on { opacity: 0.22; transition: none; }
.flash.accent { background: var(--accent-secondary); }
.flash.accent.on { opacity: 0.34; }

/* ---------- Header ---------- */
.header {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--bg-tertiary);
}
.title { font-size: 22px; font-weight: 700; letter-spacing: 2px; }
.live { display: flex; align-items: center; gap: 8px; font-size: 14px; letter-spacing: 1px; color: var(--text-secondary); }
.live .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--text-muted); transition: background 0.2s ease, box-shadow 0.2s ease; }
.live.on .dot { background: var(--accent-secondary); box-shadow: 0 0 12px var(--accent-secondary); }
.live.on { color: var(--accent-secondary); }

/* ---------- Stage ---------- */
.stage {
  position: relative; z-index: 1;
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px;
}
.beats { display: flex; gap: 14px; height: 26px; align-items: center; }
.beat-dot {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--bg-tertiary);
  border: 2px solid var(--bg-tertiary);
  transition: transform 0.08s ease, background 0.08s ease, box-shadow 0.08s ease;
}
.beat-dot.first { border-color: var(--accent-secondary); }
.beat-dot.active {
  background: var(--accent);
  box-shadow: 0 0 16px var(--focus-glow);
  transform: scale(1.35);
}
.beat-dot.first.active {
  background: var(--accent-secondary);
  box-shadow: 0 0 18px var(--accent-secondary);
}

.bpm-wrap { display: flex; flex-direction: column; align-items: center; }
.bpm {
  font-size: 150px; font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: transform 0.07s ease;
}
.bpm.beat { transform: scale(1.06); }
.bpm-unit { font-size: 20px; letter-spacing: 6px; color: var(--text-secondary); margin-top: 4px; }
.tempo-name { font-size: 20px; color: var(--accent); letter-spacing: 1px; font-weight: 600; }

/* ---------- Controls ---------- */
.controls {
  position: relative; z-index: 1;
  padding: 16px 20px 22px;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--bg-primary);
  border-top: 1px solid var(--bg-tertiary);
}
.btn {
  min-height: 56px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 18px; font-weight: 600;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  cursor: pointer;
  user-select: none;
}
.btn-primary { background: var(--accent); color: #04141a; min-height: 64px; font-size: 20px; }
.btn-primary.running { background: var(--danger); color: #fff; }
.stepper-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.btn.step { font-size: 22px; font-weight: 700; min-height: 60px; }
.btn.tap { background: var(--bg-secondary); font-size: 19px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Settings ---------- */
.settings-body { flex: 1; padding: 22px 24px; display: flex; flex-direction: column; gap: 16px; }
.setting-block { background: var(--bg-secondary); border-radius: var(--radius-md); padding: 18px 20px; }
.setting-label { font-size: 19px; font-weight: 600; }
.setting-hint { font-size: 14px; color: var(--text-secondary); margin: 4px 0 14px; }
.stepper { display: flex; align-items: center; gap: 16px; }
.step-btn {
  width: 64px; height: 64px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 700;
  background: var(--bg-tertiary); color: var(--text-primary);
  border-radius: var(--radius-md); border: 2px solid transparent; cursor: pointer;
}
.step-val { flex: 1; text-align: center; font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; }
.toggle-setting { justify-content: space-between; padding: 0 22px; }

/* ---------- Help ---------- */
.help-body { flex: 1; padding: 22px 26px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.help-body p { font-size: 17px; line-height: 1.5; color: var(--text-primary); }
.help-body ul { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.help-body li { font-size: 16px; line-height: 1.45; color: var(--text-secondary); padding-left: 16px; position: relative; }
.help-body li::before { content: "\2022"; color: var(--accent); position: absolute; left: 0; }
.help-body li b { color: var(--text-primary); }
.dpad-hint { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 14px; color: var(--text-muted); margin-top: 6px; }
.help-body .btn { margin-top: auto; }
