:root {
  color-scheme: dark;
  --bg: #07080a;
  --panel: rgba(16, 18, 22, 0.76);
  --panel-solid: #111318;
  --text: #f5f7fb;
  --muted: #a7adb8;
  --line: rgba(255, 255, 255, 0.16);
  --accent: #e9d36a;
  --danger: #ff6b6b;
  --ok: #6ee7a8;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

.home {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 10%, rgba(233, 211, 106, 0.12), transparent 28rem),
    linear-gradient(145deg, #07080a, #151820 54%, #090a0d);
}

.launcher {
  width: min(680px, 100%);
}

.launcher h1 {
  margin: 0 0 12px;
  font-size: clamp(32px, 7vw, 68px);
  line-height: 0.94;
  letter-spacing: 0;
}

.launcher p {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.65;
  margin: 0 0 26px;
}

.room-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 18px;
}

.room-form input {
  min-width: 0;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  text-transform: uppercase;
  outline: none;
}

.primary-button,
.secondary-button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  padding: 12px 15px;
  cursor: pointer;
}

.primary-button {
  background: var(--accent);
  border-color: var(--accent);
  color: #111;
  font-weight: 750;
}

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

.role-card {
  display: block;
  min-height: 136px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  text-decoration: none;
}

.role-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 18px;
}

.role-card span {
  color: var(--muted);
  line-height: 1.55;
}

.display-body {
  height: 100vh;
  overflow: hidden;
  background: #000;
}

.stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #000;
}

.stage img,
.stage video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.stage-media {
  position: absolute;
  inset: 0;
  opacity: 1;
  transition: opacity 180ms ease;
}

.stage-media.is-changing {
  opacity: 0;
}

.stage-placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  background: #050506;
}

.display-hud {
  position: fixed;
  z-index: 10;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(16px);
}

.hud-text {
  min-width: 0;
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.room-pill {
  color: #111;
  background: var(--accent);
  border-radius: 999px;
  padding: 4px 10px;
  font-weight: 800;
}

.camera-body {
  min-height: 100vh;
  overflow: hidden;
  background: #000;
  user-select: none;
  touch-action: manipulation;
}

.camera-shell {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: 92px 1fr 148px;
  background: #000;
}

.camera-top,
.camera-bottom {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(16px, env(safe-area-inset-top)) 22px 18px;
  background: rgba(0, 0, 0, 0.92);
}

.camera-bottom {
  padding: 18px 26px max(18px, env(safe-area-inset-bottom));
}

.camera-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: white;
  opacity: 0.92;
}

.camera-icon svg {
  width: 24px;
  height: 24px;
}

.lens-label {
  color: #ffd84d;
  font-size: 14px;
  font-weight: 700;
}

.viewfinder {
  position: relative;
  overflow: hidden;
  background: #151515;
}

.fake-feed {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    #101113;
  background-size: 32px 32px;
}

.fake-feed img {
  width: 82%;
  max-height: 86%;
  object-fit: contain;
  filter: contrast(0.96) saturate(0.88) brightness(0.72);
  transform: perspective(900px) rotateX(1deg) rotateY(-2deg);
}

.focus-box {
  position: absolute;
  width: 92px;
  height: 92px;
  border: 1.5px solid rgba(255, 216, 77, 0.95);
  left: 50%;
  top: 48%;
  transform: translate(-50%, -50%);
  opacity: 0;
  animation: focusFlash 3.6s ease-in-out infinite;
}

@keyframes focusFlash {
  0%,
  66%,
  100% {
    opacity: 0;
  }
  72%,
  84% {
    opacity: 1;
  }
}

.camera-mode-row {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  display: flex;
  justify-content: center;
  gap: 18px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.04em;
}

.camera-mode-row .active {
  color: #ffd84d;
}

.thumbnail {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  overflow: hidden;
  background: #202226;
}

.thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.72);
}

.shutter {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 5px solid #e9e9ea;
  background: white;
  box-shadow: inset 0 0 0 5px #101010;
}

.swap-camera {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #1f2226;
}

.hotspot {
  position: absolute;
  z-index: 10;
  border: 0;
  padding: 0;
  background: transparent;
  opacity: 0;
}

.debug .hotspot {
  opacity: 1;
  border: 1px dashed rgba(255, 216, 77, 0.7);
  background: rgba(255, 216, 77, 0.08);
}

.hotspot-top-left {
  top: 0;
  left: 0;
  width: 38%;
  height: 28%;
}

.hotspot-top-right {
  top: 0;
  right: 0;
  width: 38%;
  height: 28%;
}

.hotspot-lower-left {
  bottom: 0;
  left: 0;
  width: 34%;
  height: 34%;
}

.hotspot-lower-right {
  bottom: 0;
  right: 0;
  width: 34%;
  height: 34%;
}

.hotspot-center {
  top: 30%;
  left: 34%;
  width: 32%;
  height: 34%;
}

.control-status {
  position: fixed;
  z-index: 20;
  top: calc(env(safe-area-inset-top) + 8px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 146px;
  text-align: center;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  pointer-events: none;
}

.toast {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: 166px;
  transform: translateX(-50%) translateY(12px);
  opacity: 0;
  max-width: 82vw;
  padding: 10px 14px;
  color: #111;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 750;
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 620px) {
  .role-grid,
  .room-form {
    grid-template-columns: 1fr;
  }

  .display-hud {
    left: 8px;
    right: 8px;
    bottom: 8px;
  }

  .secondary-button {
    padding: 10px 11px;
  }
}

/* Full-screen phone camera surface. */
.camera-body {
  height: 100dvh;
  min-height: 0;
  overscroll-behavior: none;
}

.camera-shell {
  grid-template-rows: calc(54px + env(safe-area-inset-top)) minmax(0, 1fr) calc(174px + env(safe-area-inset-bottom));
  height: 100dvh;
}

.camera-top {
  z-index: 20;
  justify-content: space-between;
  padding: env(safe-area-inset-top) 19px 0;
  background: #000;
}

.camera-tool {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: #f5f5f7;
  cursor: pointer;
}

.camera-tool svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.camera-tool.is-active { color: #f5d246; }
.camera-tool .flash-slash { stroke: #f5d246; }
.camera-tool.is-active .flash-slash { display: none; }
.camera-menu-toggle { border-radius: 50%; background: #27272a; }
.camera-menu-toggle svg { width: 18px; }

.viewfinder {
  min-height: 0;
  background: #0b0b0b;
  touch-action: none;
}

.fake-feed {
  display: block;
  background: #101010;
}

.fake-feed img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
  object-position: 53% center;
  filter: brightness(.88) contrast(1.03);
  transform: scale(var(--preview-zoom, 1));
  transition: transform 200ms ease;
}

.camera-grid {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 33.2%, rgba(255,255,255,.34) 33.3%, transparent 33.4%, transparent 66.5%, rgba(255,255,255,.34) 66.6%, transparent 66.7%),
    linear-gradient(0deg, transparent 33.2%, rgba(255,255,255,.34) 33.3%, transparent 33.4%, transparent 66.5%, rgba(255,255,255,.34) 66.6%, transparent 66.7%);
}
.camera-grid.is-visible { display: block; }

.zoom-controls {
  position: absolute;
  z-index: 12;
  left: 50%;
  bottom: 15px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px;
  border-radius: 22px;
  background: rgba(0,0,0,.44);
}

.zoom-controls button {
  width: 35px;
  height: 35px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #f8f8f8;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.zoom-controls button.is-active { background: #f5d246; color: #111; }

.hotspot {
  z-index: 10;
  touch-action: none;
}
.hotspot-top-left, .hotspot-top-right { height: 25%; width: 34%; }
.hotspot-lower-left, .hotspot-lower-right { height: 27%; width: 30%; }
.debug .hotspot { background: rgba(255,216,77,.1); }

.camera-bottom {
  z-index: 5;
  display: grid;
  grid-template-rows: 44px minmax(0, 1fr) 16px;
  padding: 0 0 env(safe-area-inset-bottom);
  background: #000;
}

.camera-mode-row {
  position: static;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: clamp(10px, 3.5vw, 20px);
  overflow: hidden;
  white-space: nowrap;
  letter-spacing: 0;
}
.camera-mode-row button {
  border: 0;
  padding: 8px 0;
  background: transparent;
  color: #dedee0;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
}
.camera-mode-row button.is-active { color: #f5d246; }

.camera-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  justify-items: center;
  width: 100%;
  padding: 0 20px;
}
.thumbnail {
  width: 48px;
  height: 48px;
  border: 1px solid #777;
  border-radius: 6px;
  padding: 0;
  cursor: pointer;
}
.thumbnail img { filter: none; }
.shutter {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border: 4px solid #fff;
  background: transparent;
  box-shadow: none;
  padding: 3px;
  cursor: pointer;
}
.shutter span {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: white;
}
.video-mode .shutter span {
  width: 44px;
  height: 44px;
  background: #fa3a40;
}
.swap-camera {
  width: 48px;
  height: 48px;
  border: 0;
  background: #2a2a2d;
  color: white;
  cursor: pointer;
}
.swap-camera svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.home-indicator {
  align-self: end;
  justify-self: center;
  width: 108px;
  height: 4px;
  border-radius: 4px;
  background: white;
}

.camera-options {
  position: absolute;
  z-index: 30;
  top: calc(54px + env(safe-area-inset-top));
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px;
  background: #202023;
  color: #ededee;
  font-size: 12px;
}
.camera-options[hidden] { display: none; }
.camera-options button {
  border: 0;
  border-radius: 6px;
  padding: 9px 11px;
  background: #35353a;
  color: white;
  cursor: pointer;
}
.camera-options button[aria-pressed="true"] { color: #f5d246; }
.camera-room-form { display: flex; gap: 5px; }
.camera-room-form input {
  width: 80px;
  min-width: 0;
  border: 1px solid #666;
  border-radius: 5px;
  padding: 7px;
  background: #121214;
  color: white;
  text-transform: uppercase;
}

.capture-flash {
  position: absolute;
  z-index: 35;
  inset: calc(54px + env(safe-area-inset-top)) 0 calc(174px + env(safe-area-inset-bottom));
  background: #fff;
  opacity: 0;
  pointer-events: none;
}
.capture-flash.firing { animation: cameraFlash 240ms ease-out; }
@keyframes cameraFlash { 0% { opacity: .8; } 100% { opacity: 0; } }

.toast { bottom: calc(190px + env(safe-area-inset-bottom)); white-space: nowrap; }

@media (max-height: 650px) {
  .camera-shell { grid-template-rows: calc(48px + env(safe-area-inset-top)) minmax(0, 1fr) calc(145px + env(safe-area-inset-bottom)); }
  .camera-bottom { grid-template-rows: 36px minmax(0, 1fr) 10px; }
  .shutter { width: 62px; height: 62px; }
  .camera-options { top: calc(48px + env(safe-area-inset-top)); }
}

.live-feed,
.live-feed video,
.live-feed canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.live-feed {
  overflow: hidden;
  background: #111;
}
.live-feed video,
.live-feed canvas {
  object-fit: cover;
  transform: scale(var(--preview-zoom, 1));
  transform-origin: center;
}
.live-feed canvas { pointer-events: none; }
.camera-message {
  position: absolute;
  z-index: 3;
  left: 20px;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  padding: 12px;
  background: rgba(0,0,0,.64);
  color: white;
  font-size: 14px;
  text-align: center;
}
.camera-message[hidden] { display: none; }
.is-recording .shutter span {
  width: 30px;
  height: 30px;
  border-radius: 5px;
}
.photo-preview {
  position: absolute;
  z-index: 45;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-direction: column;
  padding: calc(18px + env(safe-area-inset-top)) 18px calc(30px + env(safe-area-inset-bottom));
  background: #000;
}
.photo-preview[hidden] { display: none; }
.photo-preview img {
  min-height: 0;
  max-width: 100%;
  max-height: 75%;
  object-fit: contain;
}
.photo-preview button {
  align-self: flex-start;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 28px;
  cursor: pointer;
}
.photo-preview #savePhoto {
  align-self: center;
  border-radius: 6px;
  padding: 12px 22px;
  background: #333;
  font-size: 15px;
}
