:root {
  --bg: #0c0d0e;
  --surface: #17181a;
  --line: #2a2b2e;
  --text: #d2d3d5;
  --muted: #8f9195;
  --accent: #d8b25a;
  --blue: #3f9bd0;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding: 0 16px 48px; }
header, main { max-width: 1400px; margin: 0 auto; }
header { padding: 20px 0 8px; }
h1 { margin: 0 0 4px; font-size: 1.6rem; font-weight: 600; letter-spacing: .01em; }
header p { margin: 0; color: var(--muted); max-width: 60em; }
h2 { font-size: 1.15rem; margin: 28px 0 8px; color: var(--accent); font-weight: 600; }
a { color: var(--blue); }

#stage { position: relative; width: 100%; margin-top: 12px; touch-action: none; user-select: none; -webkit-user-select: none; }
#rack { display: block; width: 100%; aspect-ratio: 1400 / 389; background: #101112; border-radius: 4px; }
#cover { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: rgba(12, 13, 14, .55); border-radius: 4px; }
body.on #cover { display: none; }
#start { font: inherit; font-size: 1.1rem; font-weight: 600; padding: 12px 28px; border-radius: 999px; border: 1px solid var(--accent);
  background: var(--accent); color: #141414; cursor: pointer; min-width: 10em; }
#start:disabled { background: var(--surface); color: var(--muted); border-color: var(--line); cursor: default; }
#status { margin: 0; color: var(--text); text-shadow: 0 1px 2px #000; text-align: center; padding: 0 12px; }
#reading { position: absolute; right: 8px; top: 6px; font: 600 11px/1 system-ui, sans-serif; letter-spacing: .08em;
  color: #ff6a4d; opacity: 0; transition: opacity .1s; pointer-events: none; }
body.reading #reading { opacity: 1; }

#display-line { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
#note, #perf { min-height: 1.5em; margin: 8px 0 0; color: var(--muted); }
#perf { color: #ff8c6b; min-height: 0; }
#written { color: var(--accent); }

#keys { margin-top: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.bar button { font: inherit; width: 40px; height: 36px; border-radius: 6px; border: 1px solid var(--line); background: #222326; color: var(--text); cursor: pointer; }
#oct { min-width: 2.5em; text-align: center; font-variant-numeric: tabular-nums; }
.bar label { margin-left: auto; color: var(--muted); }
.bar select { font: inherit; margin-left: 6px; background: #222326; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
#kbd { --whites: 22; position: relative; height: clamp(110px, 22vw, 180px); touch-action: none; user-select: none; -webkit-user-select: none; }
.key { position: absolute; top: 0; border-radius: 0 0 5px 5px; }
.key.white { left: calc(100% / var(--whites) * var(--x)); width: calc(100% / var(--whites) - 2px); height: 100%; background: linear-gradient(#e9e9e6, #fbfbf8); }
.key.black { left: calc(100% / var(--whites) * var(--x) - 100% / var(--whites) * .32); width: calc(100% / var(--whites) * .64); height: 62%; background: linear-gradient(#2b2c2f, #111214); z-index: 1; border: 1px solid #000; }
.key span { position: absolute; bottom: 6px; left: 0; right: 0; text-align: center; font-size: 11px; color: #777; }
.key.white.on { background: linear-gradient(#cfc39e, #e2d3a3); }
.key.black.on { background: linear-gradient(#6b5a2c, #3d3319); }
#midi { margin: 8px 0 0; color: var(--muted); font-size: .9rem; min-height: 0; }
#midi:empty { display: none; }

.help { max-width: 60em; }
.help ol { padding-left: 1.4em; }
.help li { margin-bottom: 6px; }
table { border-collapse: collapse; width: 100%; max-width: 40em; }
th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; }
td:first-child { white-space: nowrap; }
@media (max-width: 520px) { td:first-child { white-space: normal; } }

/* ---- phones: full-screen landscape view */
#leave { display: none; }
#phone-hint { display: none; margin: 12px 0 0; }
body.phone.on:not(.full) #phone-hint { display: block; }
#enter { font: inherit; font-weight: 600; padding: 10px 22px; border-radius: 999px; border: 1px solid var(--accent); background: var(--accent); color: #141414; }
body.full { overflow: hidden; }
body.full #player { position: fixed; left: 0; top: 0; width: 100vw; height: 100vh; z-index: 10; background: var(--bg);
  transform-origin: 0 0; display: flex; flex-direction: column; padding: 4px 8px calc(4px + env(safe-area-inset-bottom)); }
body.full #stage { margin-top: 0; flex: none; }
body.full #keys { flex: 1; min-height: 0; display: flex; flex-direction: column; margin-top: 4px; padding: 4px 6px 6px; border-radius: 6px; }
body.full .bar { margin-bottom: 4px; gap: 6px; }
body.full .bar button { height: 30px; width: 36px; }
body.full .bar select { padding: 3px 6px; }
body.full #kbd { flex: 1; height: auto; min-height: 40px; }
body.full #note { position: absolute; left: 12px; bottom: 6px; margin: 0; z-index: 2; pointer-events: none; background: rgba(12,13,14,.85); padding: 2px 8px; border-radius: 4px; }
body.full #note:empty, body.full #perf:empty, body.full #midi { display: none; }
body.full #perf { position: absolute; right: 12px; top: 6px; margin: 0; z-index: 2; font-size: .8rem; background: rgba(12,13,14,.85); padding: 2px 8px; }
body.full #leave { display: block; position: absolute; right: 6px; top: 6px; z-index: 3; width: 36px; height: 30px; font: inherit; color: var(--text);
  background: #222326; border: 1px solid var(--line); border-radius: 6px; }
body.full #keys .bar { position: relative; }
