:root {
  --ink: #221f1b;
  --muted: rgba(92, 78, 61, 0.76);
  --soft: rgba(92, 99, 116, 0.42);
  --line: rgba(118, 70, 56, 0.28);
  --gold: #dfc765;
  --ember: #c84532;
  --paper: #f6f1e8;
  --gift-primary: #6f8fbf;
  --gift-accent: #c99448;
  --gift-bg: #f4ede0;
  --gift-surface: #fffaf2;
  --gift-ink: #221f1b;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --app-height: 100dvh;
  color-scheme: only light;
}

@supports not (height: 100dvh) {
  :root {
    --app-height: 100vh;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  height: var(--app-height);
  margin: 0;
}

body {
  overflow: hidden;
  color: var(--gift-ink);
  font-family: Gabarito, "Noto Serif SC", sans-serif;
  background:
    radial-gradient(circle at 10% 7%, color-mix(in srgb, var(--gift-primary) 30%, transparent) 0 6%, transparent 14%),
    radial-gradient(circle at 91% 18%, color-mix(in srgb, var(--gift-accent) 34%, transparent) 0 5%, transparent 12%),
    radial-gradient(circle at 78% 96%, color-mix(in srgb, var(--gift-accent) 18%, transparent) 0 10%, transparent 24%),
    linear-gradient(135deg, color-mix(in srgb, var(--gift-bg) 88%, white), var(--gift-bg));
}

body[data-theme="record"] {
  --soft: rgba(72, 78, 96, 0.42);
}

button,
input {
  font: inherit;
}

.player-shell {
  min-height: var(--app-height);
  height: var(--app-height);
  display: grid;
  place-items: center;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.player-card {
  position: relative;
  isolation: isolate;
  width: min(100vw, 460px);
  min-height: 0;
  height: 100%;
  max-height: var(--app-height);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: clamp(16px, 3.4dvh, 28px);
  padding: clamp(20px, 5vw, 28px);
  background:
    radial-gradient(circle at 90% 17%, color-mix(in srgb, var(--gift-accent) 28%, transparent) 0 5%, transparent 12%),
    radial-gradient(circle at 7% 15%, color-mix(in srgb, var(--gift-primary) 20%, transparent) 0 4%, transparent 10%),
    radial-gradient(circle at 12% 92%, color-mix(in srgb, var(--gift-accent) 14%, transparent) 0 11%, transparent 24%),
    linear-gradient(180deg, color-mix(in srgb, var(--gift-surface) 94%, white) 0%, color-mix(in srgb, var(--gift-bg) 88%, white) 100%);
  overflow: hidden;
}

.player-card::before {
  content: "";
  position: absolute;
  inset: 13px;
  border: 1.2px solid var(--line);
  border-radius: 28px 25px 30px 24px;
  pointer-events: none;
  z-index: 0;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.58),
    inset 0 -18px 38px rgba(105, 88, 60, 0.08);
}

.player-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 83% 23%, color-mix(in srgb, var(--gift-accent) 42%, white) 0 7px, rgba(31, 34, 43, 0.8) 8px 10px, transparent 11px),
    radial-gradient(circle at 86% 20%, rgba(247, 229, 138, 0.4) 0 4px, transparent 5px),
    linear-gradient(180deg, transparent 0%, transparent 70%, rgba(220, 207, 185, 0.26) 100%);
  pointer-events: none;
  z-index: -1;
}

.player-card > * {
  position: relative;
  z-index: 1;
}

.cover-backdrop {
  position: absolute;
  inset: -10% -18% auto;
  height: 78%;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--gift-primary) 32%, white), color-mix(in srgb, var(--gift-accent) 22%, white));
  background-size: cover;
  background-position: center 38%;
  filter: blur(30px) saturate(0.98) brightness(1.08);
  opacity: 0.34;
  transform: scale(1.06);
  z-index: -2;
}

.cover-backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(250, 248, 242, 0.48), rgba(244, 238, 226, 0.66) 58%, rgba(235, 228, 216, 0.92) 100%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.36), transparent 48%, rgba(239, 228, 210, 0.28));
}

.topbar {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-xl);
  min-height: 46px;
  padding-right: 54px;
}

.eyebrow {
  margin: 0 0 var(--space-sm);
  color: color-mix(in srgb, var(--gift-ink) 70%, var(--gift-primary));
  font-size: 11px;
  letter-spacing: 0.16em;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: calc(100vw - 124px);
  color: var(--gift-ink);
  font-family: "Ma Shan Zheng", "Noto Serif SC", "Kaiti SC", serif;
  font-size: clamp(34px, 8.8vw, 46px);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.65);
}

.icon-button {
  position: absolute;
  top: 0;
  right: 0;
  width: 40px;
  height: 40px;
  border: 1.5px solid var(--line);
  border-radius: 16px 18px 15px 19px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(239, 232, 219, 0.9));
  color: var(--gift-ink);
  display: grid;
  place-items: center;
  box-shadow:
    0 9px 22px rgba(31, 34, 43, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.icon {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.15;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.open-panel,
.state-panel {
  min-height: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 22px;
  text-align: center;
  padding: 24px 10px 56px;
}

.gift-route,
.state-panel p {
  margin: 0;
  color: var(--muted);
  font-family: "Noto Serif SC", serif;
  font-size: 18px;
  line-height: 1.8;
}

.open-button {
  min-width: 190px;
  height: 54px;
  border: 0;
  border-radius: 999px;
  color: white;
  background: linear-gradient(135deg, var(--gift-accent), color-mix(in srgb, var(--gift-accent) 72%, #8e4d35));
  font-weight: 700;
  box-shadow: 0 18px 40px color-mix(in srgb, var(--gift-accent) 22%, transparent);
}

.player-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(12px, 3dvh, 22px);
}

.hero {
  display: grid;
  justify-items: center;
  gap: var(--space-sm);
}

.gift-note {
  justify-self: end;
  margin: 0 min(3vw, 18px) -12px 0;
  padding: 6px 15px 7px;
  border: 1.2px solid color-mix(in srgb, var(--gift-accent) 58%, black);
  border-radius: 18px 15px 19px 14px;
  background: linear-gradient(135deg, var(--gift-accent), color-mix(in srgb, var(--gift-accent) 70%, #8e4d35));
  color: #fbf5e9;
  font-family: "Ma Shan Zheng", "Noto Serif SC", serif;
  font-size: clamp(19px, 5vw, 24px);
  line-height: 1;
  transform: rotate(2.5deg);
  z-index: 1;
  box-shadow:
    0 13px 26px color-mix(in srgb, var(--gift-accent) 18%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.disc-wrap {
  position: relative;
  width: min(68vw, 306px);
  aspect-ratio: 1;
  border-radius: 11px 14px 12px 10px;
  overflow: hidden;
  box-shadow:
    0 24px 54px rgba(31, 34, 43, 0.16),
    0 0 0 7px #fffdf8,
    0 0 0 9px color-mix(in srgb, var(--gift-accent) 42%, rgba(118, 70, 56, 0.5));
}

.disc-wrap::before,
.disc-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.disc-wrap::before {
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: inherit;
}

.disc-wrap::after {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 36%, rgba(31, 34, 43, 0.08));
}

.cover {
  width: 100%;
  height: 100%;
  display: none;
  object-fit: cover;
}

.cover.is-loaded {
  display: block;
}

.cover-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: color-mix(in srgb, var(--gift-primary) 70%, var(--gift-ink));
  background: color-mix(in srgb, var(--gift-primary) 12%, white);
  font-size: clamp(76px, 20vw, 116px);
}

.cover-fallback[hidden] {
  display: none;
}

.is-playing .disc-wrap {
  animation: cover-breathe 3.2s ease-in-out infinite;
}

.song-meta {
  max-width: 26em;
  display: grid;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  margin-bottom: var(--space-sm);
  text-align: center;
}

.artist,
.dedication {
  margin: 0;
  font-family: "Noto Serif SC", serif;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.64);
}

.artist {
  color: var(--gift-ink);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.45;
}

.dedication {
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
}

.lyrics-panel {
  min-height: 0;
  position: relative;
  display: grid;
  align-self: stretch;
  margin-top: var(--space-md);
}

.lyrics-viewport {
  height: 100%;
  min-height: 176px;
  max-height: clamp(240px, 36dvh, 420px);
  overflow-y: auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  -webkit-mask-image: linear-gradient(to bottom, transparent, black 13%, black 84%, transparent);
  mask-image: linear-gradient(to bottom, transparent, black 13%, black 84%, transparent);
}

.lyrics-viewport::-webkit-scrollbar {
  display: none;
}

.lyrics-list {
  min-height: 100%;
  display: grid;
  align-content: center;
  gap: 14px;
  padding: 52px 0 76px;
  text-align: center;
}

.lyric-line {
  margin: 0;
  color: var(--soft);
  font-family: "Noto Serif SC", serif;
  font-size: clamp(18px, 5vw, 24px);
  line-height: 1.5;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: color 220ms ease, transform 220ms ease, opacity 220ms ease;
}

.lyric-line.is-past {
  color: rgba(92, 99, 116, 0.28);
}

.lyric-line.is-active {
  color: var(--gift-accent);
  transform: scale(1.04) rotate(-0.4deg);
  opacity: 1;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.72),
    0 8px 20px color-mix(in srgb, var(--gift-accent) 15%, transparent);
}

.controls {
  display: grid;
  gap: var(--space-lg);
  padding-bottom: max(env(safe-area-inset-bottom), 2px);
}

.time-row {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.progress {
  --progress-ratio: 0%;
  --progress-track: rgba(31, 34, 43, 0.18);
  --progress-fill: var(--gift-accent);
  --progress-thumb: var(--gift-accent);
  width: 100%;
  height: 28px;
  margin: -11px 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.progress::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--progress-fill) 0 var(--progress-ratio), var(--progress-track) var(--progress-ratio) 100%);
}

.progress::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -7.5px;
  border: 0;
  border-radius: 999px;
  background: var(--progress-thumb);
}

.button-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(24px, 9vw, 44px);
}

.small-control,
.play-button {
  border: 1.5px solid var(--line);
  color: var(--gift-ink);
}

.small-control {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.76), rgba(239, 232, 219, 0.92));
  font-size: 15px;
  font-weight: 700;
}

.play-button {
  width: 82px;
  height: 82px;
  border-width: 0.6px;
  border-radius: 999px;
  background: radial-gradient(circle at 35% 25%, color-mix(in srgb, var(--gift-accent) 62%, white), var(--gift-accent) 68%, color-mix(in srgb, var(--gift-accent) 75%, black) 100%);
  color: #fffdf8;
  font-size: 25px;
  box-shadow:
    0 18px 42px color-mix(in srgb, var(--gift-accent) 18%, transparent),
    0 0 0 7px color-mix(in srgb, var(--gift-accent) 8%, transparent);
}

.state-panel p {
  align-self: center;
}

[hidden] {
  display: none !important;
}

@keyframes cover-breathe {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-2px) scale(1.012);
  }
}

@media (min-width: 520px) {
  body {
    height: auto;
    overflow: auto;
  }

  .player-shell {
    padding: 28px;
  }

  .player-card {
    height: auto;
    min-height: min(920px, calc(100dvh - 56px));
    border-radius: 30px;
    box-shadow:
      0 32px 90px rgba(31, 34, 43, 0.16),
      0 0 0 1px rgba(31, 34, 43, 0.12);
  }
}

@media (max-width: 480px) {
  .player-card {
    gap: 8px;
    padding: 18px 20px 14px;
  }

  .player-card::before {
    inset: 12px;
    border-radius: 22px;
  }

  .topbar {
    min-height: 38px;
    padding-right: 46px;
  }

  h1 {
    font-size: clamp(31px, 8.4vw, 37px);
    max-width: calc(100vw - 112px);
  }

  .icon-button {
    width: 36px;
    height: 36px;
  }

  .disc-wrap {
    width: min(64vw, 248px);
  }

  .dedication {
    max-width: 17em;
    font-size: 13px;
  }

  .lyrics-viewport {
    min-height: 118px;
    max-height: clamp(170px, 29dvh, 260px);
  }

  .lyrics-list {
    gap: 8px;
    padding: 38px 0 42px;
  }

  .lyric-line {
    font-size: clamp(16px, 5vw, 19px);
    line-height: 1.38;
  }

  .controls {
    gap: 9px;
    padding-bottom: max(env(safe-area-inset-bottom), 18px);
  }

  .small-control {
    width: 48px;
    height: 48px;
  }

  .play-button {
    width: 66px;
    height: 66px;
  }
}

@media (max-width: 480px) and (max-height: 760px) {
  .player-card {
    grid-template-rows: auto minmax(0, 1fr);
    padding-top: 14px;
  }

  .disc-wrap {
    width: min(54vw, 210px);
  }

  .lyrics-viewport {
    min-height: 76px;
    max-height: 22dvh;
  }

  .small-control {
    width: 44px;
    height: 44px;
  }

  .play-button {
    width: 60px;
    height: 60px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
