/* Phone layout: a compact horizontal header, portrait camera preview, and thumb-sized controls. */
.preview-stage video.mirrored {
  transform: scaleX(-1);
}

@media (max-width: 700px) {
  html, body { width: 100%; min-width: 0; }
  body { min-height: 100svh; overflow-x: clip; }
  .shell {
    min-height: 100svh;
    flex-direction: column;
  }
  .rail {
    position: sticky;
    top: 0;
    z-index: 10;
    width: 100%;
    height: 58px;
    flex: 0 0 58px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 0 max(14px, env(safe-area-inset-left));
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand {
    padding: 0;
    gap: 8px;
    font-size: 14px;
  }
  .brand-mark { width: 29px; height: 29px; }
  .brand > span:not(.brand-mark) { display: inline; }
  .rail-label, .rail-bottom { display: none; }
  .rail-link, .rail-link:not(.active) {
    display: flex;
    width: auto;
    height: 36px;
    justify-content: center;
    gap: 6px;
    margin: 0;
    padding: 0 10px;
    font-size: 11px;
  }
  .rail-link.active {
    font-size: 11px;
    box-shadow: inset 0 -2px var(--lime);
  }
  .rail-icon { width: auto; margin: 0; font-size: 13px; }
  .rail-link .live-dot { display: block; width: 5px; height: 5px; }
  .main { width: 100%; min-height: calc(100svh - 58px); }
  .topbar { height: 42px; padding: 0 15px; }
  .breadcrumbs { font-size: 10px; }
  .top-actions { gap: 4px; }
  .secure { font-size: 8px; letter-spacing: .55px; }
  .icon-button { display: none; }
  .content { width: 100%; min-width: 0; padding: 15px 14px calc(18px + env(safe-area-inset-bottom)); }
  .eyebrow { gap: 7px; font-size: 9px; }
  .heading-row {
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin: 14px 0 14px;
  }
  h1 { font-size: clamp(32px, 8.5vw, 40px); line-height: 1; letter-spacing: -1.9px; }
  .subtitle { max-width: 100%; margin: 7px 0 0; font-size: 11px; line-height: 1.45; }
  .status-pill { flex: 0 0 auto; margin: 0 0 2px; padding: 7px 8px; font-size: 8px; letter-spacing: .4px; }
  .camera-layout { width: 100%; min-width: 0; grid-template-columns: minmax(0, 1fr); gap: 11px; }
  .preview-card { border-radius: 11px; }
  .preview-top { height: 39px; padding: 0 12px; }
  .preview-bottom { height: 37px; padding: 0 12px; font-size: 8px; }
  .preview-bottom #deviceLabel {
    max-width: 55%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
  }
  .preview-stage {
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
    aspect-ratio: 16 / 9;
  }
  .preview-stage video { object-fit: fill; background: #0d0f0c; }
  .stage-corner { width: 14px; height: 14px; }
  .stage-overlay { left: 17px; right: 17px; top: 16px; font-size: 8px; }
  .video-controls { right: 12px; bottom: 12px; gap: 8px; }
  .control-button {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    font-size: 18px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  .empty-state { padding: 18px; }
  .camera-glyph { width: 52px; height: 52px; margin-bottom: 13px; }
  .empty-copy { max-width: 250px; margin: 6px 0 15px; font-size: 11px; }
  .button { min-height: 44px; padding: 0 17px; font-size: 12px; touch-action: manipulation; }
  .side-column { display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; }
  .info-card { padding: 15px; border-radius: 10px; }
  .info-card .session-icon { width: 31px; height: 31px; margin: 13px 0 10px; }
  .info-card h3 { font-size: 16px; }
  .info-card p { font-size: 11px; line-height: 1.55; }
  .privacy-row { margin: 9px 0; font-size: 10px; }
  .tip-card { display: none; }
  .page-footer {
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 17px;
    padding-top: 12px;
    font-size: 7px;
    letter-spacing: .45px;
  }
  .page-footer a { font-size: 9px; }
}

@media (max-width: 380px) {
  .rail { padding-right: max(10px, env(safe-area-inset-right)); padding-left: max(10px, env(safe-area-inset-left)); }
  .rail-link, .rail-link:not(.active) { gap: 4px; padding: 0 7px; font-size: 10px; }
  .heading-row { align-items: flex-start; }
  .status-pill { margin-top: 4px; }
  .preview-stage { height: auto; max-height: none; aspect-ratio: 16 / 9; }
}

@media (max-width: 700px) and (orientation: landscape) {
  .content { padding-top: 12px; }
  .heading-row { align-items: center; margin: 10px 0 12px; }
  h1 { font-size: 30px; }
  .subtitle { margin-top: 5px; }
  .preview-stage { height: auto; min-height: 0; max-height: none; aspect-ratio: 16 / 9; }
  .preview-stage video { object-fit: fill; background: #0d0f0c; }
  .side-column { grid-template-columns: minmax(0, 1fr); }
}

/* Landscape phones often report a viewport wider than 700px; adapt by height too. */
@media (max-height: 500px) and (orientation: landscape) and (min-width: 701px) {
  html, body { width: 100%; min-width: 0; }
  body { min-height: 100dvh; overflow-x: clip; }
  .shell { min-height: 100dvh; flex-direction: column; }
  .rail {
    position: sticky; top: 0; z-index: 10; width: 100%; height: 44px; flex: 0 0 44px;
    flex-direction: row; align-items: center; justify-content: space-between;
    padding: 0 max(14px, env(safe-area-inset-left)); border-right: 0; border-bottom: 1px solid var(--line);
  }
  .brand { padding: 0; gap: 8px; font-size: 13px; }
  .brand-mark { width: 26px; height: 26px; }
  .brand > span:not(.brand-mark) { display: inline; }
  .rail-label, .rail-bottom { display: none; }
  .rail-link, .rail-link:not(.active) {
    display: flex; width: auto; height: 34px; justify-content: center; gap: 5px;
    margin: 0; padding: 0 10px; font-size: 10px;
  }
  .rail-icon { width: auto; margin: 0; font-size: 12px; }
  .rail-link .live-dot { display: block; width: 5px; height: 5px; }
  .main { width: 100%; min-height: 0; }
  .topbar { height: 34px; padding: 0 16px; }
  .content { width: 100%; min-width: 0; padding: 8px 18px 10px; }
  .eyebrow { font-size: 8px; }
  .heading-row { flex-direction: row; align-items: center; gap: 12px; margin: 6px 0 8px; }
  h1 { font-size: 25px; line-height: 1; letter-spacing: -1px; }
  .subtitle { display: none; }
  .status-pill { margin: 0; padding: 6px 8px; font-size: 8px; }
  .camera-layout { width: 100%; min-width: 0; grid-template-columns: minmax(0, 1fr); gap: 0; }
  .preview-top, .preview-bottom { height: 30px; padding: 0 12px; }
  .preview-stage { width: 100%; height: auto; min-height: 0; max-height: none; aspect-ratio: 16 / 9; }
  .preview-stage video { object-fit: fill; background: #0d0f0c; }
  .side-column, .page-footer { display: none; }
}

/* The /roblox route is a camera-only screen; fill phone displays instead of letterboxing it. */
@media (max-width: 700px) and (orientation: portrait) {
  html, body { width: 100%; height: 100%; min-height: 100dvh; overflow: hidden; }
  body { display: block; }
  .camera-only { width: 100vw; height: 100dvh; max-height: none; }
  .camera-only .preview-stage { width: 100%; height: 100%; min-height: 0; aspect-ratio: auto; }
  #cameraFeed { width: 100%; height: 100%; object-fit: contain; }
}

@media (max-width: 700px) and (orientation: landscape) {
  html, body { width: 100%; height: 100%; min-height: 100dvh; overflow: hidden; }
  body { display: block; }
  .camera-only { width: 100vw; height: 100dvh; max-height: none; }
  .camera-only .preview-stage { width: 100%; height: 100%; min-height: 0; aspect-ratio: auto; }
  #cameraFeed { width: 100%; height: 100%; object-fit: contain; }
}

@media (max-height: 500px) and (orientation: landscape) and (min-width: 701px) {
  html, body { width: 100%; height: 100%; min-height: 100dvh; overflow: hidden; }
  body { display: grid; place-items: center; }
  .camera-only { width: 100vw; height: 100dvh; max-height: none; }
  .camera-only .preview-stage { width: 100%; height: 100%; min-height: 0; aspect-ratio: auto; }
  #cameraFeed { width: 100%; height: 100%; object-fit: contain; }
}
