:root {
  --green: #58cc02; --green-dark: #46a302; --blue: #1cb0f6; --blue-dark: #1899d6;
  --purple: #ce82ff; --orange: #ff9600; --red: #ff4b4b; --yellow: #ffc800;
  --ink: #3c3c3c; --ink-soft: #777; --line: #e5e5e5; --bg: #f7f7f7; --card: #fff;
  --radius: 16px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--ink); min-height: 100vh;
}
button { font-family: inherit; }

/* ---------- buttons ---------- */
.btn {
  display: inline-block; border: 0; cursor: pointer; font-weight: 800; font-size: 15px;
  letter-spacing: .4px; text-transform: uppercase; color: #fff; background: var(--green);
  padding: 12px 22px; border-radius: 14px; border-bottom: 4px solid var(--green-dark);
  transition: transform .06s, filter .15s; text-decoration: none; text-align: center;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(3px); border-bottom-width: 1px; }
.btn.blue { background: var(--blue); border-bottom-color: var(--blue-dark); }
.btn.red { background: var(--red); border-bottom-color: #d33; }
.btn.ghost { background: #fff; color: var(--blue); border: 2px solid var(--line); border-bottom: 4px solid var(--line); }
.btn.ghost:hover { background: #f0f8fd; }
.btn.small { padding: 8px 14px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { display: block; width: 100%; }

input, select, textarea {
  font-family: inherit; font-size: 16px; padding: 12px 14px; border: 2px solid var(--line);
  border-radius: 12px; width: 100%; background: #fff; color: var(--ink); outline: none;
}
input:focus, select:focus { border-color: var(--blue); }

.card {
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px; box-shadow: 0 2px 0 var(--line);
}
.muted { color: var(--ink-soft); }
.error { color: var(--red); font-weight: 700; margin: 8px 0; }

/* ---------- landing ---------- */
.landing { max-width: 420px; margin: 0 auto; padding: 40px 20px; }
.logo { text-align: center; font-size: 64px; margin-bottom: 4px; animation: bounce 2.4s infinite; }
.wordmark { text-align: center; font-size: 34px; font-weight: 900; color: var(--green); letter-spacing: .5px; }
.tagline { text-align: center; color: var(--ink-soft); font-weight: 700; margin: 6px 0 26px; }
.role-pick { display: flex; gap: 10px; margin-bottom: 12px; }
.role-pick button {
  flex: 1; padding: 12px; border-radius: 12px; border: 2px solid var(--line); background: #fff;
  font-weight: 800; font-size: 15px; cursor: pointer; color: var(--ink-soft);
}
.role-pick button.sel { border-color: var(--blue); color: var(--blue); background: #f0f8fd; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.auth-tabs button {
  flex: 1; background: none; border: none; border-bottom: 3px solid var(--line); padding: 10px;
  font-weight: 800; font-size: 15px; color: var(--ink-soft); cursor: pointer;
}
.auth-tabs button.sel { color: var(--blue); border-bottom-color: var(--blue); }

/* ---------- app shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50; background: #fff; border-bottom: 2px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 10px 16px; flex-wrap: wrap;
}
.topbar .brand { font-weight: 900; color: var(--green); font-size: 20px; }
.stat-chip { font-weight: 800; font-size: 15px; display: flex; align-items: center; gap: 5px; background: #fff; border: 2px solid var(--line); border-radius: 999px; padding: 4px 12px; box-shadow: 0 2px 0 var(--line); }
.stat-chip.streak { color: var(--orange); }
.stat-chip.xp { color: var(--blue); }
.level-ring { margin-left: auto; font-weight: 800; color: var(--purple); }
.tabs { display: flex; gap: 4px; background: #fff; border-bottom: 2px solid var(--line); padding: 0 10px; overflow-x: auto; }
.tabs button {
  background: none; border: 0; border-bottom: 3px solid transparent; padding: 12px 14px;
  font-weight: 800; color: var(--ink-soft); cursor: pointer; font-size: 14px; white-space: nowrap;
}
.tabs button.sel { color: var(--blue); border-bottom-color: var(--blue); }
.main { max-width: 720px; margin: 0 auto; padding: 20px 16px 80px; }

/* ---------- bottom tab bar (mobile, Duolingo style) ---------- */
.tabbar-bottom { display: none; }
@media (max-width: 700px) {
  .tabs { display: none; }
  .tabbar-bottom {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
    background: #fff; border-top: 2px solid var(--line);
    padding: 4px 2px calc(4px + env(safe-area-inset-bottom));
  }
  .tabbar-bottom button {
    flex: 1; background: none; border: 0; border-radius: 12px; padding: 6px 0 7px;
    font-size: 21px; display: flex; flex-direction: column; align-items: center; gap: 1px;
    color: var(--ink-soft); font-weight: 800; cursor: pointer; position: relative;
  }
  .tabbar-bottom button span { font-size: 10px; }
  .tabbar-bottom button.sel { color: var(--blue); background: #f0f8fd; }
  .tabbar-bottom button .hw-badge { position: absolute; top: 2px; right: 12px; background: var(--red); color: #fff; font-size: 10px; font-weight: 900; border-radius: 999px; padding: 1px 6px; }
  .main { padding-bottom: 110px; }
}

/* ---------- adventure map ---------- */
.unit-map {
  position: relative; max-width: 480px; margin: 0 auto 22px; overflow: hidden;
  background: linear-gradient(180deg, #e3f4ff 0%, #f2f9ec 160px, #eef7e6 100%);
  border: 2px solid var(--line); border-radius: 20px; box-shadow: 0 2px 0 var(--line);
}
.unit-map svg { display: block; width: 100%; height: auto; }
.map-path-todo { fill: none; stroke: #e0dac9; stroke-width: 13; stroke-linecap: round; stroke-dasharray: 0.1 21; }
.map-path-done { fill: none; stroke: var(--green); stroke-width: 13; stroke-linecap: round; opacity: .7; }
.lesson-node.on-map { position: absolute; transform: translate(-50%, -50%); margin: 0; z-index: 2; }
.lesson-node.on-map .label { text-shadow: 0 1px 0 #fff, 0 0 6px #fff; }
.map-goal { position: absolute; transform: translate(-50%, -50%); width: 116px; text-align: center; z-index: 2; }
.map-goal .goal-bubble {
  width: 86px; height: 86px; margin: 0 auto; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 42px; background: #fff; border: 3px solid var(--line);
  border-bottom-width: 6px; filter: grayscale(1); opacity: .8;
}
.map-goal.clear .goal-bubble {
  filter: none; opacity: 1; background: #fffbe8; border-color: var(--yellow);
  box-shadow: 0 0 0 6px #fff6d6, 0 0 26px #ffe58a; animation: bounce 1.8s infinite;
}
.map-goal .goal-label { font-size: 11px; font-weight: 900; color: var(--ink-soft); margin-top: 7px; text-transform: uppercase; letter-spacing: .6px; text-shadow: 0 1px 0 #fff; }
.map-goal.clear .goal-label { color: #b8860b; }
.map-mascot { position: absolute; font-size: 42px; z-index: 4; pointer-events: none; filter: drop-shadow(0 3px 2px rgba(0,0,0,.25)); }
.map-mascot span { display: inline-block; animation: bounce 1.4s infinite; }

/* ---------- skill path (legacy) ---------- */
.path-col { display: flex; flex-direction: column; align-items: center; gap: 20px; padding: 20px 0 28px; }
.lesson-node .start-bubble {
  position: absolute; top: -36px; left: 50%; transform: translateX(-50%);
  background: #fff; border: 2px solid var(--line); color: var(--green); font-weight: 900;
  font-size: 13px; padding: 5px 14px; border-radius: 12px; box-shadow: 0 2px 0 var(--line);
  animation: bounce 1.6s infinite; white-space: nowrap; z-index: 3; letter-spacing: .5px;
}
.lesson-node .start-bubble::after {
  content: ''; position: absolute; bottom: -7px; left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: #fff; border-bottom: 0;
}
.unit-head {
  border-radius: var(--radius); padding: 14px 18px; color: #fff; font-weight: 900;
  margin: 22px 0 14px; box-shadow: 0 4px 0 rgba(0,0,0,.12);
}
.unit-head small { display: block; font-weight: 700; opacity: .92; }
.lesson-row { display: flex; flex-wrap: wrap; gap: 16px; justify-content: flex-start; padding: 4px 6px 10px; }
.lesson-node.in-path { width: 88px; }
.lesson-node { position: relative; width: 86px; text-align: center; }
.lesson-node .bubble {
  width: 72px; height: 72px; border-radius: 50%; margin: 0 auto; display: flex; align-items: center;
  justify-content: center; font-size: 30px; background: #fff; border: 3px solid var(--line);
  border-bottom-width: 6px; cursor: pointer; transition: transform .08s; position: relative;
}
.lesson-node .bubble:hover { transform: scale(1.06); }
.lesson-node.locked .bubble { background: #eee; color: #bbb; cursor: not-allowed; filter: grayscale(1); }
.lesson-node.done .bubble { background: var(--green); border-color: var(--green-dark); color: #fff; }
.lesson-node.current .bubble { border-color: var(--yellow); box-shadow: 0 0 0 5px #fff6d6; animation: bounce 1.6s infinite; }
@keyframes bounce { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-6px);} }
.lesson-node .label { font-size: 12px; font-weight: 800; margin-top: 6px; color: var(--ink-soft); }
.lesson-node .stars { position: absolute; top: -6px; right: 0; font-size: 12px; letter-spacing: -2px; }

/* ---------- leaderboard / lists ---------- */
.lb-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 2px solid var(--line);
  border-radius: 14px; margin-bottom: 8px; background: #fff; font-weight: 700;
}
.lb-row.me { border-color: var(--yellow); background: #fffbe8; }
.lb-rank { width: 34px; font-size: 18px; text-align: center; font-weight: 900; color: var(--ink-soft); }
.lb-xp { margin-left: auto; color: var(--blue); font-weight: 900; }
.hw-item { display: flex; gap: 12px; align-items: center; }
.hw-item .info { flex: 1; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.badge-cell { text-align: center; padding: 12px 6px; border: 2px solid var(--line); border-radius: 14px; background: #fff; }
.badge-cell.locked { opacity: .38; filter: grayscale(1); }
.badge-cell .ic { font-size: 30px; }
.badge-cell .nm { font-weight: 800; font-size: 12px; margin-top: 4px; }
.badge-cell .ds { font-size: 11px; color: var(--ink-soft); }

/* ---------- tables ---------- */
table.roster { width: 100%; border-collapse: collapse; font-size: 14px; }
table.roster th { text-align: left; font-size: 12px; text-transform: uppercase; color: var(--ink-soft); padding: 8px 10px; border-bottom: 2px solid var(--line); }
table.roster td { padding: 10px; border-bottom: 1px solid var(--line); font-weight: 700; }
table.roster tr:hover td { background: #fafafa; }

/* ---------- lesson player ---------- */
.player { max-width: 640px; margin: 0 auto; padding: 18px 16px 60px; min-height: 100vh; display: flex; flex-direction: column; }
.progress-track { height: 14px; background: var(--line); border-radius: 8px; overflow: hidden; margin: 12px 0 20px; }
.progress-fill { height: 100%; background: var(--green); border-radius: 8px; transition: width .35s; position: relative; overflow: hidden; }
.progress-fill::after {
  content: ''; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.5), transparent);
  animation: shine 2.4s infinite;
}
@keyframes shine { 55%, 100% { transform: translateX(100%); } }
.ex-prompt { font-size: 22px; font-weight: 900; text-align: center; margin: 10px 0 4px; }
.ex-hint { text-align: center; color: var(--ink-soft); font-weight: 700; min-height: 22px; margin-bottom: 10px; }
.staff-box { background: #fff; border: 2px solid var(--line); border-radius: var(--radius); padding: 14px 8px; display: flex; justify-content: center; }
.heard-box { text-align: center; margin: 16px 0; min-height: 58px; }
.heard-note { font-size: 40px; font-weight: 900; color: var(--blue); }
.heard-note.ok { color: var(--green); }
.heard-note.bad { color: var(--red); }
.feedback { text-align: center; font-size: 18px; font-weight: 900; min-height: 26px; }
.feedback.ok { color: var(--green); }
.feedback.bad { color: var(--red); }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.choice-grid .btn { text-transform: none; font-size: 17px; }
.big-tap { width: 180px; height: 180px; border-radius: 50%; font-size: 22px; margin: 20px auto; display: block; }
.rhythm-glyphs { font-size: 44px; text-align: center; margin: 8px 0; display: flex; justify-content: center; align-items: baseline; gap: 18px; flex-wrap: wrap; }
.rhythm-glyphs span { letter-spacing: -3px; } /* keep the augmentation dot hugging its note */
.tempo-row { display: flex; gap: 8px; justify-content: center; margin: 6px 0 2px; flex-wrap: wrap; }
.tempo-pill { border: 2px solid var(--line); background: var(--card); border-radius: 999px; padding: 5px 13px; font-weight: 800; font-size: 13px; color: var(--ink-soft); cursor: pointer; transition: transform .08s; }
.tempo-pill:active { transform: scale(.93); }
.tempo-pill.on { border-color: var(--blue); color: var(--blue-dark); background: #e8f6fe; }
.rhythm-glyphs span.done { color: var(--green); }
.rhythm-glyphs span.now { color: var(--blue); text-shadow: 0 0 12px #bfe6fd; }
.center { text-align: center; }
.count-overlay { text-align: center; font-size: 76px; font-weight: 900; color: var(--blue); min-height: 96px; line-height: 1.15; }
.count-overlay.pop { animation: pop .3s; }
.count-overlay.go { color: var(--green); font-size: 56px; }
.mic-meter { height: 6px; background: var(--line); border-radius: 4px; max-width: 220px; margin: 8px auto 0; overflow: hidden; }
.mic-fill { height: 100%; background: var(--blue); width: 0%; border-radius: 4px; transition: width .08s linear; }
.quest-row { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.quest-row:last-child { border-bottom: 0; }
.quest-info { flex: 1; }
.results { text-align: center; padding-top: 30px; }
.results .big-emoji { font-size: 80px; animation: pop .5s; }
@keyframes pop { 0% { transform: scale(.3); opacity: 0;} 70% { transform: scale(1.15);} 100% { transform: scale(1); opacity: 1;} }
.results .stars-big { font-size: 46px; letter-spacing: 6px; margin: 12px 0; }
.xp-pill { display: inline-block; background: var(--yellow); color: #7a5800; font-weight: 900; padding: 8px 22px; border-radius: 999px; font-size: 19px; margin: 10px 0; }
.badge-toast { background: #fff8e0; border: 2px solid var(--yellow); border-radius: 14px; padding: 10px 16px; font-weight: 800; margin: 8px 0; }
.shake { animation: shake .35s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-7px)} 75%{transform:translateX(7px)} }

/* free practice */
.free-note { font-size: 72px; font-weight: 900; text-align: center; color: var(--blue); min-height: 90px; }
.mic-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--red); margin-right: 6px; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .3; } }

@media (max-width: 560px) {
  .choice-grid { grid-template-columns: 1fr; }
  .lesson-node { width: 76px; }
  .lesson-node .bubble { width: 64px; height: 64px; font-size: 26px; }
}
