:root {
  color-scheme: dark;
  font-family: "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
  color: #fff3ed;
  background: #140b14;
  --left: #ff577e;
  --right: #ffb66e;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(ellipse at 50% 0, #402030, #140b14 66%),
    #140b14;
}
button { font: inherit; cursor: pointer; touch-action: none; }
[hidden] { display: none !important; }
.cabinet {
  width: min(100%, 34rem);
  height: 100vh;
  height: 100dvh;
  min-height: 420px;
  margin-inline: auto;
  padding: max(.7rem, env(safe-area-inset-top)) max(.75rem, env(safe-area-inset-right)) max(.55rem, env(safe-area-inset-bottom)) max(.75rem, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: .55rem;
  -webkit-user-select: none;
  user-select: none;
}
header, footer { display: flex; justify-content: space-between; align-items: center; gap: .4rem; }
.controls { display: flex; justify-content: end; gap: .35rem; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.4rem, 6vw, 2.3rem); line-height: 1.16; }
.wordmark, .track-label { color: #ff85a3; font: 700 .78rem system-ui; letter-spacing: .13em; }
.stats { display: grid; grid-template-columns: 1fr .76fr 1fr; background: #241520; border: 1px solid #533044; border-radius: .7rem; }
.stats div { display: flex; flex-direction: column; padding: .4rem .65rem; }
.stats div + div { border-left: 1px solid #533044; }
.stats span { color: #e9b9c7; font-size: .85rem; }
.stats strong { font-size: 1.22rem; font-variant-numeric: tabular-nums; }
progress { width: 100%; height: .27rem; border: 0; appearance: none; background: #502b3c; border-radius: 9px; overflow: hidden; }
progress::-webkit-progress-bar { background: #502b3c; }
progress::-webkit-progress-value { background: var(--left); }
progress::-moz-progress-bar { background: var(--left); }
.stage {
  min-height: 0; flex: 1; position: relative; overflow: hidden;
  isolation: isolate; border: 1px solid #66364e; border-radius: .9rem;
  background: radial-gradient(ellipse at 50% 16%, #612033, #20101f 58%, #0f0912);
}
.stage::before {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, transparent 0 4px, #ffe3d709 5px 6px);
  pointer-events: none;
}
.moon {
  width: min(47%, 24vh); aspect-ratio: 1; position: absolute; top: 11%; left: 50%; transform: translateX(-50%);
  border-radius: 50%; opacity: .65;
  background: radial-gradient(circle at 70% 30%, #ffb280, #e94459 50%, #731437 79%);
  box-shadow: 0 0 3rem #fa2c5670, inset 0 0 1.2rem #ff8c75;
}
.moon::before {
  content: ""; position: absolute; inset: 4%; border-radius: 50%;
  background: repeating-radial-gradient(circle, #29122188 0 1px, transparent 2px 8px);
}
.stage.blood .moon { opacity: 1; box-shadow: 0 0 5rem #fa2c56, inset 0 0 1.2rem #ff8c75; }
.stage.blood { border-color: #ff839f; box-shadow: inset 0 0 1.8rem #ff577e58, 0 0 .85rem #ff577e68; }
.phase {
  position: absolute; z-index: 1; top: .65rem; left: 50%; transform: translateX(-50%);
  border: 1px solid #ff839f; border-radius: 99rem; padding: .21rem .75rem;
  color: #ffcf73; background: #371326; font: 900 .82rem system-ui; letter-spacing: .12em;
  visibility: hidden; white-space: nowrap; pointer-events: none;
}
.blood .phase { visibility: visible; }
canvas { position: absolute; width: 100%; height: 100%; inset: 0; }
#judgment {
  position: absolute; z-index: 1; top: 57%; width: 100%; text-align: center; color: #ffe5a5;
  font: italic 950 clamp(1.5rem, 9vw, 3rem) system-ui; letter-spacing: -.035em;
  text-shadow: 2px 3px #652139, 0 2px 10px #100910, 0 0 15px #f89c5f77; pointer-events: none;
}
#judgment[data-grade="good"] { color: #a7f3ff; }
#judgment[data-grade="miss"] { color: #e6aab7; text-shadow: 0 2px 8px #100910; }
.panel { position: absolute; inset: 0; display: grid; place-items: center; padding: 1rem; background: #1309128c; overflow: auto; }
.panel-content {
  width: min(100%, 23rem); text-align: center; display: grid; gap: .85rem;
  border: 1px solid #88435c; border-radius: 1rem; background: #231321f5;
  padding: clamp(.8rem, 4vw, 1.65rem); box-shadow: 0 1rem 2.5rem #0006;
}
.panel h2 { font-size: clamp(2rem, 10vw, 3.8rem); line-height: 1; }
.track-card { position: relative; display: grid; align-items: center; }
.track-card.cover {
  min-height: clamp(4.7rem, 22vw, 8rem); text-align: left; overflow: hidden;
  border-radius: .65rem; padding: .5rem; isolation: isolate;
  background: radial-gradient(circle at 83% 68%, #c43665, #451a33 46%, #290f26 85%);
}
.track-card.cover > div { z-index: 1; }
.track-card.cover h2 { text-shadow: 0 2px 6px #27061c; font-size: clamp(1.8rem, 8.7vw, 3rem); }
.track-card img {
  position: absolute; right: 0; bottom: -.45rem; height: 107%; width: auto;
  filter: drop-shadow(0 .3rem .4rem #420924);
}
#track-meta { color: #ffbb96; font-weight: 800; }
.guide { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem; color: #ffdfba; text-align: left; }
.guide span { border: 1px solid #6b344e; border-radius: .5rem; padding: .3rem .35rem; font-size: .83rem; }
#song-choice { display: flex; justify-content: center; gap: .55rem; align-items: center; }
#song { font: inherit; min-width: 9rem; background: #321a2e; color: inherit; padding: .3rem; border-color: #88435c; border-radius: .4rem; }
.mascot {
  position: absolute; z-index: 3; top: .7rem; right: .45rem; display: flex; align-items: flex-start;
  max-width: min(78%, 17rem); gap: .28rem; pointer-events: none; animation: pop-in .24s cubic-bezier(.12,.9,.3,1.35);
}
.mascot.cat { right: auto; left: .45rem; flex-direction: row-reverse; }
.mascot img { width: clamp(3.35rem, 17vw, 5.7rem); height: auto; object-fit: contain; filter: drop-shadow(0 .3rem .32rem #070309bd); }
.mascot p {
  margin-top: .65rem; color: #351027; background: #ffe3ef; padding: .26rem .45rem; font: 900 .86rem system-ui;
  border-radius: .65rem .65rem 0 .65rem; box-shadow: 0 3px #d25477; line-height: 1.4;
}
.mascot.cat p { background: #ffe1ad; box-shadow: 0 3px #ce7a35; border-radius: .65rem .65rem .65rem 0; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-.5rem) scale(.88); } }
#detail { color: #f1cbd6; line-height: 1.55; }
#status { color: #ffc3bb; font-size: .9rem; }
#status:empty { display: none; }
#start { min-height: 3rem; border: 0; border-radius: .65rem; background: #ff6587; color: #2b101d; font-weight: 850; }
button:disabled { opacity: .65; cursor: wait; }
.secondary { color: #ffcfdb; background: #291824; border: 1px solid #88435c; border-radius: .55rem; padding: .4rem .75rem; min-height: 2.5rem; }
#sound { padding-inline: .45rem; font-size: .83rem; }
#sound[aria-pressed="false"] { color: #d0a5bb; border-color: #56324b; }
.pads { display: grid; grid-template-columns: repeat(2, 1fr); gap: .55rem; }
.pad {
  height: clamp(3.4rem, 12vh, 6rem); display: flex; align-items: center; justify-content: space-between;
  padding-inline: 1rem; background: #321b2a; border: 1px solid currentColor; border-bottom-width: .27rem;
  border-radius: .65rem; color: var(--left); font-weight: 800; font-size: 1.2rem;
}
.pad.right { color: var(--right); background: #382220; }
.pad.active { background: currentColor; }
.pad.active span, .pad.active kbd { color: #27151e; }
kbd { font-size: .9rem; }
footer { color: #e3adbd; font-size: .83rem; }
footer a { color: inherit; text-underline-offset: .18em; }
@media (max-height: 620px) {
  .cabinet { gap: .3rem; }
  .panel-content { gap: .5rem; }
  .panel h2 { font-size: 2rem; }
}
@media (prefers-reduced-motion: reduce) {
  .mascot { animation: none; }
}
