:root {
  color-scheme: dark;
  --bg: #0b1224;
  --text: #e5e7eb;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: radial-gradient(1200px 700px at 40% 30%, #172554 0%, var(--bg) 55%, #070a14 100%);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji";
}

#stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  height: 100vh;
  background: transparent;
  overflow: hidden;
}

#stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.trivia {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  max-width: 560px;
  margin: 0 auto;
  overflow-y: auto;
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px));
  border-radius: 20px 20px 0 0;
  background: rgba(11, 18, 36, 0.5);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4);
  color: var(--text);
  transform: translateY(0);
  transition: transform 280ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 200ms ease;
}

.trivia.is-hidden {
  transform: translateY(110%);
  pointer-events: none;
  opacity: 0;
}

.trivia__inner {
  display: grid;
  gap: 10px;
}

.trivia__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.trivia__progress {
  font-size: 11px;
  opacity: 0.6;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 600;
}

.trivia__status {
  font-size: 12px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 200ms ease;
}

.trivia__status.is-success {
  opacity: 1;
  color: #4ade80;
}

.trivia__status.is-error {
  opacity: 1;
  color: #f87171;
}

.trivia__question {
  font-size: 15px;
  margin: 0;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0.15px;
}

.trivia__options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

@media (max-width: 480px) {
  .trivia__options {
    grid-template-columns: 1fr;
  }
}

.trivia__option {
  appearance: none;
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  color: inherit;
  padding: 8px 10px 8px 8px;
  font-family: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
}

.trivia__option:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

.trivia__option:focus-visible {
  outline: 2px solid rgba(99, 102, 241, 0.6);
  outline-offset: 2px;
}

.trivia__option:disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.trivia__option.is-hidden {
  display: none;
}

.trivia__option.is-correct {
  background: rgba(34, 197, 94, 0.2);
  border-color: rgba(74, 222, 128, 0.5);
}

.trivia__option.is-wrong {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(248, 113, 113, 0.5);
}

.trivia__letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  font-weight: 700;
  font-size: 11px;
}

.trivia__comment {
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  padding: 10px 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  opacity: 0;
  transition: opacity 300ms ease;
}

.trivia__comment.is-visible {
  opacity: 1;
}

.trivia.is-answered {
  background: rgba(0, 0, 0, 0.88);
}

.trivia.is-answered .trivia__question,
.trivia.is-answered .trivia__status,
.trivia.is-answered .trivia__comment,
.trivia.is-answered .trivia__progress {
  color: #f5f5f5;
}

.trivia.is-answered .trivia__option {
  color: #f5f5f5;
}

.trivia.is-answered .trivia__option:disabled {
  opacity: 0.5;
}

@media (min-width: 600px) {
  .trivia {
    padding: 18px 24px calc(18px + env(safe-area-inset-bottom, 0px));
  }

  .trivia__question {
    font-size: 17px;
  }

  .trivia__option {
    font-size: 14px;
    padding: 10px 12px 10px 10px;
  }

  .trivia__comment {
    font-size: 15px;
  }
}

.player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 101;
  max-width: 560px;
  margin: 0 auto;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  color: var(--text);
  transform: translateY(0);
  transition: transform 280ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 280ms ease;
}

.player.is-hidden {
  transform: translateY(-100vh);
  pointer-events: none;
  opacity: 0;
}

.player__inner {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
}

.player__btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 10px;
  padding: 0;
  transition: background 150ms ease;
}

.player__btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.player__icon--pause {
  display: none;
}

.player.is-playing .player__icon--play {
  display: none;
}

.player.is-playing .player__icon--pause {
  display: inline;
}

.player__info {
  min-width: 0;
}

.player__name {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.1px;
}

.player__artist {
  font-size: 10px;
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player__progress {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
}

.player__time,
.player__duration {
  font-size: 10px;
  opacity: 0.6;
  font-variant-numeric: tabular-nums;
  min-width: 26px;
}

.player__time {
  text-align: right;
}

.player__duration {
  text-align: left;
}

.player__bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.player__fill {
  height: 100%;
  width: 0%;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 2px;
  transition: width 100ms linear;
}

.player__bar:hover .player__fill {
  background: #4ade80;
}

.trivia__next {
  appearance: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  color: inherit;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease;
  flex: 1;
}

.trivia__next:hover {
  background: rgba(255, 255, 255, 0.15);
}

.trivia__next.is-hidden {
  display: none;
}

.trivia.is-answered .trivia__next {
  color: #f5f5f5;
}

.trivia__nav {
  display: flex;
  gap: 8px;
}

.trivia__prev {
  appearance: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  color: inherit;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease;
  flex: 1;
}

.trivia__prev:hover {
  background: rgba(255, 255, 255, 0.15);
}

.trivia__prev.is-hidden {
  display: none;
}

.trivia.is-answered .trivia__prev {
  color: #f5f5f5;
}

@media (min-width: 600px) {
  .player {
    padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .player__name {
    font-size: 13px;
  }

  .player__artist {
    font-size: 11px;
  }

  .player__time,
  .player__duration {
    font-size: 11px;
  }
}

.intro {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 24px;
  transition: opacity 1.5s ease;
}

.intro.is-fading-out {
  opacity: 0;
  pointer-events: none;
}

.intro.is-done {
  display: none;
}

.intro__text {
  color: #f5f5f5;
  text-align: center;
  max-width: 600px;
  font-size: 18px;
  line-height: 1.5;
  margin: 0;
  transition: opacity 1.5s ease;
  opacity: 0;
}

.intro__text.is-visible {
  opacity: 1;
}

.intro__btn {
  appearance: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  color: #f5f5f5;
  padding: 10px 24px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 1.5s ease, background 150ms ease;
}

.intro__btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.intro__btn.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.outro {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 24px;
  transition: opacity 1.5s ease;
}

.outro.is-hidden {
  display: none;
}

.outro.is-fading-out {
  opacity: 0;
  pointer-events: none;
}

.outro__text {
  color: #f5f5f5;
  text-align: center;
  max-width: 600px;
  font-size: 18px;
  line-height: 1.5;
  margin: 0;
  transition: opacity 1.5s ease;
  opacity: 0;
}

.outro__text.is-visible {
  opacity: 1;
}

.outro__btn {
  appearance: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  color: #f5f5f5;
  padding: 10px 24px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 1.5s ease, background 150ms ease;
}

.outro__btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.outro__btn.is-hidden {
  opacity: 0;
  pointer-events: none;
}

@media (min-width: 600px) {
  .intro__text {
    font-size: 24px;
  }

  .outro__text {
    font-size: 24px;
  }
}
