*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #000000;
  --bg2: #1a1a1a;
  --accent: #CFFF00;
  --accent-dim: rgba(207, 255, 0, 0.25);
  --text: #ffffff;
  --muted: #89888D;
  --muted-light: #D7D7D7;
  --border: #2a2a2a;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  height: 100dvh;
  overflow: hidden;
}

/* ── MOBILE ─────────────────────────────────── */
body.mobile {
  position: relative;
  height: 100dvh;
}

.is-hidden { display: none !important; }

#join-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
}

#join-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
#join-logo img {
  width: 64px;
  height: 64px;
}
#join-logo span {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 6px;
  text-transform: uppercase;
  color: var(--text);
}

#name-input {
  width: 100%;
  max-width: 340px;
  padding: 14px 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1.1rem;
  outline: none;
}
#name-input:focus { border-color: var(--accent); }
#name-input:disabled { opacity: 0.6; }

#go-live-btn {
  width: 100%;
  max-width: 340px;
  padding: 16px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #000;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  text-transform: uppercase;
}
#go-live-btn:disabled { opacity: 0.35; cursor: not-allowed; }

#join-powered-by {
  position: absolute;
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255,255,255,0.4);
  font-size: 0.7rem;
  letter-spacing: 0.5px;
  pointer-events: none;
}
#join-powered-by img { height: 18px; width: auto; opacity: 0.5; }

#live-screen {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

#camera-frame {
  position: absolute;
  inset: 0;
  border: 3px solid rgba(207, 255, 0, 0.75);
  pointer-events: none;
  z-index: 8;
}

#selfie-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}
#selfie-video.mirror { transform: scaleX(-1); }

/* ── top bar (waiting + flip + esci) ── */
#live-top-bar {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  z-index: 10;
}
#live-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

#live-indicator {
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 6px 12px;
  border-radius: 5px;
  flex-shrink: 0;
}
#live-indicator.waiting {
  background: rgba(0,0,0,0.55);
  color: #ccc;
  border: 1px solid var(--border);
}
#live-indicator.live {
  background: var(--accent);
  color: #000;
  box-shadow: 0 0 0 3px var(--accent-dim);
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--accent-dim); }
  50%      { box-shadow: 0 0 0 10px rgba(207, 255, 0, 0); }
}

#onledwall-msg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.75);
  color: #fff;
  font-size: 1.2rem;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: 8px;
  z-index: 20;
}

#powered-by {
  position: absolute;
  bottom: max(12px, env(safe-area-inset-bottom));
  right: 12px;
  color: rgba(255,255,255,0.85);
  font-size: 0.7rem;
  letter-spacing: 0.5px;
  padding: 5px 10px;
  background: rgba(0,0,0,0.45);
  border-radius: 4px;
  z-index: 10;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
#powered-by svg, #powered-by img { display: block; height: 18px; width: auto; }
.powered-by-lgi { height: 20px; }
.powered-by-cc  { height: 16px; }
.powered-by-sep { font-size: 0.65rem; opacity: 0.5; letter-spacing: 0; }
.powered-by-name {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 2.5px;
  color: rgba(255,255,255,0.85);
}

#exit-btn {
  background: rgba(0,0,0,0.6);
  border: 1px solid var(--border);
  color: #fff;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
}

#flip-btn {
  background: rgba(0,0,0,0.6);
  border: 1px solid var(--border);
  color: #fff;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
#flip-btn svg { display: block; }
#flip-btn:active { transform: scale(0.92); }
#flip-btn:disabled { opacity: 0.5; }

/* ── DASHBOARD ───────────────────────────────── */
body.dashboard {
  display: grid;
  grid-template-rows: 48px 1fr;
  height: 100dvh;
}

body.dashboard header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: #0a0a0a;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--text);
  margin-right: auto;
}
.logo svg, .logo img { display: block; height: 22px; width: auto; }

.header-info { color: var(--muted); }

body.dashboard main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
}

.pane-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--muted);
  padding: 12px 16px 8px;
  text-transform: uppercase;
}

#live-pane {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
}

#live-video-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px 16px;
  overflow: hidden;
  position: relative;
}

#live-video-frame {
  position: relative;
  max-height: 100%;
  max-width: 100%;
  aspect-ratio: 9/16;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg2);
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 4px var(--accent-dim);
}
#live-video-frame.is-empty { display: none; }

#protagonist-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#protagonist-overlay {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 24px 14px 12px;
  background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
}

#protagonist-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #000;
  background: var(--accent);
  padding: 3px 8px;
  border-radius: 3px;
  flex-shrink: 0;
}

.pane-empty {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  line-height: 1.6;
  padding: 32px;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

#peers-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#peer-grid {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  align-content: start;
}

.peer-card {
  position: relative;
  background: var(--bg2);
  border: 2px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.peer-card:hover { border-color: var(--muted); }
.peer-card:active { transform: scale(0.98); }
.peer-card.protagonist { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }

.peer-card video {
  width: 100%;
  /* L'aspect-ratio sta sul video, non sulla .peer-card: dentro la grid un
     item con aspect-ratio veniva reso piu alto della sua riga e sbordava
     sopra la card sotto, coprendone le info in basso (nome/bitrate). */
  aspect-ratio: 9/16;
  height: auto;
  object-fit: cover;
  display: block;
}

.peer-card .peer-overlay {
  position: absolute;
  inset: auto 0 0 0;
  background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
  padding: 20px 7px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.peer-card .peer-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-width: 0;
}
.peer-card .peer-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.peer-card .peer-badge {
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--accent);
  flex-shrink: 0;
}

.peer-card .peer-status {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 0.55rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 5px;
  border-radius: 3px;
  background: rgba(0,0,0,0.6);
  color: var(--muted);
}
.peer-card .peer-status.status-connected,
.peer-card .peer-status.status-completed { color: #4ade80; }
.peer-card .peer-status.status-failed,
.peer-card .peer-status.status-disconnected { color: var(--accent); }
.peer-card .peer-status.status-connecting,
.peer-card .peer-status.status-new,
.peer-card .peer-status.status-checking { color: #fbbf24; }

#debug-panel {
  position: fixed;
  bottom: 12px;
  right: 12px;
  width: 420px;
  max-height: 50vh;
  background: rgba(0,0,0,0.92);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
#debug-panel.collapsed { max-height: 32px; overflow: hidden; }

#debug-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: #111;
  flex-shrink: 0;
}
#debug-header strong { color: var(--accent); letter-spacing: 1px; }
#debug-summary { flex: 1; color: var(--muted); font-size: 10px; }
#debug-header button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-family: inherit;
}
#debug-header button:hover { color: #fff; border-color: var(--muted); }

#debug-log {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px;
  color: #d4d4d4;
  line-height: 1.5;
}
#debug-log .row { padding: 1px 0; word-break: break-all; }
#debug-log .row.ok    { color: #4ade80; }
#debug-log .row.warn  { color: #fbbf24; }
#debug-log .row.err   { color: var(--accent); }
#debug-log .row.info  { color: #94a3b8; }
#debug-log .ts { color: #555; margin-right: 6px; }

/* ── WALL ────────────────────────────────────── */
body.wall {
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#spotlight {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#spotlight video {
  height: 100vh;
  width: calc(100vh * 9 / 16);
  max-width: 100vw;
  object-fit: cover;
}

#wall-name {
  position: absolute;
  left: 50%;
  top: 5vh;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: var(--accent);
  font-size: 3vh;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  padding: 1vh 2.5vh;
  border-radius: 4px;
  max-width: 80%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 10;
}

#gallery {
  display: flex;
  gap: 4px;
  height: 100vh;
  align-items: center;
  justify-content: center;
}
#gallery video {
  height: 100vh;
  flex: 1;
  object-fit: cover;
}

/* idle state — shown when no participant is on air */
#wall-idle {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3vh;
  background: #000;
  z-index: 5;
}
#wall-idle img {
  width: 16vh;
  height: 16vh;
  opacity: 0.9;
  animation: idle-breathe 3s ease-in-out infinite;
}
#wall-idle span {
  font-size: 2.4vh;
  font-weight: 700;
  letter-spacing: 1.2vh;
  color: var(--muted);
}
@keyframes idle-breathe {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 1; }
}

/* ── MOBILE — T&C consent ────────────────────────── */
#consent-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 340px;
  width: 100%;
  cursor: pointer;
  color: var(--muted-light);
  font-size: 0.85rem;
  line-height: 1.5;
}
#consent-label input[type="checkbox"] {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
#consent-label a { color: var(--accent); text-decoration: none; }
#consent-label a:hover { text-decoration: underline; }

#lobby-msg {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.75);
  color: var(--muted-light);
  font-size: 0.85rem;
  padding: 8px 18px;
  border-radius: 6px;
  z-index: 20;
  white-space: nowrap;
}

/* ── DASHBOARD — header extras ───────────────────── */
.room-code-badge {
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--accent);
  background: rgba(207, 255, 0, 0.08);
  border: 1px solid rgba(207, 255, 0, 0.25);
  border-radius: 4px;
  padding: 2px 10px;
}

.lobby-info { color: var(--muted); }

.header-btn {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--muted-light);
  font-size: 0.8rem;
  padding: 4px 12px;
  border-radius: 5px;
  cursor: pointer;
  margin-left: 4px;
}
.header-btn:hover { border-color: var(--muted); color: var(--text); }

/* ── DASHBOARD — room panel ──────────────────────── */
.room-panel {
  position: fixed;
  top: 48px;
  right: 12px;
  z-index: 200;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 22px 22px;
  width: 320px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}
.room-panel-inner { position: relative; }
.room-panel-close {
  position: absolute;
  top: -4px;
  right: -4px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}
.room-panel-close:hover { color: var(--text); }
.room-panel h3 {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
}
.room-panel h3 span { color: var(--accent); letter-spacing: 3px; }
.rp-row { margin-bottom: 12px; }
.rp-row label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.rp-link-row { display: flex; align-items: center; gap: 8px; }
.rp-url {
  flex: 1;
  font-size: 0.75rem;
  font-family: ui-monospace, monospace;
  color: var(--muted-light);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.copy-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted-light);
  font-size: 0.7rem;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.rp-qr-row { margin-top: 16px; text-align: center; }
.rp-qr-wrap {
  position: relative;
  display: inline-block;
  width: 160px;
  height: 160px;
}
#rp-qr-img {
  width: 160px;
  height: 160px;
  display: block;
  border-radius: 6px;
  background: #fff;
}
.rp-qr-logo-wrap {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 36px;
  height: 36px;
  background: #fff;
  border-radius: 6px;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rp-qr-logo {
  width: 100%;
  height: 100%;
  display: block;
  filter: brightness(0);
}
.rp-qr-label {
  display: block;
  margin-top: 8px;
  font-size: 0.7rem;
  color: var(--muted);
}

/* ── DASHBOARD — stats panel ──────────────────────── */
.stats-panel { width: 380px; }
.stats-table {
  font-size: 0.72rem;
  font-family: ui-monospace, monospace;
  color: var(--muted-light);
  max-height: 50vh;
  overflow-y: auto;
}
.stats-table table { width: 100%; border-collapse: collapse; }
.stats-table th, .stats-table td {
  text-align: right;
  padding: 3px 6px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.stats-table th { color: var(--muted); font-weight: 600; }
.stats-table td:first-child, .stats-table th:first-child {
  text-align: left;
  color: var(--text);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stats-table td.is-low { color: var(--accent); }
.stats-table .sp-empty { color: var(--muted); padding: 12px 0; text-align: center; }
.sp-actions { display: flex; gap: 8px; margin-top: 12px; }
.sp-note { margin-top: 10px; font-size: 0.66rem; color: var(--muted); line-height: 1.4; }

/* ── DASHBOARD — peer card extras ────────────────── */
.kick-btn {
  position: absolute;
  top: 5px;
  right: 5px;
  background: rgba(0,0,0,0.65);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.5);
  font-size: 0.65rem;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}
.peer-card:hover .kick-btn { opacity: 1; }
.kick-btn:hover { color: #fff; border-color: rgba(255,255,255,0.4); }

.pin-btn {
  position: absolute;
  top: 5px;
  right: 30px;
  background: rgba(0,0,0,0.65);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.5);
  font-size: 0.7rem;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}
.peer-card:hover .pin-btn { opacity: 1; }
.pin-btn:hover { color: #fff; border-color: rgba(255,255,255,0.4); }
.pin-btn.is-active { opacity: 1; color: var(--accent); border-color: var(--accent); }
.peer-card.pinned { box-shadow: inset 0 0 0 2px var(--accent-dim); }

.header-airtime {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--muted);
}
.header-btn-sm { padding: 5px 9px; font-size: 0.78rem; }
.header-airtime input {
  width: 44px;
  background: var(--surface, #111);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--text);
  border-radius: 4px;
  padding: 3px 5px;
  font-size: 0.8rem;
  text-align: center;
}

.airtime-countdown {
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  flex-shrink: 0;
}
.airtime-countdown.is-ending { color: #ff5555; }

.peer-timer-row {
  width: 100%;
  display: flex;
  gap: 5px;
  align-items: center;
  margin-top: 2px;
}
.peer-timer {
  font-size: 0.6rem;
  font-family: ui-monospace, monospace;
  color: var(--muted);
  letter-spacing: 0;
}
.peer-timer-air { color: var(--accent); }

.peer-stats {
  font-size: 0.6rem;
  font-family: ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  color: #9ca3af;
  letter-spacing: 0;
  margin-top: 1px;
  min-height: 0.72rem;
}
.peer-stats.is-low { color: #fbbf24; }

/* ── ROOMS PAGE ──────────────────────────────────── */
.rooms-page {
  display: grid;
  grid-template-rows: 48px 1fr;
  min-height: 100dvh;
}
.rooms-main {
  padding: 32px 24px;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  overflow-y: auto;
}
.rooms-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.rooms-top h2 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted-light);
}
#create-room-btn {
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #000;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 8px 18px;
  cursor: pointer;
}
#create-room-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.rooms-list { display: flex; flex-direction: column; gap: 12px; }
.rooms-empty { color: var(--muted); font-size: 0.9rem; padding: 32px 0; }

.room-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.room-card-code {
  font-family: ui-monospace, monospace;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--accent);
  flex-shrink: 0;
}
.room-card-info {
  font-size: 0.8rem;
  color: var(--muted);
  flex: 1;
}
.room-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.room-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted-light);
  font-size: 0.8rem;
  padding: 6px 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  white-space: nowrap;
}
.room-btn:hover { border-color: var(--muted); color: var(--text); }
.room-btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  font-weight: 700;
}
.room-btn-primary:hover { background: #b8e600; border-color: #b8e600; color: #000; }

/* ── TERMS PAGE ──────────────────────────────────── */
.terms-page { overflow-y: auto; }
.terms-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}
.terms-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}
.terms-logo img { height: 32px; width: auto; }
.terms-logo span {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--text);
}
.terms-wrap h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 16px;
}
.terms-wrap h2 {
  font-size: 1rem;
  font-weight: 700;
  margin: 28px 0 8px;
  color: var(--muted-light);
}
.terms-wrap p {
  font-size: 0.9rem;
  color: var(--muted-light);
  line-height: 1.7;
}
.terms-notice {
  background: rgba(207, 255, 0, 0.06);
  border: 1px solid rgba(207, 255, 0, 0.2);
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 24px;
  color: var(--muted-light) !important;
}
.terms-close { margin-top: 40px; }
.terms-close button {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--muted-light);
  font-size: 0.9rem;
  padding: 10px 24px;
  border-radius: 6px;
  cursor: pointer;
}
.terms-close button:hover { border-color: var(--muted); color: var(--text); }

/* ── landing page ─────────────────────────────────────────────────────────── */
.landing-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.landing-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  padding: 2rem 1rem;
  width: 100%;
  max-width: 380px;
}

.landing-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.landing-logo img {
  width: 36px;
  height: 36px;
}

.landing-logo span {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

.login-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted-light);
  margin: 0 0 0.25rem;
  text-align: center;
}

.login-input {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  outline: none;
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
}

.login-input:focus {
  border-color: var(--accent);
}

#code-input {
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-weight: 600;
}

.login-btn {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  font-family: inherit;
}

.login-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.login-error {
  color: #ff5555;
  font-size: 0.875rem;
  text-align: center;
}

.landing-powered-by {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  opacity: 0.5;
  font-size: 0.8rem;
}

.landing-powered-by img {
  height: 18px;
  filter: brightness(0) invert(1);
}

/* ── admin gestionale ─────────────────────────────────────────────────────── */
.admin-page {
  background: var(--bg);
  min-height: 100vh;
}

.admin-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.admin-badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
  background: rgba(207,255,0,0.1);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 2px 8px;
  text-transform: uppercase;
}

.admin-main {
  max-width: 820px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.admin-section h2 {
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
  margin: 0 0 1rem;
}

.create-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 480px;
}

.create-form input {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
}

.create-form input:focus { border-color: var(--accent); }

.create-pass-row {
  display: flex;
  gap: 0.5rem;
}

.create-pass-row input { flex: 1; }

.btn-primary {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 6px;
  padding: 0.6rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
}

.btn-danger {
  background: transparent;
  color: #ff5555;
  border: 1px solid #ff5555;
  border-radius: 6px;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
}

.btn-copy {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
}

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }

.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.admin-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.refresh-status {
  font-size: 0.75rem;
  color: var(--muted);
}

.events-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.events-empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 1rem 0;
}

.event-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.event-card.status-terminato {
  opacity: 0.55;
}

.event-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.event-name {
  font-weight: 600;
  color: var(--text);
}

.event-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  color: var(--accent);
  letter-spacing: 0.1em;
}

.event-badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 4px;
  padding: 2px 7px;
}

.badge-attivo {
  color: var(--accent);
  background: rgba(207,255,0,0.1);
  border: 1px solid var(--accent);
}

.badge-terminato {
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
}

.event-pass-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  flex-wrap: wrap;
}

.event-pass-label {
  color: var(--muted);
}

.event-pass-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text);
  font-size: 0.875rem;
}

.event-meta-row {
  display: flex;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--muted);
  flex-wrap: wrap;
}

.event-live-row {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--muted-light);
  flex-wrap: wrap;
}

.event-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

/* Dashboard — pausa & admit */
#pause-btn.is-paused {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
}
#admit-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Dashboard — flip camera per-card */
.card-flip-btn {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.card-flip-btn:hover {
  background: rgba(0, 0, 0, 0.8);
}

/* Mobile — mini tutorial join */
#join-steps {
  list-style: none;
  margin: 0 0 4px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 320px;
}
#join-steps li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  color: rgba(255, 255, 255, 0.85);
}
#join-steps .step-num {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  color: #000;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Mobile — schermata coda */
#lobby-msg .lobby-card,
#paused-overlay .paused-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  padding: 24px;
}
.lobby-title, .paused-title {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
}
.lobby-sub, .paused-sub {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.7);
}
.lobby-pos {
  font-size: 17px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.lobby-pos:empty { display: none; }
.lobby-spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  animation: cc-spin 0.9s linear infinite;
  margin-bottom: 6px;
}
@keyframes cc-spin { to { transform: rotate(360deg); } }

/* Mobile — overlay pausa (copre il live-screen) */
#paused-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(6px);
}
.paused-emoji { font-size: 44px; }

/* Ledwall — schermata di pausa */
#wall-paused {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: #000;
}
#wall-paused img {
  width: 140px;
  height: auto;
  opacity: 0.95;
}
#wall-paused .wall-paused-title {
  font-size: 48px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
}
