/* 听音记忆 Tone Memory · 独立样式（选择器统一前缀 .g-tonememory） */

.g-tonememory {
  justify-content: flex-start;
  gap: 10px;
}

.g-tonememory .btn:focus { outline: none; }
.g-tonememory .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------- 数据 ---------------- */

.g-tonememory .stats { gap: 8px; }
.g-tonememory .stat { padding: 7px 6px; }
.g-tonememory .stat-v { font-size: 16.5px; }
.g-tonememory .tm-lives { color: #ff7ab8; letter-spacing: 0.08em; }
.g-tonememory .tm-lives.low { color: #ff5c6c; }

/* ---------------- 舞台 ---------------- */

.g-tonememory .tm-stagewrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.g-tonememory .tm-stage {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
}

.g-tonememory .tm-board {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: 6px 0 4px;
  transition: filter 0.24s ease;
}

/* 整体播放提示：波形 + 呼吸（不暴露具体音块） */
.g-tonememory .tm-wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 30px;
  opacity: 0.35;
  transition: opacity 0.22s ease;
}

.g-tonememory .tm-wave span {
  display: block;
  width: 5px;
  height: 8px;
  border-radius: 3px;
  background: linear-gradient(180deg, #d9c8ff, #7c4ddb);
  box-shadow: 0 0 6px rgba(183, 140, 255, 0.4);
  transform-origin: center;
}

.g-tonememory .tm-board.playing .tm-wave { opacity: 1; }

.g-tonememory .tm-board.playing .tm-wave span {
  animation: tmWave 0.9s ease-in-out infinite;
}

.g-tonememory .tm-wave span:nth-child(1) { animation-delay: 0s; }
.g-tonememory .tm-wave span:nth-child(2) { animation-delay: 0.09s; }
.g-tonememory .tm-wave span:nth-child(3) { animation-delay: 0.18s; }
.g-tonememory .tm-wave span:nth-child(4) { animation-delay: 0.27s; }
.g-tonememory .tm-wave span:nth-child(5) { animation-delay: 0.36s; }
.g-tonememory .tm-wave span:nth-child(6) { animation-delay: 0.27s; }
.g-tonememory .tm-wave span:nth-child(7) { animation-delay: 0.18s; }
.g-tonememory .tm-wave span:nth-child(8) { animation-delay: 0.09s; }
.g-tonememory .tm-wave span:nth-child(9) { animation-delay: 0s; }

@keyframes tmWave {
  0%, 100% { height: 8px; opacity: 0.55; }
  50% { height: 26px; opacity: 1; }
}

.g-tonememory .tm-blocks {
  display: flex;
  align-items: stretch;
  gap: 8px;
  width: 100%;
  transition: box-shadow 0.3s ease;
}

.g-tonememory .tm-board.playing .tm-blocks {
  box-shadow: 0 0 0 1px rgba(183, 140, 255, 0.22), 0 0 34px rgba(183, 140, 255, 0.16);
  border-radius: 20px;
}

.g-tonememory .tm-block {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  height: clamp(190px, 44dvh, 330px);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background:
    radial-gradient(120% 90% at 30% 16%, rgba(255, 255, 255, 0.4), transparent 52%),
    linear-gradient(180deg, var(--c1), var(--c2));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.32),
    inset 0 -14px 26px rgba(0, 0, 0, 0.16),
    0 14px 28px -20px rgba(0, 0, 0, 0.9);
  transition: transform 0.1s ease, filter 0.12s ease, box-shadow 0.12s ease;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  overflow: hidden;
  cursor: pointer;
}

/* 柔和竖向高光，不显示任何文字 */
.g-tonememory .tm-block::before {
  content: "";
  position: absolute;
  left: 18%;
  top: 10%;
  bottom: 10%;
  width: 18%;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.18);
  filter: blur(3px);
  pointer-events: none;
}

.g-tonememory .tm-block:active { transform: scale(0.985); filter: brightness(1.06); }

.g-tonememory .tm-block.ripple::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at 50% 55%, rgba(255, 255, 255, 0.6), transparent 62%);
  animation: tmRipple 0.42s ease-out;
  pointer-events: none;
}

@keyframes tmRipple {
  from { opacity: 0.9; transform: scale(0.6); }
  to { opacity: 0; transform: scale(1.15); }
}

.g-tonememory .tm-block.wrong {
  animation: tmWrong 0.5s ease;
  box-shadow: 0 0 0 3px #ff5c6c, 0 0 26px rgba(255, 92, 108, 0.7), inset 0 2px 0 rgba(255, 255, 255, 0.3);
}

@keyframes tmWrong {
  0%, 100% { transform: translateX(0); filter: none; }
  25% { transform: translateX(-5px); filter: saturate(1.6) brightness(0.85); }
  75% { transform: translateX(5px); filter: saturate(1.6) brightness(0.85); }
}

/* ---------------- 覆盖层 ---------------- */

.g-tonememory .tm-cover {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  border-radius: 20px;
  background: rgba(8, 11, 18, 0.82);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s;
}

.g-tonememory .tm-cover.show { opacity: 1; visibility: visible; }

.g-tonememory .tm-cover-card {
  width: 100%;
  max-width: 286px;
  text-align: center;
}

.g-tonememory .tm-cover-title {
  font-size: 21px;
  font-weight: 800;
  line-height: 1.3;
}

.g-tonememory .tm-cover-sub {
  margin-top: 7px;
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--dim);
}

.g-tonememory .tm-cover-stats {
  display: flex;
  gap: 8px;
  margin: 13px 0 4px;
}

.g-tonememory .tm-cstat {
  flex: 1;
  min-width: 0;
  padding: 7px 4px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
}

.g-tonememory .tm-cstat span {
  display: block;
  font-size: 10px;
  color: var(--faint);
  margin-bottom: 2px;
}

.g-tonememory .tm-cstat b {
  display: block;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.g-tonememory .tm-cover .btn { min-height: 45px; margin-top: 12px; }
.g-tonememory .tm-cover-extra {
  margin-top: 8px;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--faint);
}

/* ---------------- 操作行 / 底部 ---------------- */

.g-tonememory .tm-toolbar .btn { min-height: 44px; }
.g-tonememory .tm-toolbar .btn.is-disabled { opacity: 0.42; pointer-events: none; }

.g-tonememory .tm-meta { padding: 8px 12px 9px; }
.g-tonememory .tm-meta-head { align-items: baseline; gap: 8px; }
.g-tonememory .tm-meta-head .hint:first-child { color: var(--dim); font-weight: 600; font-variant-numeric: tabular-nums; }
.g-tonememory .tm-meta-head .hint:last-child { flex: none; color: #ff8b96; }
.g-tonememory .tm-meta-right { display: flex; align-items: baseline; gap: 8px; flex: none; }
.g-tonememory .tm-phase { color: var(--faint); font-weight: 600; }
.g-tonememory .tm-phase.ok { color: var(--accent); }
.g-tonememory .tm-tip {
  margin-top: 5px;
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--faint);
}

/* ---------------- 窄屏 / 动效偏好 ---------------- */

@media (max-width: 359px) {
  .g-tonememory .stat-v { font-size: 15.5px; }
  .g-tonememory .tm-blocks { gap: 6px; }
  .g-tonememory .tm-block { border-radius: 14px; height: clamp(170px, 42dvh, 300px); }
}

@media (prefers-reduced-motion: reduce) {
  .g-tonememory .tm-board.playing .tm-wave span { animation: none; height: 16px; }
  .g-tonememory .tm-board.playing .tm-blocks { box-shadow: 0 0 0 1px rgba(183, 140, 255, 0.3); }
  .g-tonememory .tm-cover { transition: none; }
  .g-tonememory .tm-block.wrong { animation: none; }
}
