:root {
  --primary: #6C63FF;
  --secondary: #EC4899;
  --bg: #0f0f1a;
  --card: #181830;
  --text: #ffffff;
  --text-muted: rgba(255,255,255,0.5);
  --success: #2ecc71;
  --font: 'Space Grotesk', Arial, sans-serif;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  width: 100%;
  max-width: 480px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

/* Header */
header {
  text-align: center;
  padding: 0.75rem 0;
  flex-shrink: 0;
}

header h1 {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: 1.6rem;
}

/* Screens */
.screen { display: none; flex: 1; }
.screen.active { display: flex; flex-direction: column; }
.hidden { display: none !important; }

.screen-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1rem;
}

h2 {
  text-align: center;
  font-size: 1.3rem;
  margin-bottom: 0.5rem;
}

.sub { color: var(--text-muted); font-size: 0.9rem; }

/* Waiting pulse */
.pulse-ring {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 4px solid var(--primary);
  animation: pulse 2s ease-in-out infinite;
  margin-bottom: 1rem;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 1; box-shadow: 0 0 0 0 rgba(108,99,255,0.4); }
  70% { transform: scale(1.1); opacity: 0.7; box-shadow: 0 0 0 20px rgba(108,99,255,0); }
  100% { transform: scale(0.9); opacity: 1; box-shadow: 0 0 0 0 rgba(108,99,255,0); }
}

.waiting-text { font-size: 1.2rem; }

#participant-qr {
  background: white;
  border-radius: 12px;
  padding: 12px;
  margin: 0.8rem 0;
}

#participant-qr img {
  width: 160px;
  height: 160px;
  display: block;
}

.share-text {
  font-weight: 600;
  color: var(--primary) !important;
  font-size: 0.95rem !important;
}

/* Error */
.icon-big {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #e74c3c;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: bold;
}

/* Vote header */
#vote-header { text-align: center; margin-bottom: 0.5rem; }

#vote-timer {
  font-size: 3rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

/* Step dots */
#step-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 0.5rem 0;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  transition: all 0.3s;
}

.dot.active { background: var(--primary); transform: scale(1.3); }
.dot.done { background: var(--secondary); }

/* Vote choices */
#vote-choices {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex: 1;
  overflow-y: auto;
  padding-bottom: 0.5rem;
}

.vote-btn {
  background: var(--card);
  border: 2px solid rgba(255,255,255,0.08);
  color: white;
  padding: 1rem 1.2rem;
  border-radius: 14px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  -webkit-tap-highlight-color: transparent;
}

.vote-btn { flex-direction: column; align-items: flex-start; }
.vote-desc { font-size: 0.8rem; color: var(--text-muted); font-weight: 400; }
.vote-btn:active { transform: scale(0.97); }
.vote-btn.disabled { opacity: 0.5; cursor: default; }
.vote-btn.disabled:active { transform: none; }

.present-wait {
  text-align: center;
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 2rem 0;
}

.vote-btn.selected {
  border-color: var(--primary);
  background: linear-gradient(135deg, rgba(108,99,255,0.2), rgba(236,72,153,0.15));
  box-shadow: 0 0 15px rgba(108,99,255,0.2);
}


/* Vote confirmed */
#vote-confirmed, #variant-confirmed {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.check-icon {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: var(--success);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: white;
  animation: popCheck 0.4s cubic-bezier(0.175,0.885,0.32,1.275);
}

@keyframes popCheck {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

/* Word grid */
#word-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  padding: 0.75rem 0;
  flex: 1;
  align-content: flex-start;
  overflow-y: auto;
}

.word-chip {
  padding: 0.6rem 1rem;
  border-radius: 20px;
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.15);
  font-size: 1rem;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s;
}

.word-chip:active { transform: scale(0.95); }

.word-chip.selected {
  border-color: var(--primary);
  background: linear-gradient(135deg, rgba(108,99,255,0.3), rgba(236,72,153,0.2));
}

#words-header {
  text-align: center;
}

#word-timer {
  font-size: 3rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

#word-count {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0.3rem 0;
}

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border: none;
  color: white;
  padding: 1rem;
  border-radius: 14px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: block;
  transition: all 0.2s;
}

.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  background: var(--card);
  border: 2px solid rgba(255,255,255,0.1);
  color: white;
  padding: 0.85rem;
  border-radius: 14px;
  font-size: 1rem;
  cursor: pointer;
  text-align: center;
  margin-top: 0.5rem;
}

.btn-full { width: 100%; }

/* Result */
.result-label {
  font-size: 1.1rem;
  color: var(--text-muted);
}

.result-winner {
  font-size: 2.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.result-winner > div {
  -webkit-text-fill-color: white;
  -webkit-background-clip: initial;
  font-size: 1rem;
  font-weight: 600;
  animation: popCheck 0.4s cubic-bezier(0.175,0.885,0.32,1.275);
}

.lyrics-highlight {
  color: var(--primary);
  font-weight: 700;
}

.lyrics-preview {
  text-align: left;
  font-size: 0.85rem;
  line-height: 1.5;
  margin-top: 0.5rem;
  white-space: pre-wrap;
  color: var(--text-muted);
}

/* Lyrics */
#lyrics-box, #final-lyrics-box {
  flex: 1;
  overflow-y: auto;
  background: var(--card);
  border-radius: 12px;
  padding: 1rem;
  margin: 0.5rem 0;
}

#lyrics-text, #final-lyrics {
  white-space: pre-wrap;
  line-height: 1.7;
  font-size: 0.95rem;
  font-family: var(--font);
}

/* Generating loader */
.loader-dots {
  display: flex;
  gap: 8px;
  margin-bottom: 1rem;
}

.loader-dots span {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  animation: bounce 1.4s ease-in-out infinite;
}

.loader-dots span:nth-child(2) { animation-delay: 0.2s; background: var(--secondary); }
.loader-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* Variant vote */
#variant-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  flex: 1;
  align-content: center;
}

.variant-btn {
  background: var(--card);
  border: 2px solid rgba(255,255,255,0.08);
  color: white;
  padding: 2rem 1rem;
  border-radius: 16px;
  font-size: 1.3rem;
  font-weight: bold;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.variant-btn:active { transform: scale(0.95); }

.variant-btn.selected {
  border-color: var(--primary);
  background: linear-gradient(135deg, rgba(108,99,255,0.25), rgba(236,72,153,0.2));
  box-shadow: 0 0 20px rgba(108,99,255,0.3);
}

/* Final */
.final-header { text-align: center; margin-bottom: 0.5rem; }

#final-audio {
  width: 100%;
  margin: 0.5rem 0;
  border-radius: 8px;
}

#download-btn {
  margin-top: 0.75rem;
}
