:root {
  --sky-top: #4a90e2;
  --sky-bottom: #142850;
  --card: #ffffff;
  --card-soft: #f4f7ff;
  --ink: #22283a;
  --ink-soft: #5b6178;
  --orange: #ff9f43;
  --yellow: #ffc93c;
  --green: #26de81;
  --red: #ff6b6b;
  --purple: #7c6cf6;
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --shadow: 0 10px 30px rgba(10, 20, 60, 0.25);
  --tap-min: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior-y: contain;
}

body {
  font-family: 'Baloo 2', 'Fredoka', system-ui, -apple-system, sans-serif;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 100%);
  color: var(--ink);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 10% 20%, #fff, transparent),
    radial-gradient(2px 2px at 80% 15%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 50% 8%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 30% 35%, #fff, transparent),
    radial-gradient(2px 2px at 90% 40%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 65% 25%, #fff, transparent);
  opacity: 0.55;
}

button { font-family: inherit; }

.app {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 8px;
  color: #fff;
}

.topbar h1 {
  font-size: 26px;
  margin: 0;
  font-weight: 700;
}

.streak-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.18);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 700;
  font-size: 18px;
}

main { padding: 12px 16px 24px; flex: 1; }

.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
}

.card h2 { margin: 0 0 10px; font-size: 22px; }

.suggestion-card {
  background: linear-gradient(135deg, #ffd66b, var(--orange));
  border-radius: var(--radius-lg);
  padding: 26px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  color: #40260a;
}
.suggestion-card .reason { font-size: 15px; opacity: 0.85; font-weight: 600; margin-bottom: 4px; }
.suggestion-card .piece-title { font-size: 30px; font-weight: 800; margin: 4px 0 18px; line-height: 1.15; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: var(--tap-min);
  border: none;
  border-radius: 999px;
  padding: 16px 28px;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: transform 0.08s ease;
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-launch { background: var(--red); color: #fff; font-size: 22px; }
.btn-secondary { background: rgba(0,0,0,0.08); color: var(--ink); }
.btn-ghost { background: transparent; color: #fff; text-decoration: underline; }
.btn-green { background: var(--green); color: #073d24; }

.week-strip { display: flex; gap: 8px; justify-content: space-between; margin-top: 6px; }
.day-cell {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: var(--tap-min);
  border: none;
  border-radius: var(--radius-sm);
  background: var(--card-soft);
  padding: 10px 4px;
  cursor: pointer;
}
.day-cell.today { outline: 3px solid var(--orange); }
.day-cell .dot {
  width: 30px; height: 30px; border-radius: 50%;
  background: #dfe3f0;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.day-cell.done .dot { background: var(--green); color: #fff; }
.day-cell .label { font-size: 13px; font-weight: 700; color: var(--ink-soft); }

.badge-row { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px; }
.badge-chip {
  flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--card-soft); border-radius: var(--radius-sm);
  padding: 12px 14px; min-width: 78px;
}
.badge-chip .icon { font-size: 30px; }
.badge-chip .title { font-size: 12px; font-weight: 700; text-align: center; color: var(--ink-soft); }
.badge-chip.locked { opacity: 0.35; }

.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 5;
  background: rgba(20, 28, 58, 0.92);
  backdrop-filter: blur(10px);
  display: flex;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  gap: 4px;
}
.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.55);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 4px;
  min-height: 60px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 700;
}
.tab-btn .icon { font-size: 26px; }
.tab-btn.active { color: #fff; background: rgba(255,255,255,0.12); }

.lesson-card, .piece-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  border: none;
  width: 100%;
  text-align: left;
}
.lesson-card .thumb, .piece-card .thumb {
  width: 56px; height: 56px; border-radius: 16px;
  background: var(--card-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
}
.lesson-card .meta { flex: 1; min-width: 0; }
.lesson-card .date { font-size: 13px; color: var(--ink-soft); font-weight: 700; }
.lesson-card .title { font-size: 18px; font-weight: 700; margin: 2px 0; }
.tag-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.tag { background: var(--card-soft); color: var(--ink-soft); font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.lesson-card .done-check { font-size: 22px; }

.pieces-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.piece-tile {
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 18px 14px;
  box-shadow: var(--shadow);
  border: none;
  text-align: center;
  min-height: 120px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
}
.piece-tile .icon { font-size: 34px; }
.piece-tile .title { font-weight: 700; font-size: 15px; line-height: 1.2; }

.badges-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.badge-tile {
  background: var(--card); border-radius: var(--radius-md); padding: 18px 12px;
  box-shadow: var(--shadow); text-align: center;
}
.badge-tile.locked { opacity: 0.4; }
.badge-tile .icon { font-size: 40px; }
.badge-tile .title { font-weight: 800; margin-top: 6px; }
.badge-tile .desc { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

.sheet-overlay {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(10, 16, 40, 0.6);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: #fff;
  width: 100%; max-width: 760px;
  border-radius: 28px 28px 0 0;
  padding: 22px 20px calc(24px + env(safe-area-inset-bottom));
  max-height: 88dvh;
  overflow-y: auto;
}
.sheet .close-x {
  float: right; background: var(--card-soft); border: none; border-radius: 50%;
  width: 40px; height: 40px; font-size: 18px; font-weight: 800; color: var(--ink-soft);
}

.play-audio-btn {
  display: flex; align-items: center; gap: 14px;
  background: var(--card-soft); border-radius: var(--radius-md); border: none;
  padding: 14px 18px; width: 100%; margin-bottom: 10px; text-align: left;
}
.play-audio-btn .circle {
  width: 52px; height: 52px; border-radius: 50%; background: var(--purple);
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 22px;
  flex-shrink: 0;
}
.play-audio-btn.playing .circle { background: var(--red); }
.play-audio-btn .label { font-weight: 700; }

.ritual-overlay {
  position: fixed; inset: 0; z-index: 30;
  background: linear-gradient(180deg, #1e3c72, #0b1230);
  display: flex; flex-direction: column;
  color: #fff;
  padding: 20px;
}
.ritual-skip { align-self: flex-end; background: none; border: none; color: rgba(255,255,255,0.7); font-size: 16px; font-weight: 700; padding: 10px; }
.ritual-body { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 16px; align-items: center; text-align: center; }
.ritual-title { font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.ritual-check {
  width: 100%; max-width: 420px;
  display: flex; align-items: center; gap: 16px;
  background: rgba(255,255,255,0.08); border: 2px solid rgba(255,255,255,0.2);
  border-radius: var(--radius-md); padding: 18px 20px; min-height: 76px;
}
.ritual-check.done { background: rgba(38, 222, 129, 0.25); border-color: var(--green); }
.ritual-check .emoji { font-size: 30px; }
.ritual-check .text { font-size: 18px; font-weight: 700; flex: 1; text-align: left; }
.ritual-check .mark { font-size: 24px; }
.rocket-wrap { font-size: 70px; margin-bottom: 6px; }
.rocket-wrap.launching { animation: launch 1.1s ease-in forwards; }
@keyframes launch {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(-500px) scale(0.6); opacity: 0; }
}

.timer-display { font-size: 56px; font-weight: 800; margin: 10px 0; font-variant-numeric: tabular-nums; }

.practice-overlay {
  position: fixed; inset: 0; z-index: 30;
  background: linear-gradient(180deg, #1e3c72, #0b1230);
  display: flex; flex-direction: column;
  color: #fff;
}
.practice-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px 12px;
}
.practice-summary { font-size: 18px; line-height: 1.5; margin: 0 0 14px; }
.practice-bottombar {
  background: rgba(0,0,0,0.25);
  padding: 14px 20px calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.practice-actions { display: flex; gap: 10px; width: 100%; max-width: 460px; }
.practice-actions .btn { min-height: 56px; font-size: 17px; }
.practice-bottombar .timer-display { font-size: 34px; margin: 0; }

.chord-player { display: flex; flex-direction: column; align-items: center; gap: 16px; margin: 10px 0 20px; }
.chord-prompt { font-size: 19px; font-weight: 700; text-align: center; max-width: 440px; }
.string-stack {
  width: 100%; max-width: 380px;
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.string-row { display: flex; align-items: center; gap: 12px; position: relative; }
.string-label { width: 72px; font-size: 13px; font-weight: 700; color: rgba(255,255,255,0.55); flex-shrink: 0; }
.string-line { flex: 1; height: 2px; background: rgba(255,255,255,0.18); border-radius: 2px; }
.string-row.active .string-label { color: #fff; }
.string-row.active .string-line { background: var(--yellow); height: 3px; }
.note-dot {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--yellow); color: #40260a;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; flex-shrink: 0;
  box-shadow: 0 0 0 6px rgba(255,201,60,0.25);
  animation: glow 1.4s ease-in-out infinite;
}
@keyframes glow {
  0%, 100% { box-shadow: 0 0 0 6px rgba(255,201,60,0.25); }
  50% { box-shadow: 0 0 0 10px rgba(255,201,60,0.4); }
}
.step-nav { display: flex; align-items: center; gap: 16px; font-weight: 700; }

.celebrate-overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(10,16,40,0.85);
  display: flex; align-items: center; justify-content: center;
  color: #fff; text-align: center; padding: 24px;
}
.celebrate-card { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.celebrate-emoji { font-size: 90px; animation: pop 0.5s ease; }
@keyframes pop { 0% { transform: scale(0.3); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
.confetti-piece {
  position: fixed; top: -20px; width: 10px; height: 16px; z-index: 39;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(360deg); opacity: 0.9; }
}

.empty-state { color: rgba(255,255,255,0.85); text-align: center; padding: 40px 20px; }

.pdf-link {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--ink); color: #fff; border-radius: var(--radius-md);
  padding: 18px; font-weight: 700; font-size: 18px; text-decoration: none; margin-bottom: 14px;
}

h2, h3 { font-family: 'Baloo 2', 'Fredoka', system-ui, sans-serif; }
