/* stream.kl4us.com
   Mørkt tema, fordi siden mest bruges til at se video. Accentfarven er tennisboldens gulgrønne.
   Rummet: billedet er hovedopgaven og fylder højden. Panelet står ved siden af fra 1100 px og under billedet på smalle skærme. */

:root {
  --bg: #0b0d10;
  --bg-2: #12161b;
  --panel: #151a20;
  --line: #262d36;
  --line-2: #36404b;
  --text: #e9eef3;
  --muted: #9aa6b2;
  --accent: #c8f03c;
  --accent-ink: #141a05;
  --danger: #ff6b6b;
  --warn: #ffb020;
  --ok: #3ddc84;
  --radius: 12px;
  --gap: 16px;
  --panel-w: clamp(300px, 21vw, 400px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h2 { font-size: 15px; font-weight: 650; letter-spacing: .01em; }
p { margin: 0 0 .75em; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 1.25em; }

.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Knapper */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--bg-2);
  font-weight: 600; white-space: nowrap; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-danger { border-color: #6a2d2d; color: #ffc2c2; background: #2a1517; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn-lg { min-height: 56px; padding: 0 28px; font-size: 18px; border-radius: 14px; }
.btn-lg .ico { width: 24px; height: 24px; }
.btn-icon { width: 40px; padding: 0; }
.btn-sm.btn-icon { width: 36px; }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { border-color: #4a5664; background: #1a2027; }
  .btn-primary:hover { background: #d6f85e; border-color: #d6f85e; }
  .btn-danger:hover { background: #3a1a1d; }
  .btn-ghost:hover { color: var(--text); background: transparent; border-color: transparent; }
}
@media (pointer: coarse) {
  .btn, .btn-sm { min-height: 44px; }
  .btn-icon, .btn-sm.btn-icon { width: 44px; }
}
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

input[type="text"], select {
  width: 100%; min-height: 40px; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--bg); color: var(--text);
}
@media (pointer: coarse) { input[type="text"], select { min-height: 44px; font-size: 16px; } }

.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 750; font-size: 18px; letter-spacing: -.01em; }
.brand-ico { width: 26px; height: 26px; color: var(--accent); }
.brand-sub { color: var(--muted); font-weight: 500; }

/* ---------- Forside ---------- */
.home { min-height: 100vh; padding: 20px clamp(16px, 4vw, 48px) 48px; }
.home-top { max-width: 1280px; margin: 0 auto 24px; }
.home-grid {
  max-width: 1280px; margin: 0 auto; display: grid; gap: var(--gap);
  grid-template-columns: minmax(0, 1fr);
}
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: clamp(20px, 3vw, 36px); }
.hero h1 { font-size: clamp(28px, 3.4vw, 44px); letter-spacing: -.02em; max-width: 18ch; }
.lead { font-size: 17px; color: #c9d2db; max-width: 60ch; margin-bottom: 1.5em; }
.hero .btn-lg { margin-bottom: 10px; }
.hero .btn-ghost { margin-top: 8px; padding-left: 0; }
.note { padding: 12px 14px; border-radius: 10px; background: #1b2128; border: 1px solid var(--line-2); max-width: 60ch; }
.steps { margin: 0; padding-left: 1.3em; }
.steps li { margin-bottom: .5em; }
.recent { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.recent a { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); color: var(--text); text-decoration: none; min-height: 44px; }
.recent a span:last-child { color: var(--muted); }
@media (hover: hover) and (pointer: fine) { .recent a:hover { border-color: var(--line-2); } }

@media (min-width: 900px) {
  .home-grid { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); grid-template-areas: "hero info" "hero recent"; align-items: start; }
  .hero { grid-area: hero; align-self: stretch; display: flex; flex-direction: column; justify-content: center; min-height: 420px; }
  .home-grid > .card:nth-child(2) { grid-area: info; }
  #recent-card { grid-area: recent; }
}

/* ---------- TV venter ---------- */
.tv-wait { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 5vh 5vw; text-align: center; }
.tv-box { max-width: 1100px; }
.brand-lg { font-size: clamp(24px, 3vw, 44px); margin-bottom: 4vh; }
.brand-lg .brand-ico { width: 1.3em; height: 1.3em; }
.tv-label { font-size: clamp(18px, 2.2vw, 32px); color: var(--muted); margin: 0; }
.tv-code { font: 700 clamp(72px, 15vw, 240px)/1 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .06em; color: var(--accent); margin: 1vh 0 4vh; white-space: nowrap; }
.tv-help { font-size: clamp(18px, 2.2vw, 32px); max-width: 34ch; margin: 0 auto 2vh; }
.tv-status { color: var(--muted); font-size: clamp(14px, 1.5vw, 22px); }

/* ---------- Rum ---------- */
.room { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr); }
.topbar { display: flex; align-items: center; gap: 16px; padding: 8px 16px; min-height: 56px; border-bottom: 1px solid var(--line); background: var(--bg); }
.conn { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; min-width: 0; }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; }
.conn.ok .dot { background: var(--ok); }
.conn.bad .dot { background: var(--danger); }
.top-actions { margin-left: auto; display: flex; gap: 8px; }

.room-main {
  display: grid; gap: var(--gap); padding: var(--gap); min-height: 0;
  grid-template-columns: minmax(0, 1fr) var(--panel-w);
  grid-template-areas: "stage panel";
}
.room.panel-hidden .room-main { grid-template-columns: minmax(0, 1fr); grid-template-areas: "stage"; }
.room.panel-hidden .panel { display: none; }

.stage-wrap { grid-area: stage; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 10px; min-height: 0; min-width: 0; }
.stage { position: relative; min-height: 0; background: #000; border-radius: var(--radius); overflow: hidden; }
.stage video { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.stage[data-state="idle"] video, .stage[data-state="connecting"] video { opacity: 0; }

.overlay { position: absolute; top: 0; right: 0; bottom: 0; left: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; }
.overlay-idle { background: radial-gradient(ellipse at 50% 40%, #18202a 0%, #0b0d10 70%); }
.overlay-box { width: 100%; max-width: 560px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.overlay-box h2 { font-size: clamp(20px, 2.4vw, 30px); margin: 0; }
.overlay-box p { margin: 0; }
.invite-stage { width: 100%; margin-top: 12px; }
.tv-corner { color: var(--muted); }
.overlay-connecting { background: rgba(0, 0, 0, .55); gap: 14px; color: #dfe6ec; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid rgba(255,255,255,.15); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.unmute {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: inline-flex; align-items: center; gap: 10px; padding: 16px 26px; border-radius: 999px;
  border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 18px; cursor: pointer;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.unmute .ico { width: 24px; height: 24px; }
.badge-live { position: absolute; top: 12px; left: 12px; display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: rgba(0,0,0,.65); font-size: 13px; font-weight: 600; }
.badge-live .dot { width: 8px; height: 8px; border-radius: 50%; background: #ff4d4d; box-shadow: 0 0 0 0 rgba(255,77,77,.6); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255,77,77,.6); } 70% { box-shadow: 0 0 0 8px rgba(255,77,77,0); } 100% { box-shadow: 0 0 0 0 rgba(255,77,77,0); } }
.stats-overlay {
  position: absolute; top: 12px; right: 12px; margin: 0; padding: 10px 12px; max-width: calc(100% - 24px);
  background: rgba(0,0,0,.72); border-radius: 10px; font: 12.5px/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace; color: #dfe6ec; white-space: pre-wrap; pointer-events: none;
}

.controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-height: 48px; }
.controls-left, .controls-right { display: flex; align-items: center; gap: 8px; }
.controls-right { margin-left: auto; }
.controls-status { color: var(--muted); font-size: 14px; min-width: 0; flex: 1 1 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.controls-status .warn { color: var(--warn); }
.volume { display: flex; align-items: center; gap: 6px; }
.volume input { width: 110px; accent-color: var(--accent); }

/* Panel */
.panel { grid-area: panel; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-right: 2px; }
.panel-sec { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.panel-sec h2 { display: flex; align-items: center; gap: 8px; }
.count { color: var(--muted); font-weight: 500; }
.invite { display: flex; gap: 8px; }
.invite input { flex: 1 1 auto; min-width: 0; font-size: 13px; color: #c9d2db; }
.row-btns { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.field { display: grid; gap: 4px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.field select, .field input { color: var(--text); font-size: 14px; }
#sec-quality .btn { margin-top: 10px; }
.peers { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.peer { padding: 8px 10px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); }
.peer-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.peer-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.peer-you { color: var(--muted); font-weight: 400; }
.tag { margin-left: auto; flex: none; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #1f262e; color: var(--muted); }
.tag-live { background: #3a1416; color: #ffb3b3; }
.peer-stats { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.peer-stats .ok { color: var(--ok); }
.peer-stats .relay { color: var(--warn); }
.peer-stats .bad { color: var(--danger); }
.tips summary { cursor: pointer; font-weight: 650; min-height: 24px; }
.tips ul { margin: 10px 0 0; padding-left: 1.1em; color: #c9d2db; font-size: 14px; }
.tips li { margin-bottom: 8px; }

/* Smalle skærme: billedet øverst i 16:9, betjening under, panelet under det. */
@media (max-width: 1099px) {
  .room { height: auto; min-height: 100vh; grid-template-rows: auto auto; }
  .room-main, .room.panel-hidden .room-main { grid-template-columns: minmax(0, 1fr); grid-template-areas: "stage" "panel"; padding: 10px; gap: 12px; }
  .room.panel-hidden .panel { display: flex; }
  .only-wide { display: none; }
  .stage-wrap { grid-template-rows: auto auto; }
  .stage { height: 56.25vw; max-height: 72vh; }
  @supports (aspect-ratio: 16 / 9) { .stage { height: auto; aspect-ratio: 16 / 9; } }
  .panel { overflow: visible; }
}
@media (max-width: 640px) {
  .topbar { gap: 10px; padding: 6px 10px; }
  .top-actions .btn span { display: none; }
  .top-actions .btn { width: 44px; padding: 0; }
  .controls-status { order: 3; flex-basis: 100%; }
  .volume input { width: 80px; }
  .btn-lg { width: 100%; }
}
/* Telefon på langs: billedet fylder skærmen, resten ligger under. */
@media (max-width: 1099px) and (orientation: landscape) and (max-height: 560px) {
  .topbar { display: none; }
  .room-main { padding: 0 0 10px; }
  .stage { height: 100vh; height: 100dvh; max-height: none; border-radius: 0; }
  .controls { padding: 0 10px; }
}

/* Fuld skærm: kun billedet. Betjeningen ligger ovenpå og skjules, når musen holder stille. */
.stage-wrap:fullscreen { display: block; background: #000; }
.stage-wrap:fullscreen .stage { position: absolute; top: 0; left: 0; width: 100%; height: 100%; max-height: none; border-radius: 0; }
.stage-wrap:fullscreen .controls { position: absolute; left: 0; right: 0; bottom: 0; padding: 40px 24px 20px; background: linear-gradient(transparent, rgba(0,0,0,.8)); transition: opacity .25s; }
.stage-wrap:fullscreen.idle .controls { opacity: 0; pointer-events: none; }
.stage-wrap:fullscreen.idle { cursor: none; }
.stage-wrap:-webkit-full-screen { display: block; background: #000; width: 100%; height: 100%; }
.stage-wrap:-webkit-full-screen .stage { position: absolute; top: 0; left: 0; width: 100%; height: 100%; max-height: none; border-radius: 0; }
.stage-wrap:-webkit-full-screen .controls { position: absolute; left: 0; right: 0; bottom: 0; padding: 40px 24px 20px; background: linear-gradient(transparent, rgba(0,0,0,.8)); }

/* TV-tilstand: kun billedet, intet andet. Betjenes med fjernbetjeningens OK-knap. */
body.tv-mode { overflow: hidden; }
body.tv-mode .topbar, body.tv-mode .panel, body.tv-mode .controls { display: none !important; }
body.tv-mode .room { height: 100vh; min-height: 0; grid-template-rows: minmax(0, 1fr); }
body.tv-mode .room-main { padding: 0; grid-template-columns: minmax(0, 1fr); grid-template-areas: "stage"; }
body.tv-mode .stage-wrap { grid-template-rows: minmax(0, 1fr); }
body.tv-mode .stage { height: 100vh; max-height: none; border-radius: 0; aspect-ratio: auto; }
body.tv-mode #idle-share, body.tv-mode #idle-invite { display: none; }
body.tv-mode .overlay-box h2 { font-size: clamp(28px, 4vw, 56px); }
body.tv-mode .overlay-box p { font-size: clamp(18px, 2vw, 30px); }
body.tv-mode .unmute { font-size: clamp(20px, 2.4vw, 34px); padding: 1em 1.6em; }
body.tv-mode .unmute:focus { outline: 4px solid #fff; outline-offset: 4px; }

/* Dialoger og beskeder */
.dialog { border: 1px solid var(--line-2); border-radius: 16px; background: var(--panel); color: var(--text); padding: 24px; width: min(440px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(0,0,0,.6); }
.dialog h2 { font-size: 20px; }
.code-input { font: 700 32px/1 ui-monospace, Consolas, monospace !important; text-align: center; letter-spacing: .15em; margin-top: 8px; min-height: 60px !important; }
.dialog-msg { min-height: 1.5em; margin: 10px 0 0; color: var(--muted); }
.dialog-msg.ok { color: var(--ok); }
.dialog-msg.err { color: var(--danger); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: max-content; max-width: calc(100vw - 32px); pointer-events: none; }
.toast { background: #222a33; border: 1px solid var(--line-2); padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.4); transition: opacity .3s, transform .3s; text-align: center; }
.toast-error { border-color: #7a3333; background: #2d1719; }
.toast.out { opacity: 0; transform: translateY(6px); }
