/* ============================================================
   String Stars — styles
   Theme: "concert night" — indigo sky, gold stars, big friendly
   buttons sized for 8-12 year old fingers on tablets.
   ============================================================ */

@font-face {
  font-family: "Bravura";
  src: url("../fonts/Bravura.woff2") format("woff2");
  font-display: block; /* music glyphs must never flash as tofu */
}

:root {
  --bg1: #2b1b6b;
  --bg2: #6b2fa0;
  --card: #ffffff;
  --card-soft: #f6f2ff;
  --ink: #2a2140;
  --ink-soft: #6a5f8a;
  --gold: #ffc83d;
  --gold-deep: #e8a800;
  --pink: #ff5d8f;
  --green: #2fbf71;
  --red: #ff5a5f;
  --blue: #3aa0ff;
  --purple: #7c4dff;
  --radius: 22px;
  --shadow: 0 6px 20px rgba(20, 10, 60, 0.35);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(165deg, var(--bg1) 0%, #45208c 55%, var(--bg2) 100%) fixed;
  background-color: var(--bg1);
}

/* twinkly star field, pure CSS */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 8% 12%,  rgba(255,255,255,.8) 50%, transparent 51%),
    radial-gradient(2px 2px at 22% 38%, rgba(255,255,255,.5) 50%, transparent 51%),
    radial-gradient(3px 3px at 36% 8%,  rgba(255,200,61,.9)  50%, transparent 51%),
    radial-gradient(2px 2px at 52% 26%, rgba(255,255,255,.6) 50%, transparent 51%),
    radial-gradient(2px 2px at 68% 10%, rgba(255,255,255,.7) 50%, transparent 51%),
    radial-gradient(3px 3px at 82% 32%, rgba(255,200,61,.8)  50%, transparent 51%),
    radial-gradient(2px 2px at 92% 16%, rgba(255,255,255,.55) 50%, transparent 51%),
    radial-gradient(2px 2px at 14% 72%, rgba(255,255,255,.4) 50%, transparent 51%),
    radial-gradient(2px 2px at 88% 78%, rgba(255,255,255,.45) 50%, transparent 51%);
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 920px;
  margin: 0 auto;
  padding: 14px 16px calc(28px + env(safe-area-inset-bottom));
  min-height: 100vh;
}

/* ---------- header ---------- */

.screen-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 6px 0 18px;
  color: #fff;
}

.screen-head h1 {
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  margin: 0;
  flex: 1;
  text-shadow: 0 2px 8px rgba(0,0,0,.35);
  letter-spacing: .3px;
}

.btn-back {
  background: rgba(255,255,255,.16);
  color: #fff;
  border: 2px solid rgba(255,255,255,.35);
  border-radius: 16px;
  font-size: 1.5rem;
  line-height: 1;
  padding: 10px 16px;
  cursor: pointer;
}
.btn-back:active { transform: scale(.94); }

/* ---------- home ---------- */

.hero {
  text-align: center;
  color: #fff;
  margin: 10px 0 22px;
}
.hero .logo { font-size: clamp(2.6rem, 8vw, 4rem); line-height: 1; }
.hero h1 {
  margin: 6px 0 2px;
  font-size: clamp(2rem, 6vw, 2.9rem);
  letter-spacing: .5px;
  text-shadow: 0 3px 12px rgba(0,0,0,.4);
}
.hero p { margin: 0; opacity: .85; font-size: 1.05rem; }

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}

.tile {
  position: relative;
  border: none;
  border-radius: var(--radius);
  padding: 20px 12px 16px;
  min-height: 128px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: var(--shadow);
  color: var(--ink);
  font-family: inherit;
  transition: transform .12s ease;
}
.tile:active { transform: scale(.96); }
.tile .t-emoji { font-size: 2.6rem; line-height: 1; }
.tile .t-label { font-size: 1.12rem; font-weight: 700; }

.tile.g1 { background: linear-gradient(150deg, #fff7dd, #ffdf8e); }
.tile.g2 { background: linear-gradient(150deg, #e8f6ff, #b5e0ff); }
.tile.g3 { background: linear-gradient(150deg, #ffe9f1, #ffbed6); }
.tile.g4 { background: linear-gradient(150deg, #eaffe9, #b8f0c0); }
.tile.g5 { background: linear-gradient(150deg, #f3ecff, #d5c3ff); }
.tile.g6 { background: linear-gradient(150deg, #fff0e4, #ffd2a8); }
.tile.g7 { background: linear-gradient(150deg, #e7fff9, #b1f0e1); }

.tile .ribbon {
  position: absolute;
  top: 10px;
  right: -6px;
  background: var(--pink);
  color: #fff;
  font-size: .72rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 10px 0 0 10px;
  letter-spacing: .5px;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}

.tile .mini-badge {
  position: absolute;
  top: 8px;
  left: 10px;
  font-size: .95rem;
  font-weight: 800;
  background: rgba(255,255,255,.85);
  border-radius: 12px;
  padding: 3px 9px;
}

.home-foot {
  text-align: center;
  color: rgba(255,255,255,.55);
  font-size: .82rem;
  margin-top: 26px;
}

/* ---------- generic cards & buttons ---------- */

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.btn {
  font-family: inherit;
  font-weight: 800;
  font-size: 1.15rem;
  border: none;
  border-radius: 18px;
  padding: 14px 24px;
  cursor: pointer;
  color: #fff;
  background: var(--purple);
  box-shadow: 0 4px 14px rgba(30, 15, 80, .3);
  transition: transform .12s ease;
}
.btn:active { transform: scale(.95); }
.btn.gold  { background: linear-gradient(160deg, var(--gold), var(--gold-deep)); color: #4a3300; }
.btn.green { background: var(--green); }
.btn.ghost {
  background: rgba(255,255,255,.14);
  border: 2px solid rgba(255,255,255,.4);
}
.btn.big { font-size: 1.4rem; padding: 18px 34px; }
.btn:disabled { opacity: .45; cursor: default; }

.btn-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 18px;
}

/* ---------- level select ---------- */

.level-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  border: none;
  font-family: inherit;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: transform .12s ease;
}
.level-card:active { transform: scale(.98); }
.level-card.locked { opacity: .62; background: #e9e4f5; }
.level-card .lv-emoji { font-size: 2.1rem; }
.level-card .lv-main { flex: 1; }
.level-card .lv-name { font-size: 1.2rem; font-weight: 800; color: var(--ink); }
.level-card .lv-notes { color: var(--ink-soft); font-size: .95rem; margin-top: 2px; }
.level-card .lv-stars { font-size: 1.3rem; letter-spacing: 2px; }
.star-on  { color: var(--gold-deep); }
.star-off { color: #cfc7e4; }

/* ---------- drill ---------- */

.progress-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 14px;
}
.pdot {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: rgba(255,255,255,.28);
}
.pdot.hit  { background: var(--green); }
.pdot.miss { background: var(--red); }
.pdot.cur  { outline: 3px solid var(--gold); outline-offset: 2px; }

.staff-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px 10px;
  margin-bottom: 16px;
  text-align: center;
}
.staff-card svg { width: 100%; max-width: 420px; height: auto; display: block; margin: 0 auto; }

.feedback {
  text-align: center;
  min-height: 2.2rem;
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,.4);
  margin-bottom: 12px;
}
.feedback .good { color: #7dffb5; }
.feedback .bad  { color: #ffb3b5; }

.answers {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
}
@media (max-width: 560px) {
  .answers { grid-template-columns: repeat(4, 1fr); }
}

.ans-btn {
  font-family: inherit;
  font-size: 1.7rem;
  font-weight: 900;
  color: var(--ink);
  background: var(--card);
  border: none;
  border-radius: 18px;
  padding: 18px 0;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .1s ease, background .15s ease;
}
.ans-btn:active { transform: scale(.93); }
.ans-btn.correct { background: var(--green); color: #fff; }
.ans-btn.wrong   { background: var(--red);   color: #fff; animation: shake .4s; }
.ans-btn:disabled { cursor: default; }

@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

/* ---------- round end ---------- */

.end-wrap { text-align: center; color: #fff; padding-top: 8px; }
.end-wrap h2 { font-size: 2rem; margin: 8px 0; text-shadow: 0 2px 10px rgba(0,0,0,.4); }
.end-score { font-size: 1.3rem; opacity: .9; }

.stars-big { font-size: 4.2rem; letter-spacing: 10px; margin: 12px 0; }
.stars-big .s {
  display: inline-block;
  color: rgba(255,255,255,.25);
}
.stars-big .s.earned {
  color: var(--gold);
  text-shadow: 0 0 18px rgba(255,200,61,.8);
  animation: starpop .5s cubic-bezier(.2,1.8,.4,1) both;
}
.stars-big .s.earned:nth-child(2) { animation-delay: .25s; }
.stars-big .s.earned:nth-child(3) { animation-delay: .5s; }

@keyframes starpop {
  0% { transform: scale(0) rotate(-40deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* confetti burst */
.confetti {
  position: fixed;
  left: 50%; top: 42%;
  font-size: 1.6rem;
  pointer-events: none;
  animation: burst 1.4s ease-out forwards;
  z-index: 50;
}
@keyframes burst {
  0%   { transform: translate(0,0) rotate(0);   opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; }
}

/* ---------- tuner ---------- */

.tuner-note {
  text-align: center;
  color: #fff;
}
.tuner-note .big-letter {
  font-size: 5rem;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 4px 16px rgba(0,0,0,.45);
}
.tuner-note .sub { opacity: .8; font-size: 1.05rem; }

.gauge-card { text-align: center; }
.gauge-card svg { width: 100%; max-width: 380px; height: auto; }

.tuner-status {
  font-size: 1.5rem;
  font-weight: 900;
  min-height: 2rem;
  margin-top: 4px;
}
.tuner-status.low  { color: var(--blue); }
.tuner-status.high { color: var(--red); }
.tuner-status.good { color: var(--green); }

.drone-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 10px;
}
.drone-btn {
  font-family: inherit;
  font-size: 1.5rem;
  font-weight: 900;
  border: none;
  border-radius: 16px;
  padding: 16px 0;
  cursor: pointer;
  background: var(--card-soft);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.drone-btn.on { background: var(--gold); color: #4a3300; }

/* ---------- metronome ---------- */

.metro-bpm {
  text-align: center;
  color: #fff;
}
.metro-bpm .num {
  font-size: 4.6rem;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 4px 16px rgba(0,0,0,.45);
}
.metro-bpm .lbl { opacity: .8; letter-spacing: 3px; font-weight: 700; }

.metro-controls { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 14px 0; flex-wrap: wrap; }
.bpm-btn {
  font-family: inherit;
  font-size: 1.2rem;
  font-weight: 800;
  width: 62px; height: 54px;
  border: none;
  border-radius: 16px;
  background: rgba(255,255,255,.16);
  border: 2px solid rgba(255,255,255,.35);
  color: #fff;
  cursor: pointer;
}
.bpm-btn:active { transform: scale(.93); }

input[type="range"].bpm-slider {
  width: 100%;
  max-width: 420px;
  accent-color: var(--gold);
  height: 34px;
}

.beat-dots { display: flex; gap: 14px; justify-content: center; margin: 16px 0; }
.beat-dot {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  transition: transform .08s ease, background .08s ease;
}
.beat-dot.accent { border: 3px solid rgba(255,255,255,.5); }
.beat-dot.on { background: var(--gold); transform: scale(1.35); box-shadow: 0 0 16px rgba(255,200,61,.8); }

.pulse-wrap { display: flex; justify-content: center; margin: 8px 0 4px; }
.pulse-circle {
  width: 120px; height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff3cd, var(--gold));
  box-shadow: 0 0 30px rgba(255,200,61,.4);
  transform: scale(.8);
  opacity: .75;
}
.pulse-circle.beat { animation: pulse .18s ease-out; }
@keyframes pulse {
  0% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(.8); opacity: .75; }
}

.seg-row { display: flex; gap: 8px; justify-content: center; margin-top: 6px; }
.seg-btn {
  font-family: inherit;
  font-weight: 800;
  font-size: 1.05rem;
  padding: 10px 18px;
  border-radius: 14px;
  border: 2px solid rgba(255,255,255,.4);
  background: rgba(255,255,255,.12);
  color: #fff;
  cursor: pointer;
}
.seg-btn.on { background: var(--gold); border-color: var(--gold); color: #4a3300; }

/* ---------- practice / streaks ---------- */

.streak-hero {
  text-align: center;
  color: #fff;
  margin-bottom: 18px;
}
.streak-hero .flame { font-size: 3.6rem; line-height: 1; }
.streak-hero .n { font-size: 3rem; font-weight: 900; }
.streak-hero .lbl { opacity: .85; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(14, 1fr);
  gap: 5px;
}
.cal-cell {
  aspect-ratio: 1;
  border-radius: 6px;
  background: #e9e4f5;
}
.cal-cell.active { background: var(--gold); box-shadow: inset 0 0 0 2px var(--gold-deep); }
.cal-cell.today  { outline: 2px solid var(--purple); outline-offset: 1px; }

.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}
.badge {
  text-align: center;
  background: var(--card-soft);
  border-radius: 18px;
  padding: 14px 8px;
}
.badge .b-emoji { font-size: 2.2rem; }
.badge .b-name { font-weight: 800; margin-top: 4px; font-size: .95rem; }
.badge .b-desc { color: var(--ink-soft); font-size: .8rem; margin-top: 2px; }
.badge.locked { filter: grayscale(1); opacity: .5; }

.section-title {
  color: #fff;
  font-size: 1.2rem;
  font-weight: 800;
  margin: 20px 0 10px;
  text-shadow: 0 2px 8px rgba(0,0,0,.35);
}

/* ---------- stub / coming soon ---------- */

.stub-wrap {
  text-align: center;
  color: #fff;
  padding-top: 10vh;
}
.stub-wrap .s-emoji { font-size: 5rem; }
.stub-wrap h2 { font-size: 2rem; margin: 12px 0 6px; }
.stub-wrap p { opacity: .85; font-size: 1.1rem; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  padding: 13px 22px;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
  opacity: 0;
  transition: all .25s ease;
  z-index: 100;
  max-width: 88vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- misc ---------- */

.mic-error {
  background: #fff4f4;
  color: #8a2a2e;
  border-radius: var(--radius);
  padding: 16px;
  font-weight: 600;
  text-align: center;
}

/* ---------- multiple-choice questions (rhythm, symbols) ---------- */

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.choice-btn {
  font-family: inherit;
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--ink);
  background: var(--card);
  border: none;
  border-radius: 18px;
  padding: 18px 10px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .1s ease, background .15s ease;
}
.choice-btn:active { transform: scale(.95); }
.choice-btn.correct { background: var(--green); color: #fff; }
.choice-btn.wrong   { background: var(--red);   color: #fff; animation: shake .4s; }
.choice-btn:disabled { cursor: default; }

/* Bravura glyphs shown large in choice buttons (fill-the-measure) */
.choice-btn .ch-glyph {
  font-family: "Bravura";
  font-size: 44px;
  display: block;
  line-height: 1.6;
}

/* ---------- big glyph / term flashcard display ---------- */

.glyph-display {
  font-family: "Bravura";
  font-size: 96px;
  color: var(--ink);
  text-align: center;
  padding: 34px 10px 52px;
  line-height: 1.15;
}

.term-display {
  font-size: 2.5rem;
  font-weight: 900;
  font-style: italic;
  color: var(--ink);
  text-align: center;
  padding: 46px 10px;
}

/* one measure of rhythm glyphs (echo game) */
.rhythm-line {
  font-family: "Bravura";
  font-size: 62px;
  color: var(--ink);
  text-align: center;
  padding: 26px 6px 44px;
  letter-spacing: 10px;
}

.timesig {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--ink-soft);
  text-align: center;
}

/* ---------- fingerboard game ---------- */

.fb-wrap { display: grid; gap: 14px; }
@media (min-width: 720px) {
  .fb-wrap { grid-template-columns: 1fr 1fr; align-items: start; }
}

.fb-card svg {
  width: 100%;
  max-width: 330px;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* ---------- echo-tap drum pad ---------- */

.pad-btn {
  width: min(52vw, 230px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  margin: 0 auto;
  display: block;
  background: radial-gradient(circle at 35% 30%, #ffe9a8, var(--gold));
  box-shadow: 0 8px 30px rgba(255, 200, 61, .45);
  font-size: 2.6rem;
  font-weight: 900;
  color: #4a3300;
  transition: transform .06s ease;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.pad-btn:active { transform: scale(.93); }
.pad-btn:disabled { filter: grayscale(.6); opacity: .6; cursor: default; }

button:focus-visible, input:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
