:root {
  --bg: #0c1220;
  --surface: rgba(22, 31, 47, 0.92);
  --surface-2: #1d293b;
  --text: #f8fafc;
  --muted: #aeb9c9;
  --border: rgba(255, 255, 255, 0.08);
  --cyan: #3bc7d5;
  --mint: #70e0ce;
  --lime: #c7ef54;
  --danger: #ff6b6b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 10%, rgba(59, 199, 213, 0.12), transparent 32%),
    radial-gradient(circle at 90% 25%, rgba(199, 239, 84, 0.10), transparent 28%),
    linear-gradient(160deg, #0a101c 0%, #111a2a 58%, #0a111e 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.background-glow {
  position: fixed;
  width: 260px;
  height: 260px;
  border-radius: 999px;
  filter: blur(85px);
  opacity: 0.13;
  pointer-events: none;
}
.background-glow-a { top: -80px; left: -100px; background: var(--cyan); }
.background-glow-b { right: -110px; bottom: 5%; background: var(--lime); }

.app-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 560px);
  min-height: calc(100dvh - 48px);
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 20px 34px;
  display: flex;
  align-items: center;
}

.screen {
  display: none;
  width: 100%;
  animation: enter 180ms ease-out;
}
.screen.active { display: block; }

@keyframes enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.home-screen { text-align: center; }
.brand-logo {
  width: min(88vw, 390px);
  height: auto;
  display: block;
  margin: 0 auto 8px;
  filter: drop-shadow(0 20px 38px rgba(0, 0, 0, 0.25));
}
.hero-copy {
  max-width: 390px;
  margin: -8px auto 28px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.screen-header {
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 26px;
}
.screen-header h1 {
  margin: 2px 0 0;
  font-size: clamp(1.6rem, 6vw, 2.15rem);
  letter-spacing: -0.04em;
}
.eyebrow {
  margin: 0;
  color: var(--mint);
  text-transform: uppercase;
  letter-spacing: 0.13em;
  font-size: 0.72rem;
  font-weight: 800;
}

.icon-btn {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: 1px solid var(--border);
  color: var(--text);
  background: rgba(255,255,255,0.05);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:active { transform: scale(0.96); }

.btn {
  min-height: 54px;
  border: 0;
  border-radius: 15px;
  padding: 14px 20px;
  font-weight: 800;
  color: #07121a;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, box-shadow 120ms ease;
}
.btn:not(:disabled):active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(105deg, var(--cyan), var(--mint) 52%, var(--lime));
  box-shadow: 0 12px 34px rgba(59, 199, 213, 0.18);
}
.btn-stop {
  color: #fff;
  background: rgba(255,255,255,0.075);
  border: 1px solid var(--border);
}
.btn-large {
  width: min(100%, 390px);
  font-size: 1.08rem;
}

.tool-grid { display: grid; gap: 14px; }
.tool-card {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px;
  display: grid;
  grid-template-columns: 50px 1fr auto;
  gap: 14px;
  align-items: center;
  text-align: left;
  color: var(--text);
  background: linear-gradient(150deg, rgba(31,43,61,0.96), rgba(19,28,43,0.94));
  box-shadow: var(--shadow);
  cursor: pointer;
}
.tool-card:active { transform: scale(0.99); }
.tool-icon {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  background: rgba(112, 224, 206, 0.10);
  font-size: 1.45rem;
}
.tool-copy { display: grid; gap: 4px; }
.tool-copy strong { font-size: 1rem; }
.tool-copy small { color: var(--muted); line-height: 1.35; }
.chevron { color: var(--mint); font-size: 1.8rem; }

.status-panel {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  margin-bottom: 16px;
  background: rgba(255,255,255,0.045);
  border: 1px solid var(--border);
  border-radius: 16px;
}
.status-panel div { display: grid; gap: 2px; }
.status-panel small { color: var(--muted); }
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #6f7c8f;
  box-shadow: 0 0 0 5px rgba(111,124,143,0.10);
}
.status-panel[data-state="running"] .status-dot {
  background: var(--lime);
  box-shadow: 0 0 0 5px rgba(199,239,84,0.12), 0 0 18px rgba(199,239,84,0.45);
  animation: pulse 1s infinite;
}
@keyframes pulse { 50% { transform: scale(0.75); opacity: 0.65; } }

.training-card, .metronome-panel {
  position: relative;
  padding: 22px;
  margin-bottom: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: linear-gradient(155deg, rgba(30,42,60,0.98), rgba(18,27,41,0.96));
  box-shadow: var(--shadow);
}
.training-card h2 { margin: 0 0 10px; padding-right: 68px; letter-spacing: -0.025em; }
.training-card p { margin: 0 0 18px; color: var(--muted); line-height: 1.55; }
.card-badge {
  position: absolute;
  right: 18px;
  top: 18px;
  padding: 7px 10px;
  border-radius: 999px;
  color: #07121a;
  background: linear-gradient(105deg, var(--mint), var(--lime));
  font-size: 0.82rem;
  font-weight: 900;
}
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.helper-text, .section-intro {
  color: var(--muted);
  line-height: 1.55;
}
.helper-text { margin: 14px 4px 0; text-align: center; font-size: 0.88rem; }
.section-intro { margin: 0 0 20px; }

.coach-grid { display: grid; gap: 14px; }
.coach-btn {
  min-height: 106px;
  border: 1px solid var(--border);
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text);
  background: linear-gradient(145deg, rgba(31,43,61,0.98), rgba(18,27,41,0.96));
  box-shadow: var(--shadow);
  font-weight: 800;
  font-size: 1.08rem;
  cursor: pointer;
}
.coach-btn:active { transform: scale(0.985); border-color: rgba(112,224,206,0.45); }
.coach-number {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 17px;
  color: #07121a;
  background: linear-gradient(110deg, var(--cyan), var(--mint), var(--lime));
  font-size: 1.45rem;
  font-weight: 950;
}
.cue-flash {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  color: #07121a;
  background: rgba(199,239,84,0.86);
  font-weight: 950;
  font-size: clamp(2.2rem, 13vw, 5rem);
  letter-spacing: 0.05em;
}
.cue-flash.active { animation: cueFlash 220ms ease-out; }
@keyframes cueFlash { 0% { opacity: 0; } 22% { opacity: 1; } 100% { opacity: 0; } }

.metronome-panel { text-align: center; padding-top: 30px; }
.bpm-readout {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin-bottom: 22px;
}
.bpm-readout span {
  font-size: clamp(4rem, 18vw, 6rem);
  line-height: 0.9;
  font-weight: 950;
  letter-spacing: -0.07em;
}
.bpm-readout small { color: var(--muted); font-weight: 800; }
input[type="range"] {
  width: 100%;
  accent-color: var(--mint);
  cursor: pointer;
}
.range-labels {
  display: flex;
  justify-content: space-between;
  margin: 6px 2px 24px;
  color: var(--muted);
  font-size: 0.78rem;
}
.beat-indicator {
  width: 18px;
  height: 18px;
  margin: 0 auto 24px;
  border-radius: 999px;
  background: rgba(255,255,255,0.14);
}
.beat-indicator.active {
  background: var(--lime);
  box-shadow: 0 0 26px rgba(199,239,84,0.6);
  transform: scale(1.35);
}

.app-footer {
  position: relative;
  z-index: 1;
  padding: 0 20px max(18px, env(safe-area-inset-bottom));
  text-align: center;
  color: #738096;
  font-size: 0.72rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 680px) {
  .app-shell { padding-inline: 30px; }
  .coach-grid { grid-template-columns: repeat(3, 1fr); }
  .coach-btn { flex-direction: column; min-height: 150px; }
}
