:root {
  --bg: #16181d; --panel: #20232a; --panel2: #2a2e37; --line: #3a3f4b; --text: #eceef2; --muted: #9aa1ad;
  --accent: #5aa9ff; --good: #3ccf7a; --bad: #ff5a5f; --warn: #ffb44c; --paper: #fbf8f1; --ink: #1d1d1f;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); -webkit-text-size-adjust: 100%; }
body { font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Ubuntu, sans-serif; min-height: 100vh; min-height: 100dvh; }
a { color: var(--accent); }
header {
  display: flex; align-items: center; gap: 8px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 3;
  padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
}
.logo { color: var(--text); text-decoration: none; font-weight: 700; font-size: 19px; flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo-keys { flex: none; width: 26px; height: 18px; border-radius: 3px; background:
  linear-gradient(90deg, #111 0 3px, transparent 3px) 4px 0/6px 11px repeat-x, repeating-linear-gradient(90deg, #fff 0 5px, #888 5px 6px); }
.who { display: flex; gap: 6px; align-items: center; }
.chip { color: var(--text); text-decoration: none; background: var(--panel2); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; min-height: 40px; display: inline-flex; align-items: center; max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.icon { padding: 6px 12px; font-size: 18px; }
main {
  max-width: 1280px; margin: 0 auto;
  padding: 12px max(12px, env(safe-area-inset-right)) max(30px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
h1 { font-size: 24px; margin: 4px 0 14px; line-height: 1.2; }
h2 { font-size: 16px; margin: 22px 0 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: 15px; }
[hidden] { display: none !important; }

button, .btn {
  font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 14px; min-height: 44px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center;
  justify-content: center; gap: 6px; touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
}
button:hover, .btn:hover { border-color: var(--accent); }
button:focus-visible, .btn:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.go, .btn.go { background: var(--accent); border-color: var(--accent); color: #08131f; font-weight: 700; }
button.on { background: #1f3a57; border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button.small { min-height: 36px; padding: 4px 12px; font-size: 15px; }
button.danger { border-color: #6b2a2d; color: #ffb3b5; }
button.linkish { background: none; border: 0; color: var(--accent); padding: 0; min-height: 0; font-size: inherit; text-decoration: underline; }
input {
  font: inherit; font-size: 17px; /* 16px or more: iPhone does not zoom in on focus */
  color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 46px; width: 100%;
}
input::placeholder { color: #6d7480; }
label { display: block; font-weight: 600; margin: 0 0 6px; }
.msg { min-height: 1.4em; color: var(--warn); margin: 8px 0 0; }
form.inline { display: flex; gap: 8px; margin: 10px 0; max-width: 520px; }
form.inline input { flex: 1; min-width: 0; }

/* panels: sign-in, errors */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; max-width: 480px; margin: 8px auto; }
.auth form { display: flex; flex-direction: column; gap: 10px; margin: 18px 0 8px; }
.auth .lead { color: var(--muted); }
input.code { font-size: 30px; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }

/* players, songs, history */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 12px; }
.person { display: flex; align-items: center; justify-content: center; min-height: 110px; padding: 12px; border-radius: 16px; font-size: 24px; font-weight: 700;
  color: var(--text); text-decoration: none; background: var(--panel); border: 1px solid var(--line); text-align: center; }
.person:hover { border-color: var(--accent); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column; }
.card:hover { border-color: var(--accent); }
.cardlink { color: inherit; text-decoration: none; padding: 14px 16px 8px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card .title { font-size: 21px; font-weight: 700; }
.card .meta { color: var(--muted); font-size: 15px; }
.card .best { font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card .star { margin: 4px 12px 12px; align-self: flex-start; min-height: 38px; font-size: 15px; }
.card .star.on { color: var(--warn); }
.spark { color: var(--accent); vertical-align: middle; }
.empty { background: var(--panel); border: 1px dashed var(--line); border-radius: 14px; padding: 16px; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stats div { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; }
.stats b { font-size: 26px; }
.stats span { color: var(--muted); font-size: 14px; line-height: 1.25; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; height: 150px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
.day { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; }
.day .barv { width: 70%; max-width: 34px; background: var(--accent); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.day b { font-size: 13px; min-height: 1em; }
.day i { font-style: normal; color: var(--muted); font-size: 13px; }
.day.today i { color: var(--text); font-weight: 700; }
.rows { display: flex; flex-direction: column; gap: 6px; }
.row { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; color: inherit; text-decoration: none;
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.row span { color: var(--muted); font-size: 15px; }
.row.edit { flex-wrap: nowrap; }
.row.edit input { flex: 1; min-width: 0; }
.row.edit span { flex: 1; color: var(--text); overflow-wrap: anywhere; }
a.row:hover { border-color: var(--accent); }
.ptop { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.ptop h1 { margin: 4px 0 10px; min-width: 0; }
.ptop .by { color: var(--muted); font-size: 16px; font-weight: 400; }
details.danger-zone { margin-top: 28px; color: var(--muted); }
details.danger-zone summary { cursor: pointer; color: #ffb3b5; }

/* practice */
.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.actions > button { flex: 1 1 auto; }
.actions > .go { flex-grow: 2; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex: 1 1 100%; }
.seg button { border: 0; border-radius: 0; flex: 1; }
.tempo { display: inline-flex; align-items: center; gap: 4px; }
.tempo b { min-width: 70px; text-align: center; font-variant-numeric: tabular-nums; }
.tempo button { width: 44px; padding: 0; font-size: 22px; }
.level { width: 34px; height: 6px; background: #3b4250; border-radius: 3px; overflow: hidden; flex: none; }
#mic:not(.on) .level { display: none; }
.level i { display: block; height: 100%; width: 0; background: var(--good); transition: width .06s; }
.opts { display: none; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; padding: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.opts.open { display: flex; }
button.icon { min-width: 44px; padding: 8px 12px; flex: none; }
.wide { display: none; }
details.tip { background: var(--panel); border-left: 4px solid var(--accent); padding: 6px 12px; border-radius: 6px; margin: 0 0 8px; color: var(--muted); font-size: 15px; }
details.tip summary { cursor: pointer; color: var(--text); }

.sheet { background: var(--paper); color: var(--ink); border-radius: 12px; padding: 6px; overflow: hidden; }
.sheet svg { display: block; width: 100%; height: auto; }
.sheet.follow svg { width: auto; max-width: none; transition: transform .3s ease; will-change: transform; }
.sheet .stl { stroke: #555; stroke-width: 1.2; }
.sheet .bl { stroke: #333; stroke-width: 1.4; }
.sheet .clef { font: 72px "Noto Music", "Apple Symbols", "Segoe UI Symbol", serif; fill: var(--ink); }
.sheet .note { fill: var(--ink); stroke: var(--ink); }
.sheet .note .hollow { fill: var(--paper); stroke-width: 1.8; }
.sheet .note .stem { stroke-width: 1.6; }
.sheet .note .ledger { stroke-width: 1.4; }
.sheet .lbl { font: 600 14px system-ui, sans-serif; fill: #666; stroke: none; text-anchor: middle; }
.sheet .fng { font: 700 13px system-ui, sans-serif; fill: #8a6d00; stroke: none; text-anchor: middle; }
.sheet .note.cur { fill: #1f74d6; stroke: #1f74d6; }
.sheet .note.cur .lbl { fill: #1f74d6; }
.sheet .note.ok { fill: #19934f; stroke: #19934f; }
.sheet .note.miss { fill: #d98200; stroke: #d98200; }
.sheet .note.bad { fill: #d8343a; stroke: #d8343a; }
.sheet .hl { fill: #1f74d6; opacity: .1; }
.sheet .playhead { stroke: #1f74d6; stroke-width: 2; opacity: .7; }

.status { min-height: 44px; display: flex; align-items: center; gap: 14px; font-size: 20px; margin: 4px 2px; }
.status .good { color: var(--good); }
.status .bad { color: var(--bad); }
.count { font-size: 56px; font-weight: 800; color: var(--accent); line-height: 1; }

.kb { background: #0d0e11; border-radius: 12px; padding: 8px 8px 4px; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.kb svg { display: block; width: 100%; height: auto; }
.kb .w { fill: #fdfdfd; stroke: #222; stroke-width: 1; }
.kb .k { fill: #1b1b1b; stroke: #000; }
.kb .w.next, .kb .k.next { fill: #5aa9ff; }
.kb .w.hit, .kb .k.hit { fill: #3ccf7a; }
.kb .w.wrong, .kb .k.wrong { fill: #ff5a5f; }
.kb .kl { font: 600 13px system-ui, sans-serif; fill: #777; text-anchor: middle; pointer-events: none; }
.kb .kl.c { fill: #333; }
.kb .fl { font: 800 20px system-ui, sans-serif; fill: #fff; text-anchor: middle; pointer-events: none; }

.done { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; margin-top: 12px; }
.done .big { font-size: 44px; font-weight: 800; }
.done p { margin: 6px 0; }
.done .bar { margin-top: 14px; }
.note-hint { color: var(--muted); font-size: 15px; margin-top: 8px; }

/* room for one row of buttons: the Wait / Beat switch joins them */
@media (min-width: 640px) {
  .actions > button, .actions > .go { flex: 0 0 auto; }
  .seg { flex: 0 1 340px; margin-left: auto; }
}
/* big screens (tablet, laptop): every option in view, longer labels */
@media (min-width: 760px) and (min-height: 521px) {
  body { font-size: 18px; }
  h1 { font-size: 28px; }
  .wide { display: inline; }
  #opts-btn { display: none; }
  .opts { display: flex; background: none; border: 0; padding: 0; }
}
/* a phone held sideways: little height, so less around the music and keys; options stay behind ⚙ */
@media (max-height: 520px) and (orientation: landscape) {
  header { position: static; padding-top: 4px; padding-bottom: 4px; }
  main { padding-top: 6px; }
  .ptop h1 { font-size: 20px; margin: 0 0 6px; }
  details.tip { display: none; }
  .status { min-height: 34px; font-size: 18px; margin: 2px; }
  .practice { min-height: calc(100dvh + 150px); } /* room to scroll the music up to the top */
}
@media (prefers-reduced-motion: reduce) { .sheet.follow svg { transition: none; } }
