/* Pulse Meter — rhythm & timing trainer.
   Loads alongside shared.css (vars + leaderboard/modal styles) and site-chrome.css
   (header/footer). All game classes are pm- namespaced to avoid collisions. */

body {
    display: block;          /* shared.css centers body as a flex column; this page flows normally */
    padding: 0;
    margin: 0;
}

.pm-page { max-width: 860px; margin: 0 auto; padding: 28px 20px 48px; }

.pm-intro { text-align: center; margin-bottom: 22px; }
.pm-intro h1 { font-size: 34px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 8px; color: var(--text, #0f172a); }
.pm-intro p { margin: 0 auto; max-width: 560px; color: var(--text-light, #64748b); font-size: 15.5px; line-height: 1.6; }

/* Game card */
.pm-card { background: var(--card, #fff); border: 1px solid var(--border, #e2e8f0);
    border-radius: 18px; padding: 22px; box-shadow: var(--shadow, 0 1px 3px rgba(0,0,0,.1)); position: relative; }

.pm-controls { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.pm-mode { display: flex; background: var(--bg, #f8fafc); border: 1px solid var(--border, #e2e8f0); border-radius: 10px; padding: 3px; }
.pm-mode button { border: 0; background: transparent; font: inherit; font-weight: 700; font-size: 13.5px;
    color: var(--text-light, #64748b); padding: 8px 14px; border-radius: 8px; cursor: pointer; }
.pm-mode button.active { background: var(--primary, #0d9488); color: #fff; }

.pm-timer { display: none; font-variant-numeric: tabular-nums; font-weight: 800; font-size: 18px;
    color: var(--primary, #0d9488); border: 2px solid var(--primary, #0d9488); border-radius: 10px; padding: 6px 14px; }
.pm-timer.warning { color: #d97706; border-color: #d97706; }
.pm-timer.danger { color: #dc2626; border-color: #dc2626; }

.pm-tempo { display: flex; align-items: center; gap: 12px; margin: 18px 0 4px; flex-wrap: wrap; }
.pm-tempo label { font-weight: 700; font-size: 13.5px; color: var(--text-light, #64748b); }
.pm-tempo input[type="range"] { flex: 1; min-width: 140px; accent-color: var(--primary, #0d9488); }
.pm-bpm { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 16px; color: var(--text, #0f172a); min-width: 84px; }
.pm-ghost { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; color: var(--text-light, #64748b); cursor: pointer; }
.pm-ghost input { accent-color: var(--primary, #0d9488); width: 16px; height: 16px; }

/* Beat dots */
.pm-beats { display: flex; justify-content: center; gap: 26px; margin: 26px 0 6px; }
.pm-beat { width: 26px; height: 26px; border-radius: 50%; background: var(--border, #e2e8f0); transition: transform .08s ease, background .08s ease; }
.pm-beat.on { background: var(--primary, #0d9488); transform: scale(1.35); }
.pm-beat.accent.on { background: #d97706; }
.pm-bar-label { text-align: center; min-height: 22px; font-size: 13.5px; font-weight: 700;
    letter-spacing: .06em; text-transform: uppercase; color: var(--text-light, #64748b); }
.pm-bar-label.silent { color: #d97706; }

/* Needle gauge */
.pm-gauge { position: relative; height: 14px; border-radius: 100px; margin: 20px 8px 6px;
    background: linear-gradient(90deg, #fca5a5, #fcd34d 32%, #6ee7b7 46%, #6ee7b7 54%, #fcd34d 68%, #fca5a5); opacity: .9; }
.pm-gauge-center { position: absolute; left: 50%; top: -5px; bottom: -5px; width: 2px; background: var(--text, #0f172a); opacity: .55; }
.pm-needle { position: absolute; left: 50%; top: -7px; width: 4px; height: 28px; border-radius: 3px;
    background: var(--text, #0f172a); transform: translateX(-50%); transition: left .09s ease-out; }
.pm-gauge-labels { display: flex; justify-content: space-between; font-size: 11.5px; font-weight: 700;
    letter-spacing: .05em; color: var(--text-light, #64748b); margin: 4px 10px 0; text-transform: uppercase; }

/* Readout */
.pm-readout { text-align: center; margin: 18px 0 2px; min-height: 74px; }
.pm-ms { font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.05; color: var(--text, #0f172a); }
.pm-ms.good { color: var(--primary, #0d9488); }
.pm-ms.close { color: #d97706; }
.pm-ms.off { color: #dc2626; }
.pm-verdict { font-size: 14px; font-weight: 700; color: var(--text-light, #64748b); margin-top: 4px; min-height: 20px; }

/* Tap pad */
.pm-pad { display: block; width: 100%; margin: 18px 0 6px; padding: 34px 20px; font: inherit;
    font-size: 22px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
    color: #fff; background: linear-gradient(135deg, #14b8a6, #0d9488); border: 0; border-radius: 16px;
    cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: manipulation;
    box-shadow: 0 6px 18px rgba(13, 148, 136, .35); }
.pm-pad:active { transform: scale(.985); }
.pm-pad[disabled] { background: var(--border, #e2e8f0); color: var(--text-light, #64748b); box-shadow: none; cursor: default; }
.pm-pad-hint { text-align: center; font-size: 12.5px; color: var(--text-light, #64748b); margin: 0 0 14px; }

.pm-start { display: block; margin: 16px auto 0; font: inherit; font-weight: 800; font-size: 15px;
    padding: 12px 34px; border-radius: 12px; border: 2px solid var(--primary, #0d9488);
    background: transparent; color: var(--primary, #0d9488); cursor: pointer; }
.pm-start.running { border-color: #dc2626; color: #dc2626; }

/* Stats */
.pm-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 20px; }
.pm-stat { background: var(--bg, #f8fafc); border: 1px solid var(--border, #e2e8f0); border-radius: 12px;
    text-align: center; padding: 12px 6px; }
.pm-stat .v { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text, #0f172a); }
.pm-stat.good .v { color: var(--primary, #0d9488); }
.pm-stat.bad .v { color: #dc2626; }
.pm-stat .l { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
    color: var(--text-light, #64748b); margin-top: 4px; }

/* Countdown overlay */
.pm-countdown { position: absolute; inset: 0; border-radius: 18px; display: none;
    align-items: center; justify-content: center; background: rgba(15, 23, 42, .82); z-index: 30; }
.pm-countdown.show { display: flex; }
.pm-countdown span { font-size: 110px; font-weight: 800; color: #fff; }

/* Info sections */
.pm-info { margin-top: 34px; }
.pm-info h2 { font-size: 22px; font-weight: 800; letter-spacing: -.01em; color: var(--text, #0f172a); margin: 28px 0 10px; }
.pm-info p, .pm-info li { color: var(--text-light, #64748b); font-size: 15px; line-height: 1.7; }
.pm-info ul { padding-left: 22px; }
.pm-info strong { color: var(--text, #0f172a); }

/* Leaderboard section (styles come from shared.css) gets breathing room */
#leaderboard { margin-top: 30px; }

@media (max-width: 560px) {
    .pm-stats { grid-template-columns: repeat(2, 1fr); }
    .pm-intro h1 { font-size: 28px; }
    .pm-ms { font-size: 36px; }
    .pm-beats { gap: 18px; }
}

@media (prefers-reduced-motion: reduce) {
    .pm-beat, .pm-needle { transition: none; }
}
