*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg:         #1a1a2e;
  --bg-card:    #16213e;
  --accent:     #e94560;
  --text:       #eaeaea;
  --text-muted: #8892a4;
  --border:     rgba(255,255,255,0.08);

  --white-key-w: 48px;
  --white-key-h: 150px;
  --black-key-w: 30px;
  --black-key-h: 94px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* ── Header ─────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.app-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.stats {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.stat-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;
}

.stat-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
}

/* ── Main ────────────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 48px;
  padding: 24px 16px;
  overflow: hidden;
}

/* ── Challenge ───────────────────────────────────────────────── */
.challenge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.challenge-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.challenge-note {
  font-size: 5rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
  letter-spacing: -0.03em;
  min-width: 1.2ch;
  text-align: center;
  transition: transform 0.15s ease;
}

.challenge-note.pop {
  transform: scale(1.15);
}

/* ── Piano ───────────────────────────────────────────────────── */
.piano-scroller {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  display: flex;
  justify-content: center;
  padding-bottom: 4px;
}

.piano {
  position: relative;
  display: flex;
  flex-shrink: 0;
  height: var(--white-key-h);
  touch-action: none;
  user-select: none;
}

/* ── White keys ──────────────────────────────────────────────── */
.key-white {
  width: var(--white-key-w);
  height: var(--white-key-h);
  background: #f2f2f2;
  border: 1px solid #bbb;
  border-top: none;
  border-radius: 0 0 6px 6px;
  position: relative;
  z-index: 1;
  cursor: pointer;
  transition: background 0.08s;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 8px;
}

.key-white:active {
  background: #ddd;
}

/* ── Black keys ──────────────────────────────────────────────── */
.key-black {
  position: absolute;
  width: var(--black-key-w);
  height: var(--black-key-h);
  background: #1e1e1e;
  border-radius: 0 0 4px 4px;
  top: 0;
  z-index: 2;
  cursor: pointer;
  transition: background 0.08s;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
}

.key-black:active {
  background: #444;
}

/* ── Key labels ──────────────────────────────────────────────── */
.key-label {
  font-size: 0.6rem;
  font-weight: 700;
  color: #999;
  pointer-events: none;
}

.key-black .key-label {
  color: #555;
  font-size: 0.55rem;
}

/* ── Feedback states ─────────────────────────────────────────── */
.key-white.correct,
.key-black.correct {
  background: #7ed492 !important;
  transition: background 0s;
}

.key-white.wrong,
.key-black.wrong {
  background: #f08080 !important;
  transition: background 0s;
}

/* ── Responsive: shrink keys on narrow screens ───────────────── */
@media (max-width: 400px) {
  :root {
    --white-key-w: 42px;
    --white-key-h: 130px;
    --black-key-w: 26px;
    --black-key-h: 82px;
  }
}
