:root {
  color-scheme: light dark;
  --bg: #f4f2f8;
  --panel: #ffffff;
  --text: #15151a;
  --muted: #6d6a75;
  --line: rgba(21, 21, 26, 0.1);
  --primary: #111111;
  --secondary: #f0edf6;
  --accent: #356dff;
  --media-frame: #050505;
  --media-pad: 0;
  --card-shadow: rgba(30, 24, 48, 0.12);
  --theme-badge-bg: rgba(53, 109, 255, 0.12);
  --theme-badge-text: var(--accent);
  --text-memory-bg: #ffffff;
  --text-memory-text: #15151a;
  --text-memory-border: rgba(21, 21, 26, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  background: radial-gradient(circle at 20% 0%, rgba(53, 109, 255, 0.18), transparent 28%),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
  color: var(--text);
}

.shell {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 28px 18px 36px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: linear-gradient(135deg, #356dff, #b346ff, #ff4f8b);
  color: white;
  font-weight: 800;
  font-size: 26px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 8vw, 44px);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: 28px;
  line-height: 1.08;
  letter-spacing: 0;
}

.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 18px 50px var(--card-shadow);
}

.state-card {
  padding: 36px 24px;
  text-align: center;
}

.state-card p {
  color: var(--muted);
  line-height: 1.45;
}

.memory-card {
  display: grid;
  gap: 0;
}

.media-slot {
  min-height: 280px;
  padding: var(--media-pad);
  background: var(--media-frame);
}

.media-slot.text-slot {
  min-height: 0;
  padding: 18px;
  background: transparent;
}

.main-media {
  display: block;
  width: 100%;
  max-height: 640px;
  object-fit: contain;
  background: #050505;
  border-radius: 18px;
}

.text-memory-card {
  display: block;
  width: 100%;
  padding: 28px;
  border-radius: 18px;
  border: 1px solid var(--text-memory-border);
  background: var(--text-memory-bg);
  color: var(--text-memory-text);
  font-size: clamp(1.3rem, 4vw, 2rem);
  font-weight: 750;
  line-height: 1.25;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.collage {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  background: #050505;
}

.collage img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 12px;
}

.memory-body {
  padding: 22px;
}

.pill {
  display: inline-flex;
  margin-bottom: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--theme-badge-bg);
  color: var(--theme-badge-text);
  font-size: 13px;
  font-weight: 700;
}

.theme-badge {
  display: inline-flex;
  margin: 0 0 12px 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--theme-badge-bg);
  color: var(--theme-badge-text);
  font-size: 13px;
  font-weight: 800;
}

.song-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.03);
}

.special-card {
  margin: 16px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.035);
}

.special-type {
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.special-card h3 {
  margin-bottom: 8px;
  font-size: 20px;
}

.special-prompt {
  color: var(--muted);
}

.special-countdown {
  display: grid;
  gap: 4px;
  margin: 12px 0;
  padding: 14px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  text-align: center;
}

.special-countdown strong {
  display: block;
  font-size: 28px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.special-countdown span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.special-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.special-option {
  border: 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.special-option:active {
  transform: translateY(1px);
}

.special-option.is-selected {
  background: var(--accent);
  color: #fff;
  font-size: 18px;
}

.special-option.is-locked,
.special-option:disabled {
  cursor: default;
  opacity: 0.55;
}

.song-battle-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  padding: 10px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.song-battle-art {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: 12px;
  background: #ddd;
}

.song-battle-text {
  min-width: 0;
}

.song-battle-text strong,
.song-battle-text span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.song-battle-text span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.song-battle-controls {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.song-battle-preview,
.song-battle-vote {
  min-height: 40px;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
}

.song-battle-preview {
  background: var(--panel);
  color: var(--accent);
}

.song-battle-vote {
  background: var(--accent);
  color: #fff;
}

.song-battle-vote.is-selected {
  font-size: 20px;
}

.song-battle-vote.is-locked,
.song-battle-vote:disabled,
.song-battle-preview:disabled {
  cursor: default;
  opacity: 0.55;
}

.memory-rate {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 4px;
}

.memory-rate-button {
  min-height: 38px;
  padding: 0;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 900;
}

.question-response {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.question-response textarea {
  width: 100%;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}

.special-submit {
  min-height: 46px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.special-response-status {
  min-height: 18px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.special-response-status.is-success {
  color: #16843a;
}

.special-response-status.is-error {
  color: #d23b3b;
}

.album-art {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border-radius: 12px;
  background: #ddd;
}

.song-title {
  margin-bottom: 3px;
  font-weight: 800;
}

.artist-name,
.expires-note {
  color: var(--muted);
}

.audio-controls {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.audio-button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(53, 109, 255, 0.08);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.audio-button.is-playing {
  background: rgba(53, 109, 255, 0.18);
  color: var(--accent);
}

.audio-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-weight: 900;
}

.expires-note {
  margin: 16px 0;
  line-height: 1.4;
}

.actions {
  display: grid;
  gap: 10px;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 14px;
  font-weight: 800;
  text-decoration: none;
}

.primary-button {
  background: var(--primary);
  color: #ffffff;
}

.secondary-button {
  background: var(--secondary);
  color: var(--text);
}

.primary-button:visited,
.primary-button:hover,
.primary-button:active {
  color: #ffffff;
}

.secondary-button:visited,
.secondary-button:hover,
.secondary-button:active {
  color: var(--text);
}

.spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 14px;
  border: 4px solid rgba(53, 109, 255, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.expired-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: rgba(255, 76, 76, 0.12);
  color: #d82020;
  font-size: 28px;
  font-weight: 900;
}

.hidden {
  display: none;
}

body.theme-beach,
body.theme-chill {
  --bg: #e9fbff;
  --panel: rgba(255, 255, 255, 0.9);
  --accent: #09aeb3;
  --primary: #063d42;
  --secondary: rgba(9, 174, 179, 0.14);
  --media-frame: linear-gradient(135deg, #08b7bd, #f4d35e);
  --media-pad: 6px;
  --theme-badge-bg: rgba(255, 255, 255, 0.86);
  --theme-badge-text: #047b83;
}

body.theme-birthday,
body.theme-bday,
body.theme-fun {
  --bg: #fff0f7;
  --panel: rgba(255, 255, 255, 0.9);
  --accent: #ff3f86;
  --primary: #32111f;
  --secondary: rgba(255, 63, 134, 0.14);
  --media-frame: linear-gradient(135deg, #ff8eb8, #ffd166);
  --media-pad: 6px;
  --theme-badge-bg: rgba(255, 255, 255, 0.86);
  --theme-badge-text: #c72666;
}

body.theme-neon,
body.theme-glow {
  --bg: #12061b;
  --panel: rgba(255, 255, 255, 0.10);
  --text: #fff8ff;
  --muted: rgba(255, 248, 255, 0.72);
  --line: rgba(255, 255, 255, 0.14);
  --primary: #ff8a24;
  --secondary: rgba(255, 255, 255, 0.13);
  --accent: #ff8a24;
  --media-frame: linear-gradient(135deg, #ff8a24, #c83dff);
  --media-pad: 6px;
  --card-shadow: rgba(200, 61, 255, 0.22);
  --theme-badge-bg: rgba(255, 255, 255, 0.12);
  --theme-badge-text: #ff8a24;
  --text-memory-bg: #061f1d;
  --text-memory-text: #ffffff;
  --text-memory-border: rgba(255, 255, 255, 0.16);
}

body.theme-film,
body.theme-classic,
body.theme-retro {
  --bg: #f5efe3;
  --panel: rgba(255, 255, 255, 0.88);
  --accent: #181513;
  --primary: #181513;
  --secondary: rgba(24, 21, 19, 0.10);
  --media-frame: linear-gradient(90deg, #181513, #c2a36b, #181513);
  --media-pad: 6px;
  --theme-badge-bg: rgba(255, 255, 255, 0.86);
  --theme-badge-text: #181513;
}

body.theme-dream,
body.theme-soft {
  --bg: #f1f1ff;
  --panel: rgba(255, 255, 255, 0.88);
  --accent: #6862d9;
  --primary: #29284d;
  --secondary: rgba(104, 98, 217, 0.14);
  --media-frame: linear-gradient(135deg, #b7b3ff, #f4c7ff);
  --media-pad: 6px;
  --theme-badge-bg: rgba(255, 255, 255, 0.86);
  --theme-badge-text: #554fd0;
}

body.theme-vip,
body.theme-elegant {
  --bg: #0f0b07;
  --panel: rgba(255, 255, 255, 0.10);
  --text: #fff8ec;
  --muted: rgba(255, 248, 236, 0.72);
  --line: rgba(255, 255, 255, 0.13);
  --primary: #eab950;
  --secondary: rgba(255, 255, 255, 0.13);
  --accent: #eab950;
  --media-frame: linear-gradient(135deg, #f5d77a, #7c5a1d);
  --media-pad: 6px;
  --card-shadow: rgba(234, 185, 80, 0.22);
  --theme-badge-bg: rgba(255, 255, 255, 0.12);
  --theme-badge-text: #f5d77a;
  --text-memory-bg: #061f1d;
  --text-memory-text: #ffffff;
  --text-memory-border: rgba(255, 255, 255, 0.16);
}

body.theme-rainbow {
  --bg: #fff7ff;
  --panel: rgba(255, 255, 255, 0.9);
  --accent: #d83dff;
  --primary: #25102f;
  --secondary: rgba(216, 61, 255, 0.12);
  --media-frame: linear-gradient(90deg, #ff3b30, #ff9500, #ffcc00, #34c759, #00c7be, #007aff, #af52de);
  --media-pad: 6px;
  --theme-badge-bg: rgba(255, 255, 255, 0.86);
  --theme-badge-text: #d83dff;
}

body.theme-lively,
body.theme-green {
  --bg: #edfff3;
  --panel: rgba(255, 255, 255, 0.9);
  --accent: #28c955;
  --primary: #083817;
  --secondary: rgba(40, 201, 85, 0.14);
  --media-frame: linear-gradient(135deg, #28c955, #00c7be);
  --media-pad: 6px;
  --theme-badge-bg: rgba(255, 255, 255, 0.86);
  --theme-badge-text: #158536;
}

body.theme-sunshine,
body.theme-yellow {
  --bg: #fffbea;
  --panel: rgba(255, 255, 255, 0.92);
  --accent: #d99a00;
  --primary: #3a2700;
  --secondary: rgba(255, 204, 0, 0.18);
  --media-frame: linear-gradient(135deg, #ffcc00, #ff9f0a, #fff2a8);
  --media-pad: 6px;
  --theme-badge-bg: rgba(255, 255, 255, 0.9);
  --theme-badge-text: #9c6b00;
}

body.theme-neon .primary-button,
body.theme-glow .primary-button,
body.theme-vip .primary-button,
body.theme-elegant .primary-button {
  color: #111111;
}

.legal-page {
  width: min(720px, calc(100% - 32px));
  margin: 32px auto;
  padding: 34px 24px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 18px 50px var(--card-shadow);
}

.legal-page h1 {
  margin: 0 0 20px;
  font-size: clamp(36px, 8vw, 64px);
  letter-spacing: -0.04em;
}

.legal-page p {
  margin: 0 0 16px;
  color: var(--text);
  font-size: 18px;
  line-height: 1.55;
}

.legal-page h2 {
  margin: 30px 0 10px;
  font-size: clamp(22px, 5vw, 30px);
}

.legal-page ul {
  margin: 0 0 18px;
  padding-left: 24px;
}

.legal-page li {
  margin-bottom: 10px;
  font-size: 17px;
  line-height: 1.55;
}

.legal-page a {
  color: #004fc4;
  font-weight: 800;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

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

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0d12;
    --panel: #191820;
    --text: #f7f4ff;
    --muted: #aaa4b8;
    --line: rgba(255, 255, 255, 0.1);
    --primary: #ffffff;
    --secondary: #272531;
    --theme-badge-bg: rgba(255, 255, 255, 0.1);
    --theme-badge-text: var(--accent);
    --text-memory-bg: #061f1d;
    --text-memory-text: #ffffff;
    --text-memory-border: rgba(255, 255, 255, 0.14);
  }

  body.theme-beach,
  body.theme-chill {
    --bg: #07191b;
    --panel: rgba(255, 255, 255, 0.10);
    --text: #f6ffff;
    --muted: rgba(246, 255, 255, 0.72);
    --line: rgba(255, 255, 255, 0.13);
    --primary: #7df5ff;
    --secondary: rgba(125, 245, 255, 0.13);
    --theme-badge-bg: rgba(255, 255, 255, 0.12);
    --theme-badge-text: #7df5ff;
  }

  body.theme-birthday,
  body.theme-bday,
  body.theme-fun {
    --bg: #1d0b14;
    --panel: rgba(255, 255, 255, 0.10);
    --text: #fff7fb;
    --muted: rgba(255, 247, 251, 0.72);
    --line: rgba(255, 255, 255, 0.13);
    --primary: #ff8eb8;
    --secondary: rgba(255, 142, 184, 0.13);
    --theme-badge-bg: rgba(255, 255, 255, 0.12);
    --theme-badge-text: #ff8eb8;
  }

  body.theme-film,
  body.theme-classic,
  body.theme-retro {
    --bg: #14110e;
    --panel: rgba(255, 255, 255, 0.10);
    --text: #fff8ec;
    --muted: rgba(255, 248, 236, 0.72);
    --line: rgba(255, 255, 255, 0.13);
    --primary: #d6bc7d;
    --secondary: rgba(214, 188, 125, 0.13);
    --theme-badge-bg: rgba(255, 255, 255, 0.12);
    --theme-badge-text: #d6bc7d;
  }

  body.theme-dream,
  body.theme-soft {
    --bg: #11112b;
    --panel: rgba(255, 255, 255, 0.10);
    --text: #f6f4ff;
    --muted: rgba(246, 244, 255, 0.72);
    --line: rgba(255, 255, 255, 0.13);
    --primary: #b7b3ff;
    --secondary: rgba(183, 179, 255, 0.13);
    --theme-badge-bg: rgba(255, 255, 255, 0.12);
    --theme-badge-text: #b7b3ff;
  }

  body.theme-rainbow {
    --bg: #19091c;
    --panel: rgba(255, 255, 255, 0.10);
    --text: #fff7ff;
    --muted: rgba(255, 247, 255, 0.72);
    --line: rgba(255, 255, 255, 0.13);
    --primary: #f06cff;
    --secondary: rgba(240, 108, 255, 0.13);
    --theme-badge-bg: rgba(255, 255, 255, 0.12);
    --theme-badge-text: #f06cff;
  }

  body.theme-lively,
  body.theme-green {
    --bg: #06170d;
    --panel: rgba(255, 255, 255, 0.10);
    --text: #f4fff7;
    --muted: rgba(244, 255, 247, 0.72);
    --line: rgba(255, 255, 255, 0.13);
    --primary: #6ee88b;
    --secondary: rgba(110, 232, 139, 0.13);
    --theme-badge-bg: rgba(255, 255, 255, 0.12);
    --theme-badge-text: #6ee88b;
  }

  body.theme-sunshine,
  body.theme-yellow {
    --bg: #211604;
    --panel: rgba(255, 255, 255, 0.10);
    --text: #fff8df;
    --muted: rgba(255, 248, 223, 0.72);
    --line: rgba(255, 255, 255, 0.13);
    --primary: #ffd45a;
    --secondary: rgba(255, 212, 90, 0.13);
    --theme-badge-bg: rgba(255, 255, 255, 0.12);
    --theme-badge-text: #ffd45a;
  }

  .legal-page a {
    color: #8fb8ff;
  }

  .primary-button {
    color: #111111;
  }
}
