:root {
  --bg: #05040b;
  --ink: #f6f3ff;
  --muted: rgba(236, 230, 255, .66);
  --line: rgba(255, 255, 255, .12);
  --violet: #a855f7;
  --lilac: #c084fc;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* ---------- scena 3D ---------- */
#scene { position: fixed; inset: 0; z-index: 1; }
#scene canvas { position: absolute; inset: 0; display: block; }
.css3d { position: absolute !important; inset: 0; pointer-events: none; z-index: 2; }
#sheet { display: none; }

/* ---------- schermata iniziale ---------- */
.enter {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: #000; cursor: pointer; outline: none;
  transition: opacity 1.2s ease .35s, visibility 0s 1.6s;
}
.enter.gone { opacity: 0; visibility: hidden; pointer-events: none; }

.loading { position: absolute; display: flex; gap: 8px; transition: opacity .3s; }
.loading i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--lilac);
  animation: dot 1s ease-in-out infinite;
}
.loading i:nth-child(2) { animation-delay: .15s; }
.loading i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 100% { opacity: .2; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-6px); } }
.enter.ready .loading { opacity: 0; }

.enter-inner { display: flex; align-items: center; gap: 12px; perspective: 400px; }
.enter-txt {
  display: flex;
  font: 600 clamp(24px, 4.2vw, 36px)/1 "Space Grotesk", Inter, sans-serif;
  color: #fff;
  letter-spacing: .01em;
}
.ch {
  display: inline-block;
  opacity: 0;
  transform: translateY(22px) rotateX(80deg);
  filter: blur(8px);
  text-shadow: 0 0 18px rgba(192, 132, 252, .55);
}
.enter.ready .ch {
  animation: chIn .75s cubic-bezier(.2, .8, .2, 1) forwards, chGlow 3s ease-in-out infinite;
  animation-delay: calc(var(--i) * 55ms + 120ms), calc(var(--i) * 90ms + 1.6s);
}
@keyframes chIn { to { opacity: 1; transform: none; filter: blur(0); } }
@keyframes chGlow {
  0%, 100% { text-shadow: 0 0 18px rgba(192, 132, 252, .5); }
  50% { text-shadow: 0 0 26px rgba(216, 180, 254, .95), 0 0 2px #fff; }
}
.enter.gone .ch {
  animation: chOut .55s ease-in forwards;
  animation-delay: calc(var(--i) * 22ms);
}
@keyframes chOut {
  from { opacity: 1; transform: none; filter: blur(0); }
  to { opacity: 0; transform: translateY(-20px) scale(1.25); filter: blur(10px); }
}

/* farfalle */
.fly {
  width: 34px; height: 34px;
  opacity: 0; transform: scale(.3) rotate(-20deg);
  filter: drop-shadow(0 0 8px rgba(192, 132, 252, .8));
  transition: opacity .6s ease, transform .8s cubic-bezier(.2, 1.6, .4, 1);
  overflow: visible;
}
.enter.ready .fly { opacity: 1; transform: none; transition-delay: .95s; }
.enter.ready .fly-l { animation: bob 2.2s ease-in-out 1.6s infinite; }
.enter.ready .fly-r { animation: bob 2.2s ease-in-out 2.1s infinite; }
.fly-r { transform: scale(.3) rotate(20deg); }
.enter.gone .fly { opacity: 0; transform: translateY(-40px) scale(.6); transition: .6s ease-in; }
.wing { transform-box: view-box; transform-origin: 20px 20px; animation: flap .32s ease-in-out infinite alternate; }
.fly-r .wing { animation-duration: .36s; animation-delay: -.1s; }
@keyframes flap { from { transform: scaleX(1); } to { transform: scaleX(.18); } }
@keyframes bob { 0%, 100% { translate: 0 0; rotate: -6deg; } 50% { translate: 0 -7px; rotate: 6deg; } }

/* ---------- tasto audio ---------- */
.vol {
  position: fixed; top: 16px; left: 16px; z-index: 40;
  width: 46px; height: 46px; border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(14, 11, 26, .6);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: #fff; display: grid; place-items: center; cursor: pointer;
  opacity: 0; transform: translateY(-10px); pointer-events: none;
  transition: opacity .5s, transform .5s, background .2s, color .2s;
}
.vol.show { opacity: 1; transform: none; pointer-events: auto; }
.vol:hover { background: rgba(60, 40, 100, .7); }
.vol.muted { color: rgba(255, 255, 255, .55); }
.vol svg { width: 21px; height: 21px; }

/* ---------- contenuti sulla lastra ---------- */
.el { color: var(--ink); text-shadow: 0 1px 2px rgba(0, 0, 0, .55); }
.el > .in {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transform: translateY(12px) scale(.96);
  filter: blur(6px);
  transition: opacity .8s ease, transform 1s cubic-bezier(.2, .8, .2, 1), filter .8s ease;
}
.el.show > .in { opacity: 1; transform: none; filter: blur(0); }

.avatar-slot img { display: none; }

.name > .in {
  font: 700 36px/1 "Space Grotesk", Inter, sans-serif;
  letter-spacing: -.01em; white-space: nowrap;
  text-shadow: 0 0 16px rgba(192, 132, 252, .75), 0 2px 4px rgba(0, 0, 0, .6);
}
.caret { font-weight: 400; color: var(--lilac); margin-left: 2px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.handle > .in { font-size: 14px; font-weight: 600; color: var(--muted); }
.bio > .in { font-size: 14.5px; line-height: 1.4; text-align: center; color: rgba(246, 243, 255, .9); }

.badges > .in { gap: 8px; }
.badge {
  position: relative;
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; font-size: 16px;
  background: rgba(10, 8, 20, .45);
  border: 1px solid var(--line);
  transition: transform .25s, background .25s, border-color .25s;
}
.badge:hover { transform: translateY(-3px); background: rgba(168, 85, 247, .25); border-color: rgba(192, 132, 252, .5); }
.badge::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%) translateY(4px);
  white-space: nowrap; font-size: 12px; font-weight: 600;
  padding: 5px 9px; border-radius: 7px;
  background: #17122b; border: 1px solid rgba(192, 132, 252, .35);
  opacity: 0; pointer-events: none; transition: .2s;
}
.badge:hover::after { opacity: 1; transform: translateX(-50%); }

/* riquadri */
.panel > .in { justify-content: flex-start; gap: 12px; padding: 0 12px; text-align: left; }
/* stile unico per icone, etichette e tasti */
.ico, .disc, .p-play {
  border: 1px solid rgba(192, 132, 252, .38);
  background: linear-gradient(160deg, rgba(255, 255, 255, .09), rgba(0, 0, 0, .28));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 0 16px -2px rgba(168, 85, 247, .35);
  color: #e9d5ff;
}
.ico { flex: none; width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; }
.ico svg { width: 23px; height: 23px; filter: drop-shadow(0 0 4px rgba(192, 132, 252, .6)); }

.txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.lbl {
  font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: #c4b5fd;
}
.user { font-weight: 600; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 14.5px; letter-spacing: .02em; }

.btn {
  flex: none;
  font: 700 12.5px/1 Inter, sans-serif; color: #f3e8ff;
  padding: 10px 14px; border-radius: 10px; cursor: pointer;
  background: rgba(168, 85, 247, .2);
  border: 1px solid rgba(192, 132, 252, .5);
  text-decoration: none; text-shadow: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 0 14px -4px rgba(168, 85, 247, .6);
  transition: background .2s, transform .2s, box-shadow .2s;
}
.btn:hover { background: rgba(168, 85, 247, .38); transform: translateY(-1px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .15), 0 0 20px -2px rgba(168, 85, 247, .8); }

/* player */
.disc {
  flex: none; width: 52px; height: 52px; border-radius: 50%;
  background:
    radial-gradient(circle, #0b0a14 0 13%, transparent 14%),
    radial-gradient(circle, rgba(192, 132, 252, .55) 0 30%, transparent 31%),
    repeating-radial-gradient(circle, rgba(255, 255, 255, .07) 0 1px, rgba(0, 0, 0, .25) 1px 3px);
  display: grid; place-items: center;
  animation: spin 3.2s linear infinite paused;
}
.disc span { width: 54%; height: 54%; border-radius: 50%; background: conic-gradient(from 40deg, transparent, rgba(255, 255, 255, .3), transparent 30%); }
.disc.on { animation-play-state: running; }
@keyframes spin { to { transform: rotate(360deg); } }
.p-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.p-title { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-artist { font-size: 12px; color: var(--muted); }
.p-bar { margin-top: 8px; height: 5px; border-radius: 9px; background: rgba(0, 0, 0, .4); cursor: pointer; position: relative; }
.p-bar::before { content: ""; position: absolute; inset: -8px 0; }
.p-fill { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #e9d5ff, var(--violet)); box-shadow: 0 0 10px rgba(192, 132, 252, .7); }
.p-times { display: flex; justify-content: space-between; margin-top: 5px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.p-play {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  cursor: pointer;
  display: grid; place-items: center;
  transition: transform .2s, background .2s;
}
.p-play:hover { transform: scale(1.08); background: rgba(168, 85, 247, .38); }
.p-play svg { width: 18px; height: 18px; }

/* scritta incisa sul metallo */
.foot > .in {
  font: 700 11px/1 Inter, sans-serif;
  letter-spacing: .38em; text-transform: lowercase;
  color: rgba(18, 15, 28, .7);
  text-shadow: 0 1px 0 rgba(255, 255, 255, .22);
}

/* ---------- salta intro ---------- */
.skip {
  position: fixed; right: 18px; bottom: 18px; z-index: 40;
  font: 600 13px/1 Inter, sans-serif; color: #f3e8ff;
  padding: 10px 14px; border-radius: 12px; cursor: pointer;
  background: rgba(14, 11, 26, .55);
  border: 1px solid rgba(192, 132, 252, .35);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity .5s, transform .5s, background .2s;
}
.skip.show { opacity: 1; transform: none; pointer-events: auto; }
.skip:hover { background: rgba(60, 40, 100, .7); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 60;
  transform: translate(-50%, 16px);
  padding: 10px 16px; border-radius: 12px;
  background: #17122b; border: 1px solid rgba(192, 132, 252, .4);
  font-size: 13.5px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: .3s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- versione piatta (se il 3D non parte) ---------- */
body.flat { overflow-y: auto; background: radial-gradient(60% 50% at 50% 30%, rgba(124, 58, 237, .25), transparent 70%), var(--bg); }
body.flat #scene { display: none; }
body.flat #sheet {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  min-height: 100%; padding: 60px 16px 40px; justify-content: center;
}
body.flat .el { width: min(var(--w), 100%); }
body.flat .avatar-slot img { display: block; width: 120px; height: 120px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 4px var(--lilac), 0 0 30px rgba(168, 85, 247, .6); }
body.flat .panel { padding: 12px 0; border-radius: 16px; background: #24212e; border: 1px solid var(--line); }
body.flat .foot > .in { color: var(--muted); text-shadow: none; }

@media (prefers-reduced-motion: reduce) {
  .ch, .fly, .wing { animation: none !important; }
}
