:root {
  --bg: #000;
  --fg: #f4f1ea;
  --muted: rgba(244, 241, 234, 0.5);
  --line: rgba(255, 255, 255, 0.09);
  --glass: rgba(18, 18, 20, 0.42);
  --gold: #f2c46b;
  --glow: #ff3d9a;
  --card-w: min(calc(100vw - 32px), clamp(290px, 46vh, 400px));
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "Manrope", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ——— переключение тем ——— */
:root:not([data-theme="dark"]) .ui-dark,
:root:not([data-theme="dark"]) .stage,
:root:not([data-theme="dark"]) .corners,
:root:not([data-theme="minecraft"]) .ui-mc,
:root:not([data-theme="minecraft"]) .room,
:root:not([data-theme="outlast"]) .ui-ol { display: none; }
:root[data-theme="minecraft"] body { background: #141418; }
:root[data-theme="outlast"] body { background: #050705; }

/* зерно и виньетка поверх всего (только Dark) */
:root[data-theme="dark"] body::before,
:root[data-theme="dark"] body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}
:root[data-theme="dark"] body::before {
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.75) 100%);
}
:root[data-theme="dark"] body::after {
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 0.9s steps(4) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-3%, 2%); }
  50% { transform: translate(2%, -3%); }
  75% { transform: translate(-2%, -1%); }
}

/* ——— летающая голова ——— */
.stage {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.head {
  position: absolute;
  top: 0;
  left: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  pointer-events: auto;
  will-change: transform;
  -webkit-tap-highlight-color: transparent;
}
.head img {
  display: block;
  height: clamp(110px, 22vmin, 220px);
  width: auto;
  user-select: none;
  filter: drop-shadow(0 0 28px var(--glow)) drop-shadow(0 0 2px rgba(0, 0, 0, 0.6));
  transition: filter 0.6s var(--ease);
}
.head.pop img { animation: pop 0.45s var(--ease); }
@keyframes pop {
  0% { transform: scale(0.6) rotate(-8deg); opacity: 0.2; }
  60% { transform: scale(1.08) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}

.corner-flash {
  position: fixed;
  width: 0;
  height: 0;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 0 0 var(--glow);
}
.corner-flash.on { animation: flash 1.1s var(--ease); }
@keyframes flash {
  0% { box-shadow: 0 0 0 0 var(--glow); opacity: 1; }
  100% { box-shadow: 0 0 120px 90px var(--glow); opacity: 0; }
}

/* ——— карточки ——— */
.stack {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px 16px;
  pointer-events: none;
}
.card {
  pointer-events: auto;
  width: var(--card-w);
  border-radius: 28px;
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  color: inherit;
  text-decoration: none;
  opacity: 0;
  transform: translateY(18px);
  animation: rise 0.9s var(--ease) forwards;
}
.fly { animation-delay: 0.12s; }
@keyframes rise { to { opacity: 1; transform: none; } }

/* альбом */
.album {
  display: block;
  padding: 12px 12px 14px;
  transform-style: preserve-3d;
  transition: transform 0.5s var(--ease), border-color 0.4s;
  --rx: 0deg;
  --ry: 0deg;
  --mx: 50%;
  --my: 30%;
}
.album.ready {
  opacity: 1;
  animation: none;
  transform: perspective(900px) rotateX(var(--rx)) rotateY(var(--ry));
}
.album:hover { border-color: rgba(255, 255, 255, 0.18); }
.album__art {
  position: relative;
  aspect-ratio: 1;
}
.album__cover,
.album__glow {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 18px;
  object-fit: cover;
}
.album__cover { z-index: 1; }
.album__glow {
  filter: blur(40px) saturate(1.6);
  opacity: 0.55;
  transform: scale(1.05) translateY(8%);
  animation: breathe 6s ease-in-out infinite;
}
@keyframes breathe {
  50% { opacity: 0.85; transform: scale(1.12) translateY(10%); }
}
.album__shine {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: 18px;
  background: radial-gradient(circle at var(--mx) var(--my), rgba(255, 255, 255, 0.28), transparent 45%);
  mix-blend-mode: overlay;
  opacity: 0;
  transition: opacity 0.4s;
}
.album:hover .album__shine { opacity: 1; }

.album__meta {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 6px 0 8px;
}
.eyebrow {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}
.album__title {
  display: block;
  margin-top: 4px;
  font-family: "Unbounded", sans-serif;
  font-weight: 700;
  font-size: clamp(15px, 4.6vw, 18px);
  letter-spacing: 0.01em;
  white-space: nowrap;
  background: linear-gradient(180deg, #fff3d1 0%, var(--gold) 55%, #b9832f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.go {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--fg);
  color: #000;
  transition: transform 0.45s var(--ease);
}
.album:hover .go { transform: rotate(45deg) scale(1.06); }
.album:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }

/* MUSTAFIN FLY — закрыто */
.fly {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px;
  cursor: not-allowed;
  user-select: none;
}
.fly__photo {
  position: relative;
  flex: none;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.fly__photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.55) brightness(0.5);
  transform: scale(1.05);
}
.lock { position: relative; color: var(--fg); opacity: 0.9; }
.fly__text { display: flex; flex-direction: column; gap: 4px; }
.fly__title {
  font-family: "Unbounded", sans-serif;
  font-weight: 500;
  font-size: 15px;
  letter-spacing: 0.04em;
  color: rgba(244, 241, 234, 0.55);
}
.fly__soon {
  font-size: 13px;
  font-weight: 500;
  background: linear-gradient(90deg, var(--muted) 0%, var(--muted) 40%, #fff 50%, var(--muted) 60%, var(--muted) 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 3.2s linear infinite;
}
@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: -150% 0; }
}
.fly.nope { animation: nope 0.4s ease; opacity: 1; transform: none; }
@keyframes nope {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
.fly:focus-visible { outline: 2px solid var(--muted); outline-offset: 4px; }

/* подписи внизу */
.hint,
.corners {
  position: fixed;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 11;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  pointer-events: none;
  transition: opacity 0.8s;
}
.hint { left: 50%; transform: translateX(-50%); white-space: nowrap; opacity: 0.6; }
.hint.gone { opacity: 0; }
.corners { right: 18px; opacity: 0; }
.corners.show { opacity: 0.6; }

/* кнопка звука и переключатель тем */
.topbar {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
  z-index: 12; /* над зерном и виньеткой */
  display: flex;
  gap: 8px;
}
.sound-btn {
  display: grid;
  place-items: center;
  width: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  color: var(--fg);
  cursor: pointer;
  transition: color 0.3s;
}
.sound-btn.is-muted { color: var(--muted); }
.spk-off, .is-muted .spk-on { display: none; }
.is-muted .spk-off { display: inline; }

.theme-switch {
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.theme-switch button {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font: 600 12px/1 "Manrope", sans-serif;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: color 0.3s, background-color 0.3s;
}
.theme-switch button:hover { color: var(--fg); }
.theme-switch button[aria-pressed="true"] { background: rgba(255, 255, 255, 0.1); color: var(--fg); }
.theme-switch svg { image-rendering: pixelated; }

@media (prefers-reduced-motion: reduce) {
  body::after, .album__glow, .fly__soon { animation: none; }
}
