/* PenrosePulse: night, ice and a colour that warms as the music climbs. --acc is set from script. */
:root {
  --bg: #03050a; --panel: rgba(160, 195, 255, .055); --panel2: rgba(160, 195, 255, .1); --line: rgba(170, 200, 255, .16);
  --fg: #eaf2ff; --dim: #8fa3bd; --dimmer: #5d6f87; --acc: rgb(150, 205, 255); --accrgb: 150, 205, 255; --glow: rgba(150, 205, 255, .5);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
html, body { margin: 0; color: var(--fg); font-family: var(--sans); -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; min-height: 100dvh; overflow-x: hidden; -webkit-tap-highlight-color: transparent; }
#sky { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; display: block; }
[hidden] { display: none !important; }

#app { max-width: 980px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; gap: 12px;
  padding: 12px max(14px, env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }

/* header */
.top { text-align: center; position: relative; padding-top: 6px; }
.labs-link { position: absolute; left: 0; top: 4px; color: var(--dim); font-size: 12px; text-decoration: none; padding: 6px 4px; }
.labs-link:hover, .labs-link:focus-visible { color: var(--acc); }
.logo b, .startbtn .title b { font-weight: 500; color: var(--acc); }
.logo { margin: 0; font-weight: 200; font-size: clamp(22px, 4.8vw, 34px); letter-spacing: .4em; text-indent: .4em; text-shadow: 0 0 28px var(--glow); }
.tag { margin: 4px 0 6px; color: var(--dim); font-size: 12px; letter-spacing: .28em; text-transform: uppercase; }
.chips { position: absolute; right: 0; top: 4px; display: flex; gap: 6px; }
.chip { font: inherit; font-size: 12px; color: var(--dim); background: var(--panel); border: 1px solid var(--line); border-radius: 99px; padding: 6px 12px; cursor: pointer; }
.chip:hover, .chip:focus-visible { color: var(--acc); border-color: var(--acc); outline: none; }
.chip.on { color: #02060d; background: var(--acc); border-color: var(--acc); }
.chip.ghost { cursor: default; color: var(--acc); border-color: var(--acc); animation: pulse 1.4s ease-in-out infinite; }

/* ascent */
.ascent { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 12px 16px 10px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.ahead { display: flex; justify-content: space-between; align-items: baseline; }
.sec { font-weight: 200; font-size: 22px; letter-spacing: .2em; text-transform: uppercase; color: var(--acc); text-shadow: 0 0 18px var(--glow); }
.hint { color: var(--dim); font-size: 12.5px; line-height: 1.5; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 34px; background: transparent; margin: 0; touch-action: pan-y; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: linear-gradient(90deg, rgba(150, 205, 255, .25), rgba(255, 160, 206, .55), rgba(255, 216, 152, .8)); }
input[type=range]::-moz-range-track { height: 3px; border-radius: 3px; background: linear-gradient(90deg, rgba(150, 205, 255, .25), rgba(255, 160, 206, .55), rgba(255, 216, 152, .8)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -9.5px; border-radius: 50%; border: 2px solid #fff; background: #03050a; box-shadow: 0 0 14px var(--glow), 0 0 0 4px rgba(var(--accrgb), .18); }
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #fff; background: #03050a; box-shadow: 0 0 14px var(--glow); }
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 18px var(--glow), 0 0 0 5px rgba(255, 255, 255, .5); }
#ascent { height: 40px; }
#ascent::-webkit-slider-thumb { width: 30px; height: 30px; margin-top: -13.5px; }
#ascent::-moz-range-thumb { width: 26px; height: 26px; }
.arcmap { display: block; width: 100%; height: 44px; margin: 2px 0 6px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; }
.beats { display: flex; gap: 7px; align-items: center; }
.beats i { width: 9px; height: 9px; border-radius: 50%; background: rgba(var(--accrgb), .2); transition: background .1s, box-shadow .1s, transform .1s; }
.beats i.on { background: var(--acc); box-shadow: 0 0 12px var(--glow); transform: scale(1.15); }
.beats i:first-child.on { background: #fff; box-shadow: 0 0 18px 3px var(--glow); transform: scale(1.4); }
.chord { margin: 4px 0 0; min-height: 1.4em; text-align: center; color: var(--dim); font-size: 13px; letter-spacing: .2em; }

.btn { font: inherit; font-size: 13px; color: var(--fg); background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px; min-height: 40px; cursor: pointer; touch-action: manipulation; transition: all .15s; }
.btn:hover:not(:disabled) { border-color: var(--acc); color: var(--acc); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: default; }
.btn:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
.btn.sm { padding: 6px 12px; min-height: 36px; }
.btn.big { font-size: 15px; font-weight: 600; letter-spacing: .12em; padding: 10px 26px; min-width: 150px; border-color: rgba(var(--accrgb), .6); }
.btn.big[data-on=true] { color: #02060d; background: var(--acc); border-color: var(--acc); box-shadow: 0 0 22px var(--glow); }
.btn.toggle[aria-pressed=true] { color: #02060d; background: var(--acc); border-color: var(--acc); }
.sel { display: inline-flex; align-items: center; gap: 6px; color: var(--dim); font-size: 13px; }
select { font: inherit; font-size: 13px; color: var(--fg); background: #0a1019; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-height: 36px; }
select:focus-visible { outline: 2px solid var(--acc); }

/* instruments */
.inst { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.inst button { font: inherit; font-size: 13.5px; color: var(--dim); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 9px 20px; min-height: 40px; cursor: pointer; touch-action: manipulation; transition: all .2s; letter-spacing: .06em; }
.inst button[aria-checked=true] { color: #02060d; background: var(--acc); border-color: var(--acc); box-shadow: 0 0 18px var(--glow); font-weight: 600; }
.inst button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* keyboard */
.board { display: flex; flex-direction: column; gap: 8px; flex: 1 1 auto; min-height: 220px; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; }
.grp { display: inline-flex; align-items: center; gap: 6px; }
.range-label { min-width: 74px; text-align: center; color: var(--dim); font-size: 13px; font-variant-numeric: tabular-nums; }
.keys { position: relative; flex: 1 1 auto; min-height: 180px; height: clamp(180px, 30vh, 280px); border-radius: 14px; padding: 8px 8px 10px;
  background: linear-gradient(180deg, #0a1019, #05080e); border: 1px solid var(--line); box-shadow: 0 10px 40px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(200, 220, 255, .08);
  touch-action: none; user-select: none; -webkit-user-select: none; }
.keys-inner { position: relative; width: 100%; height: 100%; }
.key { position: absolute; top: 0; touch-action: none; -webkit-user-select: none; user-select: none; transition: box-shadow .12s, filter .12s, transform .06s; }
.key.white { height: 100%; background: linear-gradient(180deg, #f4f8ff 0%, #d4e0f4 78%, #b9c9e4 100%); border: 1px solid #6f84a6; border-radius: 0 0 8px 8px;
  box-shadow: inset 0 -6px 0 rgba(40, 60, 100, .16); z-index: 1; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 8px; }
.key.black { height: 62%; background: linear-gradient(180deg, #1c2638, #0a0f1a 85%, #05080e); border: 1px solid #02040a; border-radius: 0 0 6px 6px; z-index: 2;
  box-shadow: 0 3px 6px rgba(0, 0, 0, .55), inset 0 -4px 0 rgba(170, 200, 255, .08); }
.key .lab { font-size: 11px; color: #5a6e8f; pointer-events: none; }
.key.root .lab { color: #2f6fd0; font-weight: 700; }
.key.root::after { content: ""; position: absolute; bottom: 24px; left: 50%; width: 7px; height: 7px; margin-left: -3.5px; border-radius: 50%; background: var(--acc); opacity: .95; pointer-events: none; }
.key.off { filter: brightness(.55) saturate(.7); }
.key.down { transform: translateY(2px); }
.key.white.down, .key.white.ghost { background: linear-gradient(180deg, #fff, rgba(var(--accrgb), 1) 70%, rgba(var(--accrgb), .7)); box-shadow: 0 0 26px var(--glow), inset 0 -4px 0 rgba(20, 40, 90, .25); }
.key.black.down, .key.black.ghost { background: linear-gradient(180deg, rgba(var(--accrgb), .95), rgba(var(--accrgb), .45) 90%); box-shadow: 0 0 22px var(--glow); }
.key.ghost { transition: box-shadow 1s ease-out, background 1s ease-out; }
.keys.guide .key.white.tone { background: linear-gradient(180deg, #fff, #cfe3ff 78%, #a9c7f2 100%); box-shadow: 0 0 20px var(--glow), inset 0 -6px 0 rgba(30, 80, 160, .2); animation: tonepulse 2.4s ease-in-out infinite; }
.keys.guide .key.black.tone { background: linear-gradient(180deg, #3a5890, #1c2f55 90%); box-shadow: 0 0 16px var(--glow); animation: tonepulse 2.4s ease-in-out infinite; }
.keys.guide .key.white:not(.tone) { filter: brightness(.6) saturate(.7); }
.keys.guide .key.black:not(.tone) { filter: brightness(.7); }
.keys.guide .key.white.down, .keys.guide .key.black.down { filter: none; animation: none; }
@keyframes tonepulse { 50% { filter: brightness(1.15); } }

.pads { display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(2, 1fr); gap: 10px; flex: 1 1 auto; min-height: 180px; height: clamp(180px, 30vh, 280px); touch-action: none; user-select: none; -webkit-user-select: none; }
.pad { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 16px; border: 1px solid var(--line); cursor: pointer; touch-action: none;
  background: linear-gradient(160deg, rgba(var(--accrgb), .14), rgba(var(--accrgb), .04)); color: var(--fg); transition: box-shadow .1s, background .1s, transform .06s; }
.pad .n { font-weight: 200; font-size: clamp(20px, 4.4vw, 30px); letter-spacing: .08em; }
.pad .r { font-size: 11px; color: var(--dim); letter-spacing: .14em; text-transform: uppercase; }
.pad.root { border-color: rgba(var(--accrgb), .6); background: linear-gradient(160deg, rgba(var(--accrgb), .3), rgba(var(--accrgb), .08)); }
.pad.down { transform: scale(.97); background: linear-gradient(160deg, #fff, var(--acc)); color: #02060d; box-shadow: 0 0 30px var(--glow); }
.pad.down .r { color: #1a3358; }
.coach { margin: 0; min-height: 2.6em; text-align: center; color: var(--dim); font-size: 13px; line-height: 1.5; padding: 0 6px; }
.coach b { color: var(--acc); font-weight: 600; }

.howto, .tone { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 0 16px; }
.howto summary, .tone summary { cursor: pointer; padding: 12px 0; color: var(--dim); font-size: 14px; list-style: none; letter-spacing: .06em; }
.howto summary { color: var(--fg); font-weight: 600; }
.howto summary::-webkit-details-marker, .tone summary::-webkit-details-marker { display: none; }
.howto summary::before, .tone summary::before { content: "▸ "; color: var(--acc); }
.howto[open] summary::before, .tone[open] summary::before { content: "▾ "; }
.howto ol { margin: 0 0 14px; padding-left: 20px; color: var(--dim); font-size: 13.5px; line-height: 1.6; }
.howto li { margin-bottom: 8px; } .howto b { color: var(--fg); }
.tone .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 6px 22px; padding-bottom: 14px; }
.tone label { display: flex; flex-direction: column; gap: 2px; color: var(--dim); font-size: 13px; }
.tone label.sel { flex-direction: row; justify-content: space-between; align-items: center; }
.tone output { color: var(--acc); margin-left: 6px; }
.foot { text-align: center; padding-top: 4px; } .foot p { margin: 6px 0 0; }
kbd { font: inherit; font-size: 11px; padding: 1px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel2); color: var(--fg); }

/* start */
.start { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center;
  background: radial-gradient(ellipse at 50% 50%, rgba(3, 5, 10, .25), rgba(3, 5, 10, .82) 70%); transition: opacity .8s ease; }
.start.gone { opacity: 0; pointer-events: none; }
.startbtn { display: flex; flex-direction: column; align-items: center; gap: 10px; background: none; border: 0; color: var(--fg); cursor: pointer; font: inherit; padding: 24px 28px; }
.startbtn:focus-visible { outline: 2px solid var(--acc); border-radius: 24px; }
.startbtn .title { font-weight: 200; font-size: clamp(34px, 9vw, 60px); letter-spacing: .5em; text-indent: .5em; text-shadow: 0 0 40px var(--glow); }
.startbtn .sub { color: var(--acc); letter-spacing: .4em; text-transform: uppercase; font-size: 12px; animation: pulse 2.4s ease-in-out infinite; }
#startErr { color: #ff9fb0; min-height: 1.2em; max-width: 34em; }
.small { font-size: 12px; opacity: .8; margin: 0; }
@keyframes pulse { 50% { opacity: .55; } }

@media (max-width: 640px), (max-height: 560px) {
  #app { gap: 8px; padding-top: 8px; }
  .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0; text-align: left; }
  .labs-link { position: static; font-size: 11px; padding: 4px 0; order: 3; }
  .logo { font-size: 20px; letter-spacing: .35em; text-indent: 0; order: 1; }
  .tag { display: none; }
  .chips { position: static; order: 2; margin-left: auto; } .chip { padding: 5px 10px; }
  .ascent { padding: 8px 12px 6px; border-radius: 14px; }
  .sec { font-size: 18px; }
  #ascent { height: 36px; } .arcmap { height: 34px; }
  .btn.big { min-width: 0; padding: 8px 18px; }
  .chord { margin-top: 0; font-size: 12px; }
  .inst { flex-wrap: nowrap; gap: 5px; } .inst button { flex: 1 1 auto; padding: 7px 6px; font-size: 12.5px; min-height: 38px; }
  .tools { gap: 6px; } .range-label { min-width: 62px; font-size: 12px; }
  .board { min-height: 0; gap: 6px; }
  .keys, .pads { height: clamp(150px, 28vh, 200px); min-height: 150px; } .pads { gap: 7px; }
  .key .lab { font-size: 10px; } .pad .r { font-size: 10px; }
  .coach { font-size: 12px; min-height: 2.4em; }
}
@media (max-height: 460px) and (orientation: landscape) {
  #app { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); align-items: start; column-gap: 12px; }
  .top, .ascent, .inst { grid-column: 1; }
  .board { grid-column: 2; grid-row: 1 / span 3; height: 100%; }
  .howto, .tone, .foot { grid-column: 1 / -1; }
  .keys, .pads { height: clamp(130px, 60vh, 220px); } .hint.small { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; } }
