/* Playalator: black and white, like the keys, with one splash of gold.
   Green and red mean only "play this" and "wrong": nothing else uses them. */
:root {
  --ink: #111;
  --paper: #fff;
  --page: #f4f3ef;
  --line: #d9d6cf;
  --muted: #6b6860;
  --gold: #ffc21a;
  --gold-ink: #8a6500;      /* gold dark enough to read on white */
  --next: #22b35e;          /* the key to play */
  --next-soft: #c8f1d7;
  --wrong: #ff4040;
  --right: #22b35e;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
/* No double-tap zoom on iPads (keyboard.js does the rest), and no copy menu or
   text selection from a long press while playing. */
html, body { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
.play, .keys-wrap, .bar { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body { background: var(--page); color: var(--ink); display: flex; flex-direction: column; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.warn { color: #b3261e; font-weight: 600; }

/* ── Top bar ── */
.bar { display: flex; align-items: center; gap: 14px; padding: 10px 16px; background: var(--ink); color: #fff; flex: none; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: .2px; }
.logo { width: 30px; height: 30px; border-radius: 8px; background: var(--gold);
  background-image: linear-gradient(90deg, #fff 0 22%, var(--ink) 22% 26%, #fff 26% 48%, var(--ink) 48% 52%, #fff 52% 74%, var(--ink) 74% 78%, #fff 78%);
  border: 3px solid var(--gold); position: relative; }
.logo::after { content: ''; position: absolute; left: 13%; top: 0; width: 22%; height: 58%; background: var(--ink); box-shadow: 9px 0 0 var(--ink); border-radius: 0 0 2px 2px; }
.bar-mid { flex: 1; }
.bar-right { display: flex; gap: 10px; align-items: center; }
.bar-btn { white-space: nowrap; background: transparent; border: 1.5px solid #555; color: #fff; border-radius: 999px; padding: 7px 14px; font-weight: 600; }
.bar-btn:hover { border-color: var(--gold); }
.chip { font-size: 13px; line-height: 1.25; padding: 5px 10px; border-radius: 999px; background: #222; color: #ddd; }
.chip.on { background: var(--gold); color: var(--ink); font-weight: 700; }
.chip.warn { background: #5a1a16; color: #fff; }

/* ── Screens ── */
.screen { flex: 1; overflow: auto; padding: 22px 18px 40px; }
.card { background: var(--paper); border-radius: var(--radius); padding: 26px; border: 1px solid var(--line); }
.narrow { max-width: 560px; margin: 30px auto; }
h1 { margin: 0 0 6px; font-size: 26px; }
.class-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 18px; }
.class-list button { padding: 16px 12px; border-radius: 12px; border: 2px solid var(--ink); background: var(--paper); font-weight: 700; font-size: 17px; }
.class-list button:hover { background: var(--ink); color: #fff; }

#library { max-width: 1100px; margin: 0 auto; }
.stage { margin-bottom: 26px; }
.stage h3 { display: flex; align-items: baseline; gap: 10px; margin: 0 0 10px; font-size: 20px; }
.stage h3 small { font-weight: 500; color: var(--muted); font-size: 15px; }
.step { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: var(--gold); font-size: 15px; flex: none; align-self: center; }
.songs { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.song { text-align: left; background: var(--paper); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 3px; min-height: 92px; }
.song:hover { border-color: var(--ink); box-shadow: 0 3px 0 var(--gold); }
.song b { font-size: 17px; }
.song .composer { font-size: 13px; color: var(--muted); }
.song .facts { font-size: 13px; font-weight: 700; color: var(--gold-ink); }
.song .known { font-size: 12.5px; color: var(--muted); font-style: italic; }

/* ── Playing ── */
.play { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.play-top { display: flex; align-items: center; gap: 14px; padding: 10px 16px; background: var(--paper); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.song-head { flex: 1; min-width: 200px; }
.song-head h2 { margin: 0; font-size: 20px; }
.song-head div { font-size: 13px; }
.modes { display: flex; background: var(--page); border-radius: 999px; padding: 3px; border: 1px solid var(--line); }
.mode { border: 0; background: transparent; padding: 8px 20px; border-radius: 999px; font-weight: 700; font-size: 15px; }
.mode.on { background: var(--ink); color: #fff; }
.tools { display: flex; gap: 6px; flex-wrap: wrap; }
.tool { border: 1.5px solid var(--line); background: var(--paper); border-radius: 999px; padding: 7px 12px; font-size: 14px; font-weight: 600; }
.tool:hover { border-color: var(--ink); }
.tool.toggle.on { background: var(--gold); border-color: var(--gold); }

.score-scroll { flex: 1; overflow-y: auto; background: var(--paper); min-height: 150px; padding: 4px 10px; }
#score svg { display: block; }
/* VexFlow 5 draws noteheads as text (Bravura), stems and flags as paths. */
#score .sv-note.now path, #score .sv-note.now rect, #score .sv-note.now text { fill: var(--next); stroke: var(--next); }
#score .sv-note.done:not(.now) path, #score .sv-note.done:not(.now) rect, #score .sv-note.done:not(.now) text { fill: #a8a59d; stroke: #a8a59d; }

.play-bar { display: flex; align-items: center; gap: 14px; padding: 8px 16px; background: var(--page); border-top: 1px solid var(--line); flex: none; min-height: 58px; flex-wrap: wrap; }
.status { flex: 1; font-size: 16px; min-width: 220px; }
.perform-controls, .learn-controls { display: flex; align-items: center; gap: 14px; }
.tempo { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.tempo input { width: 160px; accent-color: var(--ink); }
#tempo-out { min-width: 110px; font-variant-numeric: tabular-nums; }
.go { background: var(--ink); color: #fff; border: 0; border-radius: 999px; padding: 11px 24px; font-weight: 800; font-size: 16px; box-shadow: 0 3px 0 var(--gold); }
.go.stop { background: #444; }
.go:disabled { opacity: .5; }
.ghost { background: transparent; border: 1.5px solid var(--ink); border-radius: 999px; padding: 9px 18px; font-weight: 700; }

.count { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); font-size: 140px; font-weight: 900; color: var(--ink);
  text-shadow: 0 6px 0 var(--gold); pointer-events: none; }

/* ── The piano ── */
.keys-wrap { flex: none; height: clamp(170px, 34vh, 300px); padding: 0 8px 10px; background: var(--ink); }
.piano { position: relative; display: flex; height: 100%; user-select: none; -webkit-user-select: none; touch-action: none; }
.key { position: relative; -webkit-tap-highlight-color: transparent; }
.key.white { flex: 1; background: #fff; border: 1px solid #222; border-top: 0; border-radius: 0 0 9px 9px; margin: 0 1px; }
.key.black { position: absolute; top: 0; width: calc(100% / var(--whites) * 0.6); height: 60%; background: #1b1b1b; border-radius: 0 0 7px 7px; z-index: 2;
  border: 1px solid #000; box-shadow: inset 0 -6px 0 #333; }
.key-label { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 1px; pointer-events: none; }
.key-label b { font-size: clamp(13px, 1.9vw, 20px); }
.key-label i { font-style: normal; font-size: clamp(11px, 1.4vw, 15px); color: var(--muted); }
.key.black .key-label { bottom: 8px; color: #fff; }
.key.black .key-label b { font-size: clamp(11px, 1.4vw, 15px); }
.key.black .key-label i { color: #bbb; font-size: clamp(10px, 1.2vw, 13px); }
.no-labels .key-label { display: none; }
.mc { position: absolute; top: 10px; left: 50%; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: var(--gold); border: 1.5px solid var(--ink); }
.key.down.white { background: #e8e6e0; }
.key.down.black { background: #3a3a3a; }
.key.next.white, .key.next.black { background: var(--next); }
.key.next .key-label, .key.next .key-label i { color: #fff; }
.key.right { animation: right .45s ease-out; }
.key.wrong { animation: wrong .45s ease-out; }
.key.wrong-flash { animation: wrong-flash .26s steps(1) 3; }
@keyframes right { 0% { box-shadow: inset 0 0 0 999px rgba(34, 179, 94, .85), 0 0 22px var(--right); } 100% { box-shadow: inset 0 0 0 999px rgba(34, 179, 94, 0); } }
@keyframes wrong-flash { 0% { box-shadow: inset 0 0 0 999px rgba(255, 64, 64, .95), 0 0 22px var(--wrong); } 60% { box-shadow: none; } }
@keyframes wrong { 0% { box-shadow: inset 0 0 0 999px rgba(255, 64, 64, .95), 0 0 22px var(--wrong); } 100% { box-shadow: inset 0 0 0 999px rgba(255, 64, 64, 0); } }

/* ── Pop-ups ── */
.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: grid; place-items: center; z-index: 20; padding: 16px; }
.sheet-card { background: var(--paper); border-radius: 18px; padding: 24px; width: min(560px, 100%); max-height: 90vh; overflow: auto; border-top: 6px solid var(--gold); }
.sheet-card h2 { margin: 0 0 8px; }
.sheet-btns { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.marks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0; }
.marks div { background: var(--page); border-radius: 12px; padding: 12px; text-align: center; }
.marks span { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
.marks b { font-size: 30px; }
.marks .total { background: var(--ink); color: #fff; }
.marks .total span { color: var(--gold); }
.note { background: #fff7db; border-radius: 12px; padding: 12px 14px; }
.board { list-style: none; padding: 0; margin: 8px 0; counter-reset: rank; }
.board li { display: grid; grid-template-columns: 34px 60px 70px 1fr; align-items: center; padding: 8px 10px; border-radius: 10px; counter-increment: rank; }
.board li::before { content: counter(rank); font-weight: 800; color: var(--muted); }
.board li:nth-child(odd) { background: var(--page); }
.board li.mine { background: var(--gold); }
.board .who { font-weight: 900; font-size: 18px; letter-spacing: 2px; }
.board .pts { font-weight: 800; font-size: 18px; }
.board .split { font-size: 13px; color: var(--muted); }
.board li.mine .split { color: var(--ink); }
.initials { background: var(--page); border-radius: 12px; padding: 14px; text-align: center; }
.initials h3 { margin: 0 0 4px; }
.ini { display: flex; gap: 10px; justify-content: center; margin: 10px 0; }
.ini input { width: 64px; height: 76px; font-size: 44px; font-weight: 900; text-align: center; text-transform: uppercase; border: 3px solid var(--ink); border-radius: 12px; }
.tip-count { font-size: 13px; font-weight: 700; color: var(--gold-ink); text-transform: uppercase; letter-spacing: .5px; }
.tip p { font-size: 17px; line-height: 1.45; }
.tip-score { background: var(--page); border-radius: 12px; padding: 6px; }

@media (max-width: 700px) {
  .tempo input { width: 110px; }
  .brand { font-size: 17px; }
}

/* ── The teacher page ── */
.bar-tag { background: var(--gold); color: var(--ink); font-size: 12px; font-weight: 800; padding: 3px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .5px; }
.t-wrap { max-width: 1000px; margin: 0 auto; }
.t-wrap section { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.t-wrap h2 { margin: 0 0 10px; font-size: 20px; }
.field { font: inherit; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; width: 100%; }
.field:focus { outline: 2px solid var(--gold); border-color: var(--ink); }
#login-form .field { margin: 12px 0; }
.add-ways { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.add-way { text-align: left; background: var(--ink); color: #fff; border: 0; border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 4px; box-shadow: 0 4px 0 var(--gold); }
.add-way .big { font-size: 30px; }
.add-way b { font-size: 19px; }
.add-way span { color: #ccc; font-size: 14px; }
.t-row { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.t-row:first-child { border-top: 0; }
.t-row-main { flex: 1; display: flex; flex-direction: column; min-width: 220px; }
select.strict { font: inherit; font-size: 14px; padding: 6px 8px; border-radius: 8px; border: 1.5px solid var(--line); background: #fff; }
.class-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cchip { background: var(--page); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-weight: 600; }
.cchip button { border: 0; background: none; color: #b3261e; font-weight: 800; padding: 0 0 0 4px; }
.add-class { display: flex; gap: 8px; flex: 1; min-width: 280px; }
.add-class .field { padding: 7px 10px; }
.setting { display: flex; align-items: center; gap: 10px; font-weight: 600; flex-wrap: wrap; }
.setting select { font: inherit; padding: 6px 8px; border-radius: 8px; }
.edit-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.edit-head h2 { margin: 0; }
.edit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.edit-grid label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 14px; }
.edit-classes { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.ck { font-size: 14px; white-space: nowrap; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-top: 10px; }
.panel h3 { margin: 0 0 4px; }
.rec-row { display: flex; align-items: center; gap: 14px; }
.fix-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.tool:disabled { opacity: .4; }
.score-box { max-height: 360px; overflow: auto; background: #fff; }
#t-score.pickable .sv-note { cursor: pointer; }
#t-score .sv-note.sel path, #t-score .sv-note.sel rect, #t-score .sv-note.sel text { fill: var(--gold-ink); stroke: var(--gold-ink); }
.t-keys { height: 170px; margin-top: 10px; border-radius: var(--radius); padding-top: 0; }
.save-row { display: flex; justify-content: flex-end; align-items: center; gap: 14px; margin: 14px 0 30px; }
@media (max-width: 700px) { .add-ways { grid-template-columns: 1fr; } }

/* ── Show me: the key being played for you is gold (green means it's your turn) ── */
.key.show.white, .key.show.black { background: var(--gold); }
.key.show .key-label, .key.show .key-label i { color: var(--ink); }
#score .sv-note.showing path, #score .sv-note.showing rect, #score .sv-note.showing text { fill: var(--gold-ink); stroke: var(--gold-ink); }

/* ── Confetti and the record ── */
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 50; }
.confetti-flash { position: fixed; inset: 0; background: #fff; z-index: 49; pointer-events: none; animation: flash .7s ease-out forwards; }
@keyframes flash { 0% { opacity: .95; } 100% { opacity: 0; } }
.shake { animation: shake .7s cubic-bezier(.36, .07, .19, .97); }
@keyframes shake {
  10%, 90% { transform: translate(-3px, 2px); } 20%, 80% { transform: translate(6px, -4px); }
  30%, 50%, 70% { transform: translate(-10px, 6px) rotate(-.6deg); } 40%, 60% { transform: translate(10px, -6px) rotate(.6deg); }
}
.record-banner { position: fixed; left: 50%; top: 42%; z-index: 51; pointer-events: none; transform: translate(-50%, -50%) scale(.2);
  font-size: clamp(48px, 11vw, 130px); font-weight: 900; color: var(--gold); white-space: nowrap; letter-spacing: 2px;
  -webkit-text-stroke: 3px var(--ink); text-shadow: 0 8px 0 var(--ink); display: flex; align-items: center; gap: 16px;
  animation: pop .6s cubic-bezier(.2, 1.6, .4, 1) forwards; }
.record-banner span { -webkit-text-stroke: 0; text-shadow: none; }
.record-banner.going { animation: popout .6s ease-in forwards; }
@keyframes pop { to { transform: translate(-50%, -50%) scale(1) rotate(-4deg); } }
@keyframes popout { from { transform: translate(-50%, -50%) scale(1) rotate(-4deg); opacity: 1; } to { transform: translate(-50%, -50%) scale(1.4) rotate(-4deg); opacity: 0; } }
.show-controls { display: flex; align-items: center; gap: 14px; }
.fix-song { margin-left: auto; display: flex; gap: 6px; align-items: center; font-weight: 600; font-size: 14px; }
.cut { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; }
.cut input { width: 62px; font: inherit; padding: 5px 6px; border: 1.5px solid var(--line); border-radius: 8px; }
.shift { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; }
/* The teacher's preview of an unsaved song */
.preview-tag { background: var(--gold); color: var(--ink); font-weight: 800; padding: 5px 12px; border-radius: 999px; font-size: 14px; }
.previewing #board-btn { display: none; }

/* The Delivery kit: a download, not a banner (as in Songalator). */
.kit { display: inline-flex; gap: 16px; align-items: center; max-width: 720px; margin: 0 0 16px; padding: 12px 14px 12px 12px;
  border-radius: 18px; background: #fff; color: var(--ink); text-decoration: none; border: 3px solid var(--ink);
  box-shadow: 0 5px 0 var(--gold); cursor: pointer; transition: transform .1s, box-shadow .1s; }
.kit:hover { transform: translateY(-2px); box-shadow: 0 7px 0 var(--gold); }
.kit:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--gold); }
.kit-file { flex: none; width: 58px; height: 64px; border-radius: 10px; background: var(--page); border: 2px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 28px; line-height: 1; }
.kit-file small { font-size: 11px; font-weight: 900; color: var(--gold-ink); margin-top: 4px; }
.kit-words { display: flex; flex-direction: column; gap: 2px; }
.kit-words b { font-size: 20px; }
.kit-words span { font-size: 14px; color: var(--muted); }
.kit-go { flex: none; background: var(--ink); color: var(--gold); font-weight: 900; font-size: 17px; padding: 12px 18px; border-radius: 14px; white-space: nowrap; }

/* The teacher's leaderboards at a glance: songs down, classes across. */
.glance-wrap { overflow-x: auto; }
.glance { border-collapse: collapse; font-size: 14px; }
.glance th, .glance td { padding: 4px 6px; text-align: center; white-space: nowrap; }
.glance thead th { font-size: 12.5px; color: var(--muted); }
.glance tbody th { text-align: left; font-weight: 700; position: sticky; left: 0; background: var(--paper); }
.glance tbody tr:nth-child(odd) td { background: var(--page); }
.glance td.none { color: var(--line); }
.glance .lead { background: none; border: 0; font: inherit; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.glance .lead:hover { background: var(--gold); }
.glance .lead b { letter-spacing: 1px; }
.glance .lead small { display: block; font-size: 11px; color: var(--muted); }

/* The students' Class top 10: every song's number one, opening to its top 10. */
.library-top { max-width: 1100px; margin: 0 auto 6px; display: flex; justify-content: flex-end; }
.class-board { border-bottom: 1px solid var(--line); }
.class-board summary { display: flex; justify-content: space-between; gap: 12px; padding: 10px 4px; cursor: pointer; font-weight: 700; }
.class-board summary::marker { color: var(--muted); }
.class-board .title { flex: 1; }
.class-board .first b { letter-spacing: 1px; }

/* Song requests on the teacher page: how many asked, A to Z. */
.request .tally { flex: none; min-width: 34px; height: 34px; border-radius: 10px; background: var(--gold); display: grid; place-items: center; font-weight: 900; }
.library-top { gap: 8px; }
