:root {
  --ink: #f5f2ff;
  --ink-soft: rgba(245, 242, 255, 0.72);
  --ink-faint: rgba(245, 242, 255, 0.5);
  --glass: rgba(255, 255, 255, 0.08);
  --glass-strong: rgba(255, 255, 255, 0.14);
  --line: rgba(255, 255, 255, 0.18);
  --accent: #ffd27a;
  --accent-ink: #231a05;
  --font: ui-rounded, system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  color-scheme: dark;
}

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

html, body { height: 100%; }

body {
  margin: 0;
  background: #0d0b1a;
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  overscroll-behavior: none;
}

.art {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

.stage {
  position: relative;
  z-index: 1;
  height: 100%;
  min-height: 100dvh;
  padding: calc(var(--safe-t) + 20px) calc(var(--safe-r) + 20px) calc(var(--safe-b) + 20px) calc(var(--safe-l) + 20px);
}

.screen[hidden] { display: none !important; }

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

.eyebrow {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ---------- Landing ---------- */
.landing {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  animation: rise 0.7s cubic-bezier(.2, .8, .2, 1) both;
}

.title {
  margin: 0 0 34px;
  max-width: 14ch;
  font-size: clamp(34px, 7.2vw, 74px);
  line-height: 1.02;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.name-form {
  width: min(640px, 100%);
  display: flex;
  gap: 10px;
  padding: 8px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.name-form:focus-within { border-color: rgba(255, 255, 255, 0.42); box-shadow: 0 0 0 4px rgba(255, 210, 122, 0.18), 0 20px 60px rgba(0, 0, 0, 0.35); }
.name-form.shake { animation: shake 0.42s; }

.name-input {
  flex: 1;
  min-width: 0;
  padding: 0 18px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: clamp(20px, 4.4vw, 30px);
  font-weight: 650;
  letter-spacing: -0.01em;
}
.name-input::placeholder { color: rgba(245, 242, 255, 0.42); font-weight: 500; }

.form-msg {
  min-height: 1.4em;
  margin: 14px 0 0;
  color: var(--accent);
  font-size: 15px;
}

.note {
  max-width: 36ch;
  margin: 6px 0 0;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink-faint);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--glass);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  font-weight: 650;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transition: transform 0.15s ease, background 0.2s, border-color 0.2s, opacity 0.2s;
}
.btn:active { transform: scale(0.96); }
.btn:focus-visible, .overlay-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn .icon { width: 20px; height: 20px; fill: currentColor; flex: none; }

@media (hover: hover) {
  .btn:hover:not(:disabled) { background: var(--glass-strong); border-color: rgba(255, 255, 255, 0.32); }
  .btn-play:hover, .btn-primary:hover:not(:disabled) { background: #ffdc94; }
}

.btn-play, .btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
}
.btn-play {
  min-height: 60px;
  padding: 0 28px 0 24px;
  font-size: 20px;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.btn-play .icon { width: 24px; height: 24px; }

.btn-round { width: 56px; min-height: 56px; padding: 0; }
.btn-round .icon { width: 24px; height: 24px; }
.btn-primary { width: 64px; min-height: 64px; }
.btn-primary .icon { width: 28px; height: 28px; margin-left: 3px; }
.btn-ghost { background: transparent; }

/* ---------- Player ---------- */
.player {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
  pointer-events: none;
  animation: fade 0.6s ease both;
}
.player-head, .player-foot { pointer-events: auto; }

.song-name {
  margin: 0;
  font-size: clamp(32px, 7vw, 68px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  overflow-wrap: anywhere;
  text-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}
.song-info {
  margin: 10px 0 0;
  font-size: 15px;
  color: var(--ink-soft);
}

.player-foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.progress {
  width: min(420px, 80%);
  height: 3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.hint {
  margin: 0;
  font-size: 14px;
  color: var(--ink-soft);
}
.hint[hidden] { display: none; }

/* ---------- Overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  background: rgba(10, 8, 22, 0.35);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: fade 0.4s ease both;
}
.overlay[hidden] { display: none; }
.has-overlay .landing { visibility: hidden; }

.overlay-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: calc(var(--safe-t) + 24px) calc(var(--safe-r) + 24px) calc(var(--safe-b) + 24px) calc(var(--safe-l) + 24px);
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
.overlay-ring {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 0 0 0 rgba(255, 210, 122, 0.5);
  animation: breathe 2.4s ease-in-out infinite;
}
.overlay-ring .icon { width: 40px; height: 40px; fill: currentColor; margin-left: 5px; }
.overlay-text {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.overlay-name {
  max-width: 100%;
  font-size: clamp(30px, 7vw, 64px);
  font-weight: 800;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  top: calc(var(--safe-t) + 16px);
  z-index: 10;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: #16122a;
  font-size: 15px;
  font-weight: 650;
  opacity: 0;
  transform: translate(-50%, -12px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  max-width: calc(100% - 32px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes shake {
  20% { transform: translateX(-8px); } 40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); } 80% { transform: translateX(3px); }
}
@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 210, 122, 0.45); transform: scale(1); }
  50% { box-shadow: 0 0 0 18px rgba(255, 210, 122, 0); transform: scale(1.04); }
}

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

/* ---------- Small screens ---------- */
@media (max-width: 560px) {
  .title { margin-bottom: 26px; }
  .name-form { flex-direction: column; border-radius: 28px; padding: 10px; }
  .name-input { min-height: 58px; text-align: center; padding: 0 12px; }
  .btn-play { width: 100%; }
  .btn-pill { padding: 0 16px; font-size: 15px; }
  .controls { gap: 8px; }
  .btn-ghost { flex-basis: 100%; max-width: 240px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .title { font-size: 34px; margin-bottom: 18px; }
  .song-name { font-size: 30px; }
  .player-foot { gap: 10px; }
}
