/* style.css — Note Quest */
:root {
  --bg: #14111f;
  --bg2: #1b1729;
  --surface: #221d36;
  --surface2: #2c2645;
  --border: #38305a;
  --text: #ece8f5;
  --muted: #9b93b8;
  --accent: #f5c451;
  --accent2: #8b6cff;
  --good: #4ade80;
  --bad: #ef5b6b;
  --parchment: #f3ead2;
  --parchment-line: #3a3225;
  --parchment-note: #2a2418;
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f1ea;
    --bg2: #ece7dc;
    --surface: #ffffff;
    --surface2: #f3eee3;
    --border: #d9d0bf;
    --text: #2c2735;
    --muted: #6b6478;
    --accent: #b8860b;
    --accent2: #6b4ed6;
    --shadow: 0 8px 24px rgba(60,50,40,0.12);
    color-scheme: light;
  }
}
html[data-theme="dark"] {
  --bg: #14111f; --bg2: #1b1729; --surface: #221d36; --surface2: #2c2645;
  --border: #38305a; --text: #ece8f5; --muted: #9b93b8;
  --accent: #f5c451; --accent2: #8b6cff; --shadow: 0 10px 30px rgba(0,0,0,0.35);
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg: #f4f1ea; --bg2: #ece7dc; --surface: #ffffff; --surface2: #f3eee3;
  --border: #d9d0bf; --text: #2c2735; --muted: #6b6478;
  --accent: #b8860b; --accent2: #6b4ed6; --shadow: 0 8px 24px rgba(60,50,40,0.12);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(139,108,255,0.18), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(245,196,81,0.10), transparent 60%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  overflow: hidden;
}
#app {
  height: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 14px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
}

/* Top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  font-size: 30px; line-height: 1;
  color: var(--accent);
  filter: drop-shadow(0 2px 6px rgba(245,196,81,0.4));
}
.brand h1 { margin: 0; font-size: 22px; letter-spacing: 0.3px; font-weight: 800; }
.tag { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.modes { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.mode {
  border: 0; background: transparent; color: var(--muted);
  font-size: 13px; font-weight: 600; padding: 7px 14px; border-radius: 999px;
  cursor: pointer; transition: all .18s ease;
}
.mode.active { background: var(--accent2); color: #fff; box-shadow: 0 2px 8px rgba(139,108,255,0.4); }
.mode:not(.active):hover { color: var(--text); }

/* Stats */
.stats { display: flex; gap: 8px; flex-wrap: wrap; }
.stat {
  flex: 1 1 0; min-width: 70px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 8px 10px; text-align: center;
  display: flex; flex-direction: column; gap: 2px;
}
.stat-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.stat-val { font-size: 18px; font-weight: 800; }
.stat.streak { position: relative; }
.stat.streak .flame { position: absolute; top: 4px; right: 8px; font-size: 14px; }
.stat.lives .stat-val { color: var(--bad); letter-spacing: 1px; }

/* Level bar */
.level-bar { height: 7px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.level-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent2), var(--accent)); transition: width .5s cubic-bezier(.2,.8,.2,1); }

/* Play area */
.play { display: flex; flex-direction: column; gap: 12px; }
.staff-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow);
  transition: box-shadow .25s, transform .25s;
  position: relative;
}
.staff-card.good { box-shadow: 0 0 0 2px var(--good), 0 12px 30px rgba(74,222,128,0.18); }
.staff-card.bad { box-shadow: 0 0 0 2px var(--bad), 0 12px 30px rgba(239,91,107,0.18); animation: shake .35s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }

#staff {
  display: block; width: 100%; height: auto;
  background: var(--parchment);
  border-radius: 12px;
  max-height: 38vh;
}
#staff line { stroke: var(--parchment-line); stroke-width: 1.4; }
#staff line.ledger { stroke-width: 1.6; }
#staff .clef-treble, #staff .clef-bass {
  fill: var(--parchment-note);
  font-family: "Noto Music", "Segoe UI Symbol", "Apple Symbols", serif;
  font-size: 92px;
}
#staff .clef-bass { font-size: 70px; }
#staff .stem { stroke: var(--parchment-note); stroke-width: 2; }
#staff .note ellipse { fill: var(--parchment-note); }
#staff .note.pop { animation: popin .35s cubic-bezier(.2,1.3,.4,1); transform-box: fill-box; }
@keyframes popin { 0%{ transform: scale(.2) rotate(-8deg); opacity:0 } 100%{ transform: scale(1) rotate(0); opacity:1 } }

.prompt { text-align: center; margin: 10px 0 2px; font-size: 14px; color: var(--muted); font-weight: 600; }
.feedback { text-align: center; min-height: 20px; font-size: 15px; font-weight: 700; transition: color .2s; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }

/* Answers */
.answers { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.ans {
  appearance: none; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-size: 20px; font-weight: 800; letter-spacing: 0.5px;
  padding: 14px 0; border-radius: 14px; cursor: pointer;
  transition: transform .12s, background .18s, border-color .18s, color .18s;
  user-select: none;
}
.ans:hover:not(:disabled) { transform: translateY(-2px); background: var(--surface2); border-color: var(--accent2); }
.ans:active:not(:disabled) { transform: translateY(0) scale(.96); }
.ans:disabled { cursor: default; }
.ans.right { background: var(--good); border-color: var(--good); color: #07210f; }
.ans.wrong { background: var(--bad); border-color: var(--bad); color: #2a0608; }
.hint { text-align: center; font-size: 12px; color: var(--muted); margin: 0; }

/* Achievements */
.achievements h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); margin: 6px 0 8px; font-weight: 700; }
.ach-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ach {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 6px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  opacity: .55; transition: opacity .25s, border-color .25s, transform .25s;
}
.ach.got { opacity: 1; border-color: var(--accent); background: linear-gradient(180deg, var(--surface), rgba(245,196,81,0.08)); }
.ach-icon { font-size: 22px; }
.ach-label { font-size: 11px; font-weight: 700; color: var(--text); }

/* Game over */
.gameover {
  position: fixed; inset: 0; background: rgba(10,8,16,0.78);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(4px); z-index: 50;
}
.gameover[hidden] { display: none; }
.go-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 26px 24px; max-width: 380px; width: 100%;
  text-align: center; box-shadow: var(--shadow);
  animation: popin .3s cubic-bezier(.2,1.2,.4,1);
}
.go-card h2 { margin: 0 0 10px; font-size: 24px; color: var(--accent); }
.go-card p { margin: 0 0 18px; color: var(--muted); line-height: 1.6; font-size: 15px; }
.go-card b { color: var(--text); }
.play-again {
  appearance: none; border: 0; cursor: pointer;
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  color: #1a1430; font-weight: 800; font-size: 16px;
  padding: 13px 26px; border-radius: 999px; width: 100%;
  transition: transform .12s, filter .2s;
}
.play-again:hover { transform: translateY(-2px); filter: brightness(1.08); }
.play-again:active { transform: translateY(0) scale(.98); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 18px; transform: translate(-50%, 20px);
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); padding: 11px 18px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 60;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Responsive */
@media (max-width: 480px) {
  #app { padding: 10px 10px 14px; gap: 10px; }
  .brand h1 { font-size: 18px; }
  .tag { display: none; }
  .stat { padding: 6px 6px; min-width: 56px; }
  .stat-val { font-size: 15px; }
  .stat-label { font-size: 9.5px; }
  .ans { font-size: 17px; padding: 12px 0; border-radius: 12px; }
  .ach-grid { grid-template-columns: repeat(4, 1fr); }
  #staff .clef-treble { font-size: 78px; }
  #staff .clef-bass { font-size: 58px; }
}
@media (max-width: 360px) {
  .answers { gap: 5px; }
  .ans { font-size: 15px; padding: 11px 0; }
}
