/* ── Poll button — sits just below the animations button ──────────────── */
#polls-wrapper {
  position: absolute;
  right: 14px;
  top: calc(50% + 44px); /* animations button (34px) + gap (10px) */
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

#polls-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: border-color 0.2s, color 0.2s, transform 0.15s;
}

#polls-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.05);
}

#polls-svg {
  width: 20px;
  height: 20px;
}

.polls-btn-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #00c853;
  border: 1.5px solid var(--bg-header);
  display: none;
}

.polls-btn-dot.visible { display: block; }

body.circuit-panel-open #polls-wrapper {
  display: none;
}

@media (max-width: 768px) {
  #polls-wrapper {
    right: 10px;
    top: calc(42% + 34px); /* animations button (26px) + gap (8px) */
  }

  #polls-btn {
    width: 26px;
    height: 26px;
  }

  #polls-svg {
    width: 15px;
    height: 15px;
  }
}

/* ── Poll modal — same glass-card language as the hamburger menu ───────── */
#poll-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.32);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#poll-backdrop.visible {
  opacity: 1;
  pointer-events: all;
}

#poll-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(380px, 90vw);
  max-height: 80vh;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  z-index: 1600;
  display: flex;
  flex-direction: column;
  transform: translate(-50%, -50%) scale(0.94);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), opacity 0.25s ease;
  overflow: hidden;
  pointer-events: none;
  box-shadow: var(--shadow-float);
}

#poll-modal.open {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: all;
}


#poll-modal-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 12px 12px 0;
  border-bottom: none;
  flex-shrink: 0;
}


#poll-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 1rem;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.15s, color 0.15s;
}

#poll-modal-close:hover {
  background: var(--bg-pill-hover);
  color: var(--text-primary);
}


/* Fixed top: question + countdown — never scrolls */
#poll-modal-top {
  flex-shrink: 0;
  padding: 0 20px 12px;
}

/* Scrolling middle: options only — this is the one region that grows
   the modal up to its max-height, then scrolls internally past that */
#poll-modal-scroll {
  flex: 1;
  min-height: 0; /* required for flex child to actually respect overflow instead of forcing the parent to grow */
  overflow-y: auto;
  padding: 0 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#poll-modal-scroll::-webkit-scrollbar { width: 4px; }
#poll-modal-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* Fixed bottom: instruction + total votes — never scrolls */
#poll-modal-bottom {
  flex-shrink: 0;
  padding: 12px 20px 20px;
}

.poll-question {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.35;
  margin-bottom: 8px;
}

.poll-countdown {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 14px;
}

.poll-upcoming-note,
.poll-empty {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-style: italic;
  padding: 12px 0;
}

.poll-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.poll-option {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--bg-pill);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  transition: background 0.15s, border-color 0.15s;
}

.poll-option:hover:not(.locked) {
  background: var(--bg-pill-hover);
  border-color: var(--accent);
}

.poll-option.locked {
  cursor: default;
}

.poll-option.selected {
  border-color: var(--accent);
}

.poll-option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.poll-option-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.poll-option-mine {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent);
}

.poll-option-pct {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.poll-option-bar {
  margin-top: 6px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  overflow: hidden;
}

.poll-option-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.poll-instruction {
  font-size: 0.68rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 8px;
}

.poll-total-votes {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
}

@media (max-width: 480px) {
  #poll-modal {
    width: 92vw;
    max-height: 85vh;
    border-radius: 16px;
  }
}