/* Color Variables */
:root {
  --background-color: #FDF6E3; /* Softer cream */
  --text-color: #2D3748; /* Darker slate for readability */
  --accent-color: #2B6B66; /* Richer teal */
  --button-hover: #1D4A47; /* Darker teal hover */
  --progress-unanswered: #A0B1BA;
  --progress-correct: #38A169; /* Professional green */
  --progress-wrong: #E53E3E; /* Softer red */
}

body.dark-mode {
  --background-color: #1A202C; /* Deep slate */
  --text-color: #E2E8F0; /* Brighter for contrast */
  --accent-color: #2B6B66;
  --button-hover: #4A8A84;
  --progress-unanswered: #4A5568;
  --progress-correct: #38A169;
  --progress-wrong: #E53E3E;
}

/* General Styles */
body {
  font-family: 'Roboto', 'Helvetica Neue', sans-serif; /* Modern font pairing */
  background: linear-gradient(135deg, var(--background-color) 0%, #FFECB3 100%);
  color: var(--text-color);
  margin: 0;
  padding: 0;
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  animation: gradientShift 15s ease infinite; /* Subtle background animation */
}

body.dark-mode {
  background: linear-gradient(135deg, var(--background-color) 0%, #2D3748 100%);
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.container {
  max-width: 800px; /* Slightly wider for balance */
  margin: 30px auto; /* More spacing */
  padding: 30px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.95), rgba(245, 245, 245, 0.9));
  border: 1px solid rgba(0, 0, 0, 0.05); /* Subtle border */
  border-radius: 16px; /* Softer corners */
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1); /* Deeper shadow */
  position: relative;
  overflow: hidden;
  flex: 1;
}

body.dark-mode .container {
  background: linear-gradient(to bottom, rgba(30, 41, 59, 0.95), rgba(45, 55, 72, 0.9));
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Header */
h1 {
  font-size: 48px; /* Larger for impact */
  font-weight: 900; /* Bolder */
  color: var(--accent-color);
  text-align: center;
  margin-bottom: 15px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1); /* Subtle depth */
}

p {
  font-size: 20px; /* Slightly larger */
  text-align: center;
  margin-bottom: 25px;
  font-weight: 400;
  color: var(--text-color);
}

/* Quiz Header (Hideable) */
.quiz-header {
  transition: opacity 0.3s ease;
}

.quiz-header.hidden {
  opacity: 0;
  height: 0;
  margin: 0;
  overflow: hidden;
}

/* Quiz Answers Container */
.quiz-answers {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 0 20px;
  box-sizing: border-box;
}

/* Buttons */
.quiz-button.btn {
  display: block;
  width: 100%;
  max-width: 450px; /* Slightly wider */
  margin: 12px 0;
  padding: 16px;
  background: linear-gradient(135deg, var(--accent-color), var(--button-hover)); /* Gradient */
  color: #fff;
  border: none;
  border-radius: 10px; /* Softer edges */
  font-size: 18px; /* Larger text */
  font-weight: 700; /* Bolder */
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease; /* Smoother transition */
  text-align: center;
  overflow-wrap: break-word;
}

.quiz-button.btn:hover {
  background: linear-gradient(135deg, var(--button-hover), var(--accent-color));
  transform: translateY(-3px) scale(1.03); /* More pronounced lift */
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}

body.dark-mode .quiz-button.btn {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Top Controls Container */
.top-controls {
  position: relative;
  text-align: center;
  margin-bottom: 15px;
  z-index: 10;
}

/* Top Button Row (Lopeta and Theme Toggle) */
.top-button-row {
  display: flex;
  justify-content: space-between;
  padding: 0 20px;
  margin-bottom: 15px;
}

/* End Button */
.end-button {
  background: linear-gradient(135deg, var(--accent-color), var(--button-hover));
  color: #fff;
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
}

.end-button:hover {
  background: linear-gradient(135deg, var(--button-hover), var(--accent-color));
  transform: translateY(-2px);
}

body.dark-mode .end-button {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Dark Mode Toggle Button */
#dark-mode-toggle, .dark-mode-toggle {
  background: linear-gradient(135deg, var(--accent-color), var(--button-hover));
  color: #fff;
  padding: 10px 20px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  transition: all 0.3s ease;
}

#dark-mode-toggle:hover, .dark-mode-toggle:hover {
  background: linear-gradient(135deg, var(--button-hover), var(--accent-color));
  transform: translateY(-2px);
}

/* Progress Container */
.quiz-progress {
  text-align: center;
  margin: 10px 0;
  padding: 12px;
  background-color: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

body.dark-mode .quiz-progress {
  background-color: rgba(0, 0, 0, 0.7);
}

.quiz-progress.hidden {
  display: none;
}

.quiz-progress span {
  font-size: 18px;
  color: var(--text-color);
  font-weight: 500;
}

/* Bottom Controls Container */
.bottom-controls {
  position: relative;
  text-align: center;
  margin-top: 20px;
  z-index: 10;
  padding-bottom: 20px; /* Ensure space for progress-circles */
}

/* Button Row (Timer and High Scores Button) */
.button-row {
  display: flex;
  justify-content: space-between;
  padding: 0 20px;
  margin-bottom: 10px;
}

/* Timer */
.quiz-timer {
  font-size: 16px;
  color: var(--text-color);
  padding: 6px 12px;
  background-color: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

body.dark-mode .quiz-timer {
  background-color: rgba(0, 0, 0, 0.7);
}

/* High Scores Button */
.high-scores-button {
  background: linear-gradient(135deg, var(--accent-color), var(--button-hover));
  color: #fff;
  padding: 10px 20px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
}

.high-scores-button:hover {
  background: linear-gradient(135deg, var(--button-hover), var(--accent-color));
  transform: translateY(-2px);
}

body.dark-mode .high-scores-button {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Progress Circles Placeholder */
.progress-circles-placeholder {
  min-height: 30px; /* Ensure space for progress-circles */
}

/* Progress Circles */
.progress-circles {
  display: none;
  text-align: center;
  position: relative; /* Use relative positioning to flow with content */
  margin: 15px auto 0; /* Increased margin for better spacing */
  z-index: 10;
}

.progress-circles.show {
  display: block;
}

.progress-circles li {
  display: inline-block;
  width: 14px; /* Slightly larger */
  height: 14px;
  margin: 0 5px;
  background-color: var(--progress-unanswered);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.progress-circles li.correct {
  background-color: var(--progress-correct);
}

.progress-circles li.wrong {
  background-color: var(--progress-wrong);
}

/* Image Centering */
.question-image {
  text-align: center;
}

.question-image img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 20px auto;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); /* Deeper shadow */
}

/* Additional Styles for Quiz Elements */
.carousel.slide {
  height: auto;
}

.carousel-inner .item {
  height: auto;
  min-height: 400px;
  padding: 30px 0; /* More padding */
}

.quiz-title {
  color: var(--accent-color);
}

.results-ratio {
  font-size: 22px; /* Larger for emphasis */
  color: var(--text-color);
  text-align: center;
  margin: 15px 0;
  font-weight: 500;
}

/* SweetAlert Customization */
.sweet-alert {
  background: linear-gradient(to bottom, var(--background-color), rgba(245, 245, 245, 0.9));
  color: var(--text-color);
  border-radius: 16px;
  padding: 25px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

body.dark-mode .sweet-alert {
  background: linear-gradient(to bottom, var(--background-color), rgba(45, 55, 72, 0.9));
}

.sweet-alert h2 {
  color: var(--accent-color);
  font-size: 32px; /* Larger */
  margin-bottom: 20px;
  font-weight: 700;
}

.sweet-alert p {
  color: var(--text-color);
  font-size: 18px;
}

.sweet-alert button {
  background: linear-gradient(135deg, var(--accent-color), var(--button-hover));
  color: #fff;
  border-radius: 10px;
  padding: 12px 24px;
  font-size: 18px;
  font-weight: 700;
}

.sweet-alert button:hover {
  background: linear-gradient(135deg, var(--button-hover), var(--accent-color));
}

/* Ensure nickname input text is black */
.sweet-alert input[type="text"] {
  color: #000000 !important;
  background-color: #ffffff;
  border: 1px solid var(--text-color);
  border-radius: 8px;
  padding: 10px;
  font-size: 16px;
  width: 100%;
  max-width: 220px;
  margin: 15px auto;
  display: block;
}

body.dark-mode .sweet-alert input[type="text"] {
  border: 1px solid #E2E8F0;
}

/* New High Score Popup */
.new-high-score-popup .sweet-alert {
  border: 2px solid var(--accent-color);
  padding: 30px;
  border-radius: 20px;
}

.new-high-score-content {
  text-align: center;
}

.new-high-score-content p {
  font-size: 20px;
  margin: 12px 0;
  line-height: 1.6;
}

.new-high-score-content .rank-text {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-color);
}

.new-high-score-content .input-label {
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 8px;
}

/* High Scores Table */
.high-scores-table {
  width: 100%;
  padding: 20px;
  font-family: 'Courier New', Courier, monospace;
  color: var(--text-color);
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
  max-height: 350px;
  overflow-y: auto;
}

body.dark-mode .high-scores-table {
  background: rgba(0, 0, 0, 0.2);
}

.high-score-header {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  padding-bottom: 15px;
  border-bottom: 2px solid var(--accent-color);
  margin-bottom: 15px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  position: sticky;
  top: 0;
  background: var(--background-color);
  z-index: 1;
}

.high-score-content {
  display: block;
}

.high-score-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  transition: background-color 0.2s;
  font-size: 16px;
  font-weight: 500;
}

.high-score-row:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

body.dark-mode .high-score-row {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode .high-score-row:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

/* Column widths */
.high-score-header span, .high-score-row span {
  flex: 1;
  text-align: center;
}

.high-score-header .rank, .high-score-row .rank {
  flex: 0 0 50px;
}

.high-score-header .nickname, .high-score-row .nickname {
  flex: 3;
}

.high-score-header .score, .high-score-row .score {
  flex: 1;
}

.high-score-header .time, .high-score-row .time {
  flex: 1.5;
}

/* Medal colors */
.high-score-row.gold {
  color: #FFD700;
  font-size: 16px;
  font-weight: 500;
}

.high-score-row.silver {
  color: #C0C0C0;
  font-size: 16px;
  font-weight: 500;
}

.high-score-row.bronze {
  color: #CD7F32;
  font-size: 16px;
  font-weight: 500;
}

/* Adjust popup width and style */
.high-scores-popup .sweet-alert {
  min-width: 650px;
  border-radius: 16px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  padding: 25px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .container {
    margin: 15px;
    padding: 20px;
  }

  .carousel-inner .item {
    min-height: 350px;
    padding: 20px 0;
  }

  .quiz-button.btn {
    max-width: 100%;
    padding: 12px; /* Reduce padding for smaller screens */
    font-size: 14px; /* Reduce font size from 18px to 14px */
  }

  .top-button-row, .button-row {
    padding: 0 15px;
  }

  .end-button {
    padding: 8px 16px; /* Reduce padding for smaller screens */
    font-size: 14px; /* Reduce font size from 16px to 14px */
  }

  .dark-mode-toggle {
    padding: 8px 16px; /* Reduce padding for smaller screens */
    font-size: 14px; /* Reduce font size from 16px to 14px */
  }

  .high-scores-button {
    padding: 8px 16px; /* Reduce padding for smaller screens */
    font-size: 14px; /* Reduce font size from 16px to 14px */
  }

  .quiz-progress span {
    font-size: 14px; /* Reduce from 18px to 14px */
  }

  .bottom-controls {
    margin-top: 10px; /* Reduce margin on smaller screens */
    padding-bottom: 10px; /* Adjusted padding */
  }

  .progress-circles {
    margin-top: 10px; /* Slightly reduced margin for smaller screens */
  }

  .progress-circles li {
    width: 12px; /* Slightly smaller circles on mobile */
    height: 12px;
    margin: 0 4px;
  }
}

/* Leaderboard Container */
.leaderboard-container {
  margin-top: 25px;
  text-align: center;
  padding: 15px;
}

.leaderboard-table {
  width: 100%;
  max-width: 650px;
  margin: 0 auto;
  border-collapse: separate;
  border-spacing: 0;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.95), rgba(245, 245, 245, 0.9));
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
}

body.dark-mode .leaderboard-table {
  background: linear-gradient(to bottom, rgba(30, 41, 59, 0.95), rgba(45, 55, 72, 0.9));
}

/* Table Header */
.leaderboard-table thead th {
  background: linear-gradient(135deg, var(--accent-color), var(--button-hover));
  color: #fff;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 14px 12px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.2);
}

/* Table Cells */
.leaderboard-table td, .leaderboard-table th {
  padding: 14px 12px;
  text-align: center;
  border: none;
}

.leaderboard-table tbody tr {
  background-color: rgba(255, 255, 255, 0.9);
  transition: background-color 0.2s ease;
}

body.dark-mode .leaderboard-table tbody tr {
  background-color: rgba(255, 255, 255, 0.05);
}

/* Alternating Rows and Hover Effects */
.leaderboard-table tbody tr:nth-child(even) {
  background-color: rgba(0, 0, 0, 0.03);
}

body.dark-mode .leaderboard-table tbody tr:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.03);
}

.leaderboard-table tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

body.dark-mode .leaderboard-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Rank Column with Icons and Colors */
.leaderboard-table .rank {
  font-weight: 700;
  color: var(--text-color);
}

.leaderboard-table tr.gold td {
  color: #FFD700; /* Gold for entire row */
}

.leaderboard-table tr.silver td {
  color: #C0C0C0; /* Silver for entire row */
}

.leaderboard-table tr.bronze td {
  color: #CD7F32; /* Bronze for entire row */
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .leaderboard-table {
    max-width: 100%;
  }

  .leaderboard-table th, .leaderboard-table td {
    padding: 10px 8px;
    font-size: 14px;
  }
}
