.app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  text-align: center;
}

.view {
  display: none;
  width: 100%;
  max-width: 640px;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.app[data-state="connecting"] [data-view="connecting"],
.app[data-state="waiting"] [data-view="waiting"],
.app[data-state="voting"] [data-view="voting"],
.app[data-state="submitted"] [data-view="submitted"],
.app[data-state="results"] [data-view="results"] {
  display: flex;
}

.status-line,
.waiting-sub,
.vote-hint {
  color: var(--ink-dim);
  font-size: 19px;
  line-height: 1.6;
}

.waiting-title {
  font-size: clamp(36px, 10vw, 54px);
  color: var(--ember-bright);
  margin: 8px 0 0;
}

.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ember);
  box-shadow: 0 0 0 0 rgba(217, 164, 65, 0.6);
  animation: pulse 1.8s infinite;
  margin-top: 10px;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(217, 164, 65, 0.55); }
  70% { box-shadow: 0 0 0 22px rgba(217, 164, 65, 0); }
  100% { box-shadow: 0 0 0 0 rgba(217, 164, 65, 0); }
}

.poll-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}

.eyebrow {
  color: var(--ember);
  letter-spacing: 0.25em;
  font-size: 17px;
}

.poll-title {
  font-size: clamp(30px, 8vw, 46px);
  margin: 0;
  color: var(--ink);
}

.options-grid {
  --grid-gap: 14px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--grid-gap);
  width: 100%;
}

.options-grid .option-card {
  flex: 0 1 calc((100% - (var(--cols, 2) - 1) * var(--grid-gap)) / var(--cols, 2));
  max-width: calc((100% - (var(--cols, 2) - 1) * var(--grid-gap)) / var(--cols, 2));
}

.option-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: var(--bg-panel);
  border: 3px solid var(--opt-color, var(--ember));
  border-radius: var(--radius-lg);
  cursor: pointer;
  color: inherit;
  font: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.option-card:active {
  transform: scale(0.96);
}

.option-card:disabled {
  opacity: 0.45;
  cursor: default;
}

.option-card.selected {
  box-shadow: 0 0 0 4px var(--opt-color, var(--ember)), 0 0 26px var(--opt-color, var(--ember));
}

.option-media {
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: var(--radius-md);
  background: var(--bg-panel-2);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.option-media .fallback-glyph {
  font-family: var(--font-display);
  font-size: 40px;
  color: var(--opt-color, var(--ember));
  opacity: 0.5;
}

.option-name {
  font-family: var(--font-body);
  font-size: 20px;
  color: var(--ink);
  text-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
}

.choice-line {
  font-size: clamp(20px, 5vw, 26px);
  color: var(--ink-dim);
  margin: 0;
}

.consequence-line {
  font-size: clamp(32px, 9vw, 52px);
  line-height: 1.4;
  color: var(--danger);
  text-shadow: 0 0 24px rgba(230, 35, 30, 0.55);
}

.dots span {
  animation: dotFade 1.4s infinite;
  opacity: 0;
}
.dots span:nth-child(1) { animation-delay: 0s; }
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotFade {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

.results-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-row {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  background: var(--bg-panel);
  border: 2px solid var(--opt-color, var(--ember));
  border-radius: var(--radius-md);
  padding: 10px 14px;
}

.result-media {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--bg-panel-2);
  background-size: cover;
  background-position: center;
}

.result-content {
  flex: 1;
  min-width: 0;
}

.result-row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}

.result-name {
  font-size: 19px;
}

.result-pct {
  font-family: var(--font-display);
  color: var(--opt-color, var(--ember));
  font-size: 21px;
}

.result-bar-track {
  height: 10px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  overflow: hidden;
}

.result-bar-fill {
  height: 100%;
  background: var(--opt-color, var(--ember));
  border-radius: 999px;
  transition: width 0.5s ease;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 3, 2, 0.78);
  backdrop-filter: blur(2px);
}

.modal-box {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 28px 24px;
  background: var(--bg-panel);
  border: 3px solid var(--ember);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glow);
  text-align: center;
}

.modal-question {
  font-size: 21px;
  line-height: 1.5;
  color: var(--ink);
  margin: 0;
}

.modal-actions {
  display: flex;
  gap: 14px;
  width: 100%;
}

.modal-btn {
  flex: 1;
  padding: 12px 10px;
  font-size: 18px;
  border-radius: var(--radius-md);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.modal-btn-cancel {
  background: transparent;
  border: 2px solid var(--ink-dim);
  color: var(--ink-dim);
}

.modal-btn-confirm {
  background: var(--ember);
  border: 2px solid var(--ember);
  color: #1a1108;
}
