/* 钢琴垫 · 样式（.g-piano 前缀） */

.g-piano {
  gap: 10px;
  padding-bottom: calc(12px + var(--safe-b));
}

/* ---------------- 顶部模式 ---------------- */

.g-piano .p-head { min-height: 40px; }
.g-piano .p-head .grow { width: 100%; }
.g-piano .p-head .seg { width: 100%; padding: 4px; }
.g-piano .p-head .seg-item { min-height: 40px; font-size: 12.5px; }

/* ---------------- 练习条 ---------------- */

.g-piano .p-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
}

.g-piano .p-songs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.g-piano .p-chip {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 0 6px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--dim);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  touch-action: manipulation;
  transition: color 0.16s ease, border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.g-piano .p-chip.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(180deg, var(--accent), var(--accent2));
  box-shadow: 0 5px 14px -6px var(--accent);
}

.g-piano .p-chip.learned:not(.active) { color: var(--ok); }

.g-piano .p-chip.learned::after {
  content: "✓";
  font-size: 10px;
  margin-left: 3px;
  color: var(--ok);
}

.g-piano .p-chip.active.learned::after { color: rgba(255, 255, 255, 0.85); }

.g-piano .p-acts { display: flex; align-items: center; gap: 6px; flex: none; }

.g-piano .p-act {
  min-height: 40px;
  padding: 0 10px;
  border-radius: 12px;
  font-size: 11.5px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--dim);
  touch-action: manipulation;
}

.g-piano .p-act.on {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

/* ---------------- 音块区 ---------------- */

.g-piano .p-pad-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
}

.g-piano .p-pad {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 6px;
  min-height: 0;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.g-piano .p-key {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  padding: 10px 4px 12px;
  border-radius: 14px;
  border: 1px solid hsla(var(--h), 90%, 72%, 0.4);
  background:
    radial-gradient(120% 60% at 30% 8%, rgba(255, 255, 255, 0.5), transparent 55%),
    linear-gradient(170deg, hsla(var(--h), 96%, 80%, 0.97), hsla(var(--h), 84%, 54%, 0.94));
  color: var(--fg, #3a2408);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 -10px 18px -12px rgba(0, 0, 0, 0.5),
    0 8px 18px -12px rgba(0, 0, 0, 0.9);
  overflow: hidden;
  touch-action: manipulation;
  transition: transform 0.11s ease, box-shadow 0.11s ease, filter 0.11s ease;
  -webkit-tap-highlight-color: transparent;
  will-change: transform;
}

.g-piano .p-key-deg {
  position: absolute;
  top: 9px;
  left: 10px;
  font-size: 10px;
  line-height: 1;
  font-weight: 800;
  opacity: 0.5;
}

.g-piano .p-key-note {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  opacity: 0.88;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);
}

.g-piano .p-key.press {
  transform: scale(0.962);
  filter: brightness(1.16);
  box-shadow:
    0 0 24px hsla(var(--h), 100%, 66%, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    inset 0 -6px 12px -8px rgba(0, 0, 0, 0.45);
}

.g-piano .p-key.ok {
  box-shadow:
    0 0 26px rgba(62, 207, 142, 0.65),
    inset 0 0 0 2px rgba(62, 207, 142, 0.85);
}

.g-piano .p-key.bad {
  box-shadow:
    0 0 24px rgba(255, 92, 108, 0.6),
    inset 0 0 0 2px rgba(255, 92, 108, 0.85);
}

.g-piano .p-key.hint {
  z-index: 1;
  animation: pHint 0.9s ease-in-out infinite;
}

@keyframes pHint {
  0%, 100% {
    box-shadow:
      inset 0 0 0 2px rgba(255, 255, 255, 0.55),
      0 0 18px hsla(var(--h), 100%, 70%, 0.55);
  }
  50% {
    box-shadow:
      inset 0 0 0 3px #fff,
      0 0 34px hsla(var(--h), 100%, 76%, 0.95);
  }
}

.g-piano .p-ripple {
  position: absolute;
  left: 50%;
  top: 58%;
  width: 150px;
  height: 150px;
  margin: -75px 0 0 -75px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.7);
  pointer-events: none;
  animation: pRipple 0.55s ease-out forwards;
}

.g-piano .p-ripple.demo { border-color: rgba(255, 255, 255, 0.45); }

@keyframes pRipple {
  from { transform: scale(0.22); opacity: 0.75; }
  to { transform: scale(1.65); opacity: 0; }
}

/* ---------------- 底部状态 ---------------- */

.g-piano .p-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 2px;
}

.g-piano .p-foot-main { flex: 1; min-width: 0; }

.g-piano .p-foot-text {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.g-piano .p-foot-count {
  flex: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.g-piano .p-progress { margin-top: 5px; height: 4px; }

/* ---------------- 结算层 ---------------- */

.g-piano .p-result {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  border-radius: 14px;
  background: rgba(8, 11, 18, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s;
}

.g-piano .p-result.show { opacity: 1; visibility: visible; }

.g-piano .p-result-card {
  width: 100%;
  max-width: 280px;
  padding: 18px 16px 16px;
  text-align: center;
  border-radius: 18px;
  border: 1px solid var(--line-2);
  background: linear-gradient(180deg, #161c2b, #111623);
  box-shadow: 0 24px 60px -22px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.g-piano .p-result-badge {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--dim);
  margin-bottom: 6px;
}

.g-piano .p-result-title { font-size: 19px; font-weight: 800; letter-spacing: 0.01em; }
.g-piano .p-result-sub { margin-top: 4px; font-size: 11.5px; color: var(--dim); }

.g-piano .p-result-stats { display: flex; gap: 8px; margin: 14px 0; }

.g-piano .p-result-stat {
  flex: 1;
  min-width: 0;
  padding: 8px 4px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.g-piano .p-result-stat span {
  display: block;
  font-size: 10px;
  color: var(--faint);
  margin-bottom: 2px;
}

.g-piano .p-result-stat b {
  display: block;
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.g-piano .p-result .btn { min-height: 44px; }

/* ---------------- 窄屏 ---------------- */

@media (max-width: 359px) {
  .g-piano .p-chip { font-size: 11px; }
  .g-piano .p-act { padding: 0 8px; font-size: 11px; }
  .g-piano .p-key-note { font-size: 12px; }
  .g-piano .p-foot-text { font-size: 11px; }
}
