* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: #1a1a2e;
  color: white;
}

body {
  display: flex;
  flex-direction: column;
}

.screen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

header {
  padding: 15px 20px;
  text-align: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  flex-shrink: 0;
}

header h1 {
  font-size: 24px;
  font-weight: 700;
}

main {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.loading {
  text-align: center;
  color: #888;
  font-size: 18px;
  padding: 40px;
}

.polls-grid {
  display: flex;
  flex-direction: column;
  gap: 15px;
  max-width: 800px;
  margin: 0 auto;
}

.poll-card {
  background: linear-gradient(135deg, #2d2d44 0%, #1a1a2e 100%);
  border-radius: 16px;
  padding: 25px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 2px solid transparent;
}

.poll-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
  border-color: #667eea;
}

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

.poll-card h2 {
  font-size: 20px;
  margin-bottom: 15px;
  line-height: 1.4;
}

.poll-card .meta {
  color: #888;
  font-size: 14px;
  display: flex;
  gap: 15px;
}

.poll-card .options-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 15px;
}

.poll-card .option-tag {
  background: rgba(102, 126, 234, 0.2);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  color: #a0a0c0;
}

.poll-card .option-tag img {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 5px;
  object-fit: cover;
}

#poll-screen {
  background: #1a1a2e;
}

.poll-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: #2d2d44;
  flex-shrink: 0;
}

.back-btn {
  background: none;
  border: none;
  color: white;
  font-size: 16px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background 0.2s;
}

.back-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.votes-badge {
  background: rgba(102, 126, 234, 0.3);
  padding: 6px 12px;
  border-radius: 15px;
  font-size: 13px;
}

#poll-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.question-container {
  padding: 20px;
  text-align: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  flex-shrink: 0;
}

.question-text {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.4;
}

.mode-toggle {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  background: #2d2d44;
  flex-shrink: 0;
}

.mode-btn {
  flex: 1;
  max-width: 180px;
  padding: 12px 20px;
  border: 2px solid #667eea;
  background: transparent;
  color: white;
  font-size: 15px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-color: transparent;
}

.mode-btn:hover:not(.active) {
  background: rgba(102, 126, 234, 0.2);
}

.options-grid {
  flex: 1;
  display: grid;
  padding: 10px;
  gap: 10px;
  align-content: stretch;
  min-height: 0;
}

.options-grid.grid-2 {
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: 1fr;
}

.options-grid.grid-3 {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: 1fr;
}

.options-grid.grid-4 {
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
}

.options-grid.grid-5,
.options-grid.grid-6 {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
}

.option-card {
  background: linear-gradient(145deg, #3d3d5c 0%, #2d2d44 100%);
  border-radius: 16px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 15px;
  border: 3px solid transparent;
  position: relative;
  overflow: hidden;
}

.option-card:hover {
  box-shadow: 0 0 30px rgba(102, 126, 234, 0.5);
}

.option-card:active {
  transform: scale(0.97);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.option-card .content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.option-card img {
  width: 60%;
  max-width: 120px;
  height: auto;
  aspect-ratio: 1;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(255, 255, 255, 0.2);
}

.option-card .option-text {
  font-size: 18px;
  font-weight: 600;
  word-break: break-word;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.results-grid {
  flex: 1;
  display: grid;
  padding: 10px;
  gap: 10px;
  align-content: stretch;
  min-height: 0;
}

.results-grid.grid-2 {
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: 1fr;
}

.results-grid.grid-3 {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: 1fr;
}

.result-card {
  background: #2d2d44;
  border-radius: 16px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: center;
}

.result-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.result-image {
  width: 50%;
  max-width: 80px;
  height: auto;
  aspect-ratio: 1;
  border-radius: 50%;
  object-fit: cover;
}

.result-text {
  font-size: 16px;
  font-weight: 600;
}

.result-votes {
  color: #888;
  font-size: 13px;
}

.result-bar-container {
  height: 25px;
  background: #1a1a2e;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}

.result-bar {
  height: 100%;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  border-radius: 12px;
  transition: width 0.5s ease-out;
  min-width: 0;
}

.result-percentage {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-weight: 700;
  font-size: 14px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.pulse {
  animation: pulse 0.3s ease-in-out;
}

@media (max-width: 600px) {
  header h1 {
    font-size: 20px;
  }

  .poll-card {
    padding: 20px;
  }

  .poll-card h2 {
    font-size: 18px;
  }

  .question-text {
    font-size: 18px;
  }

  .question-container {
    padding: 15px;
  }

  .option-card {
    padding: 10px;
  }

  .option-card img {
    max-width: 80px;
  }

  .option-card .option-text {
    font-size: 15px;
  }

  .mode-btn {
    padding: 10px 15px;
    font-size: 14px;
  }
}

@media (min-width: 768px) {
  .option-card img {
    max-width: 150px;
  }

  .option-card .option-text {
    font-size: 22px;
  }

  .question-text {
    font-size: 28px;
  }
}
