/* One visual language for the host's start and the invited viewer. */
:root{--entry-mint:#91ded0;--entry-ink:#f5f2e9;--entry-muted:#b5c5be}
a.brand{position:relative;display:block;width:max-content;max-width:100%;padding-left:43px;color:var(--entry-ink);font-size:21px;line-height:1;font-weight:780;letter-spacing:-1.2px;text-decoration:none}
a.brand:before,a.brand:after{content:"";position:absolute;left:0;top:4px;width:25px;height:15px;border:2px solid var(--entry-mint);border-radius:50%;transform:rotate(-35deg)}
a.brand:after{left:10px;top:12px;border-color:var(--entry-ink)}
a.brand span{display:block;margin-top:9px;color:#d0dfd5;font-size:8px;letter-spacing:2.3px;font-weight:500}
.lobby{left:clamp(28px,8vw,150px);width:min(670px,calc(100vw - 56px));top:clamp(130px,20vh,232px);padding-bottom:24px;max-height:calc(100dvh - 150px)}
.lobby h1{font-family:Manrope,system-ui,sans-serif;font-size:clamp(57px,6.8vw,99px);line-height:1.025;letter-spacing:-.071em;font-weight:510;margin:0 0 22px;text-wrap:balance}
.lobby p.entry-kicker{font-size:11px;letter-spacing:.16em;color:#c6e9d4;font-weight:700;margin:0 0 21px}
.lobby p.entry-lead{font-size:clamp(15px,1.2vw,18px);line-height:1.66;color:#edf4e8e7;max-width:520px;margin:0 0 28px;text-wrap:pretty}
.lobby-starts{max-width:310px}
.lobby-starts #startReality{font-size:14px;font-weight:720;padding:15px 23px;min-height:56px;min-width:265px;border-radius:999px;background:#d7f2c0;color:#17372f;box-shadow:0 5px 25px #07140b36}
.lobby-starts #startRealityLabel{font-size:inherit}
.lobby-starts #roomCreateError:not([hidden]){margin:2px 0 0;padding:2px 4px;color:#ffe3c7;font-size:13px;line-height:1.5}

.lobby p.entry-next{max-width:520px;font-size:12px;line-height:1.65;color:#c6d6cb;margin:17px 0 0}
.entry-divider{width:520px;max-width:100%;height:1px;background:#a9cebb55;margin:22px 0 18px}
.lobby p.entry-invite{font-size:12px;line-height:1.75;color:#dce9df;max-width:520px;margin:0 0 8px}
.entry-invite strong{color:#b8edda}
.lobby .subtle{font-size:11px;letter-spacing:.02em}
body:has(.lobby:not([hidden])) .vignette{background:linear-gradient(90deg,#071e1bdb 0%,#0a221dba 32%,#0b29252e 82%),linear-gradient(0deg,#081a1894,transparent 38%)}
body.page-viewer{height:auto;min-height:100dvh;overflow:auto;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:var(--entry-ink);background:radial-gradient(ellipse at 70% 15%,#244c3c 0%,#182b23 42%,#101a16 100%)}
.page-viewer .topbar{display:flex;justify-content:space-between;align-items:center;gap:12px;position:relative;padding:28px clamp(20px,4vw,48px);max-width:1340px;margin:0 auto;pointer-events:auto}
.page-viewer .viewer-role{font-size:10px;letter-spacing:.16em;font-weight:700;color:#b9d4c5}
.page-viewer main{max-width:1340px;padding:28px clamp(20px,4vw,48px) 52px;margin:0 auto}
.page-viewer .watch-layout{margin-top:0;gap:clamp(20px,3vw,42px);grid-template-columns:minmax(0,1fr) minmax(260px,320px)}
.page-viewer #destinationProvider{font-size:11px;letter-spacing:.16em;color:var(--entry-mint);margin:0 0 14px}
.page-viewer #destinationTitle{font-size:clamp(32px,4vw,58px);line-height:1.08;letter-spacing:-.04em}
.page-viewer .destination{color:#cfdfd3;font-size:15px}
.page-viewer .embed-player{background:#091912;border-color:#91ded03d;border-radius:17px;box-shadow:0 22px 60px #0005}
.page-viewer #participation{background:#202d26db;border:1px solid #a3d9bf35;border-radius:18px;padding:24px;box-shadow:0 16px 40px #05130d3b}
.page-viewer .primary,.page-viewer button{border-radius:10px;background:var(--entry-mint);color:#102e25;font-weight:650}
.page-viewer .room button,.page-viewer #cancelRideRequest,.page-viewer .broadcast-stage #watchStream{color:#e8f2ec;background:#2b4839}
.page-viewer button:hover,.page-viewer .primary:hover{filter:brightness(1.08)}
.page-viewer #participation input{background:#16261e;border:1px solid #8db9a15f;border-radius:10px}
.page-viewer .room,.page-viewer .ride-request,.page-viewer .viewer-reactions{border-color:#91ded036}
.page-viewer .room h2,.page-viewer .ride-request h2,.page-viewer .viewer-reactions h2{color:#eff8ef}
.page-viewer :is(a,button,input):focus-visible{outline:3px solid var(--entry-mint);outline-offset:3px}
@media(max-width:960px){.page-viewer .watch-layout{grid-template-columns:minmax(0,1fr)}.page-viewer #participation{max-width:none}}
@media(max-width:600px){.lobby{top:clamp(118px,18vh,180px);left:24px;width:calc(100vw - 48px);max-height:calc(100dvh - 130px)}.lobby h1{font-size:clamp(47px,11.2vw,67px);letter-spacing:-.065em;line-height:1.025}.lobby p.entry-lead{font-size:15px}.entry-kicker{font-size:9px}.page-viewer .topbar{padding:20px}.page-viewer .viewer-role{font-size:9px}.page-viewer main{padding:18px 20px 40px}.page-viewer #participation{padding:19px}.page-viewer .watch-layout{gap:22px}.page-viewer #destinationTitle{font-size:32px}}
@media(max-height:560px){.lobby{top:100px;max-height:calc(100dvh - 108px)}}

body:has(#lobby:not([hidden])) .ride-top,body:has(#lobby:not([hidden])) #connection{display:none}

.page-viewer button:disabled{opacity:.42;cursor:not-allowed;filter:none}

body:has(#lobby:not([hidden])) #setupToggle{display:none}

@media(max-width:360px) and (max-height:740px){.lobby{top:100px;max-height:calc(100dvh - 108px)}.lobby h1{font-size:40px;letter-spacing:-.065em;margin-bottom:12px}.lobby p.entry-lead{font-size:13px;line-height:1.45;margin-bottom:18px}.entry-divider{margin:14px 0 12px}.lobby p.entry-invite{font-size:11px;line-height:1.45}.lobby p.entry-next{font-size:11px;margin:12px 0 0}}

/* The broadcast identity and controls stay above the moving picture. Connection
   diagnostics remain available when needed, not as a permanent admin card. */
.page-viewer .broadcast-stage.has-broadcast #destinationProvider{margin:0 0 5px}
.page-viewer .broadcast-stage.has-broadcast #destinationTitle{font-size:clamp(27px,3vw,38px);line-height:1.14;margin:0 0 4px}
.page-viewer .broadcast-stage.has-broadcast .destination{font-size:13px;margin:0 0 14px}
.page-viewer .broadcast-stage.has-broadcast .playback-actions{margin:0 0 16px}
.page-viewer .broadcast-stage.has-broadcast .embed-player{margin:10px 0 12px}
@media(max-width:500px){
 .page-viewer .broadcast-stage.has-broadcast .destination{margin-bottom:10px}
 .page-viewer .broadcast-stage.has-broadcast .playback-actions{margin-bottom:10px}
 .page-viewer .broadcast-stage.has-broadcast .embed-player{margin-bottom:10px}
}


/* Admission and recovery share one clear panel instead of the host landing page. */
.lobby:has(#roomRecovery:not([hidden])){width:min(570px,calc(100vw - 56px));top:clamp(142px,25vh,244px)}
.lobby:has(#roomRecovery:not([hidden]))>:not(#roomRecovery){display:none}
.lobby:has(#roomRecovery:not([hidden])) #roomRecovery{
 display:block;margin:0;padding:clamp(22px,4vw,34px);
 background:linear-gradient(150deg,#182f28f0,#10221ef1);
 border:1px solid #9bcfb44d;border-radius:20px;
 box-shadow:0 20px 65px #020e0a7a
}
.lobby #roomRecovery h2{
 margin:0 0 15px;font-size:clamp(31px,5vw,43px);font-weight:560;
 line-height:1.08;letter-spacing:-.047em;color:var(--entry-ink)
}
.lobby #roomRecovery p{margin:0 0 23px;font-size:14px;line-height:1.65;color:#d6e8db}
.lobby #roomRecovery .row{display:flex;flex-wrap:wrap;gap:11px}
.lobby #roomRecovery button{min-height:46px;padding:12px 17px;border-radius:10px;font-size:13px;font-weight:620}
.lobby #roomRecovery #retryRoom:not([hidden]){background:#d7f2c0;color:#16362b;border:1px solid #d7f2c0}
.lobby #roomRecovery #clearRoom{background:#263e34;color:#e9f2eb;border:1px solid #a8ceb45f}
@media(max-width:520px){
 .lobby:has(#roomRecovery:not([hidden])){top:clamp(135px,20vh,195px);left:22px;width:calc(100vw - 44px)}
 .lobby #roomRecovery .row{display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}
 .lobby #roomRecovery .row:has(#retryRoom[hidden]):not(:has(#restoreSavedRide:not([hidden]))){grid-template-columns:minmax(0,1fr)}
 .lobby #roomRecovery button{padding:12px 9px;white-space:normal}
}


/* The host's first view should show a real place, not an empty canvas. This
   image is a recorded PandaSet source frame, never the room's live camera. */
.entry-scene{display:none;position:absolute;inset:0;margin:0;overflow:hidden;pointer-events:none;background:#0a201f;z-index:0}
body:has(#lobby:not([hidden])) .entry-scene{display:block}
.entry-scene img{position:absolute;inset:0 0 0 auto;display:block;width:77%;height:100%;object-fit:cover;object-position:56% center;filter:brightness(.82) saturate(.82) contrast(1.07)}
.entry-scene::after{content:"";position:absolute;inset:0;background:linear-gradient(90deg,#071b1b 0%,#071b1bf7 25%,#071b1bd9 42%,#071b1b65 62%,#071b1b05 89%),linear-gradient(0deg,#071b1bd6 0%,transparent 30%,transparent 66%,#071b1b9f 100%);pointer-events:none}
.entry-scene figcaption{position:absolute;z-index:1;right:34px;bottom:28px;max-width:50%;margin:0;text-align:right;color:#e6eee6;font-size:10px;font-weight:700;letter-spacing:.11em;text-shadow:0 1px 9px #07110f;line-height:1.7}
.entry-scene figcaption span{display:block;font-size:8px;font-weight:500;letter-spacing:.03em;color:#d0ddd9}
body:has(#lobby:not([hidden])) .stage>.vignette{z-index:1}
@media(max-width:760px){
 .entry-scene img{width:100%;object-position:53% center;filter:brightness(.56) saturate(.7) contrast(1.12)}
 .entry-scene::after{background:linear-gradient(90deg,#071b1bf0 0%,#071b1bc8 50%,#071b1b9e 100%),linear-gradient(0deg,#071b1bf4 0%,transparent 40%,#071b1b84 100%)}
 .entry-scene figcaption{right:18px;bottom:13px;max-width:82%;font-size:8px;opacity:.88}
 .entry-scene figcaption span{font-size:7px}
}

/* The stream is the main phone activity: use the full screen width while
   names, room controls and participation keep their comfortable text gutters. */
/* The loaded broadcast margin shorthand has higher specificity than the
   original bleed rule. Match it so phones do not acquire 20px page overflow. */
@media(max-width:500px){
 .page-viewer .broadcast-stage .embed-player,
 .page-viewer .broadcast-stage.has-broadcast .embed-player{width:calc(100% + 40px);margin-left:-20px;margin-right:-20px;border-left:0;border-right:0;border-radius:0}
}

/* Short landscape phones should open on the picture itself. Keep the channel
   name and seat action, but fold redundant provider/URL labels into the
   existing external-watch link below the frame. */
@media (min-width:730px) and (max-height:600px) and (orientation:landscape) {
 body.page-viewer .topbar {padding:8px 20px 0}
 body.page-viewer .topbar .brand {font-size:15px;line-height:1.15}
 body.page-viewer .topbar .brand span {display:none}
 body.page-viewer main {padding:6px 20px 24px}
 body.page-viewer .watch-layout {margin-top:0}
 body.page-viewer .broadcast-stage.has-broadcast #destinationProvider,
 body.page-viewer .broadcast-stage.has-broadcast .destination {display:none}
 body.page-viewer .broadcast-stage.has-broadcast #destinationTitle {font-size:20px;line-height:1.1;margin:0 0 6px}
 body.page-viewer .broadcast-stage.has-broadcast .embed-player {margin:0 0 8px}
}

/* --- Active session responsive zero-overlap topbar --- */
body:not(:has(#lobby:not([hidden]))):not(.page-viewer) header.topbar {
  display: grid;
  grid-template-columns: minmax(72px, 1fr) minmax(0, auto);
  align-items: center;
  column-gap: 10px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) calc(24px + env(safe-area-inset-right, 0px)) 12px calc(24px + env(safe-area-inset-left, 0px));
  background: rgba(11, 18, 24, 0.88);
  border-bottom: 1px solid rgba(148, 163, 184, 0.26);
  backdrop-filter: blur(12px);
  z-index: 9;
}
body:not(:has(#lobby:not([hidden]))):not(.page-viewer) header.topbar > a.brand {
  min-width: 0;
  width: auto;
  max-width: 100%;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #f8fafc;
}
body:not(:has(#lobby:not([hidden]))):not(.page-viewer) header.topbar > .top-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}
body:not(:has(#lobby:not([hidden]))):not(.page-viewer) header.topbar > .top-actions > * {
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 760px) {
  body:not(:has(#lobby:not([hidden]))):not(.page-viewer) header.topbar {
    column-gap: 8px;
    padding: calc(8px + env(safe-area-inset-top, 0px)) calc(12px + env(safe-area-inset-right, 0px)) 8px calc(12px + env(safe-area-inset-left, 0px));
  }
  body:not(:has(#lobby:not([hidden]))):not(.page-viewer) header.topbar > a.brand {
    font-size: 15px;
    letter-spacing: 0.04em;
    line-height: 1.2;
    padding-left: 30px;
  }
  body:not(:has(#lobby:not([hidden]))):not(.page-viewer) header.topbar > a.brand::before,
  body:not(:has(#lobby:not([hidden]))):not(.page-viewer) header.topbar > a.brand::after {
    width: 18px;
    height: 11px;
    top: 2px;
  }
  body:not(:has(#lobby:not([hidden]))):not(.page-viewer) header.topbar > a.brand::after {
    left: 7px;
    top: 7px;
  }
  body:not(:has(#lobby:not([hidden]))):not(.page-viewer) header.topbar > a.brand span {
    display: none;
  }
  body:not(:has(#lobby:not([hidden]))):not(.page-viewer) header.topbar > .top-actions {
    gap: 5px;
  }
}
@media (max-width: 380px) {
  body:not(:has(#lobby:not([hidden]))):not(.page-viewer) header.topbar {
    grid-template-columns: minmax(68px, 1fr) minmax(0, auto);
    column-gap: 6px;
    padding: calc(8px + env(safe-area-inset-top, 0px)) calc(10px + env(safe-area-inset-right, 0px)) 8px calc(10px + env(safe-area-inset-left, 0px));
  }
  body:not(:has(#lobby:not([hidden]))):not(.page-viewer) header.topbar > a.brand {
    font-size: 13px;
    letter-spacing: 0.03em;
    padding-left: 26px;
  }
  body:not(:has(#lobby:not([hidden]))):not(.page-viewer) header.topbar > a.brand::before,
  body:not(:has(#lobby:not([hidden]))):not(.page-viewer) header.topbar > a.brand::after {
    width: 15px;
    height: 9px;
    top: 2px;
  }
  body:not(:has(#lobby:not([hidden]))):not(.page-viewer) header.topbar > a.brand::after {
    left: 6px;
    top: 6px;
  }
  body:not(:has(#lobby:not([hidden]))):not(.page-viewer) header.topbar > .top-actions {
    gap: 4px;
  }
  body:not(:has(#lobby:not([hidden]))):not(.page-viewer) header.topbar > .top-actions button {
    min-width: 0;
    padding: 7px 8px;
    font-size: 11px;
  }
}
@media (min-width: 521px) and (max-height: 500px) {
  body:not(:has(#lobby:not([hidden]))):not(.page-viewer) header.topbar {
    padding: calc(6px + env(safe-area-inset-top, 0px)) calc(14px + env(safe-area-inset-right, 0px)) 6px calc(14px + env(safe-area-inset-left, 0px));
  }
  body:not(:has(#lobby:not([hidden]))):not(.page-viewer) header.topbar > a.brand {
    font-size: 15px;
    letter-spacing: 0.04em;
    line-height: 1.2;
    padding-left: 30px;
  }
  body:not(:has(#lobby:not([hidden]))):not(.page-viewer) header.topbar > a.brand span {
    display: none;
  }
  body:not(:has(#lobby:not([hidden]))):not(.page-viewer) header.topbar > .top-actions button {
    min-height: 40px;
    padding: 6px 10px;
  }
}
