/* Lukas 30 Quiz - Festligt lila tema */

/* ============================================
   DESIGN TOKENS / VARIABLER
   ============================================ */
:root {
  /* Färger */
  --primary: #8B5CF6;
  --primary-dark: #7C3AED;
  --primary-light: #A78BFA;
  --secondary: #EC4899;
  --background: #1E1033;
  --background-light: #2D1B4E;
  --surface: #3D2663;
  --text: #FFFFFF;
  --text-muted: #C4B5FD;
  --success: #22C55E;
  --error: #EF4444;
  --gold: #FFD700;
  --silver: #C0C0C0;
  --bronze: #CD7F32;
  
  /* Gradienter */
  --gradient-primary: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  --gradient-text: linear-gradient(135deg, var(--text) 0%, var(--primary-light) 100%);
  --gradient-gold: linear-gradient(135deg, var(--gold) 0%, #FFA500 100%);
  
  /* Skuggor */
  --shadow-sm: 0 4px 20px rgba(139, 92, 246, 0.3);
  --shadow-md: 0 10px 40px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.4);
  
  /* Rundning */
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 50px;
  
  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
}

/* ============================================
   RESET & BASE
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, var(--background) 0%, var(--background-light) 100%);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* ============================================
   ANIMERAD BAKGRUND (gemensam för alla sidor)
   ============================================ */
.bg-animation {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
}

.bubble {
  position: absolute;
  border-radius: 50%;
  background: var(--gradient-primary);
  opacity: 0.1;
  animation: float 20s infinite ease-in-out;
}

.bubble:nth-child(1) { width: 80px; height: 80px; left: 5%; animation-delay: 0s; animation-duration: 18s; }
.bubble:nth-child(2) { width: 120px; height: 120px; left: 15%; animation-delay: -3s; animation-duration: 22s; }
.bubble:nth-child(3) { width: 60px; height: 60px; left: 28%; animation-delay: -6s; animation-duration: 16s; }
.bubble:nth-child(4) { width: 100px; height: 100px; left: 42%; animation-delay: -9s; animation-duration: 24s; }
.bubble:nth-child(5) { width: 140px; height: 140px; left: 58%; animation-delay: -12s; animation-duration: 20s; }
.bubble:nth-child(6) { width: 70px; height: 70px; left: 72%; animation-delay: -15s; animation-duration: 19s; }
.bubble:nth-child(7) { width: 90px; height: 90px; left: 88%; animation-delay: -18s; animation-duration: 21s; }

@keyframes float {
  0% { transform: translateY(100vh) rotate(0deg); opacity: 0.05; }
  5% { opacity: 0.1; }
  95% { opacity: 0.1; }
  100% { transform: translateY(-100vh) rotate(360deg); opacity: 0.05; }
}

/* ============================================
   LAYOUT CONTAINERS
   ============================================ */
.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.screen-centered {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.screen-centered .card {
  width: 100%;
  max-width: 100%;
}

.display-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  height: 100vh;
  text-align: center;
  padding: 2vh 4vw;
  box-sizing: border-box;
  overflow: hidden;
}

/* ============================================
   HEADER (gemensam)
   ============================================ */
.header {
  text-align: center;
  padding: 20px 0 30px;
}

.logo {
  font-size: 3rem;
  margin-bottom: 10px;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.title {
  font-size: 2rem;
  font-weight: bold;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.display-title {
  font-size: clamp(2rem, 5vw, 4rem);
  margin-bottom: 1vh;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-muted);
  margin-top: 5px;
  font-size: 1.1rem;
}

/* ============================================
   CARDS (gemensam)
   ============================================ */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 30px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
  animation: slideUp var(--transition-slow);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   FORMULÄR
   ============================================ */
input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 16px 20px;
  border: 2px solid var(--primary);
  border-radius: var(--radius-md);
  background: var(--background);
  color: var(--text);
  font-size: 1.1rem;
  outline: none;
  transition: all var(--transition-normal);
}

input[type="text"]:focus,
input[type="password"]:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 20px rgba(236, 72, 153, 0.3);
}

input::placeholder {
  color: var(--text-muted);
}

/* ============================================
   KNAPPAR
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 32px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  text-decoration: none;
}

.btn-primary {
  background: var(--gradient-primary);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 30px rgba(139, 92, 246, 0.6);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--background);
  color: var(--text);
  border: 2px solid var(--primary);
}

.btn-secondary:hover {
  background: var(--primary);
}

.btn-danger {
  background: var(--error);
  color: var(--text);
}

.btn-danger:hover {
  background: #DC2626;
}

.btn-success {
  background: var(--success);
  color: var(--text);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.btn-full {
  width: 100%;
}

/* ============================================
   QUIZ - SVARSALTERNATIV
   ============================================ */
.options-grid {
  display: grid;
  gap: 15px;
  margin-top: 20px;
}

.option {
  padding: 20px;
  border: 3px solid var(--primary);
  border-radius: var(--radius-md);
  background: var(--background);
  cursor: pointer;
  transition: all var(--transition-normal);
  text-align: center;
  font-size: 1.1rem;
}

.option:hover {
  border-color: var(--secondary);
}

.option.selected {
  background: var(--gradient-primary);
  border-color: transparent;
}

.option-color {
  display: flex;
  align-items: center;
  gap: 15px;
}

.color-swatch {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid white;
  flex-shrink: 0;
}

.option-image {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 15px;
}

.option-image img {
  width: 100%;
  max-width: 120px;
  height: auto;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

/* ============================================
   PROGRESS BAR
   ============================================ */
.progress-container {
  margin: 20px 0;
}

.progress-bar {
  height: 12px;
  background: var(--background);
  border-radius: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: 10px;
  transition: width var(--transition-slow);
}

.progress-text {
  text-align: center;
  margin-top: 10px;
  color: var(--text-muted);
}

/* ============================================
   QUIZ - FRÅGOR
   ============================================ */
.question-number {
  color: var(--primary-light);
  font-size: 0.9rem;
  margin-bottom: 10px;
}

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

/* ============================================
   QUIZ - NAVIGATION
   ============================================ */
.quiz-navigation {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid rgba(139, 92, 246, 0.3);
}

.quiz-navigation .btn {
  padding: 12px 24px;
  font-size: 0.95rem;
}

/* ============================================
   QR-KOD (storbildsskärm)
   ============================================ */
.qr-container {
  background: white;
  padding: clamp(8px, 1vw, 15px);
  border-radius: var(--radius-md);
  margin: 1vh auto;
  box-shadow: var(--shadow-lg);
  display: inline-block;
  line-height: 0;
}

.qr-container img,
.qr-container canvas {
  display: block;
  width: clamp(200px, 25vw, 320px);
  height: clamp(200px, 25vw, 320px);
}

.scan-text {
  font-size: clamp(1rem, 2vw, 1.5rem);
  color: var(--text-muted);
  margin-top: 1vh;
}

/* ============================================
   DELTAGARE FLYTANDE BUBBLOR (storbildsskärm)
   ============================================ */
.participants-floating {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
}

.participant-bubble {
  position: absolute;
  left: 0;
  top: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--surface);
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: clamp(1rem, 1.5vw, 1.3rem);
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  animation: bubbleAppear 0.6s ease-out forwards;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  transform-origin: center center;
  will-change: transform;
}

.bubble-progress {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0%;
  background: var(--gradient-primary);
  opacity: 0.6;
  transition: width 0.5s ease-out;
  z-index: 0;
  border-radius: var(--radius-full);
}

.participant-bubble.finished {
  background: var(--gradient-primary);
}

.participant-bubble.finished .bubble-progress {
  display: none;
}

.participant-bubble .participant-name-bubble {
  position: relative;
  z-index: 1;
}

.participant-bubble .checkmark {
  color: var(--success);
  font-weight: bold;
  font-size: 1.2em;
  position: relative;
  z-index: 1;
}

@keyframes bubbleAppear {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ============================================
   RESULTAT (display top 3)
   ============================================ */
.results-container {
  width: 100%;
  max-width: 700px;
  position: relative;
}

.results-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--surface);
  padding: clamp(12px, 2vh, 20px) clamp(15px, 2vw, 30px);
  border-radius: var(--radius-md);
  animation: slideIn var(--transition-slow) backwards;
}

.result-item:nth-child(1) { background: linear-gradient(135deg, rgba(255, 215, 0, 0.3), rgba(255, 165, 0, 0.2)); }
.result-item:nth-child(2) { background: linear-gradient(135deg, rgba(192, 192, 192, 0.3), rgba(169, 169, 169, 0.2)); }
.result-item:nth-child(3) { background: linear-gradient(135deg, rgba(205, 127, 50, 0.3), rgba(184, 115, 51, 0.2)); }

.result-item:nth-child(1) { animation-delay: 0.1s; }
.result-item:nth-child(2) { animation-delay: 0.2s; }
.result-item:nth-child(3) { animation-delay: 0.3s; }
.result-item:nth-child(4) { animation-delay: 0.4s; }
.result-item:nth-child(5) { animation-delay: 0.5s; }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-50px); }
  to { opacity: 1; transform: translateX(0); }
}

.result-rank {
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  font-weight: bold;
  min-width: 60px;
  text-align: center;
}

.result-item:nth-child(1) .result-rank { color: var(--gold); }
.result-item:nth-child(2) .result-rank { color: var(--silver); }
.result-item:nth-child(3) .result-rank { color: var(--bronze); }

.result-name {
  flex: 1;
  font-size: clamp(1.1rem, 2vw, 1.5rem);
}

.result-score {
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  font-weight: bold;
  color: var(--primary-light);
}

/* ============================================
   VINNARE
   ============================================ */
.winner-container {
  text-align: center;
  animation: pulse 2s infinite;
}

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

.winner-crown {
  font-size: clamp(3rem, 8vw, 6rem);
  margin-bottom: 1vh;
}

.winner-name {
  font-size: clamp(2rem, 6vw, 4rem);
  font-weight: bold;
  background: var(--gradient-gold);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1vh;
}

.winner-text {
  font-size: clamp(1rem, 3vw, 2rem);
  color: var(--text-muted);
}

/* ============================================
   ADMIN PANEL
   ============================================ */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 15px;
}

.stat-box {
  background: var(--surface);
  padding: 20px;
  border-radius: var(--radius-md);
  text-align: center;
}

.stat-number {
  font-size: 2.5rem;
  font-weight: bold;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 1rem;
  color: var(--text-muted);
  margin-top: 5px;
}

.participant-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px;
  background: var(--background);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}

.participant-info {
  display: flex;
  flex-direction: column;
}

.participant-name {
  font-weight: 600;
  font-size: 1.1rem;
}

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

.participant-status.finished {
  color: var(--success);
}

.btn-remove {
  padding: 8px 16px;
  font-size: 0.9rem;
}

/* ============================================
   ALLA KLARA MEDDELANDE
   ============================================ */
.all-finished-message {
  margin-top: 2vh;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.5s ease, max-height 0.5s ease;
}

.all-finished-message.visible {
  opacity: 1;
  max-height: 150px;
}

.all-finished-message h2 {
  font-size: clamp(1.5rem, 3vw, 2.5rem);
  color: var(--success);
}

.all-finished-message p {
  color: var(--text-muted);
  font-size: clamp(0.9rem, 1.5vw, 1.3rem);
  margin-top: 10px;
}
.hidden {
  display: none !important;
}

.text-muted {
  color: var(--text-muted);
}

.text-center {
  text-align: center;
}

/* ============================================
   FACIT / ANSWERS LIST
   ============================================ */
.answers-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.answer-item {
  background: var(--surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  border-left: 4px solid var(--primary);
}

.answer-item.correct {
  border-left-color: var(--success);
}

.answer-item.incorrect {
  border-left-color: var(--error);
}

.answer-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.answer-header:hover {
  background: rgba(139, 92, 246, 0.1);
}

.answer-status {
  font-size: 1.3rem;
  font-weight: bold;
  width: 28px;
  text-align: center;
}

.answer-item.correct .answer-status {
  color: var(--success);
}

.answer-item.incorrect .answer-status {
  color: var(--error);
}

.answer-question {
  flex: 1;
  font-size: 0.95rem;
  line-height: 1.4;
}

.answer-toggle {
  color: var(--text-muted);
  font-size: 0.8rem;
  transition: transform var(--transition-fast);
}

.answer-details {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
  background: var(--background);
}

.answer-details.expanded {
  max-height: 200px;
  padding: 15px;
}

.answer-detail {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.answer-detail:last-child {
  margin-bottom: 0;
}

.answer-detail.correct {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.answer-detail.incorrect {
  background: rgba(239, 68, 68, 0.15);
  color: var(--error);
}

/* ============================================
   SPINNER / LADDNING
   ============================================ */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--primary);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   KONFETTI
   ============================================ */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
}

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--background);
}

::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-dark);
}

/* ============================================
   RESPONSIV DESIGN
   ============================================ */
@media (max-width: 600px) {
  .container {
    padding: 15px;
  }
  
  .card {
    padding: 20px;
    border-radius: 20px;
  }
  
  .title {
    font-size: 1.5rem;
  }
  
  .question-text {
    font-size: 1.2rem;
  }
  
  .btn {
    padding: 14px 24px;
    font-size: 1rem;
  }
}

/* ============================================
   TILLGÄNGLIGHET
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
