/* Rumhoot - Main Styles (Dark Red Theme for Light Background) */

:root {
  --primary: #c62828;
  --primary-dark: #8e0000;
  --primary-light: #ef5350;
  --secondary: #d32f2f;
  --accent-red: #c62828;
  --accent-blue: #1565c0;
  --accent-yellow: #ef6c00;
  --accent-green: #2e7d32;
  --white: #ffffff;
  --gray-light: rgba(255, 255, 255, 0.1);
  --gray: #9e9e9e;
  --dark: #1a1212;
  --dark-card: rgba(35, 18, 18, 0.92);
  --dark-nav: rgba(28, 12, 12, 0.95);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.5);
  --border-color: rgba(255, 255, 255, 0.1);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  color: var(--text-primary);
  position: relative;
}

/* Blurred background image using pseudo-element */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url('/rumhoot.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.3;
  z-index: -1;
  transform: scale(1.1); /* Prevent blur edges showing */
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.container-sm {
  max-width: 500px;
  margin: 0 auto;
  padding: 20px;
}

/* Cards - Dark glassmorphism style */
.card {
  background: var(--dark-card);
  border-radius: 16px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
  padding: 30px;
  margin-bottom: 20px;
}

/* Only apply backdrop blur on desktop (iOS Safari has severe performance issues with it) */
@supports (backdrop-filter: blur(20px)) {
  @media (hover: hover) and (min-width: 1024px) {
    .card,
    .navbar,
    .game-header {
      backdrop-filter: blur(20px);
      -webkit-backdrop-filter: blur(20px);
    }
    .stat-card {
      backdrop-filter: blur(10px);
      -webkit-backdrop-filter: blur(10px);
    }
  }
}

.card-header {
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border-color);
}

.card-title {
  font-size: 1.5rem;
  color: var(--primary-light);
  margin-bottom: 5px;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: all 0.3s ease;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary-dark) 100%);
  color: var(--white);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #ff8a80 0%, var(--primary) 100%);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-success {
  background: linear-gradient(135deg, #00c853 0%, #009624 100%);
  color: var(--white);
}

.btn-danger {
  background: linear-gradient(135deg, #ff1744 0%, #c51162 100%);
  color: var(--white);
}

.btn-warning {
  background: linear-gradient(135deg, #ffab00 0%, #ff8f00 100%);
  color: #1a1a2e;
}

.btn-block {
  display: block;
  width: 100%;
}

.btn-lg {
  padding: 16px 32px;
  font-size: 1.25rem;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.875rem;
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text-primary);
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  transition: all 0.3s ease;
}

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

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 0 3px rgba(124, 77, 255, 0.2);
}

.form-select {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.form-select option {
  background: var(--dark);
  color: var(--text-primary);
}

/* Navigation */
.navbar {
  background: var(--dark-nav);
  padding: 15px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
  border-bottom: 1px solid var(--border-color);
}

.navbar-brand {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary-light);
  text-decoration: none;
}

.navbar-nav {
  display: flex;
  gap: 20px;
  align-items: center;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 6px;
  transition: all 0.3s ease;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
}

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

.table th {
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
  color: var(--text-secondary);
}

.table tr:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Answer Options (Game) */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-top: 20px;
}

.option-btn {
  padding: 30px 20px;
  border: none;
  border-radius: 12px;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--white);
  cursor: pointer;
  transition: transform 0.2s, opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
}

.option-btn:hover:not(:disabled) {
  transform: scale(1.02);
}

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

.option-btn.option-0 { background: var(--accent-red); }
.option-btn.option-1 { background: var(--accent-blue); }
.option-btn.option-2 { background: var(--accent-yellow); }
.option-btn.option-3 { background: var(--accent-green); }

.option-btn.selected {
  opacity: 0.8;
  box-shadow: inset 0 0 0 5px rgba(255,255,255,0.5);
}

.option-btn.correct {
  box-shadow: inset 0 0 0 5px var(--white);
}

.option-btn.incorrect {
  opacity: 0.4;
}

/* PIN Code Display */
.pin-display {
  font-size: 4rem;
  font-weight: 700;
  color: var(--primary-light);
  text-align: center;
  letter-spacing: 10px;
  padding: 30px;
  background: rgba(198, 40, 40, 0.15);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  margin: 20px 0;
}

/* PIN Input */
.pin-input {
  font-size: 2.5rem;
  text-align: center;
  letter-spacing: 10px;
  padding: 20px;
  border: 2px solid var(--primary);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

/* Countdown Timer */
.countdown {
  font-size: 5rem;
  font-weight: 700;
  color: var(--white);
  text-align: center;
  text-shadow: 3px 3px 6px rgba(0,0,0,0.5);
  background: var(--primary-dark);
  width: 150px;
  height: 150px;
  line-height: 150px;
  border-radius: 50%;
  margin: 0 auto;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.countdown-small {
  font-size: 2.5rem;
  width: 80px;
  height: 80px;
  line-height: 80px;
}

/* Question Display */
.question-display {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: var(--white);
  padding: 40px;
  border-radius: 12px;
  text-align: center;
  font-size: 1.5rem;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

/* Player List */
.player-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.player-tag {
  background: rgba(198, 40, 40, 0.3);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 500;
  border: 1px solid var(--border-color);
}

/* Leaderboard */
.leaderboard {
  margin-top: 20px;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  padding: 15px 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 10px;
}

.leaderboard-rank {
  font-size: 1.5rem;
  font-weight: 700;
  width: 50px;
  color: var(--primary-light);
}

.leaderboard-rank.gold { color: #ffd740; }
.leaderboard-rank.silver { color: #e0e0e0; }
.leaderboard-rank.bronze { color: #ffab91; }

.leaderboard-name {
  flex: 1;
  font-weight: 600;
  color: var(--text-primary);
}

.leaderboard-score {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-light);
}

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.05);
  padding: 25px;
  border-radius: 12px;
  text-align: center;
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
}

.stat-card:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}

.stat-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary-light);
}

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

/* Quiz List */
.quiz-list {
  margin-top: 20px;
}

.quiz-item {
  display: flex;
  align-items: center;
  padding: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  margin-bottom: 15px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.quiz-item:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateX(5px);
  border-color: var(--primary);
}

.quiz-info {
  flex: 1;
}

.quiz-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.quiz-meta {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 5px;
}

.quiz-actions {
  display: flex;
  gap: 10px;
}

/* Alerts */
.alert {
  padding: 15px 20px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.alert-error {
  background: rgba(255, 82, 82, 0.15);
  color: #ff8a80;
  border: 1px solid rgba(255, 82, 82, 0.3);
}

.alert-success {
  background: rgba(105, 240, 174, 0.15);
  color: #69f0ae;
  border: 1px solid rgba(105, 240, 174, 0.3);
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

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

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

/* Result Animation */
.result-correct {
  animation: pulse-green 0.5s ease;
}

.result-incorrect {
  animation: shake 0.5s ease;
}

@keyframes pulse-green {
  0%, 100% { background-color: var(--accent-green); }
  50% { background-color: #4caf50; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

/* Hide/Show utilities */
.hidden {
  display: none !important;
}

/* Full screen game view */
.game-fullscreen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.game-header {
  background: var(--dark-nav);
  padding: 15px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

.game-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 30px;
}

/* Responsive */
@media (max-width: 768px) {
  .options-grid {
    grid-template-columns: 1fr;
  }

  .pin-display {
    font-size: 2.5rem;
    letter-spacing: 5px;
  }

  .navbar {
    flex-direction: column;
    gap: 15px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 10px;
  }

  .card {
    padding: 20px;
  }

  .option-btn {
    padding: 20px 15px;
    font-size: 1rem;
    min-height: 80px;
  }
}

/* ========== Celebration Effects ========== */

/* Confetti Container */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 1000;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -10px;
  animation: confetti-fall 3s ease-out forwards;
}

.confetti:nth-child(odd) {
  border-radius: 50%;
}

.confetti:nth-child(even) {
  border-radius: 2px;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(0) rotate(0deg) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg) scale(0.5);
    opacity: 0;
  }
}

/* Trophy Animation */
.trophy-icon {
  font-size: 5rem;
  animation: trophy-bounce 1s ease infinite;
  display: inline-block;
}

@keyframes trophy-bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-20px) scale(1.1); }
}

/* Podium rank styles */
.rank-display {
  font-size: 4rem;
  font-weight: 800;
  animation: rank-pop 0.5s ease-out;
}

.rank-1 { color: #ffd700; text-shadow: 0 0 20px rgba(255, 215, 0, 0.5); }
.rank-2 { color: #c0c0c0; text-shadow: 0 0 20px rgba(192, 192, 192, 0.5); }
.rank-3 { color: #cd7f32; text-shadow: 0 0 20px rgba(205, 127, 50, 0.5); }

@keyframes rank-pop {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); opacity: 1; }
}

/* Celebration message */
.celebration-message {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 15px 0;
  animation: celebration-pulse 2s ease-in-out infinite;
}

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

/* Stars burst effect */
.stars-container {
  position: absolute;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.star {
  position: absolute;
  font-size: 1.5rem;
  animation: star-burst 1.5s ease-out forwards;
  opacity: 0;
}

@keyframes star-burst {
  0% { transform: scale(0) rotate(0deg); opacity: 1; }
  50% { opacity: 1; }
  100% { transform: scale(1) rotate(180deg) translateY(-100px); opacity: 0; }
}

/* ========== Answer Review Styles ========== */

.answer-review-item {
  background: var(--dark-card);
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 15px;
  border-left: 4px solid var(--gray);
}

.answer-review-item.correct {
  border-left-color: var(--accent-green);
}

.answer-review-item.incorrect {
  border-left-color: var(--accent-red);
}

.answer-review-question {
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.answer-review-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.answer-review-option {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--gray-light);
  color: var(--text-secondary);
}

.answer-review-option.your-answer {
  border: 2px solid var(--accent-blue);
  background: rgba(21, 101, 192, 0.2);
}

.answer-review-option.correct-answer {
  background: rgba(46, 125, 50, 0.3);
  color: var(--accent-green);
}

.answer-review-option.your-answer.correct-answer {
  background: rgba(46, 125, 50, 0.4);
  border-color: var(--accent-green);
}

.answer-review-option.your-answer.wrong {
  background: rgba(198, 40, 40, 0.3);
  border-color: var(--accent-red);
}

.answer-review-result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.answer-review-points {
  font-weight: 600;
}

.answer-review-points.earned {
  color: var(--accent-green);
}

.answer-summary {
  display: flex;
  justify-content: space-around;
  padding: 15px;
  background: var(--gray-light);
  border-radius: 12px;
  margin-bottom: 15px;
}

.answer-summary-item {
  text-align: center;
}

.answer-summary-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.answer-summary-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ========== Modal Styles ========== */

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  overflow-y: auto;
  padding: 20px;
}

.modal.active {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.modal-content {
  background: var(--dark-card);
  border-radius: 16px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 700px;
  margin: 20px auto;
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.3rem;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 5px;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
  max-height: 70vh;
  overflow-y: auto;
}

/* ========== Game Review Table Styles ========== */

.clickable-row {
  cursor: pointer;
  transition: background 0.2s;
}

.clickable-row:hover {
  background: rgba(255, 255, 255, 0.1);
}

.review-link {
  color: var(--primary-light);
  font-size: 0.85rem;
}

/* ========== Answer Review List (Modal) ========== */

.answer-review-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.answer-review-item {
  display: flex;
  gap: 15px;
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 15px;
  border-left: 4px solid var(--gray);
}

.answer-review-item.correct {
  border-left-color: var(--accent-green);
}

.answer-review-item.incorrect {
  border-left-color: var(--accent-red);
}

.answer-review-item .question-number {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-muted);
  min-width: 30px;
}

.answer-review-item .question-content {
  flex: 1;
}

.answer-review-item .question-text {
  font-weight: 600;
  margin-bottom: 10px;
  line-height: 1.4;
}

.answer-review-item .answer-details {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.answer-review-item .answer-label {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-right: 8px;
}

.answer-review-item .answer-text {
  font-size: 0.9rem;
}

.answer-review-item .answer-text.correct {
  color: var(--accent-green);
}

.answer-review-item .answer-text.incorrect {
  color: var(--accent-red);
}

.answer-review-item .points-earned {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--accent-green);
  font-weight: 600;
}

.answer-review-item .result-icon {
  font-size: 1.2rem;
  font-weight: 700;
}

.answer-review-item.correct .result-icon {
  color: var(--accent-green);
}

.answer-review-item.incorrect .result-icon {
  color: var(--accent-red);
}

.answer-review-item.unanswered {
  border-left-color: var(--gray);
}

.answer-review-item.unanswered .result-icon {
  color: var(--text-muted);
}

.answer-text.unanswered {
  color: var(--text-muted);
  font-style: italic;
}

/* Summary stats in modal */
.answer-summary .summary-stat {
  text-align: center;
}

.answer-summary .summary-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-light);
}

.answer-summary .summary-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ========== AI Analysis Styles ========== */

.ai-analysis-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
  text-align: center;
}

.ai-analysis {
  background: linear-gradient(135deg, rgba(21, 101, 192, 0.15), rgba(46, 125, 50, 0.15));
  border: 1px solid rgba(21, 101, 192, 0.3);
  border-radius: 12px;
  padding: 15px;
  text-align: left;
}

.ai-analysis-header {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 10px;
  color: var(--primary-light);
}

.ai-analysis-content {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-primary);
}
