:root {
  --bg: #0b0f14;
  --panel: rgba(20, 26, 35, 0.88);
  --text: #ffffff;
  --muted: #9aa4b2;
  --accent: #2563eb;
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 16px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  /* overflow: hidden; borttagen för att startsidan ska gå att scrolla */
  background: var(--bg);
}

body.viewer-mode,
body.start-mode {
  overflow: hidden;
}

/* Multiview Mode / Mini Mode */
.mini-mode .topbar,
.mini-mode .panel,
.mini-mode .viewer-stats {
  display: none !important;
}

.mini-mode .viewer-badge {
  top: 50%;
  left: 50%;
  right: auto;
  transform: translate(-50%, -50%);
  font-size: 16px;
  padding: 12px 20px;
  background: rgba(0,0,0,0.8);
}

/* Dölj badge helt i mini-mode när videon väl är igång */
.mini-mode.is-connected .viewer-badge {
  display: none !important;
}

.app {
  position: relative;
  width: 100%;
  height: 100dvh;
  background: #000;
  overflow: hidden;
}

video {
  width: 100%;
  height: 100%;
  /* MODIFIERAT: object-fit satt till contain istället för cover så hela bilden syns utan inzoomning */
  object-fit: contain;
  background: #000;
}

.topbar {
  position: absolute;
  top: env(safe-area-inset-top, 0);
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 14px 16px;
  background: linear-gradient(to bottom, rgba(0,0,0,.6), rgba(0,0,0,0));
}

.brand {
  font-size: 1rem;
  font-weight: 700;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(0,0,0,.4);
  border: 1px solid rgba(255,255,255,.1);
  font-size: .9rem;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
}

.dot.live {
  background: var(--success);
}

.panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: env(safe-area-inset-bottom, 0);
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  background: linear-gradient(to top, rgba(0,0,0,.85), rgba(0,0,0,0));
}

button,
.btnlink,
input,
select {
  appearance: none;
  outline: none;
  border-radius: 14px;
  padding: 14px 16px;
  min-height: 52px;
  font-size: 16px;
}

input,
select {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

button,
.btnlink {
  background: var(--panel);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}

button:active,
.btnlink:active {
  transform: scale(0.98);
}

.primary {
  background: var(--accent);
  color: #fff;
}

.secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
}

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

button {
  cursor: pointer;
  transition: all 0.2s ease;
}

button:hover,
.btnlink:hover {
  filter: brightness(1.1);
}

.card {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 90px;
  z-index: 9;
  background: rgba(17,24,39,.92);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 18px;
  padding: 16px;
  backdrop-filter: blur(10px);
  max-height: 58vh;
  overflow: auto;
}

.qrbox p {
  margin-top: 0;
}

.qrbox input {
  width: 100%;
  margin-bottom: 12px;
}

.qrbox img {
  width: 220px;
  max-width: 100%;
  display: block;
  margin: 12px auto 0;
  background: #fff;
  padding: 10px;
  border-radius: 12px;
}

.password-box {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,.06);
  color: #fff;
}

@media (max-width: 640px) {
  .panel {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .btnlink,
  button {
    text-align: center;
  }

  .card {
    bottom: 150px;
  }
}
