:root {
  --bg: #090527;
  --bg-elevated: #140a35;
  --bg-bar: rgba(12, 6, 32, 0.92);
  --text: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.62);
  --text-soft: rgba(255, 255, 255, 0.42);
  --accent: #ff3d9a;
  --accent-2: #7b2ff7;
  --border: rgba(255, 255, 255, 0.1);
  --radius: 20px;
  --bar-height: 76px;
  --bar-inset: 12px;
  --bar-max-width: 520px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
  touch-action: manipulation;
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  position: fixed;
  inset: 0;
  width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(ellipse 120% 60% at 50% -10%, rgba(123, 47, 247, 0.35), transparent 55%),
    radial-gradient(ellipse 80% 40% at 100% 0%, rgba(255, 61, 154, 0.18), transparent 50%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: manipulation;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app {
  height: 100dvh;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: calc(20px + var(--safe-top)) 20px calc(var(--bar-height) + var(--safe-bottom) + 28px);
}

.hero {
  width: 100%;
  text-align: center;
}

.artwork-wrap {
  position: relative;
  width: min(260px, 72vw);
  margin: 0 auto 24px;
}

.artwork-glow {
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 61, 154, 0.45), transparent 70%);
  filter: blur(24px);
  opacity: 0.5;
  transition: opacity 0.3s;
}

.artwork-wrap.is-playing .artwork-glow {
  opacity: 1;
  animation: pulse 2.4s ease-in-out infinite;
}

.artwork {
  position: relative;
  aspect-ratio: 1;
  border-radius: 28px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  box-shadow:
    0 24px 50px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  overflow: hidden;
}

.artwork__number {
  font-size: clamp(3.5rem, 16vw, 5rem);
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1;
  transition: transform 0.3s;
}

.artwork-wrap.is-playing .artwork__number {
  transform: scale(0.92);
}

.equalizer {
  position: absolute;
  bottom: 18%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 28px;
  opacity: 0;
  transition: opacity 0.3s;
}

.artwork-wrap.is-playing .equalizer {
  opacity: 1;
}

.equalizer span {
  width: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.9);
  height: 8px;
  animation: eq 0.9s ease-in-out infinite;
}

.equalizer span:nth-child(1) { animation-delay: 0s; }
.equalizer span:nth-child(2) { animation-delay: 0.15s; }
.equalizer span:nth-child(3) { animation-delay: 0.3s; }
.equalizer span:nth-child(4) { animation-delay: 0.15s; }
.equalizer span:nth-child(5) { animation-delay: 0.45s; }

.hero__label {
  margin: 0 0 24px;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.status {
  min-height: 1.25rem;
  margin: 14px 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.status.error {
  color: #ff8fab;
}

.proxy-link {
  margin-top: 10px;
  border: none;
  background: none;
  color: #c9b3ff;
  font-size: 0.82rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 4px 8px;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  visibility: hidden;
  pointer-events: none;
}

.sheet.is-visible {
  visibility: visible;
  pointer-events: auto;
}

.sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sheet.is-open .sheet__backdrop {
  opacity: 1;
}

.sheet__panel {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: min(85dvh, 100%);
  display: flex;
  flex-direction: column;
  border-radius: 24px 24px 0 0;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.45);
  transform: translateY(100%);
  transition: transform 0.36s cubic-bezier(0.32, 0.72, 0, 1);
  will-change: transform;
}

.sheet.is-open .sheet__panel {
  transform: translateY(0);
}

.sheet__drag {
  flex-shrink: 0;
  padding: 10px 20px 0;
  touch-action: none;
  cursor: grab;
}

.sheet__drag.is-dragging {
  cursor: grabbing;
}

.sheet__handle {
  width: 40px;
  height: 5px;
  margin: 0 auto 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
}

.sheet__content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 20px 12px;
  -webkit-overflow-scrolling: touch;
}

.sheet__footer {
  flex-shrink: 0;
  padding: 12px 20px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}

.sheet__title {
  margin: 0;
  font-size: 1.15rem;
}

.sheet__hint {
  margin: 8px 0 12px;
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.sheet__input {
  width: 100%;
  resize: none;
  min-height: 110px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 16px;
  line-height: 1.5;
  touch-action: manipulation;
}

.sheet__input:focus {
  outline: 2px solid rgba(255, 61, 154, 0.45);
  outline-offset: 1px;
}

.sheet__feedback {
  min-height: 1.2em;
  margin: 10px 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.sheet__feedback.error {
  color: #ff8fab;
}

.sheet__actions {
  display: flex;
  gap: 10px;
}

.sheet__btn {
  flex: 1;
  height: 48px;
  border-radius: 14px;
  border: none;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.sheet__btn--ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.sheet__btn--primary {
  background: var(--accent);
  color: #fff;
}

body.sheet-open {
  overflow: hidden;
}

.hero-play {
  margin: 28px auto 0;
  min-width: 200px;
  height: 56px;
  padding: 0 28px;
  border: none;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #fff;
  color: var(--bg);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(255, 255, 255, 0.15);
  transition: transform 0.15s, background 0.2s, color 0.2s;
}

.hero-play:active {
  transform: scale(0.97);
}

.hero-play.is-playing {
  background: var(--accent);
  color: #fff;
}

.hero-play__icon {
  font-size: 1.1rem;
  line-height: 1;
}

.player-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: 0 var(--bar-inset) calc(10px + var(--safe-bottom));
  pointer-events: none;
}

.player-bar__main {
  pointer-events: auto;
  width: 100%;
  max-width: var(--bar-max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 10px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--bg-bar);
  backdrop-filter: blur(20px);
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  color: inherit;
  text-align: left;
}

.player-bar__artwork {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.85rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.player-bar__meta {
  flex: 1;
  min-width: 0;
}

.player-bar__title {
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-bar__status {
  display: block;
  margin-top: 2px;
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-bar__control {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fff;
  color: var(--bg);
  font-size: 1rem;
  transition: background 0.2s, color 0.2s;
}

.player-bar__main.is-playing .player-bar__control {
  background: var(--accent);
  color: #fff;
}

.install-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--bar-height) + var(--safe-bottom) + 12px);
  z-index: 30;
  padding: 0 var(--bar-inset);
  pointer-events: none;
}

.install-banner__inner {
  pointer-events: auto;
  width: 100%;
  max-width: var(--bar-max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(20, 10, 53, 0.96);
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.install-banner.hidden {
  display: none;
}

.install-banner p {
  flex: 1;
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.install-banner button {
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
}

#install-btn {
  background: var(--accent);
  color: #fff;
}

.install-banner__close {
  background: transparent;
  color: var(--text-soft);
  padding: 4px 8px;
}

@keyframes eq {
  0%, 100% { height: 8px; }
  50% { height: 26px; }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.08); opacity: 1; }
}

@media (min-width: 768px) {
  :root {
    --bar-inset: max(12px, calc((100vw - var(--bar-max-width)) / 2));
  }

  .hero-play:hover {
    transform: scale(1.02);
  }

  .player-bar__main:hover {
    border-color: rgba(255, 255, 255, 0.18);
  }
}

@media (prefers-reduced-motion: reduce) {
  .equalizer span,
  .artwork-glow,
  .sheet__panel,
  .sheet__backdrop {
    animation: none !important;
    transition: none !important;
  }
}
