:root {
  --purple: #7e3ff2;
  --purple-soft: #b9a7d6; /* greyish lighter purple for empty backgrounds */
  --bg: #0e0e12;
  --fg: #f4f4f7;
  --muted: #b6b6c2;
  --banner-h: 80px;
  --accent: #ff4f00; /* event_program international orange */
}

* { box-sizing: border-box; }

/* The `hidden` attribute must win over id selectors like `#pairing`/`#dashboard`
 * (which set `display:flex`); otherwise toggling `.hidden` in JS does nothing and
 * the pairing screen never gives way to the dashboard. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.screen { height: 100vh; width: 100vw; }

/* ---------- Pairing screen ---------- */
#pairing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}
.brand {
  font-size: clamp(28px, 5vw, 56px);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
}
.qr-wrap {
  background: #fff;
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  transition: opacity 0.6s ease;
  line-height: 0;
}
.qr-wrap.stopped { opacity: 0.30; }
.qr-img {
  width: clamp(220px, 32vmin, 360px);
  height: clamp(220px, 32vmin, 360px);
  image-rendering: pixelated;
  display: block;
}
.qr-status {
  font-size: 18px;
  color: var(--muted);
  margin: 0;
  min-height: 24px;
}
.qr-refresh {
  appearance: none;
  border: none;
  background: var(--purple);
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  padding: 12px 28px;
  border-radius: 999px;
  cursor: pointer;
}
.qr-refresh:active { transform: scale(0.97); }

/* ---------- Dashboard ---------- */
#dashboard {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.banner {
  position: relative;
  height: var(--banner-h);
  min-height: var(--banner-h);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  overflow: hidden;
  background: var(--purple); /* fallback stripe */
}
.banner-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  z-index: 0;
}
.banner-left, .banner-right { position: relative; z-index: 1; display: flex; align-items: center; }
.banner-left { gap: 12px; min-width: 0; }
.banner-right { gap: 14px; }

.banner-avatar { width: 56px; height: 56px; flex: 0 0 auto; }
.banner-titles { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.group-name {
  font-size: 14px;
  font-weight: 600;
  opacity: 0.92;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.event-title {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.05;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* avatars (image or initials circle) */
.avatar {
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  background-size: cover;
  background-position: center;
  flex: 0 0 auto;
  user-select: none;
}

/* members block: up to 7 per row, right-aligned toward the static QR */
.members {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.members-row {
  display: flex;
  flex-direction: row;
  gap: 6px;
  justify-content: flex-end;
}
.member-overflow {
  background: #6b6b76;
  color: #fff;
  font-weight: 700;
}

.static-qr { width: 64px; height: 64px; background: #fff; border-radius: 8px; padding: 4px; }
.static-qr img { width: 100%; height: 100%; image-rendering: pixelated; display: block; }

/* stage: main area (left) + widgets strip (right) */
.stage {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: row;
  min-height: 0;
  overflow: hidden;
}
.main-area {
  flex: 1 1 auto;
  min-width: 0;
  position: relative;
  background-size: cover;
  background-position: center;
  background-color: #000;
}
/* the event background, when present, sits dimmed behind the player */
.main-area::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}
.main-area > * { position: relative; z-index: 1; }

/* in-place YouTube player (mirrors the Flutter youtube widget) */
.yt-stage {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 28px;
}
.yt-frame {
  aspect-ratio: 16 / 9;
  width: 100%;
  max-height: calc(100% - 56px);
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}
.yt-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
/* Instagram embeds are portrait cards (~400px wide) on a white surface. */
.ig-frame {
  width: clamp(320px, 30vw, 420px);
  max-width: 100%;
  height: 100%;
  max-height: calc(100% - 56px);
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
}
.ig-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.yt-fallback {
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  text-decoration: none;
}
.yt-title {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  max-width: 80%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.yt-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.yt-close:hover { background: rgba(0, 0, 0, 0.75); }

/* embedded website (link_button) — fills the stage, with a bottom action bar */
.web-frame {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}
.web-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.web-fallback { color: #111; font-size: 20px; font-weight: 700; text-decoration: none; }
.web-bar {
  flex: 0 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
}
.web-label {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.web-open {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.web-open:hover { background: rgba(255, 255, 255, 0.24); }
.web-open:disabled { opacity: 0.5; cursor: default; }
.web-open svg { width: 18px; height: 18px; }

/* postit (sticky notes) mosaic */
.postit-wrap {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 28px 28px 28px 28px;
}
.postit-header { margin-bottom: 14px; }
.postit-h-title { font-size: 26px; font-weight: 800; letter-spacing: -0.01em; }
.postit-h-desc { font-size: 15px; color: var(--muted); margin-top: 4px; }
/* sort/filter toolbar at the top of the notes */
.postit-toolbar { display: flex; justify-content: flex-end; gap: 10px; margin-bottom: 16px; }
.postit-tool {
  height: 40px;
  min-width: 48px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--fg);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.postit-tool:hover { background: rgba(255, 255, 255, 0.16); }
.postit-tool.on { border-color: var(--accent); color: var(--accent); }
.postit-tool svg { width: 20px; height: 20px; }
.postit-filter-n { font-size: 15px; font-weight: 700; }
.postit-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-content: flex-start;
}
.postit-empty { color: var(--muted); font-size: 16px; padding: 12px; }
.postit-note {
  width: 170px;
  height: 170px;
  border-radius: 12px;
  padding: 14px;
  color: #1f1f1f;
  display: flex;
  flex-direction: column;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.postit-grid .postit-note { transition: transform 0.12s ease, box-shadow 0.12s ease; }
.postit-grid .postit-note:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(0, 0, 0, 0.45); }
.postit-text {
  flex: 1 1 auto;
  min-height: 0; /* let the flex child shrink so the clone's overflow can scroll */
  font-size: 15px;
  line-height: 1.3;
  font-weight: 600;
  overflow: hidden; /* mosaic tiles stay simple: clip; only the maximized note scrolls */
  white-space: pre-wrap;
  word-break: break-word;
}
/* the maximized note is the readable view — let its (long) text scroll */
.postit-clone .postit-text { overflow-y: auto; overscroll-behavior: contain; }
.postit-clone .postit-text::-webkit-scrollbar { width: 6px; }
.postit-clone .postit-text::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.28); border-radius: 3px; }
.postit-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}
.postit-stars { display: flex; gap: 2px; font-size: 14px; line-height: 1; }
.postit-star { color: rgba(0, 0, 0, 0.22); }
.postit-star.on { color: #1f1f1f; }
.postit-avatar { width: 26px; height: 26px; font-size: 11px; }

/* zoom-to-centre animation */
.postit-backdrop {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: rgba(0, 0, 0, 0);
  transition: background 0.32s ease;
  cursor: pointer;
}
.postit-backdrop.show { background: rgba(0, 0, 0, 0.55); }
.postit-clone {
  position: absolute;
  z-index: 6;
  margin: 0;
  transform-origin: top left;
  transform: translate(0, 0) scale(1);
  transition: transform 0.34s cubic-bezier(0.2, 0.7, 0.2, 1);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65);
}

.widgets-strip {
  position: relative;
  flex: 0 0 auto;
  align-self: stretch;
  background-size: cover;
  background-position: center;
  background-color: var(--purple-soft);
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
/* scrim so widget cards read over any background image */
.widgets-strip::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.25), rgba(0,0,0,0.55));
  z-index: 0;
}
.widget-card {
  position: relative;
  z-index: 1;
  background: rgba(20, 20, 28, 0.78);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px 14px;
}
.widget-card.clickable { cursor: pointer; transition: border-color 0.15s ease, transform 0.15s ease; }
.widget-card.clickable:hover { border-color: rgba(255, 255, 255, 0.28); transform: translateY(-1px); }
.widget-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.widget-head { display: flex; align-items: center; gap: 10px; }
.widget-icon {
  width: 28px; height: 28px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--fg);
}
.widget-icon svg { width: 22px; height: 22px; }
.widget-title { flex: 1 1 auto; min-width: 0; font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* small popup button on a link_button card */
.widget-popup {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--fg);
  cursor: pointer;
}
.widget-popup:hover { background: rgba(255, 255, 255, 0.16); }
.widget-popup svg { width: 16px; height: 16px; }
.widget-desc { margin-top: 6px; font-size: 13px; color: var(--muted); line-height: 1.35; }

/* poll (read-only results, shown in the main area) */
.poll-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(20px, 3.2vh, 40px);
  padding: 6vh clamp(24px, 7%, 120px);
  overflow-y: auto;
}
.poll-header { display: flex; align-items: center; gap: 16px; }
.poll-ico { flex: 0 0 auto; color: var(--accent); display: inline-flex; }
.poll-ico svg { width: clamp(28px, 3vw, 42px); height: clamp(28px, 3vw, 42px); }
.poll-title {
  font-size: clamp(24px, 3.4vw, 46px);
  font-weight: 800;
  line-height: 1.1;
}
.poll-options { display: flex; flex-direction: column; gap: clamp(16px, 2.4vh, 28px); }
.poll-row { display: flex; flex-direction: column; gap: 8px; }
.poll-row-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.poll-opt-text {
  font-size: clamp(16px, 1.9vw, 26px);
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.poll-row.leading .poll-opt-text { font-weight: 800; }
.poll-opt-pct { flex: 0 0 auto; font-size: clamp(16px, 1.9vw, 26px); font-weight: 800; }
.poll-track {
  position: relative;
  height: clamp(12px, 1.6vh, 18px);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.poll-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  min-width: 3px;
  transition: width 0.5s ease;
}
.poll-opt-votes { font-size: 13px; color: var(--muted); }
.poll-total { font-size: 15px; font-weight: 600; color: var(--muted); }

/* program footer */
.program {
  flex: 0 0 auto;
  width: 100%;
  height: 190px;
  background: #0b0b0f;
  border-top: 1px solid rgba(255,255,255,0.08);
}

/* ---------- scrum_poker (read-only dashboard view) ---------- */
/* centers the scrum block in the free area, both axes */
.sp-shell {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.sp-root {
  width: 100%;
  max-width: 760px;
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start; /* contents left-aligned inside the centered block */
  gap: 18px;
  color: var(--fg);
}
.sp-root > * { width: 100%; }
.sp-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sp-title { font-size: 28px; font-weight: 800; letter-spacing: -0.01em; }
.sp-chip {
  font-size: 32px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  padding: 10px 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  white-space: nowrap;
}
.sp-chip.urgent { background: rgba(198, 40, 40, 0.28); color: #ff6b6b; }
.sp-hint { font-size: 15px; color: var(--muted); margin-top: -8px; }

.sp-deck { display: flex; flex-wrap: wrap; gap: 12px; }
.sp-cardel {
  position: relative;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sp-poker {
  width: 64px;
  height: 88px;
  border-radius: 10px;
  background: #fff;
  color: #16161a;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(0, 0, 0, 0.10);
}
.sp-poker-val { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.sp-shirt { width: 104px; height: 112px; }
.sp-shirt svg { width: 100%; height: 100%; display: block; }
.sp-shirt-val {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateY(10%);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.3px;
}
.sp-shirt-val.long { font-size: 16px; }
.sp-mini.sp-poker { width: 46px; height: 62px; }
.sp-mini.sp-poker .sp-poker-val { font-size: 18px; }
.sp-mini.sp-shirt { width: 66px; height: 70px; }
.sp-mini.sp-shirt .sp-shirt-val { font-size: 15px; }
.sp-mini.sp-shirt .sp-shirt-val.long { font-size: 11px; }

.sp-voted { display: flex; flex-wrap: wrap; gap: 8px; }
.sp-facedown { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.30); }

.sp-results { display: flex; flex-direction: column; gap: 12px; }
.sp-group {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.sp-badge {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.sp-avs { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 auto; min-width: 0; }
.sp-count { flex: 0 0 auto; font-size: 16px; font-weight: 700; color: var(--muted); }
