: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;
  padding: 28px; gap: 20px;
}
.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; }

/* Top bar */
.bar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-secondary); border-radius: var(--radius-md);
  padding: 16px 22px; min-height: 64px;
}
.bar-title { font-size: 24px; font-weight: 600; }
.beats { font-size: 20px; color: var(--accent); font-weight: 600; }

/* Buttons */
.btn {
  display: flex; align-items: center; justify-content: center;
  min-height: 72px; padding: 0 20px;
  background: var(--bg-tertiary); color: var(--text-primary);
  border-radius: var(--radius-md);
  font-size: 24px; font-weight: 600;
  border: 2px solid transparent;
}
.btn-accent { background: linear-gradient(135deg, #00d4ff, #00a0d0); color: #06121a; }
.btn.is-saved { background: linear-gradient(135deg, #00ff88, #00b85f); color: #04130b; }
.row { display: flex; gap: 16px; }
.row .btn { flex: 1; }
.col { display: flex; flex-direction: column; gap: 14px; }

/* Home */
.home-hero {
  flex: 1; display: flex; flex-direction: column;
  justify-content: center; align-items: center; text-align: center; gap: 12px;
}
.app-title { font-size: 64px; font-weight: 800; letter-spacing: -1px; }
.app-sub { font-size: 22px; color: var(--text-secondary); }
.menu { display: flex; flex-direction: column; gap: 16px; }

/* Tap */
.tap-wrap { flex: 1; display: flex; align-items: center; justify-content: center; }
.tap-pad {
  width: 340px; height: 340px; border-radius: 32px;
  background: radial-gradient(circle at 50% 38%, #1e2740, #12121f);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; border: 2px solid #2a3350;
}
.tap-pad:focus { border-color: var(--focus-ring); box-shadow: 0 0 30px var(--focus-glow); }
.tap-pad.pulse { animation: pad-pulse 0.18s ease; }
@keyframes pad-pulse {
  0% { transform: scale(1); }
  40% { transform: scale(0.955); box-shadow: 0 0 45px rgba(0, 212, 255, 0.65); }
  100% { transform: scale(1); }
}
.tap-bpm { font-size: 96px; font-weight: 800; line-height: 1; color: var(--accent); }
.tap-unit { font-size: 24px; color: var(--text-secondary); letter-spacing: 3px; }
.tap-hint { margin-top: 12px; font-size: 18px; color: var(--text-muted); }
.msg { min-height: 22px; text-align: center; color: var(--danger); font-size: 18px; }

/* Result */
.result-body {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0;
}
.big-bpm { font-size: 138px; font-weight: 800; line-height: 1; color: var(--accent); }
.unit-lg { font-size: 28px; color: var(--text-secondary); letter-spacing: 4px; margin-top: -4px; }
.tempo { font-size: 34px; font-weight: 600; margin-top: 16px; color: var(--accent-secondary); }
.stats { display: flex; gap: 48px; margin-top: 24px; }
.stat { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.stat span { font-size: 34px; font-weight: 700; }
.stat label { font-size: 15px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; }

/* History */
.hist-list { flex: 1; overflow: hidden; display: flex; flex-direction: column; gap: 10px; }
.hist-item {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-secondary); border-radius: 10px; padding: 14px 18px;
}
.hist-left { display: flex; align-items: baseline; gap: 14px; }
.hist-bpm { font-size: 30px; font-weight: 700; color: var(--accent); }
.hist-tempo { color: var(--text-primary); font-size: 19px; }
.hist-meta { color: var(--text-secondary); font-size: 16px; }
.empty {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 20px; text-align: center; padding: 0 30px;
}

/* Help */
.help-body {
  flex: 1; background: var(--bg-secondary); border-radius: var(--radius-md);
  padding: 24px; overflow: hidden;
}
.help-body ol { padding-left: 24px; display: flex; flex-direction: column; gap: 12px; font-size: 19px; line-height: 1.35; }
.help-body b { color: var(--accent); }
.muted { color: var(--text-secondary); margin-top: 18px; font-size: 17px; }
