:root {
  color-scheme: light dark;
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f3f0ff 0%, #ffffff 70%);
  color: #1f163d;
}

.app {
  max-width: 460px;
  margin: 0 auto;
  padding: 24px 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.app-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.header-top {
  text-align: center;
  background: linear-gradient(135deg, rgba(74, 44, 192, 0.1) 0%, rgba(52, 29, 144, 0.15) 100%);
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid rgba(74, 44, 192, 0.2);
}

.program-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: #341d90;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.header-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.user-info {
  flex: 1;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  overflow: hidden;
}

.user-label {
  font-weight: 500;
  font-size: 0.9rem;
  color: #6b7280;
}

.user-name {
  font-weight: 600;
  font-size: 1rem;
  color: #4a2cc0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-info .user-name:empty {
  display: none;
}

.user-info:has(.user-name:empty) {
  display: none;
}

.link-btn {
  border: none;
  background: transparent;
  color: #4a2cc0;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.status-banner {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  display: none;
}

.status-banner--connecting {
  background: rgba(74, 44, 192, 0.12);
  color: #341d90;
  display: block;
}

.status-banner--connected {
  background: rgba(46, 204, 113, 0.15);
  color: #1d7a3a;
  display: block;
}

.status-banner--disconnected {
  background: rgba(231, 76, 60, 0.18);
  color: #a1291d;
  display: block;
}

.card {
  background: #fff;
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 18px 36px rgba(40, 28, 88, 0.16);
}

.card.hidden {
  display: none;
}

.card-title {
  margin: 0 0 12px;
  font-size: 1.2rem;
}

.name-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.name-form-row {
  display: flex;
  gap: 12px;
}

.text-input {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(74, 44, 192, 0.2);
  font-size: 1rem;
  background: #fff;
  color: #1f163d;
}

.text-input:invalid {
  border-color: rgba(231, 76, 60, 0.5);
}

.name-error {
  color: #e74c3c;
  font-size: 0.9rem;
  font-weight: 500;
  margin-top: -8px;
}

.name-error.hidden {
  display: none;
}

.primary-btn {
  padding: 12px 18px;
  background: #4a2cc0;
  color: #fff;
  border-radius: 10px;
  border: none;
  font-weight: 700;
  cursor: pointer;
  min-width: 120px;
}

.primary-btn:disabled {
  background: #a09bd3;
  cursor: not-allowed;
}

.card--empty {
  text-align: center;
  color: #5b4c96;
  background: rgba(255, 255, 255, 0.85);
  border: 1px dashed rgba(74, 44, 192, 0.2);
  box-shadow: none;
}

.empty-icon {
  font-size: 2.2rem;
  margin-bottom: 8px;
}

.poll-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.poll-header-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.poll-type-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #4a2cc0;
  background: rgba(74, 44, 192, 0.12);
  padding: 4px 10px;
  border-radius: 6px;
  align-self: flex-start;
}

.poll-type-badge.hidden {
  display: none;
}

.poll-question {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
}

.poll-timer {
  min-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.poll-timer-bar {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(74, 44, 192, 0.18);
  overflow: hidden;
}

.poll-timer-progress {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #4a2cc0 0%, #6a54d1 100%);
  transition: width 0.25s linear;
}

.poll-timer-value {
  font-weight: 700;
  color: #341d90;
}

.poll-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 18px 0 10px;
}

.poll-option-btn {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(74, 44, 192, 0.15);
  background: #f6f3ff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-start;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.poll-option-btn:active {
  transform: scale(0.98);
}

.poll-option-btn:hover {
  box-shadow: 0 6px 18px rgba(74, 44, 192, 0.18);
}

.poll-option-btn[data-selected="true"] {
  border-color: #4a2cc0;
  background: #eae3ff;
  box-shadow: 0 8px 22px rgba(74, 44, 192, 0.26);
}

.poll-option-checkmark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #4a2cc0;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}

.poll-option-text {
  flex: 1;
  text-align: left;
  font-weight: 600;
  color: #1f1742;
}

.poll-option-checkbox-label {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(74, 44, 192, 0.15);
  background: #f6f3ff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-start;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.poll-option-checkbox-label:hover {
  box-shadow: 0 6px 18px rgba(74, 44, 192, 0.18);
}

.poll-option-checkbox-label:has(.poll-option-checkbox:checked) {
  border-color: #4a2cc0;
  background: #eae3ff;
  box-shadow: 0 8px 22px rgba(74, 44, 192, 0.26);
}

.poll-option-checkbox {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: #4a2cc0;
  flex-shrink: 0;
}

.poll-option-checkbox:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.poll-results {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.poll-result-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.poll-result-bar {
  position: relative;
  height: 16px;
  border-radius: 10px;
  background: rgba(74, 44, 192, 0.16);
  overflow: hidden;
}

.poll-result-bar-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #4a2cc0 0%, #6a54d1 100%);
  width: 0;
  transition: width 0.3s ease;
}

.poll-result-values {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 600;
  gap: 12px;
  align-items: baseline;
}

.poll-result-text {
  flex: 1;
}

.poll-summary {
  font-size: 0.95rem;
  color: #4f428a;
  font-weight: 600;
  text-align: center;
}

.hidden {
  display: none !important;
}

.poll-question-reminder {
  margin-top: 10px;
  font-size: 0.95rem;
  color: #1f163d;
  background: rgba(29, 154, 138, 0.12);
  border-radius: 10px;
  padding: 10px 12px;
}

.poll-question-reminder.hidden {
  display: none;
}

.card--question {
  border-left: 6px solid #1d9a8a;
}

.question-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.question-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #0f3c36;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.question-timer {
  min-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.question-timer-bar {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(29, 154, 138, 0.2);
  overflow: hidden;
}

.question-timer-progress {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #1d9a8a 0%, #31c5b1 100%);
  transition: width 0.25s linear;
}

.question-timer-value {
  font-weight: 700;
  color: #147367;
}

.question-hint {
  margin-top: 14px;
  background: rgba(29, 154, 138, 0.08);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.question-hint.hidden {
  display: none;
}

.question-hint-label {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #1d9a8a;
  font-weight: 600;
}

.question-hint-content {
  color: #145d53;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.question-status {
  margin-top: 16px;
  font-weight: 600;
  color: #120a2f;
}

.question-form {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.text-area {
  background: #fff;
  color: #1f163d;
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(29, 154, 138, 0.32);
  padding: 12px;
  font-size: 1rem;
  resize: vertical;
  min-height: 120px;
  font-family: inherit;
}

.text-area:disabled {
  background: rgba(17, 11, 38, 0.06);
  border-color: rgba(17, 11, 38, 0.12);
}

.question-actions {
  display: flex;
  justify-content: flex-end;
}

.question-answers {
  margin-top: 16px;
  border-top: 1px solid rgba(18, 10, 47, 0.12);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 220px;
  overflow-y: auto;
}

.question-answers.hidden {
  display: none;
}

.question-answer-item {
  background: rgba(18, 10, 47, 0.05);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.question-answer-text {
  font-weight: 600;
  color: #120a2f;
}

.question-answer-author {
  font-size: 0.85rem;
  color: rgba(18, 10, 47, 0.6);
}

@keyframes animatedQuestionWiggle {
  0% { transform: rotate(-12deg); }
  50% { transform: rotate(12deg); }
  100% { transform: rotate(-12deg); }
}

.animated-question-emoji {
  display: inline-block;
  font-size: 1.4em;
  animation: animatedQuestionWiggle 3s ease-in-out infinite;
  font-style: normal;
  transform-origin: bottom center;
}

@media (max-width: 520px) {
  .app {
    padding: 20px 14px 28px;
  }

  .poll-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .poll-header-content {
    width: 100%;
  }

  .poll-timer {
    width: 100%;
    align-items: stretch;
  }

  .poll-timer-value {
    text-align: right;
  }

  .name-form-row {
    flex-direction: column;
  }

  .primary-btn {
    width: 100%;
  }
}

