:root {
  /* Same palette as desertice.link */
  color-scheme: dark;

  --bg-primary: #0a0a0a;
  --bg-secondary: #141414;
  --text-primary: #FDFCFB;
  --text-secondary: rgba(253, 252, 251, 0.75);
  --accent-primary: #00e5ff;
  --accent-secondary: #0099cc;
  --border-color: rgba(0, 229, 255, 0.2);
  --border-hover: rgba(0, 229, 255, 0.5);
  --glass-bg: rgba(253, 252, 251, 0.04);
  --glass-hover: rgba(253, 252, 251, 0.08);
}

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

html,
body {
  height: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  color-scheme: dark;
  /* Horizontal overflow stays locked, but vertical scrolling must remain
     available so the status screen is reachable on short viewports. */
  overflow-x: hidden;
}

/* Only the live player locks scrolling entirely. */
body.is-live {
  overflow: hidden;
}

/* Visually hidden, still available to assistive tech. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Animated gradient background */
.bg-gradient {
  position: fixed;
  inset: 0;
  z-index: -2;
  background: var(--bg-primary);
  overflow: hidden;
}

.bg-gradient::before,
.bg-gradient::after {
  content: '';
  position: absolute;
  inset: 0;
  animation: gradientFloat 25s ease-in-out infinite;
}

.bg-gradient::before {
  background: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(0, 153, 204, 0.25) 0%, transparent 50%);
  animation-delay: 0s;
}

.bg-gradient::after {
  background:
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(0, 229, 255, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse 40% 30% at 10% 80%, rgba(0, 153, 204, 0.1) 0%, transparent 50%);
  animation-delay: -12.5s;
}

@keyframes gradientFloat {

  0%,
  100% {
    opacity: 0.4;
    transform: translateY(0px) scale(1);
  }

  20% {
    opacity: 0.6;
    transform: translateY(-40px) scale(1.05);
  }

  40% {
    opacity: 0.5;
    transform: translateY(-80px) scale(1.1);
  }

  60% {
    opacity: 0.55;
    transform: translateY(-40px) scale(1.08);
  }

  80% {
    opacity: 0.45;
    transform: translateY(-20px) scale(1.02);
  }
}

/* Subtle noise texture overlay */
.bg-noise {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

/* Twitch embed: fills the viewport when live.
   While offline it stays mounted but invisible (never display:none,
   so the player can finish initialising in the background). */
.live-embed {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  visibility: hidden;
  pointer-events: none;
  z-index: 1;
}

.live-embed iframe {
  width: 100% !important;
  height: 100% !important;
  border: 0;
  display: block;
}

body.is-live .live-embed {
  visibility: visible;
  pointer-events: auto;
}

/* Offline/checking status screen */
.offline-screen {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* Safe centering keeps content reachable when it outgrows short viewports. */
  justify-content: safe center;
  text-align: center;
  padding: 2rem 1.5rem;
  padding: max(2rem, env(safe-area-inset-top)) max(1.5rem, env(safe-area-inset-right))
    max(2rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left));
  animation: fadeInUp 0.6s ease-out;
}

body.is-live .offline-screen {
  display: none;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Avatar with rotating glow (from desertice.link) */
.avatar-wrapper {
  position: relative;
  width: 110px;
  height: 110px;
  margin-bottom: 1.25rem;
}

.avatar-glow {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: conic-gradient(from 0deg,
      var(--accent-primary),
      var(--accent-secondary),
      var(--accent-primary));
  animation: rotate 4s linear infinite;
  opacity: 0.6;
  filter: blur(8px);
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.avatar {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3px solid var(--accent-primary);
  z-index: 1;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.offline-screen h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.9rem;
  background: var(--glass-bg);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
  flex-shrink: 0;
}

.hint {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.actions {
  display: flex;
  gap: 0.875rem;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  padding: 0.875rem 1.5rem;
  background: var(--glass-bg);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  flex-shrink: 0;
}

.btn:hover {
  background: var(--glass-hover);
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow:
    0 8px 32px rgba(0, 229, 255, 0.15),
    0 0 0 1px rgba(0, 229, 255, 0.1);
}

.btn:active {
  transform: translateY(0);
  transition-duration: 0.1s;
}

.btn.primary {
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.12) 0%, rgba(0, 153, 204, 0.08) 100%);
  border-color: rgba(0, 229, 255, 0.35);
}

.btn.primary:hover {
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.2) 0%, rgba(0, 153, 204, 0.15) 100%);
  box-shadow:
    0 8px 40px rgba(0, 229, 255, 0.25),
    0 0 0 1px rgba(0, 229, 255, 0.2);
}

/* Focus styles for accessibility */
.btn:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .avatar-wrapper {
    width: 96px;
    height: 96px;
  }

  .offline-screen h1 {
    font-size: 1.5rem;
  }

  .actions {
    flex-direction: column;
    align-items: stretch;
    width: min(100%, 320px);
  }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
