:root {
  --bg: #0d0d12;
  --accent: #eda3c4;
  --text-dim: rgba(255, 255, 255, 0.35);
  --error: #ffb3b3;
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  touch-action: none;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}
canvas:focus {
  outline: none;
}

#ident {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: var(--bg);
  transition:
    opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0.8s;
}

#ident.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#ident-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 3.7s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  background: #000;
}

#ident-video.ready {
  opacity: 1;
}

#loader-icon {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 210;
  width: 32px;
  height: 32px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1),
    scale 0.5s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0.5s;
}

#loader-icon.active {
  opacity: 1;
  visibility: visible;
}

#loader-icon svg {
  width: 100%;
  height: 100%;
  display: block;
  animation:
    loader-pulse 5s ease-in-out infinite,
    loader-wiggle 10s ease-in-out infinite;
}

@keyframes loader-pulse {
  0%,
  100% {
    opacity: 0.3;
    scale: 0.6;
  }
  50% {
    opacity: 0.6;
    scale: 0.85;
  }
}

@keyframes loader-wiggle {
  0%,
  66.6% {
    transform: rotate(0deg);
  }
  68.6% {
    transform: rotate(-5deg);
  }
  70.6% {
    transform: rotate(5deg);
  }
  72.6% {
    transform: rotate(-3deg);
  }
  74.6% {
    transform: rotate(3deg);
  }
  76.6% {
    transform: rotate(-1deg);
  }
  78.6%,
  100% {
    transform: rotate(0deg);
  }
}

#black-hold {
  position: fixed;
  inset: 0;
  z-index: 240;
  background: var(--bg);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0.6s;
}

#black-hold.active {
  opacity: 1;
  visibility: visible;
}

#black-hold.fade-out {
  opacity: 0;
  visibility: hidden;
}

#loading {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: var(--bg);
}

#loading.active {
  display: flex;
}

#loading-bar-track {
  width: min(280px, 60vw);
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

#loading-bar-track::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(237, 163, 196, 0.12),
    transparent
  );
  transform: translateX(-100%);
  animation: track-sweep 2s ease-in-out infinite;
}

#loading-bar {
  width: 0%;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  box-shadow: 0 0 10px var(--accent);
  transition: width 0.2s ease-out;
  position: relative;
  overflow: hidden;
}

#loading-bar::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.35),
    transparent
  );
  transform: translateX(-100%);
  animation: bar-shimmer 1.2s ease-in-out infinite;
}

#loading-text {
  margin-top: 14px;
  font-family: system-ui, sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  animation: text-pulse 2.4s ease-in-out infinite;
}

/* ── Play nav: peek & hover-reveal ── */
#play-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 400;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: rgba(13, 13, 18, 0.85);
  backdrop-filter: blur(10px);
  font-family:
    system-ui,
    -apple-system,
    sans-serif;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
  transform: translateY(-100%);
  visibility: hidden;
  transition:
    transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0.35s;
}

#play-nav.visible {
  visibility: visible;
  transform: translateY(calc(-100% + 0.25rem));
}

#play-nav.visible:hover,
#play-nav.visible:focus-within {
  transform: translateY(0);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.nav-brand:hover {
  color: var(--accent);
}

.nav-brand svg {
  display: block;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.nav-brand-text {
  display: none;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: #fff;
}

@media (min-width: 768px) {
  .nav-brand-text {
    display: inline;
  }
}

.nav-actions button {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.6);
  padding: 6px 14px;
  margin-left: 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: all 0.2s;
}

.nav-actions button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#play-menu {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: none;
  background: rgba(13, 13, 18, 0.96);
  backdrop-filter: blur(16px);
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

#play-menu.visible {
  display: flex;
}

.play-menu-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  text-align: center;
  cursor: default;
}

.play-menu-content a,
.play-menu-content button {
  font-family:
    system-ui,
    -apple-system,
    sans-serif;
  font-size: 18px;
  font-weight: 300;
  color: #fff;
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  letter-spacing: 0.02em;
}

.play-menu-content a:hover,
.play-menu-content button:hover {
  color: var(--accent);
}

#breakout {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: var(--bg);
}

#breakout.visible {
  display: flex;
}

#breakout-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0.35;
  filter: grayscale(0.7);
  pointer-events: none;
  background: #000;
}

.breakout-content {
  position: relative;
  z-index: 2;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  padding: 20px;
}

.breakout-title {
  font-family: system-ui, sans-serif;
  font-size: clamp(1.2rem, 4vw, 1.8rem);
  font-weight: 300;
  color: #fff;
  letter-spacing: 0.04em;
}

.breakout-sub {
  font-family: system-ui, sans-serif;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.4);
  max-width: 320px;
  line-height: 1.5;
}

.breakout-actions {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}

.breakout-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.7);
  padding: 8px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-family: system-ui, sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: all 0.2s;
}

.breakout-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#shell-error {
  display: none;
  position: absolute;
  bottom: 8%;
  left: 50%;
  transform: translateX(-50%);
  width: min(420px, 86vw);
  padding: 1rem 1.25rem;
  background: rgba(155, 57, 67, 0.15);
  border: 1px solid rgba(233, 69, 96, 0.3);
  border-radius: 0.6rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.5;
  color: var(--error);
  text-align: center;
  backdrop-filter: blur(4px);
  z-index: 300;
}

#shell-error.show {
  display: block;
}

@keyframes bar-shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}
@keyframes track-sweep {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}
@keyframes text-pulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 0.8;
  }
}

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