/* =====================================================
   MiloCam - Lobby, setup and child screen
   Follows the design canvas "MiloCam Canvas": the boards Lobby,
   Host-setup (kind) and Sessie · kind, and the building blocks Button,
   Logo, StepCard, CodeCard and Toast. 4pt grid; 44 px touch targets.
   The professional screen has its own stylesheet (css/pro-screen.css);
   nothing here styles bare elements, so nothing leaks into it.
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700;800&display=swap');

/* -----------------------------------------------------
   Tokens (canvas board "Fundament · tokens")
   ----------------------------------------------------- */
:root {
  --bg: #0d0a12;
  --bg-elevated: #15111d;
  --panel: #1c1626;
  --control: #2a2038;
  --edge-strong: rgba(150, 100, 180, 0.32);
  /* Edges of blocks (cards, inputs, buttons, messages): at least 3.5:1 against the backdrop,
     also its brightest glow, so blocks stay visible on a tablet with low brightness */
  --edge-block: #806f96;
  --edge-active: #a552bf;   /* the current setup step */
  --edge-done: #3f8621;     /* a finished setup step, a success message */
  --edge-magenta: #e6006e;  /* the code card, the camera list, a plain message */
  --edge-warning: #8b7409;
  --edge-error: #d63d4b;
  /* The top stripe of a step card: whose device the step is about (see "Step cards" below) */
  --stripe-child: #a552bf;
  --stripe-pro: #e6006e;
  --stripe-done: #4fad26;
  --text: #f5f0ff;
  --text-secondary: rgba(245, 240, 255, 0.75);
  --muted: #a597b5;   /* at least 5.6:1 on every surface */
  --yellow: #ffd600;
  --magenta: #e8006f;
  --magenta-soft: #ff8ac0;
  --purple-soft: #d9a6ec;
  --green: #4fad26;
  --green-soft: #7ddf4a;
  --red: #ff4757;
  --red-soft: #ff8a95;
  --brand: linear-gradient(135deg, #c8005f 0%, #d60067 100%); /* white text at least 5.2:1 */
  --host: linear-gradient(135deg, #600e75 0%, #8a1a8c 100%);
  /* The backdrop of the lobby, the setup and the professional screen (the professional's, from
     the canvas): purple glow top left, magenta bottom right, 16 px dots. All three screens are
     fixed to the whole window and use exactly this, so switching between them does not jump. */
  --dots: radial-gradient(rgba(245, 240, 255, 0.12) 1px, transparent 1px) 0 0 / 16px 16px;
  --backdrop:
    radial-gradient(ellipse at 12% 16%, rgba(122, 29, 145, 0.36) 0%, transparent 56%),
    radial-gradient(ellipse at 88% 88%, rgba(232, 0, 111, 0.22) 0%, transparent 56%),
    var(--dots),
    #0d0a12;
  --font: Figtree, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: Consolas, 'SF Mono', Monaco, monospace;
}

/* -----------------------------------------------------
   Base
   ----------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

:focus-visible {
  outline: 3px solid var(--magenta);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* -----------------------------------------------------
   Stage: the child device's picture (webcam or blackboard, video,
   drawings, mask). On the professional device it holds the stream.
   ----------------------------------------------------- */
.app {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: 1fr auto;
}

.stage {
  position: relative;
  overflow: hidden;
  background: #000;
  user-select: none;
  touch-action: none;
}

.layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: translate(0px, 0px) scale(1);
  transform-origin: 0 0;
}

video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
}

#videoPlayer {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: transparent;
  transform: translateZ(0);
}

canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

/* The mask (black canvas, or the blur below) hides the picture; drawings stay on top */
#maskCanvas {
  z-index: 3;
}

#draw {
  z-index: 5;
}

/* -----------------------------------------------------
   Icons (js/icons.js, filled into [data-icon] at startup)
   ----------------------------------------------------- */
svg.icon {
  display: block;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ico {
  display: inline-flex;
  flex-shrink: 0;
}

.ico .icon {
  width: 20px;
  height: 20px;
}

/* -----------------------------------------------------
   Button (building block Button): sizes md 44 (default) and lg 56,
   variants default, primary, host, secondary, ghost, success
   ----------------------------------------------------- */
.mc-btn {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
  height: 44px;
  min-width: 44px;
  margin: 0;
  padding: 0 16px;
  border: 1px solid var(--edge-block);
  border-radius: 12px;
  background: var(--control);
  color: var(--text);
  font: 600 14px/20px var(--font);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: filter 0.12s ease, opacity 0.2s ease;
}

.mc-btn:hover:not(:disabled) { filter: brightness(1.15); }
.mc-btn:active:not(:disabled) { filter: brightness(0.92); }
.mc-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.mc-btn.lg {
  height: 56px;
  min-width: 56px;
  padding: 0 24px;
  border-radius: 999px;
  font-size: 16px;
  line-height: 24px;
}

.mc-btn.full { width: 100%; }
.mc-btn.icon-only { width: 44px; padding: 0; }
.mc-btn.primary { background: var(--brand); border-color: transparent; color: #fff; box-shadow: 0 4px 20px rgba(232, 0, 111, 0.32); }
.mc-btn.host { background: var(--host); border-color: transparent; color: #fff; box-shadow: 0 4px 20px rgba(122, 29, 145, 0.4); }
.mc-btn.secondary { background: rgba(42, 32, 56, 0.8); }
.mc-btn.ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.mc-btn.success { background: rgba(79, 173, 38, 0.16); border-color: rgba(79, 173, 38, 0.4); color: var(--green-soft); }
.mc-btn.loading { pointer-events: none; opacity: 0.72; }

/* -----------------------------------------------------
   Logo (building block Logo): lg 48 px with badge, sm 24 px
   ----------------------------------------------------- */
.mc-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  font-size: 48px;
  line-height: 48px;
  font-weight: 800;
}

.mc-logo .word {
  display: inline-flex;
  letter-spacing: -0.04em;
}

.mc-logo .milo,
.mc-logo .cam {
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.mc-logo .milo { background-image: linear-gradient(135deg, #ffffff 0%, #7a1d91 100%); }
.mc-logo .cam { background-image: linear-gradient(135deg, #e8006f 0%, #ffd600 100%); }

.mc-logo .badge {
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.mc-logo.sm {
  gap: 8px;
  font-size: 24px;
  line-height: 24px;
}

.mc-step-label {
  font-size: 12px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--yellow);
}

/* -----------------------------------------------------
   Toast (building block Toast): a pill with a tinted icon per tone.
   Lobby and setup: bottom centre. Child screen: bottom right.
   The professional screen places it over the frame (pro-screen.css).
   ----------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 4000;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  max-width: calc(100vw - 32px);
  padding: 10px 20px 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--edge-magenta);
  background: var(--panel);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  color: var(--text);
  font: 500 14px/20px var(--font);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 16px) scale(0.9);
  transition: opacity 0.22s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.toast-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 999px;
  background: rgba(232, 0, 111, 0.16);
  color: var(--magenta-soft);
}

.toast-icon .icon {
  width: 16px;
  height: 16px;
  stroke-width: 2.5;
}

.toast.toast-success { border-color: var(--edge-done); }
.toast.toast-success .toast-icon { background: rgba(79, 173, 38, 0.18); color: var(--green-soft); }
.toast.toast-warning { border-color: var(--edge-warning); }
.toast.toast-warning .toast-icon { background: rgba(255, 214, 0, 0.14); color: var(--yellow); }
.toast.toast-error { border-color: var(--edge-error); }
.toast.toast-error .toast-icon { background: rgba(255, 71, 87, 0.16); color: var(--red-soft); }

body.role-host .toast {
  left: auto;
  right: 16px;
  bottom: 16px;
  transform: translateY(16px) scale(0.9);
}

body.role-host .toast.show {
  transform: none;
}

/* -----------------------------------------------------
   Confetti Animation - Super exciting for kids!
   ----------------------------------------------------- */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 9999;
}

.confetti {
  --drift: 0px;
  --rotation: 720deg;
  --wobble: 15px;
  position: absolute;
  width: 10px;
  height: 10px;
  animation: confetti-fall-physics 2.5s cubic-bezier(0.15, 0.8, 0.3, 1) forwards;
  transform-origin: center;
  will-change: transform, opacity;
}

/* Basic shapes */
.confetti.square {
  border-radius: 3px;
  box-shadow: 0 0 6px currentColor;
}

.confetti.circle {
  border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
}

/* Triangle shape */
.confetti.triangle {
  width: 0 !important;
  height: 0 !important;
  background: transparent !important;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 12px solid var(--confetti-color, #ffd600);
  filter: drop-shadow(0 0 6px var(--confetti-color, #ffd600));
}

/* Star shape using clip-path */
.confetti.star {
  background: var(--confetti-color, #ffd600) !important;
  clip-path: polygon(
    50% 0%,
    61% 35%,
    98% 35%,
    68% 57%,
    79% 91%,
    50% 70%,
    21% 91%,
    32% 57%,
    2% 35%,
    39% 35%
  );
  box-shadow: 0 0 10px var(--confetti-color, #ffd600);
}

/* Heart shape */
.confetti.heart {
  background: var(--confetti-color, #e8006f) !important;
  transform-origin: center;
  clip-path: path('M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z');
  width: 14px !important;
  height: 14px !important;
}

/* Sparkle effect */
.confetti.sparkle {
  border-radius: 50%;
  animation: sparkle-pop 0.8s ease-out forwards;
  position: fixed;
}

/* Physics-based fall animation with drift and wobble */
@keyframes confetti-fall-physics {
  0% {
    transform: translateY(-50px) translateX(0) rotate(0deg) scale(0.5);
    opacity: 0;
  }
  10% {
    opacity: 1;
    transform: translateY(0) translateX(calc(var(--wobble) * -1)) rotate(calc(var(--rotation) * 0.1)) scale(1);
  }
  25% {
    transform: translateY(20vh) translateX(calc(var(--drift) * 0.3 + var(--wobble))) rotate(calc(var(--rotation) * 0.25)) scale(1);
  }
  50% {
    transform: translateY(45vh) translateX(calc(var(--drift) * 0.6 + var(--wobble) * -0.5)) rotate(calc(var(--rotation) * 0.5)) scale(0.95);
  }
  75% {
    transform: translateY(70vh) translateX(calc(var(--drift) * 0.85 + var(--wobble) * 0.3)) rotate(calc(var(--rotation) * 0.75)) scale(0.85);
    opacity: 0.8;
  }
  100% {
    transform: translateY(105vh) translateX(var(--drift)) rotate(var(--rotation)) scale(0.5);
    opacity: 0;
  }
}

/* Sparkle pop animation */
@keyframes sparkle-pop {
  0% {
    transform: scale(0) rotate(0deg);
    opacity: 1;
  }
  50% {
    transform: scale(1.5) rotate(180deg);
    opacity: 1;
  }
  100% {
    transform: scale(0) rotate(360deg);
    opacity: 0;
  }
}

/* -----------------------------------------------------
   Utility Classes
   ----------------------------------------------------- */
.hidden {
  display: none !important;
}


/* -----------------------------------------------------
   Lobby (canvas board "Lobby"): one card per role, side by side;
   stacked on narrow screens
   ----------------------------------------------------- */
#lobby {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  overflow: auto;
  padding: 48px clamp(16px, 5vw, 64px);
  padding: max(48px, env(safe-area-inset-top)) max(clamp(16px, 5vw, 64px), env(safe-area-inset-right)) max(48px, env(safe-area-inset-bottom)) max(clamp(16px, 5vw, 64px), env(safe-area-inset-left));
  background: var(--backdrop);
}

/* The lobby and the setup fade in and out (over the same backdrop, so only the content
   changes). Browsers without transition-behavior simply switch at once. */
#lobby,
.fullscreen-prompt {
  transition-property: opacity, display;
  transition-duration: 0.24s;
  transition-timing-function: ease;
  transition-behavior: allow-discrete;
}
#lobby.hidden,
.fullscreen-prompt.hidden {
  opacity: 0;
  pointer-events: none;
}
@starting-style {
  #lobby,
  .fullscreen-prompt {
    opacity: 0;
  }
}

/* margin: auto centres the content, and lets it scroll instead of clipping when it does not fit */
.lobby-inner {
  margin: auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 40px;
}

.lobby-roles {
  display: flex;
  align-items: stretch;
  justify-content: center;
  width: 100%;
}

.lobby-role {
  position: relative;
  flex: 0 1 448px;
  min-width: 0;
  padding: 32px;
  border-radius: 24px;
  border: 1px solid var(--edge-block);
  background: var(--panel);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 24px;
}


.lobby-role-head {
  display: flex;
  align-items: center;
  gap: 16px;
}

.lobby-role-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  align-items: center;
  justify-content: center;
  background: rgba(122, 29, 145, 0.24);
  color: var(--purple-soft);
}

.lobby-role.pro .lobby-role-icon {
  background: rgba(232, 0, 111, 0.16);
  color: var(--magenta-soft);
}

.lobby-role-icon .icon {
  width: 24px;
  height: 24px;
}

.lobby-role-titles {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lobby-role h2 {
  margin: 0;
  font-size: 20px;
  line-height: 28px;
  font-weight: 700;
}

.lobby-role p {
  margin: 0;
  color: var(--text-secondary);
}

.lobby-role-action {
  margin-top: auto;
  display: flex;
  gap: 12px;
}

.lobby-role-action #btnConnect {
  flex: 1;
  min-width: 0;
}

.lobby-arrow {
  width: 64px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lobby-arrow .ico {
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--edge-block);
  background: var(--panel);
  color: var(--muted);
}

.lobby-input {
  width: 168px;
  height: 56px;
  flex-shrink: 0;
  margin: 0;
  padding: 0 16px;
  border-radius: 999px;
  border: 2px solid var(--edge-block);
  background: var(--bg);
  color: #fff;
  font: 600 20px/24px var(--font);
  letter-spacing: 0.24em;
  text-align: center;
  transition: border-color 0.12s ease;
}

.lobby-input::placeholder {
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.lobby-input:focus {
  border-color: var(--magenta);
}

.lobby-input.shake {
  animation: mc-shake 0.4s ease;
  border-color: var(--red);
}

@keyframes mc-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

@media (max-width: 960px) {
  .lobby-roles {
    flex-direction: column;
    align-items: center;
  }

  .lobby-role {
    flex: none;
    width: min(448px, 100%);
  }

  .lobby-arrow {
    width: auto;
    height: 48px;
  }

  .lobby-arrow .icon {
    transform: rotate(90deg);
  }
}

@media (max-width: 480px) {
  .lobby-inner { gap: 24px; }
  .mc-logo { font-size: 36px; line-height: 40px; }
  .lobby-role { padding: 24px; }
  .lobby-role-action { flex-direction: column; }
  .lobby-input { width: 100%; }
}

/* -----------------------------------------------------
   Setup on the child device (canvas board "Host-setup (kind)",
   building block StepCard): three steps side by side.
   States: disabled = not yet (dimmed), no class = now (purple),
   completed = done (green).
   ----------------------------------------------------- */
.fullscreen-prompt {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  overflow: auto;
  padding: 48px clamp(16px, 4.4vw, 56px);
  background: var(--backdrop);
}

.setup-logo {
  position: absolute;
  left: clamp(16px, 4.4vw, 56px);
  top: 32px;
}

.setup-inner {
  margin: auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
}

.setup-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.setup-header h1 {
  margin: 0;
  font-size: 28px;
  line-height: 36px;
  font-weight: 800;
}

.setup-header p {
  margin: 0;
  color: var(--text-secondary);
}

.setup-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  width: 100%;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.setup-step-slot {
  flex: 0 1 368px;
  min-width: 0;
  display: flex;
}

.setup-chevron {
  width: 32px;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  padding-top: 28px;
  color: var(--muted);
}

.setup-chevron .icon {
  width: 24px;
  height: 24px;
}

.setup-step {
  width: 100%;
  min-height: 296px;
  padding: 24px;
  border-radius: 16px;
  border: 1px solid var(--edge-active);
  background: #1e1429;
  box-shadow: 0 0 32px rgba(122, 29, 145, 0.32);
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: opacity 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.setup-step.disabled {
  border-color: var(--edge-block);
  background: var(--bg-elevated);
  box-shadow: none;
}

/* A later step stays readable (no fading): muted text, and its button as a dashed outline */
.setup-step.disabled .setup-btn:disabled {
  opacity: 1;
  background: transparent;
  border: 1px dashed var(--edge-block);
  color: var(--muted);
  box-shadow: none;
}
.setup-step.disabled .setup-step-desc { color: var(--muted); }

.setup-step.completed {
  border-color: var(--edge-done);
  background: #151a16;
  box-shadow: none;
}

.setup-step-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.setup-step-number {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--host);
  color: #fff;
  font-size: 14px;
  line-height: 20px;
  font-weight: 700;
}

.setup-step.disabled .setup-step-number {
  background: var(--control);
  color: var(--muted);
  border: 2px solid var(--edge-strong);
}

.setup-step.completed .setup-step-number { background: var(--green); }
.setup-step-number .ico { display: none; }
.setup-step-number .icon { width: 16px; height: 16px; stroke-width: 3; }
.setup-step.completed .setup-step-number .num { display: none; }
.setup-step.completed .setup-step-number .ico { display: inline-flex; }

.setup-step-title {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 16px;
  line-height: 24px;
  font-weight: 700;
}

.setup-step.disabled .setup-step-title { color: var(--muted); }
.setup-step.completed .setup-step-title { color: var(--green-soft); }

.setup-step-status {
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--green-soft);
}

.setup-step-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.setup-step-desc {
  margin: 0;
  color: var(--text-secondary);
}

.setup-select-wrap {
  position: relative;
}

.setup-select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 44px;
  margin: 0;
  padding: 0 44px 0 12px;
  border-radius: 8px;
  border: 1px solid var(--edge-magenta);
  background: var(--bg);
  color: var(--text);
  font: 400 14px/20px var(--font);
  cursor: pointer;
}

.setup-select:disabled { opacity: 0.6; cursor: not-allowed; }

.setup-select option {
  background: var(--panel);
  color: var(--text);
}

.setup-select-wrap > .ico {
  position: absolute;
  right: 12px;
  top: 12px;
  pointer-events: none;
  color: var(--text-secondary);
}

.setup-warning {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 214, 0, 0.32);
  background: rgba(255, 214, 0, 0.08);
  color: var(--yellow);
  font-size: 13px;
  line-height: 20px;
}

.setup-step-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.step-help {
  margin: 0;
  min-height: 16px;
  font-size: 12px;
  line-height: 16px;
  color: var(--muted);
}

/* The step's action: grey while not yet, purple now, green once done */
.setup-step:not(.disabled):not(.completed) .setup-btn {
  background: var(--host);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 20px rgba(122, 29, 145, 0.4);
}

.setup-step.completed .setup-btn {
  background: rgba(79, 173, 38, 0.16);
  border-color: rgba(79, 173, 38, 0.4);
  color: var(--green-soft);
  opacity: 1;
  cursor: default;
}

.setup-btn .ico.done { display: none; }
.setup-step.completed .setup-btn .ico { display: none; }
.setup-step.completed .setup-btn .ico.done { display: inline-flex; }

/* Recordings folder in step 1 (ticket 13). Stays usable after the step is done.
   js/recordings-folder-setup.js sets data-status; the matching [data-show] part shows. */
.setup-folder {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setup-folder[data-status="loading"],
.setup-folder [data-show] {
  display: none;
}

.setup-folder[data-status="none"] [data-show="none"],
.setup-folder[data-status="ready"] [data-show="ready"],
.setup-folder[data-status="needs-permission"] [data-show="needs-permission"],
.setup-folder[data-status="unsupported"] [data-show="unsupported"] {
  display: flex;
}

.setup-folder-label {
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.setup-folder-chosen {
  align-items: center;
  gap: 8px;
  height: 44px;
  padding-left: 12px;
  border-radius: 8px;
  border: 1px solid var(--edge-block);
  background: var(--bg);
}

.setup-folder-icon {
  color: var(--yellow);
}

.setup-folder-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.setup-folder-lost {
  margin: 0;
  font-size: 12px;
  line-height: 16px;
  color: var(--yellow);
}

.setup-folder-note {
  margin: 0;
  font-size: 12px;
  line-height: 16px;
  color: var(--muted);
}

/* Smaller laptops: the steps get narrower, then stack */
@media (max-height: 700px) {
  .fullscreen-prompt { padding-top: 24px; padding-bottom: 24px; }
  .setup-inner { gap: 24px; }
}

@media (max-width: 860px) {
  .setup-logo { position: static; align-self: flex-start; }
  .fullscreen-prompt { flex-direction: column; gap: 24px; }
  .setup-steps { flex-direction: column; align-items: center; }
  .setup-step-slot { flex: none; width: min(368px, 100%); }
  .setup-step { min-height: 0; }
  .setup-chevron { width: auto; padding: 8px 0; }
  .setup-chevron .icon { transform: rotate(90deg); }
}

/* -----------------------------------------------------
   Language dropdown (js/language-menu.js), top right on the lobby and the
   setup, at the same spot on both, so switching does not jump. Its centre
   line is the setup logo's (top 32 + 12). It scrolls with its screen, so it
   never covers content. The surface, edge and touch size of the app's
   other popovers; the current language is marked like a playing video.
   ----------------------------------------------------- */
.lang-menu {
  position: absolute;
  top: max(22px, env(safe-area-inset-top));
  right: max(clamp(16px, 4.4vw, 56px), env(safe-area-inset-right));
  z-index: 5;
}

.lang-menu[hidden],
.lang-menu-list[hidden] {
  display: none;
}

/* An .mc-btn on the popover surface */
.mc-btn.lang-menu-btn {
  padding: 0 12px;
  background: var(--panel);
  letter-spacing: 0.04em;
  touch-action: manipulation;
}

.lang-menu-btn > .icon { color: var(--muted); transition: transform 0.15s ease; }
.lang-menu.open .lang-menu-btn > .icon { transform: rotate(180deg); }

.lang-menu .flag {
  display: block;
  flex: none;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(245, 240, 255, 0.32);
}

.lang-menu-flag { display: flex; }

.lang-menu-list {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 208px;
  margin: 0;
  padding: 8px;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--edge-block);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.lang-menu-option {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.lang-menu-option:hover:not([aria-selected="true"]) { background: rgba(150, 100, 180, 0.12); }
.lang-menu-option[aria-selected="true"] { background: rgba(232, 0, 111, 0.16); border-color: rgba(232, 0, 111, 0.56); }
.lang-menu-option:focus-visible { outline: 3px solid var(--magenta); outline-offset: -1px; }
.lang-menu-option .name { flex: 1; }
.lang-menu-option .mark { display: flex; color: var(--magenta-soft); visibility: hidden; }
.lang-menu-option[aria-selected="true"] .mark { visibility: visible; }

/* A phone: the lobby's logo would sit under the dropdown, so the lobby starts below it */
@media (max-width: 560px) {
  #lobby { padding-top: max(80px, env(safe-area-inset-top)); }
}

/* -----------------------------------------------------
   Child screen (canvas board "Sessie · kind")
   ----------------------------------------------------- */

/* Code card (building block CodeCard), top right. The whole card hides while a
   professional is connected, so the code never shows on the professional screen
   through the stream; it comes back when the connection drops. */
#sessionInfo {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  width: 224px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--edge-magenta);
  background: rgba(28, 22, 38, 0.92);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

#sessionInfo.visible { display: flex; }

#smQRCode {
  width: 160px;
  height: 160px;
  padding: 12px;
  border-radius: 8px;
  background: #fff;
}

#smQRCode img,
#smQRCode canvas {
  width: 136px;
  height: 136px;
}

#sessionInfo.visible.connected {
  display: none;
}

.info-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-label {
  font-size: 12px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--yellow);
}

.info-code {
  font: 800 32px/40px var(--mono);
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.info-hint {
  font-size: 12px;
  line-height: 16px;
  color: var(--text-secondary);
}

/* Leave fullscreen: top left (Button secondary, icon only) */
.exit-fullscreen-btn {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 150;
}

/* -----------------------------------------------------
   Mask blur on the child device (ticket 10): one layer with a hole for the
   clear area (clip-path from js/child-layer.js) blurs the picture behind it:
   webcam, video and blackboard. Drawings (#draw) sit above it.
   ----------------------------------------------------- */
.mask-blur {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(13, 10, 18, 0.16);
}
.mask-blur[hidden] { display: none; }

/* -----------------------------------------------------
   Step cards: the top stripe
   A card that is a step gets a 4 px stripe in the colour of whose device the step is
   about: purple for the child's device (lobby step 1, the current setup step), magenta
   for the professional's (lobby step 2, and the code card the professional reads),
   green for a finished step. The stripe is the card's top border, so it follows the
   rounded corners and runs into the side edges. Panels, pop-ups, dialogs and messages
   are no steps and get no stripe; they show a state with their edge colour instead.
   ----------------------------------------------------- */
.lobby-role.host,
.setup-step { border-top: 4px solid var(--stripe-child); }
.lobby-role.pro,
#sessionInfo { border-top: 4px solid var(--stripe-pro); }
.setup-step.completed { border-top: 4px solid var(--stripe-done); }
.setup-step.disabled { border-top: 1px solid var(--edge-block); padding-top: 27px; }
