:root {
  color-scheme: dark;
  --bg: #101214;
  --panel: #181d20;
  --panel-strong: #20272b;
  --text: #f4f7f7;
  --muted: #a8b3b5;
  --line: #334045;
  --accent: #2fd092;
  --accent-dark: #159361;
  --danger: #ff5d5d;
  --warning: #e4bb4d;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.home-shell,
.app-shell {
  width: min(100%, 1080px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
}

.home-hero {
  display: grid;
  align-content: center;
  gap: 28px;
  min-height: calc(100vh - 40px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 8vw, 58px);
  line-height: 1.03;
  letter-spacing: 0;
}

.lead {
  max-width: 620px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.65;
}

.entry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.entry-card {
  display: grid;
  gap: 12px;
  min-height: 180px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.entry-card strong {
  font-size: 24px;
}

.entry-card span:last-child {
  color: var(--muted);
}

.entry-icon {
  display: inline-grid;
  place-items: center;
  width: 58px;
  height: 34px;
  border: 1px solid rgba(47, 208, 146, 0.45);
  border-radius: 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding-bottom: 16px;
}

.topbar h1 {
  font-size: 24px;
}

.back-link,
.status-badge {
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
}

.status-badge {
  white-space: nowrap;
}

.status-badge[data-mode="online"] {
  border-color: rgba(47, 208, 146, 0.55);
  color: var(--accent);
}

.status-badge[data-mode="pending"] {
  border-color: rgba(228, 187, 77, 0.55);
  color: var(--warning);
}

.status-badge[data-mode="error"] {
  border-color: rgba(255, 93, 93, 0.55);
  color: var(--danger);
}

.setup-panel {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.join-form {
  display: grid;
  gap: 12px;
  padding: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d0f10;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
}

.switch-row {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.switch-row input {
  width: 22px;
  min-height: 22px;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.video-stage {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #050606;
}

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

.relay-frame {
  position: absolute;
  inset: 0;
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #050606;
}

.relay-frame[data-active="true"] {
  display: block;
}

.stage-overlay {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: grid;
  gap: 3px;
  max-width: calc(100% - 24px);
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.58);
  pointer-events: none;
}

.stage-overlay strong {
  font-size: 14px;
}

.stage-overlay span {
  color: var(--muted);
  font-size: 12px;
}

.control-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.events-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.events-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.events-header h2 {
  margin: 0;
  font-size: 20px;
}

.event-player {
  width: 100%;
  max-height: 420px;
  margin-bottom: 12px;
  border-radius: 8px;
  background: #050606;
}

.events-list {
  display: grid;
  gap: 10px;
}

.event-item {
  display: grid;
  grid-template-columns: 112px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111618;
}

.event-thumb {
  width: 112px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
  background: #050606;
}

.event-meta {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.event-meta strong {
  font-size: 15px;
}

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

.event-actions {
  display: flex;
  gap: 8px;
}

.event-actions button,
.event-actions a {
  display: inline-grid;
  place-items: center;
  min-width: 58px;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text);
  font-size: 13px;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.primary-button {
  background: var(--accent-dark);
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--panel-strong);
}

.danger-button {
  background: #8d2525;
}

.secondary-button[data-mode="online"] {
  border-color: rgba(47, 208, 146, 0.65);
  color: var(--accent);
}

.secondary-button[data-mode="error"] {
  border-color: rgba(255, 93, 93, 0.65);
  color: var(--danger);
}

.blackout-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  gap: 12px;
  align-content: center;
  background: #000;
  color: #2e3636;
}

.blackout-overlay span {
  font-size: 13px;
}

.blackout-exit-button {
  min-width: 180px;
  border: 1px solid #141919;
  background: #050606;
  color: #4a5555;
}

[hidden] {
  display: none !important;
}

@media (max-width: 680px) {
  .entry-grid,
  .control-bar {
    grid-template-columns: 1fr;
  }

  .event-item {
    grid-template-columns: 88px 1fr;
  }

  .event-thumb {
    width: 88px;
  }

  .event-actions {
    grid-column: 1 / -1;
  }

  .topbar {
    grid-template-columns: 1fr auto;
  }

  .back-link {
    grid-column: 1 / -1;
    width: fit-content;
  }

  .video-stage {
    aspect-ratio: 3 / 4;
    min-height: 420px;
  }
}
