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

:root {
  --bg:      #0d0d0d;
  --surface: #1a1a1a;
  --border:  #2e2e2e;
  --accent:  #e05c5c;
  --accent2: #5c8de0;
  --text:    #f0f0f0;
  --muted:   #888;
  --radius:  10px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px;
}

/* ── Layout ────────────────────────────────────────────────────────────────── */

.screen {
  display: none;
  min-height: 100vh;
  padding: 24px 16px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.screen.active { display: flex; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 420px;
}

.logo {
  text-align: center;
  margin-bottom: 28px;
}
.logo h1 {
  font-size: 1.5rem;
  letter-spacing: -0.5px;
}
.logo span { color: var(--accent); }
.logo p { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 7px;
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary   { background: var(--accent);  color: #fff; }
.btn-secondary { background: var(--accent2); color: #fff; }
.btn-ghost     { background: var(--border);  color: var(--text); }
.btn-danger    { background: #7a1c1c; color: #ffa0a0; }
.btn-full      { width: 100%; }
.btn:hover:not(:disabled) { opacity: .85; }

/* ── Form Elements ─────────────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 0.82rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }

input[type="text"],
input[type="password"],
select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  width: 100%;
  transition: border-color .15s;
}
input:focus, select:focus { border-color: var(--accent2); }

.row { display: flex; gap: 10px; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.8rem;
  margin: 20px 0;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Stream ID badge ───────────────────────────────────────────────────────── */

.stream-id-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  word-break: break-all;
}
.stream-id-box .sid {
  font-family: monospace;
  font-size: 1.05rem;
  color: var(--accent2);
  letter-spacing: 1px;
}
.copy-btn {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 5px;
  padding: 4px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.copy-btn:hover { color: var(--text); border-color: var(--text); }

.share-url {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 18px;
  word-break: break-all;
}

.viewer-count {
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
  margin-top: 8px;
}

/* ── Video ─────────────────────────────────────────────────────────────────── */

#watch-screen {
  padding: 0;
  background: #000;
  justify-content: flex-start;
}

.watch-layout {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.video-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  min-height: 0;
}

video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.watch-bar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 12px;
}

.watch-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e05c5c;
  animation: pulse 1.4s infinite;
  flex-shrink: 0;
}
.live-dot.offline { background: var(--muted); animation: none; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .3; }
}

.watch-sid {
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ── Broadcast screen ──────────────────────────────────────────────────────── */

#broadcast-screen {
  padding: 0;
  background: #000;
  justify-content: flex-start;
}

.broadcast-layout {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.preview-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  min-height: 0;
  position: relative;
}

.preview-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scaleX(-1); /* mirror local preview */
}

.broadcast-bar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.broadcast-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.broadcast-info .bid-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.broadcast-info .bid-val {
  font-family: monospace;
  font-size: 0.88rem;
  color: var(--accent2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Status / Alerts ───────────────────────────────────────────────────────── */

.status-msg {
  text-align: center;
  padding: 12px;
  border-radius: 7px;
  font-size: 0.88rem;
  margin-bottom: 14px;
}
.status-msg.error   { background: #3a1010; color: #ffa0a0; border: 1px solid #7a2020; }
.status-msg.info    { background: #0d1f3a; color: #a0c0ff; border: 1px solid #1e3a7a; }
.status-msg.success { background: #0d3a1a; color: #a0ffb0; border: 1px solid #1e7a3a; }
.status-msg.hidden  { display: none; }

/* ── Spinner ───────────────────────────────────────────────────────────────── */

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent2);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Overlay on video ──────────────────────────────────────────────────────── */

.video-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.7);
  color: var(--text);
  gap: 12px;
  text-align: center;
  padding: 20px;
}
.video-overlay.hidden { display: none; }
.video-overlay p { color: var(--muted); font-size: 0.9rem; }

/* ── Blackout overlay ──────────────────────────────────────────────────────── */

#blackout-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
#blackout-overlay.hidden { display: none; }

#blackout-hint {
  color: rgba(255,255,255,.4);
  font-size: 0.82rem;
  animation: fadeHint 4s forwards;
  pointer-events: none;
}

@keyframes fadeHint {
  0%, 50% { opacity: 1; }
  100%     { opacity: 0; }
}

@media (max-width: 480px) {
  .card { padding: 22px 18px; }
  .watch-bar, .broadcast-bar { flex-wrap: wrap; }
}
