:root {
  --bg: #0b0e14;
  --bg-elev: #121724;
  --panel: #171d2c;
  --border: #252d40;
  --text: #e6e9f0;
  --muted: #8b94a8;
  --accent: #4f8cff;
  --accent-2: #8a5cff;
  --live: #ff3b5c;
  --ok: #2ecc71;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, .mono {
  font-family: var(--mono);
  font-size: 0.92em;
}

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* ---------- header ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.2px;
}
.brand:hover { text-decoration: none; }

.brand .logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  color: white;
  font-size: 14px;
}

/* ---------- landing ---------- */

.hero {
  padding: 56px 0 32px;
  text-align: center;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(28px, 4.5vw, 44px);
  letter-spacing: -0.5px;
}

.hero p {
  margin: 0 auto;
  max-width: 620px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
}

.keyform {
  display: flex;
  gap: 10px;
  max-width: 560px;
  margin: 28px auto 0;
}

.keyform input {
  flex: 1;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 16px;
  outline: none;
}
.keyform input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,140,255,0.2); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--accent);
  color: white;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
  white-space: nowrap;
}
.btn:hover { background: #3f7cf0; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn.secondary:hover { border-color: var(--accent); background: rgba(79,140,255,0.08); }
.btn.small { padding: 8px 12px; font-size: 13px; border-radius: 10px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  margin-top: 36px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.card .sub {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 14px;
}

.kv {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px 12px;
  font-size: 14px;
  align-items: center;
}
.kv dt { color: var(--muted); margin: 0; }
.kv dd {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.kv code {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 5px 8px;
  border-radius: 8px;
  overflow-wrap: anywhere;
}

.copy {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 12px;
}
.copy:hover { color: var(--text); border-color: var(--accent); }
.copy.done { color: var(--ok); border-color: var(--ok); }

.note {
  margin-top: 28px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

/* ---------- player ---------- */

.player-wrap {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 20px;
}

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}

.stage video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  opacity: 0;
  transition: opacity .4s ease;
}
.stage.live video { opacity: 1; }

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  background:
    radial-gradient(ellipse at center, rgba(79,140,255,0.10), transparent 60%),
    linear-gradient(180deg, #0d1119, #080a10);
  transition: opacity .4s ease;
}
.stage.live .overlay { opacity: 0; pointer-events: none; }

/* scanline texture for the offline screen */
.overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(255,255,255,0.025) 0px,
    rgba(255,255,255,0.025) 1px,
    transparent 1px,
    transparent 4px
  );
  animation: scan 8s linear infinite;
  pointer-events: none;
}
@keyframes scan {
  from { transform: translateY(0); }
  to   { transform: translateY(16px); }
}

.offline {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 24px;
}

.radar {
  position: relative;
  width: 128px;
  height: 128px;
  display: grid;
  place-items: center;
}

.radar .ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(79,140,255,0.55);
  animation: ripple 2.4s cubic-bezier(.2,.6,.2,1) infinite;
  opacity: 0;
}
.radar .ring:nth-child(2) { animation-delay: .8s; }
.radar .ring:nth-child(3) { animation-delay: 1.6s; }

@keyframes ripple {
  0%   { transform: scale(.35); opacity: .9; }
  70%  { opacity: .25; }
  100% { transform: scale(1.15); opacity: 0; }
}

.radar .mark {
  width: 64px;
  height: 64px;
  color: var(--text);
  filter: drop-shadow(0 0 18px rgba(79,140,255,0.75));
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.12); }
}

.offline .wordmark {
  display: block;
  width: auto;
  height: 26px;
  margin-top: -4px;
  opacity: 0.92;
}

.offline h2 {
  margin: 0;
  font-size: clamp(18px, 3vw, 26px);
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--text);
}

.offline p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.dots::after {
  content: "";
  display: inline-block;
  width: 1.4em;
  text-align: left;
  animation: dots 1.5s steps(4, end) infinite;
}
@keyframes dots {
  0%   { content: ""; }
  25%  { content: "."; }
  50%  { content: ".."; }
  75%  { content: "..."; }
}

.offline .key {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
}

.offline.error .radar .ring { border-color: rgba(255,59,92,0.55); }
.offline.error .radar .mark { filter: drop-shadow(0 0 18px rgba(255,59,92,0.7)); }

/* unmute hint */
.unmute {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: none;
  gap: 8px;
  align-items: center;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(10,12,18,0.75);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(6px);
}
.stage.live.muted .unmute { display: inline-flex; }

/* info bar */
.infobar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.infobar .left, .infobar .right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
}
.badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}
.badge.live { color: white; background: var(--live); border-color: var(--live); }
.badge.live::before { background: white; animation: blink 1.2s ease-in-out infinite; }
.badge.connecting { color: var(--accent); border-color: var(--accent); }
.badge.connecting::before { background: var(--accent); animation: blink 0.8s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .25; } }

.streamkey {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text);
}

.meta {
  color: var(--muted);
  font-size: 13px;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.seg button {
  background: transparent;
  color: var(--muted);
  border: 0;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--border); }
.seg button.active { background: rgba(79,140,255,0.15); color: var(--text); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all .25s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
  .keyform { flex-direction: column; }
  .kv { grid-template-columns: 1fr; }
}

/* ---------- embed (chromeless player for iframes, /embed/<key>) ---------- */

html.embed-root, body.embed {
  height: 100%;
  overflow: hidden;
  background: #000;
}

.embed .stage {
  position: fixed;
  inset: 0;
  width: auto;
  height: auto;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.embed .corner {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: opacity .3s ease;
}
.embed .corner .badge { backdrop-filter: blur(6px); background: rgba(18,23,36,0.75); }
.embed .corner .badge.live { background: var(--live); }
.embed .corner .meta {
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(18,23,36,0.75);
  font-size: 11px;
  backdrop-filter: blur(6px);
}
.embed .corner .meta:empty { display: none; }

.embed .watchlink {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(18,23,36,0.75);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  backdrop-filter: blur(6px);
  transition: opacity .3s ease;
}
.embed .watchlink:hover { text-decoration: none; border-color: var(--accent); }

/* while live, the overlays get out of the way until the viewer hovers */
.embed .stage.live .corner,
.embed .stage.live .watchlink { opacity: 0; }
.embed .stage.live:hover .corner,
.embed .stage.live:hover .watchlink,
.embed .stage.live:focus-within .corner,
.embed .stage.live:focus-within .watchlink { opacity: 1; }

.embed .corner[hidden], .embed .watchlink[hidden] { display: none; }

/* offline screen scales with the (possibly small) iframe */
.embed .offline { gap: clamp(8px, 2.5vmin, 18px); padding: 16px; }
.embed .radar { width: clamp(56px, 24vmin, 128px); height: clamp(56px, 24vmin, 128px); }
.embed .radar .mark { width: 50%; height: 50%; }
.embed .offline .wordmark { height: clamp(14px, 4.5vmin, 26px); }
.embed .offline h2 { font-size: clamp(12px, 3.6vmin, 26px); letter-spacing: clamp(2px, 0.6vmin, 4px); }
.embed .offline p { font-size: clamp(11px, 2.6vmin, 15px); }
.embed .offline .key { font-size: clamp(10px, 2.2vmin, 13px); padding: 4px 10px; }
.embed .unmute { bottom: 12px; padding: 8px 14px; font-size: 13px; }

@media (max-height: 180px) {
  .embed .offline .key, .embed .offline p, .embed .offline .wordmark { display: none; }
}
