/* =====================================================================
   urPiano — instrument surfaces (xylophone, kalimba, drums, guitar)
   ===================================================================== */

.surface {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  direction: ltr;
}
.ripple {
  position: absolute;
  z-index: 8;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  border: 2px solid var(--hl);
  pointer-events: none;
  animation: rip 0.55s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}
@keyframes rip { from { transform: scale(1); opacity: 0.9; } to { transform: scale(7); opacity: 0; } }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

/* ---------------------------------------------------------------- xylophone */
.xylo-frame { position: absolute; inset: 0; width: 100%; height: 100%; }
.xylo-rail { stroke: #7a5434; stroke-linecap: round; }
:root[data-theme="dark"] .xylo-rail { stroke: #4b321d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .xylo-rail { stroke: #4b321d; } }
.xylo-bars { position: absolute; inset: 0; }
.xbar {
  position: absolute;
  border-radius: calc(var(--bw) * 0.16);
  box-shadow: 0 7px 16px rgba(0, 0, 0, 0.3), 0 2px 3px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.08s ease, filter 0.08s ease, box-shadow 0.08s ease;
  cursor: pointer;
}
.xbar--rainbow {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0) 28%, rgba(0, 0, 0, 0) 68%, rgba(0, 0, 0, 0.2)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(0, 0, 0, 0.12)),
    var(--c);
}
.xbar--rainbow.is-portrait {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0) 28%, rgba(0, 0, 0, 0) 68%, rgba(0, 0, 0, 0.2)),
    linear-gradient(90deg, rgba(255, 255, 255, 0.16), rgba(0, 0, 0, 0.12)),
    var(--c);
}
.xbar--wood {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0) 30%, rgba(0, 0, 0, 0) 70%, rgba(0, 0, 0, 0.28)),
    repeating-linear-gradient(180deg, rgba(0, 0, 0, 0.07) 0 2px, rgba(0, 0, 0, 0) 2px 6px, rgba(255, 255, 255, 0.04) 6px 7px, rgba(0, 0, 0, 0) 7px 11px),
    linear-gradient(180deg, #92502d, #6c3519);
}
.xbar--wood.is-portrait {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0) 30%, rgba(0, 0, 0, 0) 70%, rgba(0, 0, 0, 0.28)),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.07) 0 2px, rgba(0, 0, 0, 0) 2px 6px, rgba(255, 255, 255, 0.04) 6px 7px, rgba(0, 0, 0, 0) 7px 11px),
    linear-gradient(90deg, #92502d, #6c3519);
}
.xbar--wood.xbar--sharp { filter: brightness(0.82); }
.xnail {
  position: absolute;
  left: 50%;
  width: max(6px, calc(var(--bw) * 0.14));
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, #c7c9ce 45%, #6d7078 100%);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
  transform: translate(-50%, -50%);
}
.xnail:first-child { top: 22%; }
.xnail:nth-child(2) { top: 78%; }
.is-portrait .xnail { top: 50%; }
.is-portrait .xnail:first-child { left: 22%; }
.is-portrait .xnail:nth-child(2) { left: 78%; }
.xlbl {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.32);
  font-family: var(--font-round);
  line-height: 1;
  pointer-events: none;
}
.xlbl b { font-size: clamp(11px, calc(var(--bw) * 0.34), 24px); font-weight: 700; }
.xlbl i:empty, .xlbl b:empty { display: none; }
.xlbl i {
  font-style: normal;
  font-family: var(--font);
  font-size: clamp(9px, calc(var(--bw) * 0.25), 14px);
  font-weight: 600;
  padding: 0.2em 0.45em;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.2);
  text-shadow: none;
}
.xbar--wood .xlbl { color: #f8e9d6; }
.xbar.is-down {
  transform: scale(0.985);
  filter: brightness(1.12) saturate(1.08);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3), 0 0 0 3px color-mix(in srgb, var(--hl) 65%, transparent);
}
.xbar.is-hit::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(255, 255, 255, 0.5);
  pointer-events: none;
  animation: flash 0.38s ease-out forwards;
}

/* ---------------------------------------------------------------- kalimba */
.kal-body {
  position: absolute;
  container-type: size;
  border-radius: 7% / 6%;
  background:
    radial-gradient(120% 60% at 50% 105%, rgba(0, 0, 0, 0.28), rgba(0, 0, 0, 0) 60%),
    repeating-linear-gradient(92deg, rgba(60, 28, 6, 0.08) 0 3px, rgba(0, 0, 0, 0) 3px 9px, rgba(255, 220, 170, 0.06) 9px 11px, rgba(0, 0, 0, 0) 11px 17px),
    linear-gradient(180deg, #c78a4f 0%, #b07238 45%, #8d5626 100%);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.35), 0 4px 10px rgba(0, 0, 0, 0.25), inset 0 2px 0 rgba(255, 230, 190, 0.35), inset 0 -3px 0 rgba(0, 0, 0, 0.18);
}
.kal-hole {
  position: absolute;
  left: 50%;
  bottom: 5%;
  width: min(13%, 17cqh);
  aspect-ratio: 1;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #1a0c03, #2b1606 70%, #5a3416 100%);
  box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.7), 0 1px 0 rgba(255, 230, 190, 0.3);
}
.kal-bridge {
  position: absolute;
  left: 5%;
  right: 5%;
  top: 19%;
  height: max(8px, 2.6%);
  border-radius: 6px;
  z-index: 3;
  background: linear-gradient(180deg, #4a4f57, #1e2125 55%, #3b3f45);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.tine {
  position: absolute;
  z-index: 2;
  border-radius: 2px 2px calc(var(--tw) * 0.5) calc(var(--tw) * 0.5);
  background:
    linear-gradient(90deg, #7f868f 0%, #dfe3e8 30%, #fbfcfd 46%, #c4c9d0 62%, #868d96 100%);
  box-shadow: 0 6px 8px rgba(0, 0, 0, 0.35), 0 1px 1px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transform-origin: 50% 0;
}
.tine::after {
  content: "";
  position: absolute;
  left: 15%;
  right: 15%;
  bottom: 4%;
  height: calc(var(--tw) * 0.9);
  border-radius: 50%;
  background: var(--hl);
  opacity: 0;
  filter: blur(4px);
  transition: opacity 0.4s;
}
.tine.is-down::after { opacity: 0.9; transition-duration: 0.05s; }
.tine.is-pluck { animation: tine 0.7s cubic-bezier(0.2, 0.6, 0.3, 1); }
@keyframes tine {
  0% { transform: rotate(0deg); }
  10% { transform: rotate(0.9deg); }
  22% { transform: rotate(-0.7deg); }
  36% { transform: rotate(0.45deg); }
  52% { transform: rotate(-0.25deg); }
  70% { transform: rotate(0.1deg); }
  100% { transform: rotate(0); }
}
.tine-lbl {
  position: absolute;
  left: 50%;
  bottom: calc(var(--tw) * 0.55);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--font-round);
  line-height: 1;
  pointer-events: none;
}
.tine-lbl b {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: clamp(10px, calc(var(--tw) * 0.58), 20px);
  font-weight: 700;
  color: #2d3238;
}
.tine-lbl b:empty, .tine-lbl i:empty { display: none; }
.tine-lbl .dots { font-size: 0.8em; letter-spacing: -0.12em; height: 0.75em; line-height: 0.6; color: #3c4248; }
.tine-lbl i {
  font-style: normal;
  font-family: var(--font);
  font-size: clamp(9px, calc(var(--tw) * 0.48), 14px);
  font-weight: 600;
  color: #2d3238;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 4px;
  padding: 0.15em 0.3em;
}
@media (prefers-reduced-motion: reduce) { .tine.is-pluck { animation: none; } }

/* ---------------------------------------------------------------- drums */
.surface--drums { background: radial-gradient(90% 80% at 50% 30%, var(--stage-1), var(--stage-2) 60%, var(--stage-3)); }
.kit { position: absolute; inset: 2% 2% 1%; width: 96%; height: 97%; }
.piece { cursor: pointer; transform-box: fill-box; transform-origin: center; }
.piece .flash { fill: #fff; opacity: 0; pointer-events: none; }
.piece--cymbal .flash, .piece--hihat .flash { fill: #fff6d8; }
.piece.is-hit .flash { animation: dflash 0.32s ease-out; }
@keyframes dflash { 0% { opacity: 0.55; } 100% { opacity: 0; } }
.piece--drum.is-hit, .piece--kick.is-hit { animation: dpress 0.18s ease-out; }
@keyframes dpress { 0% { transform: scale(0.965); } 100% { transform: scale(1); } }
.piece .wobble { transform-box: fill-box; transform-origin: center; }
.piece.is-hit .wobble { animation: wobble 0.9s cubic-bezier(0.2, 0.6, 0.3, 1); }
@keyframes wobble {
  0% { transform: scale(0.97) rotate(0); }
  12% { transform: scale(1.01) rotate(4deg); }
  30% { transform: rotate(-2.6deg); }
  50% { transform: rotate(1.4deg); }
  72% { transform: rotate(-0.6deg); }
  100% { transform: rotate(0); }
}
.plbl { pointer-events: none; font-family: var(--font); }
.plbl-name { font-weight: 600; fill: rgba(255, 255, 255, 0.8); letter-spacing: -0.01em; }
.plbl-key { font-weight: 700; fill: rgba(255, 255, 255, 0.55); font-family: var(--font-round); }
.plbl--dark .plbl-name { fill: rgba(40, 30, 20, 0.62); }
.plbl--dark .plbl-key { fill: rgba(40, 30, 20, 0.4); }
.piece--cymbal .plbl-name, .piece--hihat .plbl-name { fill: rgba(60, 38, 8, 0.78); }
.piece--cymbal .plbl-key, .piece--hihat .plbl-key { fill: rgba(60, 38, 8, 0.55); }
.kick-logo { font-family: var(--font-serif); fill: #c9a15b; letter-spacing: 0.04em; }
.no-labels .plbl, .no-labels .pad-name, .no-labels .pad-key { display: none; }
html.is-touch .plbl-key, html.is-touch .pad-key { display: none; }

.pads {
  position: absolute;
  inset: max(12px, 2.5%);
  display: grid;
  gap: max(8px, 1.6%);
}
.pad {
  position: relative;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 12px 14px;
  cursor: pointer;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(0, 0, 0, 0.18)),
    color-mix(in srgb, var(--pad) 22%, #18181b);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pad) 40%, transparent), inset 0 2px 0 rgba(255, 255, 255, 0.08), 0 6px 14px rgba(0, 0, 0, 0.28);
  transition: transform 0.06s, background 0.25s;
}
.pad--gold { --pad: #d7ab52; }
.pad--teal { --pad: #2fb5a5; }
.pad--amber { --pad: #ee8a3a; }
.pad--rose { --pad: #e75a7c; }
.pad--red { --pad: #e5484d; }
.pad-name { color: #f5f5f7; font-weight: 600; font-size: clamp(12px, 2.2cqmin, 17px); letter-spacing: -0.01em; }
.pad-key { position: absolute; top: 10px; right: 12px; font-family: var(--font-round); font-weight: 700; font-size: 13px; color: color-mix(in srgb, var(--pad) 80%, #fff); opacity: 0.85; }
.pad.is-hit { animation: padhit 0.35s ease-out; }
@keyframes padhit {
  0% { transform: scale(0.97); background: color-mix(in srgb, var(--pad) 80%, #fff); box-shadow: 0 0 30px color-mix(in srgb, var(--pad) 70%, transparent); }
  100% { transform: scale(1); }
}
.surface--drums { container-type: size; }

/* ---------------------------------------------------------------- guitar */
.gtr-chords {
  position: absolute;
  z-index: 6;
  left: 0;
  right: 0;
  top: 0;
  display: flex;
  gap: 6px;
  padding: 8px max(12px, env(safe-area-inset-left));
  overflow-x: auto;
  scrollbar-width: none;
  touch-action: pan-x;
}
.gtr-chords::-webkit-scrollbar { display: none; }
.gtr-chord {
  position: relative;
  flex: none;
  min-width: 54px;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 12px;
  background: var(--fill);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
}
.gtr-chord b { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.gtr-chord i { position: absolute; top: 3px; right: 6px; font-style: normal; font-size: 9px; font-weight: 700; color: var(--ink-3); }
html.is-touch .gtr-chord i { display: none; }
.gtr-chord:active { transform: scale(0.96); }
.gtr-chord.is-on {
  background: linear-gradient(180deg, var(--brass-hi), var(--brass) 60%, #b28842);
  color: #2b1e07;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 2px 6px rgba(120, 80, 20, 0.25);
}
.gtr-chord.is-on i { color: #5b4312; }

.gtr-neck { position: absolute; z-index: 2; }
.gtr-board {
  position: absolute;
  border-radius: 3px;
  background:
    repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.025) 0 1px, rgba(0, 0, 0, 0) 1px 4px, rgba(0, 0, 0, 0.06) 4px 5px, rgba(0, 0, 0, 0) 5px 9px),
    linear-gradient(180deg, #3d2316, #2a170d 50%, #3a2114);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.06), inset 0 -1px 0 rgba(0, 0, 0, 0.4);
}
.is-portrait .gtr-board {
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 1px, rgba(0, 0, 0, 0) 1px 4px, rgba(0, 0, 0, 0.06) 4px 5px, rgba(0, 0, 0, 0) 5px 9px),
    linear-gradient(90deg, #3d2316, #2a170d 50%, #3a2114);
}
.gtr-nut { position: absolute; border-radius: 2px; background: linear-gradient(90deg, #d9d1bf, #f6f1e5 50%, #cfc6b3); box-shadow: 0 0 4px rgba(0, 0, 0, 0.5); }
.is-portrait .gtr-nut { background: linear-gradient(180deg, #d9d1bf, #f6f1e5 50%, #cfc6b3); }
.gtr-fret { position: absolute; background: linear-gradient(90deg, #7e848c, #f2f4f6 50%, #8a9098); box-shadow: 1px 0 2px rgba(0, 0, 0, 0.6); }
.is-portrait .gtr-fret { background: linear-gradient(180deg, #7e848c, #f2f4f6 50%, #8a9098); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }
.gtr-inlay {
  position: absolute;
  width: clamp(8px, calc(var(--fw) * 0.2), 15px);
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 30%, #ffffff, #e7e1d3 45%, #bfc9cc 75%, #d9cfe0);
  box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.3);
  opacity: 0.85;
}
.gtr-num { position: absolute; z-index: 4; transform: translate(-50%, -50%); font-size: 11px; font-weight: 600; color: var(--ink-3); font-variant-numeric: tabular-nums; pointer-events: none; }
.is-portrait .gtr-num { color: rgba(255, 240, 220, 0.4); }
.gtr-cell { position: absolute; z-index: 4; display: grid; place-items: center; cursor: pointer; }
.gtr-cell::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(14px, calc(var(--fw) * 0.42), 30px);
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.4);
  background: var(--hl);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
}
.gtr-cell.is-down::after { opacity: 0.85; transform: translate(-50%, -50%) scale(1); transition-duration: 0.05s; }
.gtr-note { position: relative; z-index: 1; font-family: var(--font-round); font-size: clamp(9px, calc(var(--fw) * 0.17), 12px); font-weight: 700; color: rgba(255, 244, 225, 0.72); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); pointer-events: none; }
.gtr-string {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(180deg, #8d939b, #f8f9fa 45%, #7d838b);
  box-shadow: 0 2px 2px rgba(0, 0, 0, 0.45);
  border-radius: 2px;
}
.is-portrait .gtr-string { background: linear-gradient(90deg, #8d939b, #f8f9fa 45%, #7d838b); }
.gtr-string.is-wound {
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.28) 0 1px, rgba(0, 0, 0, 0) 1px 2.4px),
    linear-gradient(180deg, #8c6a3c, #f1d6a3 45%, #7d5b2e);
}
.is-portrait .gtr-string.is-wound {
  background:
    repeating-linear-gradient(180deg, rgba(0, 0, 0, 0.28) 0 1px, rgba(0, 0, 0, 0) 1px 2.4px),
    linear-gradient(90deg, #8c6a3c, #f1d6a3 45%, #7d5b2e);
}
.app--guitar[data-sound="electric"] .gtr-string.is-wound { filter: grayscale(1) brightness(1.1); }
.gtr-string.is-ring { animation: ring 0.75s ease-out; }
@keyframes ring {
  0% { box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--hl) 80%, transparent), 0 0 12px color-mix(in srgb, var(--hl) 70%, transparent); filter: blur(0.5px); }
  100% { box-shadow: 0 2px 2px rgba(0, 0, 0, 0.45); filter: none; }
}
.gtr-dot {
  position: absolute;
  z-index: 5;
  width: clamp(18px, calc(var(--fw) * 0.46), 32px);
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  font-family: var(--font-round);
  font-weight: 700;
  font-size: clamp(10px, calc(var(--fw) * 0.22), 15px);
  color: #2b1e07;
  background: radial-gradient(circle at 35% 30%, #f6e3b4, var(--brass) 60%, #9b7433);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  pointer-events: none;
}
.gtr-mark { position: absolute; z-index: 5; transform: translate(-50%, -50%); font-size: 15px; font-weight: 700; color: var(--ink-2); pointer-events: none; }
.gtr-mark.is-mute { color: var(--ink-3); }

.gtr-body {
  position: absolute;
  z-index: 1;
  overflow: hidden;
  border-radius: 22px;
  cursor: grab;
  background:
    repeating-linear-gradient(90deg, rgba(120, 70, 20, 0.06) 0 2px, rgba(0, 0, 0, 0) 2px 7px),
    radial-gradient(120% 120% at 30% 20%, #f0d39c, #ddb06a 55%, #c48f45);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35), inset 0 0 0 3px rgba(60, 30, 5, 0.25), inset 0 0 0 7px rgba(255, 240, 210, 0.18);
}
.is-portrait .gtr-body { background: repeating-linear-gradient(180deg, rgba(120, 70, 20, 0.06) 0 2px, rgba(0, 0, 0, 0) 2px 7px), radial-gradient(120% 120% at 30% 20%, #f0d39c, #ddb06a 55%, #c48f45); }
.gtr-hole {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(72%, 72cqh);
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, #120a04 0 55%, #2b1808 56% 58%, #7a4f22 59% 61%, #3b2410 62% 64%, #d8b070 65% 67%, rgba(0, 0, 0, 0) 68%);
}
.gtr-body { container-type: size; }
.gtr-strum-hint {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  z-index: 4;
  font-size: 12px;
  font-weight: 500;
  color: #3b2410;
  background: rgba(255, 245, 225, 0.75);
  padding: 4px 10px;
  border-radius: 10px;
  white-space: nowrap;
  transition: opacity 0.5s;
  pointer-events: none;
}
.gtr-strum-hint.is-gone { opacity: 0; }
