:root {
  color-scheme: dark;
  --accent: #7C9CFF;
  --bg: #090b10;
  --panel: #11151d;
  --panel-raised: #191f2b;
  --text: #f5f7fb;
  --muted: #9ba6b8;
  --danger: #ff7b8d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 15% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 42rem),
    var(--bg);
  color: var(--text);
}

button, input { font: inherit; }

button { cursor: pointer; }

.shell {
  width: min(100%, 96rem);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(1.25rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1.25rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  display: grid;
  align-content: center;
  gap: 1rem;
}

.masthead {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

.eyebrow {
  margin: 0 0 .35rem;
  color: var(--accent);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }

h1 {
  margin-bottom: .3rem;
  font-size: clamp(1.75rem, 7vw, 3.5rem);
  line-height: .95;
  letter-spacing: -.04em;
}

.description, .hint, .dialog p { color: var(--muted); }
.description { margin-bottom: 0; }
.hint { margin: 0; font-size: .85rem; text-align: center; }

.player {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  min-height: 14rem;
  background: #030405;
  border: 1px solid #283142;
  border-radius: 1.1rem;
  box-shadow: 0 2rem 6rem #0009;
}

video { width: 100%; height: 100%; object-fit: contain; background: #000; }

.scrim {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: linear-gradient(#080b10aa, #080b10e8);
  transition: opacity .25s ease;
}

.scrim.connected { opacity: 0; pointer-events: none; }

.state {
  display: grid;
  justify-items: center;
  gap: .45rem;
  color: var(--muted);
  text-align: center;
}

.state strong { color: var(--text); font-size: 1.1rem; }

.pulse {
  width: .75rem;
  height: .75rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  70% { box-shadow: 0 0 0 1rem transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.controls {
  position: absolute;
  inset: auto .65rem .65rem;
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .5rem;
  border: 1px solid #ffffff1c;
  border-radius: .8rem;
  background: #090c12dd;
  backdrop-filter: blur(1rem);
}

.controls button, .text-button {
  border: 0;
  border-radius: .55rem;
  background: transparent;
  color: var(--text);
}

.controls button {
  flex: 0 0 2.75rem;
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  padding: 0;
}

.text-button { padding: .55rem .7rem; }
.control-icon { width: 1.25rem; height: 1.25rem; pointer-events: none; }

.controls button:hover, .controls button:focus-visible, .text-button:hover, .text-button:focus-visible { background: #ffffff12; }

.volume-label { position: absolute; clip: rect(0 0 0 0); clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
#volume { width: min(22vw, 7rem); accent-color: var(--accent); }
.quality { margin-left: auto; padding: .35rem .55rem; border: 1px solid #ffffff1c; border-radius: 999px; color: var(--muted); font-size: .76rem; }

.dialog-backdrop {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  background: #05070bea;
  backdrop-filter: blur(1rem);
}

.dialog {
  width: min(100%, 27rem);
  padding: clamp(1.25rem, 5vw, 2rem);
  border: 1px solid #30394b;
  border-radius: 1.1rem;
  background: var(--panel);
  box-shadow: 0 2rem 6rem #000b;
}

.dialog label { display: block; margin-bottom: .45rem; font-weight: 700; }
.dialog input {
  width: 100%;
  border: 1px solid #3b465d;
  border-radius: .7rem;
  padding: .85rem;
  background: #090c12;
  color: var(--text);
}
.dialog input:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary {
  width: 100%;
  border: 0;
  border-radius: .7rem;
  padding: .85rem 1rem;
  background: var(--accent);
  color: #07090d;
  font-weight: 850;
}
.form-error { min-height: 1.3rem; margin: .55rem 0; color: var(--danger) !important; font-size: .85rem; }

[hidden] { display: none !important; }

@media (orientation: portrait) {
  .shell { align-content: start; }
  .masthead { align-items: start; flex-direction: column; }
  .player { width: calc(100% + max(2rem, env(safe-area-inset-left) + env(safe-area-inset-right))); margin-left: calc(-1 * max(1rem, env(safe-area-inset-left))); border-left: 0; border-right: 0; border-radius: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .pulse { animation: none; }
  .scrim { transition: none; }
}

.player:fullscreen { border: 0; border-radius: 0; }
.player:fullscreen .controls { padding-bottom: max(.5rem, env(safe-area-inset-bottom)); }
