:root {
  color-scheme: dark;
  --cream: #fff8ef;
  --ink: #3e271d;
  --brown: #8f6445;
  --brown-deep: #5f3c2b;
  --line: rgba(95, 60, 43, 0.28);
  --scene-ratio: 1534 / 1025;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background: #fbf5eb;
}

body {
  color: var(--cream);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.music-scene {
  position: relative;
  width: 100%;
  min-height: 100svh;
  overflow: visible;
  isolation: isolate;
  background: #fbf5eb;
}

.scene-frame {
  position: relative;
  width: 100%;
  max-width: 1534px;
  aspect-ratio: var(--scene-ratio);
  margin: 0 auto;
  overflow: visible;
  background: #c9a77f;
}

.scene-image,
.scene-vignette,
.scene-grain {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.scene-image {
  z-index: 0;
  display: block;
  object-fit: cover;
  object-position: center center;
  filter: saturate(0.93) contrast(0.98);
  user-select: none;
  -webkit-user-drag: none;
}

.scene-vignette {
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(49, 25, 14, 0.18), transparent 23%, transparent 75%, rgba(49, 25, 14, 0.28)),
    radial-gradient(circle at center, transparent 42%, rgba(43, 25, 15, 0.18) 100%);
}

.scene-grain {
  z-index: 2;
  pointer-events: none;
  opacity: 0.12;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.18'/%3E%3C/svg%3E");
}

.scene-header {
  position: absolute;
  top: clamp(24px, 4vw, 52px);
  left: clamp(24px, 4vw, 64px);
  right: clamp(24px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: rgba(73, 41, 27, 0.76);
  letter-spacing: 0.16em;
  z-index: 3;
  pointer-events: none;
}

.scene-header p {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
}

.scene-header .mark {
  letter-spacing: 0.22em;
}

.scene-header .mark span {
  display: inline-block;
  margin: 0 0.35em;
  color: #a44f47;
}

.scene-header .edition {
  font-size: 10px;
  letter-spacing: 0.22em;
}

.player-overlay {
  position: absolute;
  z-index: 4;
  top: 52.4%;
  left: 52.2%;
  width: 23.7%;
  aspect-ratio: 1.31;
  transform: translateX(-50%);
  transition: width 300ms cubic-bezier(0.2, 0.75, 0.25, 1);
}

.player-overlay.is-open {
  width: min(84vw, 360px);
}

.player-card-surface {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border: 1px solid rgba(95, 60, 43, 0.24);
  border-radius: 12px;
  background: rgba(255, 249, 239, 0.94);
  box-shadow: 0 8px 18px rgba(91, 53, 32, 0.16);
  color: var(--ink);
  backdrop-filter: blur(3px);
  cursor: pointer;
}

.player-title-row {
  position: absolute;
  top: 7%;
  right: 9%;
  left: 9%;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.player-title-row div {
  display: grid;
  gap: 2px;
}

.player-title-row strong {
  font-size: clamp(8px, 1.35vw, 18px);
  line-height: 1.1;
}

.player-title-row span:not(.heart) {
  color: rgba(62, 39, 29, 0.56);
  font-size: clamp(7px, 0.85vw, 12px);
}

.heart {
  color: #bd6d67;
  font-size: clamp(11px, 1.7vw, 23px);
  line-height: 1;
}

.lyrics-window {
  position: absolute;
  top: 25%;
  left: 8%;
  width: 84%;
  height: 35%;
  overflow: hidden;
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transform: translateY(5px);
  transition: opacity 220ms ease, transform 220ms ease, visibility 220ms ease;
}

.player-overlay.is-open .lyrics-window {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transform: translateY(0);
}

.lyrics-track {
  position: absolute;
  top: 50%;
  right: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  transform: translateY(-50%);
  transition: transform 500ms cubic-bezier(0.2, 0.75, 0.25, 1);
}

.lyric-line {
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: rgba(62, 39, 29, 0.34);
  font-size: clamp(8px, 1.1vw, 15px);
  line-height: 1.2;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 350ms ease, transform 350ms ease, font-size 350ms ease, opacity 350ms ease;
}

.lyric-line:hover,
.lyric-line:focus-visible {
  color: rgba(62, 39, 29, 0.68);
  outline: none;
}

.lyric-line.active {
  color: var(--brown-deep);
  font-size: clamp(10px, 1.35vw, 18px);
  font-weight: 800;
  transform: scale(1.02);
}

.lyric-line.near {
  color: rgba(62, 39, 29, 0.62);
}

.lyrics-fade {
  position: absolute;
  right: 0;
  left: 0;
  z-index: 2;
  height: 22px;
  pointer-events: none;
}

.lyrics-fade-top {
  top: 0;
  background: linear-gradient(rgba(255, 249, 239, 0.98), transparent);
}

.lyrics-fade-bottom {
  bottom: 0;
  background: linear-gradient(transparent, rgba(255, 249, 239, 0.98));
}

.play-button {
  position: absolute;
  top: 68%;
  left: 50%;
  display: grid;
  width: clamp(26px, 4.4vw, 58px);
  height: clamp(26px, 4.4vw, 58px);
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(126, 81, 55, 0.92);
  box-shadow: 0 5px 12px rgba(73, 42, 27, 0.24), 0 0 0 4px rgba(255, 248, 239, 0.28);
  color: var(--cream);
  transform: translate(-50%, -50%);
  transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.play-button:hover {
  background: #6d4834;
  box-shadow: 0 7px 16px rgba(73, 42, 27, 0.28), 0 0 0 5px rgba(255, 248, 239, 0.36);
  transform: translate(-50%, -50%) scale(1.05);
}

.play-button:focus-visible {
  outline: 3px solid rgba(255, 248, 239, 0.95);
  outline-offset: 4px;
}

.play-icon {
  position: relative;
  display: block;
  width: 0;
  height: 0;
  margin-left: 4px;
  border-top: clamp(5px, 0.65vw, 8px) solid transparent;
  border-bottom: clamp(5px, 0.65vw, 8px) solid transparent;
  border-left: clamp(8px, 0.85vw, 12px) solid currentColor;
}

.play-button.is-playing .play-icon {
  width: clamp(9px, 0.85vw, 12px);
  height: clamp(12px, 1.1vw, 16px);
  margin-left: 0;
  border: 0;
  background: linear-gradient(90deg, currentColor 0 4px, transparent 4px 8px, currentColor 8px 12px);
}

.player-progress {
  position: absolute;
  right: 10%;
  bottom: 8%;
  left: 10%;
  display: grid;
  grid-template-columns: 27px minmax(0, 1fr) 27px;
  align-items: center;
  gap: 6px;
  color: rgba(62, 39, 29, 0.7);
  font-size: clamp(6px, 0.75vw, 10px);
  font-variant-numeric: tabular-nums;
}

.player-progress span:last-child {
  text-align: right;
}

#seekBar {
  width: 100%;
  height: 4px;
  accent-color: var(--brown);
}

.listen-hint {
  position: absolute;
  bottom: clamp(30px, 5vw, 56px);
  left: 50%;
  color: rgba(67, 38, 24, 0.66);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-align: center;
  text-shadow: 0 1px 8px rgba(255, 234, 205, 0.28);
  transform: translateX(-50%);
  transition: opacity 300ms ease;
  white-space: nowrap;
}

.music-scene.is-playing .listen-hint {
  opacity: 0;
}

.keyboard-hint {
  position: absolute;
  right: clamp(24px, 4vw, 64px);
  bottom: clamp(30px, 5vw, 56px);
  margin: 0;
  color: rgba(67, 38, 24, 0.52);
  font-size: 10px;
  letter-spacing: 0.13em;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 640px) {
  .scene-frame {
    width: 100vw;
  }

  .scene-header {
    top: 16px;
    right: 18px;
    left: 18px;
  }

  .scene-header p {
    font-size: 8px;
  }

  .scene-header .edition,
  .keyboard-hint {
    display: none;
  }

  .player-overlay {
    top: calc(100% + clamp(18px, 4vw, 32px));
    left: 50%;
    width: min(84vw, 360px);
  }

  .player-overlay.is-open {
    width: min(84vw, 360px);
  }

  .player-overlay.is-open .player-title-row strong {
    font-size: 18px;
  }

  .player-overlay.is-open .player-title-row span:not(.heart) {
    font-size: 11px;
  }

  .player-overlay.is-open .heart {
    font-size: 22px;
  }

  .player-overlay.is-open .lyrics-window {
    top: 24%;
    height: 38%;
  }

  .player-overlay.is-open .lyrics-track {
    gap: 6px;
  }

  .player-overlay.is-open .lyric-line {
    font-size: 12px;
  }

  .player-overlay.is-open .lyric-line.active {
    font-size: 16px;
  }

  .player-overlay.is-open .play-button {
    width: 54px;
    height: 54px;
  }

  .player-overlay.is-open .play-icon {
    border-top-width: 8px;
    border-bottom-width: 8px;
    border-left-width: 12px;
  }

  .player-overlay.is-open .play-button.is-playing .play-icon {
    width: 12px;
    height: 16px;
  }

  .player-overlay.is-open .player-progress {
    grid-template-columns: 32px minmax(0, 1fr) 32px;
    gap: 8px;
    font-size: 9px;
  }

  .listen-hint {
    bottom: 30px;
    font-size: 10px;
    letter-spacing: 0.1em;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lyrics-track,
  .lyric-line,
  .play-button,
  .listen-hint,
  .player-overlay,
  .lyrics-window {
    transition: none;
  }
}
