/* Piano Practice "starlit synth panel" look: how this page uses Myrddin's tokens.css + components.css.
   Load order: style.css (layout and judging colours), tokens.css, components.css, theme.css (this file).
   To re-theme, change tokens.css or the :root block below. The judging colours (--ok, --soft, --loud,
   --wrong, --target and their -key twins) live in style.css and are never touched here. */
:root{
  --panel:var(--panel-bot); --panel2:var(--panel-top); --line:#23263a; --accent2:var(--accent-deep);
  --glow:rgba(138,152,255,.4); --radius:var(--r-panel); --shadow:var(--sh-panel);
  --rune-line:rgba(138,152,255,.25);   /* 1px inner line of a rune frame */
  --rune-op:.2;                        /* rune and star marks along frames (16 to 25%) */
  --frame-indigo-top:#1c2042; --frame-indigo-bot:#111430;   /* keyboard frame */
  --frame-pad:10px;                    /* lane and keyboard frames must share it (keeps bars over their keys) */
  --stone-tile:url("textures/stone-tile.webp");      /* webp: half the bytes of the .jpg in art-direction/ */
  --vellum:url("textures/vellum-staff.webp");
  --stone-dark:linear-gradient(180deg,rgba(8,10,20,.46),rgba(8,10,20,.62));   /* overlay that keeps text contrast on the stone (--muted >= 4.5) */
  --vellum-wash:rgba(255,250,238,.74);   /* pale wash over the vellum so notes and result colours stay readable */
}
html{background:transparent}           /* the body background reaches the window, so the stars show */
body{min-height:100vh}
body.sky-paused::after{animation-play-state:paused}          /* tab hidden: no twinkle */
/* the twinkle moves in 24 small steps (one every 0.375 s, 1.25% opacity each) instead of 60 frames a second:
   looks the same at this speed and lets the browser sit idle between steps */
body::after{animation-timing-function:steps(24)}
h1,h2,h3{font-family:var(--font-label);letter-spacing:.06em}
a{color:var(--accent)}
select,.rec-name input,.panel input[type=number]{background:var(--well);border:1px solid var(--edge);border-radius:9px;color:var(--ink);
  box-shadow:inset 0 2px 4px rgba(0,0,0,.6),0 1px 0 var(--groove-light)}
select option{background:var(--panel-bot)}
kbd{background:var(--cap-mid);border-color:var(--edge);color:var(--ink)}

/* ---------- rune frame: 2px dark line, 1px inner indigo line, faint runes along the top and bottom ---------- */
.rune-frame{position:relative;border:2px solid var(--edge);
  box-shadow:inset 0 0 0 1px var(--rune-line),inset 0 2px 0 var(--hi),0 0 0 1px rgba(138,152,255,.05),var(--sh-panel)}
.rune-frame::before{content:"";position:absolute;left:14px;right:14px;top:3px;bottom:3px;pointer-events:none;opacity:var(--rune-op);
  background:url("sprites/rune-marks.svg") top left/120px 9px repeat-x,url("sprites/rune-marks.svg") bottom left 60px/120px 9px repeat-x}

/* ---------- control panel (the page header) ---------- */
header.console{margin:30px 14px 0;padding:14px 16px 0;gap:10px 12px}
header.console #exerciseSelect{flex:1 1 220px;max-width:400px;min-width:0}
header.console .nameplate{position:absolute;left:20px;top:-2px;transform:translateY(-100%);margin:0;display:flex;align-items:center;gap:2px;
  font:600 13px/1 var(--font-label);letter-spacing:.1em;padding:6px 14px 5px 10px;
  color:#1a1405;-webkit-background-clip:border-box;background-clip:border-box;background:linear-gradient(180deg,var(--brass-hi),var(--brass))}
header.console .nameplate .moon{width:16px;height:16px;margin-right:6px;vertical-align:0;filter:none}
.console-row{flex:0 0 calc(100% + 32px);display:flex;flex-wrap:wrap;align-items:center;gap:14px 22px;margin:4px -16px 0;padding:12px 16px 14px;border-radius:0 0 12px 12px}
header #gameBar.console-strip{flex:0 0 calc(100% + 32px);margin:2px -16px 0;padding:10px 16px;border:0;border-radius:0;background:none;
  box-shadow:inset 0 1px 0 var(--groove-light);border-top:1px solid var(--groove-dark)}
header #gameBar.console-strip[hidden]{display:none}
.knobs{display:flex;gap:18px;align-items:flex-start}
.knob-wrap .label{margin-top:4px}
.knob-wrap output{min-height:15px}
.knob-wrap > input[type=range]{width:110px}                  /* before knob.js runs, or without it */
.knob input{cursor:grab}
.knob.turning input{cursor:grabbing}
.knob:focus-within{outline:2px solid var(--accent);outline-offset:3px}
.knob.small,.srow .knob{--size:56px}
.srow .knob text{display:none}
/* "Did you know?" (Myrddin's .fact): in the panel after a finished run, and under the keys after a quiz answer */
#factCard{flex:1 1 280px;max-width:480px;margin-left:auto;display:flex;flex-direction:column;align-items:flex-start;gap:4px}
#factCard[hidden],#quizFact.fact[hidden]{display:none}
#factCard p{margin:0;color:var(--label);font-size:14px;line-height:1.45}
#factCard .btn{align-self:flex-end}
#quizFact.fact{display:flex;flex-direction:column;align-items:flex-start;gap:2px;text-align:left;color:var(--ink);font-size:16px}
#quizFact.fact::after{content:"Did you know?";order:-1;font:600 12px var(--font-label);letter-spacing:.08em;text-transform:uppercase;color:var(--moonstone)}
.next-line:empty{display:none}
#gameBar .next-line{padding:0 4px}

/* ---------- bars under the panel ---------- */
#quizBar{position:relative;background:linear-gradient(180deg,var(--panel-top),var(--panel-bot));border:1px solid var(--edge);border-radius:var(--r-panel);
  box-shadow:inset 0 1px 0 var(--hi),0 0 0 1px rgba(138,152,255,.05),var(--sh-panel)}
#gameBar .scorebox,#quizBar .quiz-progress,.rec-name,#midiBar,.server-status{color:var(--muted)}
.scorebox b{color:var(--ink)}
.btn.primary{background:linear-gradient(180deg,#5463e0,var(--accent-deep))}   /* top a shade darker than components.css (#6372f2): white text >= 4.9:1 everywhere */
.btn.ghost{color:var(--ink);border-color:var(--edge);background:linear-gradient(180deg,#3c3f55,#2a2c3d);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.15),inset 0 -2px 0 rgba(0,0,0,.35),var(--sh-raised)}
.rec-btn{font:600 15px/1 var(--font-label);letter-spacing:.06em;text-transform:uppercase;color:var(--ink);border:1px solid var(--edge);
  background:linear-gradient(180deg,#3c3f55,#2a2c3d);box-shadow:inset 0 1px 0 rgba(255,255,255,.15),inset 0 -2px 0 rgba(0,0,0,.35),var(--sh-raised)}
.rec-btn .rec-icon{background:#ef4444;box-shadow:0 0 6px rgba(239,68,68,.6)}
.rec-btn.recording{background:linear-gradient(180deg,#30334a,#252839);color:var(--ink);border-color:#7f2d3d}
#recBar.recording{background:linear-gradient(180deg,#2a1d2c,#1f1622);border-color:#5a2433}
.dot.wait{background:var(--moonstone)}
.banner{background:linear-gradient(180deg,var(--panel-top),var(--panel-bot));border:1px solid var(--edge);border-left:3px solid var(--moonstone);color:var(--ink)}
.banner b,.banner .banner-more{color:#fff}
.banner p{color:var(--label)}
.piano-status.tap{color:var(--cream);border-color:var(--accent);background:rgba(138,152,255,.12)}
@keyframes pnudge{50%{background:rgba(138,152,255,.3)}}
#summary,#quizSummary,.piano-notice{background:linear-gradient(180deg,var(--panel-top),var(--panel-bot));border-color:var(--edge)}
#laneWrap #summary{background:rgba(21,24,38,.95)}
#instruction .big{color:#b4bfff}
.panel h3{color:var(--label)}

/* ---------- staff, lane, keyboard, hands ---------- */
#staff{margin:3px}
#keyboardWrap{background:none;border:0;box-shadow:none;padding:0;margin-top:14px}
#laneWrap{padding:13px var(--frame-pad) 0;border-bottom:0;border-radius:14px 14px 0 0;background:var(--well)}
#laneWrap::after{content:"";position:absolute;inset:4px;pointer-events:none;opacity:.22;            /* moon and star filigree in the corners */
  background:url("sprites/moon-star.svg") top left/15px no-repeat,url("sprites/moon-star.svg") top right/15px no-repeat,
    url("sprites/sparkle.svg") bottom 2px left 2px/9px no-repeat,url("sprites/sparkle.svg") bottom 2px right 2px/9px no-repeat}
#lanes{border-radius:8px 8px 0 0;   /* Myrddin's lane gradient plus a soft indigo glow rising toward the key line */
  background:linear-gradient(180deg,rgba(138,152,255,0) 72%,rgba(138,152,255,.07) 90%,rgba(138,152,255,.16) 100%),linear-gradient(180deg,#080a12 0%,#101324 75%,#191d33 100%)}
.kb-frame{padding:8px var(--frame-pad) 12px;border-radius:14px;background:linear-gradient(180deg,var(--frame-indigo-top),var(--frame-indigo-bot))}
body.mode-game .kb-frame{border-top:0;border-radius:0 0 14px 14px;padding-top:0}
#keyboard{border-radius:0 0 6px 6px}
.hands-strip{margin-top:8px;padding:6px var(--frame-pad);border-radius:12px;background:var(--inset);border:1px solid var(--edge);
  box-shadow:inset 0 1px 0 var(--groove-light),var(--sh-raised)}
#hands{margin-top:0}
#tapKeys{background:linear-gradient(180deg,var(--frame-indigo-top),var(--frame-indigo-bot));border:2px solid var(--edge);box-shadow:inset 0 0 0 1px var(--rune-line),var(--sh-panel)}
#legend{color:var(--muted)}

/* ---------- Game mode on a short screen: a slimmer panel so lane, keys and hands stay in view ---------- */
@media (max-height:920px) and (min-width:561px){
  header.console{margin-top:26px}
  body.mode-game .knob{--size:56px}
  body.mode-game .knob text{display:none}
  body.mode-game .console-row{padding:6px 16px 8px}
  body.mode-game #factCard{flex-direction:row;align-items:center;gap:12px;max-width:none;padding:6px 12px 6px 44px}
  body.mode-game #factCard p{flex:1;font-size:13px;line-height:1.35}
  body.mode-game #factCard .btn{align-self:center;flex:none}
  body.mode-game .knob-wrap{flex-direction:row;gap:8px}
  body.mode-game .knob-wrap .label{margin:0}
  body.mode-game .hands-strip{padding:3px var(--frame-pad)}
  body.mode-game #gameBar.console-strip{padding:6px 16px}
  body.mode-game .kb-frame{padding-bottom:6px}
  body.mode-game #laneWrap{padding-top:9px}
  body.mode-game #hands{height:78px}
}

/* ---------- Note quiz on phones and tablets: no knobs, so the staff and tap keys move up ---------- */
@media (max-width:1100px),(pointer:coarse){body.mode-quiz .console-row{display:none}body.mode-quiz header.console{padding-bottom:12px}}

/* ---------- touch screens: keep finger-sized targets (components.css sizes are for a mouse) ---------- */
@media (pointer:coarse){
  .btn,.seg button,select,.rec-btn{min-height:44px}
  .btn.small{min-height:40px}
  .switch{min-height:44px}
}
@media (max-width:760px){
  header.console{margin:28px 8px 0;padding:10px 10px 0}
  header #gameBar.console-strip{flex-basis:calc(100% + 20px);margin:2px -10px 0;padding:8px 10px}
  .console-row{flex-basis:calc(100% + 20px);margin:2px -10px 0;padding:10px 10px 12px;gap:10px 14px}
  #factCard{max-width:none;margin-left:0}
}
@media (max-width:560px){
  header .seg button{font-size:12px;padding:8px 6px;letter-spacing:.04em}
  .knobs{flex:1 1 100%;justify-content:space-between}
  /* phone: the screen is short, keep the keys in view (the quiz needs no knobs; the "Next" line is in the instruction) */
  #gameBar .next-line{display:none}
  body.mode-quiz #staff svg{height:150px !important;width:auto !important;margin:0 auto}   /* phone quiz: tap keys move up 50 px */
  body.mode-quiz #quizBar{gap:6px 8px}
  header #gameBar.console-strip{order:7}
  header .console-row{order:8}
  body.mode-game .knob{--size:56px}
  body.mode-game .knob text{display:none}
  body.mode-game .console-row{padding:6px 10px 8px}
}
@media (max-width:480px){.vdivider{display:none}}

/* ================= Update 4: carved blue stone panels, worn vellum staff (components.css last block) ================= */
header.console,#recBar,#midiBar,#quizBar,.banner,.panel,#summary,#quizSummary,.piano-notice{
  background:var(--stone-dark),var(--stone-tile) center/384px}
header.console,#recBar,#midiBar,#quizBar{border-radius:12px;
  box-shadow:inset 1px 1px 0 rgba(190,200,255,.16),inset -1px -2px 0 rgba(0,0,0,.55),inset 0 0 0 4px rgba(8,10,20,.18),inset 0 0 0 5px rgba(138,152,255,.14),0 10px 24px rgba(0,0,0,.5)}
header.console{box-shadow:inset 0 0 0 1px var(--rune-line),inset 1px 1px 0 rgba(190,200,255,.16),inset -1px -2px 0 rgba(0,0,0,.55),0 10px 24px rgba(0,0,0,.5)}
#recBar.recording{background:linear-gradient(180deg,rgba(60,20,34,.55),rgba(40,14,24,.7)),var(--stone-tile) center/384px}
.btn.ghost,.rec-btn,select,.rec-name input,kbd{background:linear-gradient(180deg,rgba(255,255,255,.10),rgba(0,0,0,.18)),var(--stone-tile) center/384px;
  box-shadow:inset 1px 1px 0 rgba(190,200,255,.22),inset -1px -2px 0 rgba(0,0,0,.5),var(--sh-raised)}
select,.rec-name input{background:linear-gradient(rgba(4,5,12,.72),rgba(4,5,12,.72)),var(--stone-tile) center/384px;box-shadow:inset 0 2px 4px rgba(0,0,0,.6)}
.btn.primary{background:linear-gradient(180deg,#5463e0,var(--accent-deep))}
.rec-btn.recording{background:linear-gradient(180deg,rgba(60,20,34,.6),rgba(30,12,20,.7)),var(--stone-tile) center/384px}
/* glowing engraved runes and a row of moon phases along the panel top */
.rune-frame::before{opacity:.3;filter:drop-shadow(0 0 3px rgba(138,152,255,.6))}
header.console::after{content:"";position:absolute;top:5px;left:50%;width:154px;height:14px;margin-left:-77px;pointer-events:none;opacity:.32;
  background:url("sprites/moon-phases.svg") center/contain no-repeat;filter:drop-shadow(0 0 3px rgba(183,180,232,.5))}
/* engraved orrery ring behind the knobs (static, about 8%) */
.knobs{background:url("sprites/orrery.svg") center/auto 150% no-repeat}
/* lane: starry slate with faint constellation lines behind the bars */
#laneWrap{background:linear-gradient(180deg,rgba(6,8,16,.55),rgba(6,8,16,.7)),var(--stone-tile) center/384px}
#lanes{background:linear-gradient(180deg,rgba(138,152,255,0) 72%,rgba(138,152,255,.07) 90%,rgba(138,152,255,.16) 100%),
  url("sprites/constellations.svg") center top/600px 240px repeat-x,
  linear-gradient(180deg,rgba(6,8,18,.82),rgba(14,18,40,.9)),var(--stone-tile) center/384px}
.kb-frame{background:linear-gradient(180deg,rgba(28,32,66,.55),rgba(14,16,40,.75)),var(--stone-tile) center/384px}
#tapKeys{background:linear-gradient(180deg,rgba(28,32,66,.55),rgba(14,16,40,.75)),var(--stone-tile) center/384px}
.hands-strip{background:linear-gradient(180deg,rgba(6,8,16,.62),rgba(6,8,16,.75)),var(--stone-tile) center/384px}
/* vellum staff: a pale wash over the texture and a softer burnt rim keep notes and result colours readable;
   dark ink staff lines 1.25px (VexFlow draws them grey #999 by default) */
#staff{background:linear-gradient(var(--vellum-wash),var(--vellum-wash)),var(--vellum) center/100% 100% no-repeat;
  box-shadow:inset 0 0 10px rgba(90,60,25,.35),inset 0 0 0 1px rgba(255,240,200,.18),0 0 0 3px #0c0e18,0 0 0 4px rgba(138,152,255,.22),0 6px 16px rgba(0,0,0,.5)}
#staff .vf-stave path{stroke:var(--vellum-ink);stroke-width:1.25px}
#staff .vf-stavebarline rect,#staff .vf-clef path{fill:var(--vellum-ink)}
#staff path[stroke="#444"]{stroke:var(--vellum-ink)}             /* ledger lines */
#staff text[fill="#6b7280"]{fill:#4a3820}                         /* small velocity numbers under played notes */
#laneWrap #summary{background:rgba(14,16,28,.95)}

/* ---------- Game mode on a computer screen: the MIDI bar is one slim line ----------
   The message stays visible (in the error colour); if it is too long for the line it ends in "…" and the full
   text is in its tooltip; clicking it shows it in full. The piano-sound note gives way first (it changes after a click). Hints stay in the other modes. */
@media (min-width:561px){
  body.mode-game #midiBar{flex-wrap:nowrap;gap:6px;padding:3px 12px;font-size:12.5px;min-height:0;line-height:1.25}
  body.mode-game #midiBar label{white-space:nowrap}
  body.mode-game #midiBar select{padding:1px 22px 1px 6px;min-height:0;height:24px;font-size:12.5px}
  body.mode-game #midiBar .btn.small{min-height:0;height:24px;padding:0 10px;font-size:11px}
  body.mode-game #midiStatus{flex:0 .2 auto;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:default}
  body.mode-game #midiStatus.full{white-space:normal;overflow:visible}
  body.mode-game #midiBar .piano-status{white-space:nowrap;flex:0 1 auto;min-width:4em;overflow:hidden;text-overflow:ellipsis;margin-left:auto}   /* gives way first: it changes after the first click */
}
@media (min-width:1200px){
  body.mode-game #midiStatus{flex-shrink:0;max-width:calc(100% - 300px)}   /* wide screens: the MIDI message in full, the sound note gives way */
}
/* short computer screens in Game mode: a little less padding so staff, lane, keyboard and hands fit */
@media (max-height:900px) and (min-width:561px){
  body.mode-game #gameBar.console-strip{padding:4px 14px}
  body.mode-game #gameBar .btn{min-height:0;padding-top:5px;padding-bottom:5px}
  body.mode-game .console-row{padding:4px 16px 5px}
  body.mode-game .knob{--size:46px}
  body.mode-game #instruction{font-size:16px;min-height:22px;margin:0 4px 3px}
  body.mode-game header.console{padding-bottom:0;row-gap:8px}
  body.mode-game #gameBar .seg{padding:3px}
  body.mode-game #gameBar .seg button{min-height:0;padding-top:6px;padding-bottom:6px}
  body.mode-game .hands-strip{margin-top:4px}
}
