.qte-page {
  --good: #6ed99a;
  --perfect: #e3bc62;
  --miss: #e08b7c;
  --line: rgba(236, 234, 227, 0.22);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.qte-page .domain,
.qte-page .tabs {
  animation: none;
}

.qte-page main {
  width: min(100%, 68rem);
  padding-top: clamp(4.6rem, 10vh, 6.4rem);
  padding-bottom: 3rem;
}

.qte-page h1 {
  font-size: clamp(2.8rem, 6vw, 4.2rem);
}

#shelf {
  width: 100%;
}

.shelf[hidden],
.play[hidden] {
  display: none !important;
}

.qte-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15.5rem, 18rem));
  justify-content: center;
  gap: 0.85rem;
  width: 100%;
  margin: 1.6rem 0 0;
  padding: 0;
  list-style: none;
}

.qte-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  width: 100%;
  min-height: 11.5rem;
  margin: 0;
  padding: 0.95rem 1rem 1rem;
  text-align: left;
  color: var(--fg);
  font: inherit;
  background: transparent;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: border-color 0.45s var(--ease), color 0.45s var(--ease);
}

.qte-card:hover {
  border-color: var(--accent);
}

.qte-card-icon {
  width: 2.6rem;
  height: 2.6rem;
  margin-bottom: 0.85rem;
  color: var(--fg);
}

.qte-card-icon circle {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  opacity: 0.78;
}

.qte-card-icon path {
  fill: none;
  stroke: var(--perfect);
  stroke-width: 3.4;
  stroke-linecap: butt;
}

.qte-card-icon .mini-hand {
  transform-box: view-box;
  transform-origin: center;
  animation: sweep 1.6s linear infinite;
}

.qte-card-icon .mini-hand line {
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: butt;
}

.zone-icon line {
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: butt;
}

.zone-icon rect {
  fill: var(--good);
}

.mini-zone {
  animation: zone-slide 1.6s ease-in-out infinite alternate;
}

.lane {
  position: relative;
  width: min(100%, 24rem);
  height: 4.75rem;
  margin: 1.35rem auto 0.2rem;
  touch-action: none;
}

#panel-zone.is-live { touch-action: none; }

.lane-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 3.6px;
  transform: translateY(-50%);
  background: rgba(236, 234, 227, 0.78);
}

.lane-zone {
  position: absolute;
  top: 50%;
  width: 20%;
  height: 1.45rem;
  transform: translateY(-50%);
  background: var(--good);
}

.lane-mark {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2.8px;
  height: 2.55rem;
  transform: translate(-50%, -50%);
  background: var(--fg);
}


.qte-card-name {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.7rem;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--accent);
}

.qte-card-note {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.play-box {
  width: min(100%, 32rem);
  margin: 0.4rem auto 0;
  padding: 1.15rem 1.25rem 1.45rem;
  border: 1px solid var(--line);
  transition: border-color 0.2s linear;
}

.play-box[data-result="perfect"] { border-color: var(--perfect); }
.play-box[data-result="good"] { border-color: var(--good); }
.play-box[data-result="miss"] { border-color: var(--miss); }

.play-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.play-bar h2 {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 1.7rem;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--accent);
}

.qte-back,
.qte-start {
  font: inherit;
  font-size: 0.95rem;
  color: var(--fg);
  background-color: transparent;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0 1px;
  border: 0;
  padding: 0 0 0.08rem;
  cursor: pointer;
  transition: color 0.45s var(--ease), background-size 0.45s var(--ease);
}

.qte-back:hover,
.qte-start:hover {
  color: var(--accent);
  background-size: 100% 1px;
}

.rules {
  max-width: 28rem;
  margin: 0.9rem auto 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
  text-wrap: balance;
}

.dial {
  width: min(100%, 280px);
  margin: 0.85rem auto 0;
  color: var(--fg);
}

.dial svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.ring {
  fill: none;
  stroke: rgba(236, 234, 227, 0.78);
  stroke-width: 3.6;
}

.arc {
  stroke: none;
}

.arc-good { fill: var(--good); }
.arc-perfect { fill: var(--perfect); }

.hand {
  stroke: var(--fg);
  stroke-width: 2.8;
  stroke-linecap: butt;
}

.pivot { fill: var(--fg); }

.qte-timer {
  margin: 0.85rem 0 0;
  color: var(--muted);
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 0.95rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  line-height: 1;
}

.qte-timer.is-low { color: var(--miss); }

.qte-result {
  min-height: 1.12em;
  margin: 0.1rem 0 0;
  font-family: "DM Mono", ui-monospace, monospace;
  font-style: normal;
  font-weight: 500;
  font-size: clamp(1.35rem, 3vw, 1.7rem);
  letter-spacing: 0.06em;
  line-height: 1.2;
  opacity: 0;
}

.qte-result.is-on { opacity: 1; }
.qte-result[data-result="perfect"] { color: var(--perfect); }
.qte-result[data-result="good"] { color: var(--good); }
.qte-result[data-result="miss"],
.qte-result[data-result="fail"] { color: var(--miss); }

.qte-pips {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  margin-top: 0.2rem;
}

.qte-pips span {
  width: 1.35rem;
  height: 4px;
  background: rgba(236, 234, 227, 0.22);
}

.qte-pips span[data-result="perfect"] { background: var(--perfect); }
.qte-pips span[data-result="good"] { background: var(--good); }
.qte-pips span[data-result="miss"] { background: var(--miss); }
.qte-pips span[data-result="clear"] { background: var(--good); }

.qte-status {
  min-height: 1.4em;
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.tone-perfect { color: var(--perfect); }
.tone-good { color: var(--good); }
.tone-miss { color: var(--miss); }

.qte-actions {
  display: grid;
  place-items: center;
  min-height: 1.5rem;
  margin-top: 0.75rem;
}

.qte-actions > * { grid-area: 1 / 1; }

.qte-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.play.is-live { cursor: pointer; }
.play.is-live,
.play.is-live .rules { user-select: none; }

.play { touch-action: manipulation; }

@keyframes sweep {
  to { transform: rotate(360deg); }
}

@keyframes zone-slide {
  from { transform: translateX(0); }
  to { transform: translateX(14px); }
}

.mole-icon rect:first-child {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  opacity: 0.78;
}

.mole-icon .mini-node {
  fill: var(--perfect);
  animation: node-blink 1.4s ease-in-out infinite;
}

.mole-field {
  position: relative;
  width: min(100%, 22rem);
  height: 15.5rem;
  margin: 1rem auto 0.15rem;
  border: 1px solid var(--line);
  touch-action: manipulation;
}

.mole-node {
  position: absolute;
  width: 2.75rem;
  height: 2.75rem;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--perfect);
  cursor: pointer;
  transform-origin: center;
  animation: node-pop 0.18s var(--ease) both;
}

.mole-node.is-hit,
.mole-node.is-miss {
  pointer-events: none;
  cursor: default;
  animation: none;
}

.mole-node.is-hit {
  animation: node-hit 0.24s linear forwards;
}

.mole-node.is-miss {
  transition: opacity 0.7s linear, background-color 0.7s linear, transform 0.7s linear;
}

.mole-node.is-miss.is-gone {
  opacity: 0;
  background: var(--miss);
  transform: scale(0.84);
}

@keyframes node-pop {
  from { transform: scale(0.4); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes node-hit {
  0% { transform: scale(1); opacity: 1; background: var(--perfect); }
  35% { transform: scale(1.22); opacity: 1; background: var(--good); }
  100% { transform: scale(0.72); opacity: 0; background: var(--good); }
}

@keyframes node-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.fall-icon line {
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: butt;
}

.fall-icon circle {
  fill: var(--perfect);
}

.fall-field {
  position: relative;
  width: min(100%, 16rem);
  height: 16rem;
  margin: 1rem auto 0.15rem;
  border: 1px solid var(--line);
  overflow: hidden;
  touch-action: none;
}

.fall-line {
  position: absolute;
  left: 0.7rem;
  right: 0.7rem;
  top: 78%;
  height: 3.6px;
  background: rgba(236, 234, 227, 0.78);
  transform: translateY(-50%);
}

.fall-node {
  position: absolute;
  left: 0;
  width: 1.75rem;
  height: 1.75rem;
  margin: 0;
  padding: 0;
  border-radius: 50%;
  background: var(--perfect);
  transform-origin: center;
}

.fall-node.is-perfect {
  animation: fall-perfect 0.22s linear forwards;
}

.fall-node.is-good {
  background: var(--good);
  animation: fall-perfect 0.22s linear forwards;
}

.fall-node.is-miss {
  background: var(--miss);
  animation: fall-miss 0.28s linear forwards;
}

@keyframes fall-perfect {
  0% { transform: scale(1); opacity: 1; }
  40% { transform: scale(1.18); opacity: 1; }
  100% { transform: scale(0.75); opacity: 0; }
}

@keyframes fall-miss {
  to { transform: scale(0.86); opacity: 0; }
}

#panel-fall.is-live { touch-action: none; }

.pulse-icon circle:first-child {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  opacity: 0.78;
}

.pulse-icon circle:last-child {
  fill: none;
  stroke: var(--perfect);
  stroke-width: 1.7;
}

.pulse-field {
  position: relative;
  width: min(100%, 16rem);
  aspect-ratio: 1;
  margin: 1rem auto 0.15rem;
  border: 1px solid var(--line);
  touch-action: none;
}

.pulse-target,
.pulse-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  box-sizing: border-box;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.pulse-target {
  width: 72%;
  height: 72%;
  border: 3.6px solid rgba(236, 234, 227, 0.78);
}

.pulse-ring {
  border: 3.6px solid var(--perfect);
}

.pulse-ring.is-perfect {
  animation: pulse-hit 0.22s linear forwards;
}

.pulse-ring.is-good {
  border-color: var(--good);
  animation: pulse-hit 0.22s linear forwards;
}

.pulse-ring.is-miss {
  border-color: var(--miss);
  animation: pulse-miss 0.28s linear forwards;
}

@keyframes pulse-hit {
  0% { opacity: 1; }
  40% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes pulse-miss {
  to { opacity: 0; }
}

#panel-pulse.is-live { touch-action: none; }

.hold-icon line {
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: butt;
}

.hold-icon rect {
  fill: var(--perfect);
}

.hold-lane {
  position: relative;
  width: min(100%, 24rem);
  height: 4.75rem;
  margin: 1.35rem auto 0.2rem;
  touch-action: none;
}

.hold-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 3.6px;
  transform: translateY(-50%);
  background: rgba(236, 234, 227, 0.78);
}

.hold-good,
.hold-perfect {
  position: absolute;
  top: 50%;
  height: 1.45rem;
  transform: translateY(-50%);
}

.hold-good { background: var(--good); }
.hold-perfect { background: var(--perfect); }

.hold-mark {
  position: absolute;
  top: 50%;
  left: 0;
  width: 2.8px;
  height: 2.55rem;
  transform: translate(-50%, -50%);
  background: var(--fg);
}

#panel-hold.is-live { touch-action: none; }

.sweep-icon rect {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
  opacity: 0.75;
}

.sweep-icon .mini-node {
  fill: var(--perfect);
  stroke: none;
  opacity: 1;
}

.sweep-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.28rem;
  width: min(100%, 16rem);
  margin: 1rem auto 0.15rem;
  touch-action: manipulation;
}

.mine-cell {
  appearance: none;
  aspect-ratio: 1;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--fg);
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
}

.mine-cell.is-open {
  border-color: transparent;
  background: rgba(236, 234, 227, 0.045);
  cursor: default;
}

.mine-cell.n1 { color: var(--muted); }
.mine-cell.n2 { color: var(--fg); }
.mine-cell.n3 { color: var(--perfect); }
.mine-cell.n4,
.mine-cell.n5 { color: var(--good); }

.mine-cell.is-mine {
  border-color: transparent;
  background: rgba(224, 139, 124, 0.35);
  cursor: default;
}

.mine-cell.is-blown {
  background: var(--miss);
}

.link-icon circle {
  fill: var(--perfect);
}

.link-icon line {
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: butt;
}

.link-board {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  margin: 1rem auto 0.15rem;
}

.link-side {
  position: relative;
  width: 0.7rem;
  height: calc(5 * 2.35rem + 4 * 0.28rem);
}

.link-dot {
  position: absolute;
  left: 0;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--perfect);
  transform: translateY(-50%);
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(5, 2.35rem);
  grid-template-rows: repeat(5, 2.35rem);
  gap: 0.28rem;
}

.pipe {
  position: relative;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(236, 234, 227, 0.04);
  cursor: pointer;
}

.pipe i {
  position: absolute;
  display: none;
  background: var(--fg);
}

.pipe i.on { display: block; }

.pipe i[data-d="n"],
.pipe i[data-d="s"] {
  left: 50%;
  width: 3.6px;
  height: 50%;
  transform: translateX(-50%);
}

.pipe i[data-d="n"] { top: 0; }
.pipe i[data-d="s"] { bottom: 0; }

.pipe i[data-d="e"],
.pipe i[data-d="w"] {
  top: 50%;
  width: 50%;
  height: 3.6px;
  transform: translateY(-50%);
}

.pipe i[data-d="e"] { right: 0; }
.pipe i[data-d="w"] { left: 0; }

.pipe.is-live i.on { background: var(--perfect); }

#panel-link.is-live { touch-action: manipulation; }

.echo-icon rect {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}

.echo-icon rect:nth-child(2) {
  fill: var(--perfect);
  stroke: none;
}

.echo-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.45rem;
  width: min(100%, 12rem);
  margin: 1.25rem auto 0.15rem;
}

.echo-pad {
  appearance: none;
  aspect-ratio: 1;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}

.echo-pad.is-on { background: var(--perfect); }
.echo-pad.is-bad { background: var(--miss); }

#panel-echo.is-live { touch-action: manipulation; }

@media (max-width: 640px) {
  .qte-grid { grid-template-columns: 1fr; }
  .dial { width: min(100%, 240px); }
}

@media (max-height: 820px) {
  .qte-page main { padding-top: 4.35rem; }
  .qte-page h1 { font-size: clamp(2.4rem, 6vw, 3.2rem); }
  .dial { width: min(100%, 220px); }
}

@media (prefers-reduced-motion: reduce) {
  .qte-result,
  .play-box { transition: none; }

  .mini-hand,
  .mini-zone,
  .mini-node,
  .mole-node { animation: none; }
}
