:root {
  --pink: #ff7eb6;
  --violet: #8b5cf6;
  --ink: #1b1030;
  --glass: rgba(20, 10, 40, 0.55);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #120a24;
  color: #fff;
  font-family: 'Segoe UI', 'Hiragino Sans', 'Yu Gothic UI', system-ui, sans-serif;
}

/* soft anime-style evening sky with drifting glow */
#sky {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(60vmax 40vmax at 20% 15%, rgba(255, 126, 182, 0.35), transparent 60%),
    radial-gradient(50vmax 35vmax at 85% 30%, rgba(139, 92, 246, 0.4), transparent 60%),
    radial-gradient(70vmax 50vmax at 50% 110%, rgba(56, 189, 248, 0.25), transparent 60%),
    linear-gradient(180deg, #1d1140 0%, #2a1458 45%, #120a24 100%);
  animation: drift 18s ease-in-out infinite alternate;
}

@keyframes drift {
  to {
    filter: hue-rotate(25deg) brightness(1.08);
  }
}

/* custom background set by Nog: fades in over the sky, darkened at the bottom so subtitles stay readable */
#bg {
  position: fixed;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 0.8s ease;
}

#bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.05) 40%, rgba(0, 0, 0, 0.45) 100%);
}

#bg.on {
  opacity: 1;
}

#stage {
  position: fixed;
  inset: 0;
  z-index: 1;
}

#avatar {
  position: absolute;
  inset: 0;
  transition: all 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

#avatar canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* while a video plays, the avatar slides into the corner and keeps reacting */
body.has-video #avatar {
  inset: auto 1.5vmin 1.5vmin auto;
  width: 30vmin;
  height: 38vmin;
  border-radius: 18px;
  background: var(--glass);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5), 0 0 0 2px rgba(255, 126, 182, 0.5);
  z-index: 3;
}

body.explicit #avatar {
  opacity: 0;
  transform: translateY(30%);
  pointer-events: none;
}

#video-wrap {
  position: absolute;
  inset: 2vmin 2vmin 2vmin 2vmin;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

#video {
  max-width: 100%;
  max-height: calc(100% - 3em);
  border-radius: 14px;
  background: #000;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

#video-bar {
  margin-top: 0.6em;
  display: flex;
  align-items: center;
  gap: 1em;
  max-width: 90%;
}

#video-title {
  font-weight: 600;
  opacity: 0.85;
  text-shadow: 0 2px 6px #000;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* per-viewer video volume */
#volume {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.3em 0.8em;
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(8px);
  cursor: pointer;
}

#volume-icon {
  width: 1.4em;
  text-align: center;
  user-select: none;
}

#volume-slider {
  width: clamp(80px, 14vw, 180px);
  accent-color: var(--pink);
  cursor: pointer;
}

/* subtitles in a speech bubble */
#bubble {
  position: absolute;
  left: 50%;
  bottom: 6vh;
  transform: translateX(-50%);
  max-width: min(88vw, 900px);
  padding: 0.7em 1.2em;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: clamp(16px, 2.6vmin, 28px);
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35), 0 0 0 3px var(--pink);
  z-index: 4;
  animation: pop 0.18s ease-out;
}

body.has-video #bubble {
  bottom: auto;
  top: 2vmin;
  font-size: clamp(14px, 2vmin, 22px);
}

@keyframes pop {
  from {
    transform: translateX(-50%) scale(0.92);
    opacity: 0;
  }
}

#loading {
  position: fixed;
  top: 2vmin;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.5em 1em;
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(8px);
  z-index: 5;
}

.spinner {
  width: 1em;
  height: 1em;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--pink);
  animation: spin 0.8s linear infinite;
}

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

#music {
  position: fixed;
  left: 2vmin;
  bottom: 2vmin;
  display: flex;
  align-items: center;
  gap: 0.5em;
  max-width: 45vw;
  padding: 0.45em 0.9em;
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(8px);
  font-size: clamp(12px, 1.8vmin, 18px);
  z-index: 5;
}

#music-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#music .note {
  color: var(--pink);
  animation: bob 1s ease-in-out infinite alternate;
}

@keyframes bob {
  to {
    transform: translateY(-3px);
  }
}

#sound {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 0.8em 1.6em;
  font: inherit;
  font-size: 1.3em;
  font-weight: 700;
  color: #fff;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--pink), var(--violet));
  box-shadow: 0 8px 30px rgba(139, 92, 246, 0.6);
  cursor: pointer;
  z-index: 10;
}

/* the model credit its licence asks for */
#credit {
  position: fixed;
  left: 1vmin;
  top: 1vmin;
  font-size: 10px;
  opacity: 0.45;
  z-index: 6;
  pointer-events: none;
}

#status {
  position: fixed;
  right: 1vmin;
  top: 1vmin;
  font-size: 11px;
  opacity: 0.45;
  z-index: 6;
}

/* music visualiser, between the background and the avatar */
#viz {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* pictures Nog posts slide in on the right (the game board sits on the left) */
#pics {
  position: fixed;
  right: 2vmin;
  top: 45%;
  transform: translateY(-50%);
  z-index: 5;
  pointer-events: none;
}

.pic {
  margin: 0;
  padding: 0.6vmin;
  max-width: 34vw;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 0 3px var(--pink);
  transform: translateX(130%) rotate(4deg);
  transition: transform 0.55s cubic-bezier(0.2, 0.9, 0.2, 1.2);
}

.pic.in {
  transform: translateX(0) rotate(2deg);
}

.pic img {
  display: block;
  max-width: 100%;
  max-height: 55vh;
  border-radius: 12px;
}

.pic figcaption {
  padding: 0.4em 0.3em 0.1em;
  color: var(--ink);
  font-weight: 700;
  font-size: clamp(12px, 1.8vmin, 18px);
  text-align: center;
}

/* game / poll board */
#board {
  position: fixed;
  left: 2vmin;
  top: 6vmin;
  width: min(42vw, 520px);
  padding: 1.2em 1.3em;
  border-radius: 20px;
  background: rgba(18, 10, 40, 0.82);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 0 2px rgba(57, 197, 187, 0.6);
  z-index: 6;
  font-size: clamp(13px, 1.9vmin, 20px);
  animation: pop-board 0.3s ease-out;
}

@keyframes pop-board {
  from {
    transform: scale(0.94);
    opacity: 0;
  }
}

.b-title {
  font-size: 0.85em;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #39c5bb;
  margin-bottom: 0.4em;
}

.b-text {
  font-size: 1.25em;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.8em;
}

.b-options {
  display: grid;
  gap: 0.45em;
}

.b-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.5em 0.7em;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  transition: all 0.3s ease;
}

.b-option.win {
  background: rgba(57, 197, 187, 0.35);
  box-shadow: 0 0 0 2px #39c5bb, 0 0 20px rgba(57, 197, 187, 0.6);
}

.b-option.lose {
  opacity: 0.45;
}

.b-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: rgba(255, 126, 182, 0.28);
  transition: width 0.5s ease;
}

.b-letter {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 1.6em;
  height: 1.6em;
  border-radius: 8px;
  background: var(--violet);
  font-weight: 800;
}

.b-label {
  position: relative;
  flex: 1;
}

.b-count {
  position: relative;
  font-weight: 800;
}

.b-timer {
  margin-top: 0.9em;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.b-timer-fill {
  height: 100%;
  background: linear-gradient(90deg, #39c5bb, var(--pink));
}

.b-timer.done {
  background: rgba(255, 80, 80, 0.5);
}

.b-scores {
  margin-top: 0.9em;
  display: grid;
  gap: 0.25em;
}

.b-score {
  display: flex;
  gap: 0.6em;
  align-items: center;
}

.b-rank {
  width: 1.6em;
  text-align: center;
  opacity: 0.8;
}

.b-name {
  flex: 1;
}

.b-pts {
  font-weight: 800;
  color: #39c5bb;
}

#video-next {
  flex: none;
  font-size: 0.85em;
  opacity: 0.7;
  max-width: 30vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

[hidden] {
  display: none !important;
}
