:root {
  /* Cotodama-style monochrome + a single point colour */
  --bg: #060606;
  --ink: #f4f2ee; /* near-white text */
  --dim: rgba(244, 242, 238, 0.34); /* secondary fragments */
  --faint: rgba(244, 242, 238, 0.14); /* background lines */
  --accent: #ff3b30; /* the one point colour (used sparingly) */
  --font: "Pretendard", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
  color: #fff;
  font-family: "Noto Sans KR", "Poppins", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(
    ellipse at center,
    transparent 40%,
    rgba(0, 0, 0, 0.55) 100%
  );
}

.hidden {
  display: none !important;
}

/* ---------- start screen ---------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 24px;
}

.start-card {
  width: min(560px, 100%);
  background: rgba(14, 16, 26, 0.55);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  padding: 40px 36px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}

.logo {
  font-family: "Poppins", sans-serif;
  font-weight: 800;
  font-size: clamp(38px, 7vw, 56px);
  letter-spacing: -2px;
  line-height: 1;
  color: var(--ink);
}
.logo span {
  color: var(--accent);
}

.tagline {
  margin: 10px 0 28px;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 300;
  font-size: 15px;
}

.field {
  display: block;
  margin-bottom: 16px;
}
.field span {
  display: block;
  font-size: 12px;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 8px;
  text-transform: uppercase;
}
.field input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.22);
}

.advanced {
  margin-bottom: 20px;
}
.advanced summary {
  cursor: pointer;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.45);
  user-select: none;
  padding: 6px 0;
}
.advanced summary:hover {
  color: rgba(255, 255, 255, 0.7);
}
.adv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}
.adv-grid .field {
  margin-bottom: 0;
}

.go {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 700;
  font-family: inherit;
  color: #fff;
  cursor: pointer;
  background: var(--accent);
  transition: transform 0.15s, box-shadow 0.2s, filter 0.2s;
  box-shadow: 0 14px 40px rgba(255, 59, 48, 0.32);
}
.go:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}
.go:active {
  transform: translateY(0);
}
.go:disabled {
  opacity: 0.6;
  cursor: progress;
}

.status {
  margin-top: 14px;
  min-height: 18px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.55);
  text-align: center;
}
.status.error {
  color: #ff6b8a;
}

/* ---------- lyric stage — Cotodama-style scattered kinetic typography ---------- */
.stage {
  position: fixed;
  inset: 0;
  z-index: 4;
}

/* full-viewport canvas; fragments are absolutely positioned inside */
.lyrics {
  position: fixed;
  inset: 0;
  z-index: 4;
  overflow: hidden;
}

/* one lyric fragment, placed at (--x,--y) and tilted by --rot */
.frag {
  position: absolute;
  left: var(--x, 50%);
  top: var(--y, 50%);
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
  max-width: 82vw;
  text-align: var(--align, center);
  line-height: 1;
  font-family: var(--font); /* unified gothic (Pretendard) */
  font-weight: 500;
  letter-spacing: -0.02em;
  word-break: keep-all;
}
.frag .inner {
  display: inline-block;
  will-change: opacity, translate, scale, filter;
}
/* continuous-motion layer (zoom / rotate / drift while a fragment is live) */
.frag .motion {
  display: inline-block;
  will-change: transform;
}

/* weight tiers (single font, varied weight for structure) */
.w-thin { font-weight: 300; }
.w-mid  { font-weight: 500; }
.w-bold { font-weight: 800; }

/* colour roles (monochrome + one accent) */
.frag.c-hero { color: var(--ink); }
.frag.c-dim { color: var(--dim); }
.frag.c-accent { color: var(--accent); }
.frag.c-outline {
  color: transparent;
  -webkit-text-stroke: 1.4px var(--dim);
  text-stroke: 1.4px var(--dim);
}

/* size tiers */
.frag.s-xl { font-size: clamp(48px, 10vw, 180px); }
.frag.s-l  { font-size: clamp(32px, 6vw, 100px); }
.frag.s-m  { font-size: clamp(22px, 3.4vw, 52px); }
.frag.s-s  {
  font-size: clamp(15px, 2vw, 30px);
  letter-spacing: 0.04em;
}

/* ---------- continuous motion (class on .frag, animates .motion) — punchier ---------- */
.m-zin   .motion { animation: mZin   6s ease-in-out infinite alternate; }
.m-zout  .motion { animation: mZout  7s ease-in-out infinite alternate; }
.m-sway  .motion { animation: mSway  5s ease-in-out infinite alternate; }
.m-orbit .motion { animation: mOrbit 7s ease-in-out infinite alternate; }
.m-pulse .motion { animation: mPulse 2.8s ease-in-out infinite; }

@keyframes mZin   { from { transform: scale(0.92) rotate(-1.5deg); } to { transform: scale(1.22) rotate(1.5deg); } }
@keyframes mZout  { from { transform: scale(1.22) rotate(1.5deg);  } to { transform: scale(0.94) rotate(-1.5deg); } }
@keyframes mSway  { from { transform: rotate(-8deg) scale(1.02); } to { transform: rotate(8deg) scale(1.1); } }
@keyframes mOrbit { from { transform: translate(-0.12em, -0.08em) rotate(-5deg); } to { transform: translate(0.12em, 0.09em) rotate(5deg); } }
@keyframes mPulse { 0%, 100% { transform: scale(0.96); } 50% { transform: scale(1.14); } }

/* ---------- entrance / exit — bigger zoom + rotate impact ---------- */
/* secondary fragments zoom/rotate/whoosh in as a block */
.frag:not(.hero) .inner {
  animation: fragIn 0.8s both cubic-bezier(0.16, 1.1, 0.3, 1);
}
/* hero reveals character-by-character (stagger set inline) */
.frag.hero .c {
  display: inline-block;
  opacity: 0;
  animation: cUp 0.62s both cubic-bezier(0.18, 1.3, 0.32, 1);
}

/* every fragment exits together when the line changes */
.frag.out .inner {
  animation: fragOut 0.55s forwards cubic-bezier(0.5, 0, 0.75, 0) !important;
}
.frag.out .c {
  animation: none !important;
}

@keyframes fragIn {
  from { opacity: 0; translate: 0 0.7em; scale: 0.55; rotate: -14deg; filter: blur(12px); }
  to   { opacity: 1; translate: 0 0;     scale: 1;    rotate: 0deg;   filter: blur(0); }
}
@keyframes fragOut {
  to { opacity: 0; translate: 0 -0.5em; scale: 1.45; rotate: 12deg; filter: blur(16px); }
}
@keyframes cUp {
  from { opacity: 0; transform: translateY(1em) rotate(16deg) scale(0.4); }
  to   { opacity: 1; transform: none; }
}

/* instrumental / intro placeholder */
.frag.note {
  font-family: "Poppins", sans-serif;
}
.frag.note .inner {
  animation: fragIn 0.7s both, spin 18s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .frag .inner, .frag .c { animation-duration: 0.001s !important; }
}

.now-playing {
  position: fixed;
  bottom: 4vh;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 13px;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.3);
  z-index: 4;
  pointer-events: none;
}

/* ---------- controls ---------- */
.controls {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 16px;
  background: rgba(10, 12, 20, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.4s, transform 0.4s;
  pointer-events: none;
}
.controls.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.controls.idle {
  opacity: 0;
  pointer-events: none;
}

.ctrl {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.ctrl:hover {
  background: rgba(255, 255, 255, 0.18);
}
.ctrl:active {
  transform: scale(0.92);
}

.track-info {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.65);
  max-width: 240px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 0 4px;
}

/* keep the youtube iframe present (audio) but out of sight */
#player-host {
  position: fixed;
  width: 1px;
  height: 1px;
  left: -9999px;
  top: -9999px;
  overflow: hidden;
  opacity: 0.01;
  pointer-events: none;
}

@media (max-width: 600px) {
  .adv-grid {
    grid-template-columns: 1fr;
  }
  .track-info {
    display: none;
  }
}
