/* ===============================
   CSS VARIABLES & DESIGN TOKENS
================================ */
:root {
  --bg: #000;
  --bg-radial: radial-gradient(circle at top, #2b0040 0%, #120018 35%, #000 100%);
  --card-bg: #0b0b0b;
  --review-card-bg: #181818; /* Charcoalish black tone */
  --card-border: rgba(255, 255, 255, 0.08);

  --primary: #ff4ecd;
  --secondary: #ff9800;

  --success: #00ff88;
  --success-bg: rgba(0, 255, 136, 0.12);

  --danger: #ff4d4d;
  --danger-bg: rgba(255, 77, 77, 0.12);

  --text-main: #ffffff;
  --text-muted: #aaaaaa;
  --text-subtle: #cccccc;

  --option-bg: #121212;
  --option-border: #222222;
  --option-hover-bg: #1a1a1a;
}

/* ===============================
   GLOBAL RESET & BASE STYLES
================================ */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-radial);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ===============================
   QUIZ HEADER
================================ */
header.quiz-header {
  margin-top: 30px;
  text-align: center;
}

.quiz-header img {
  width: 90px;
  height: auto;
  border-radius: 18px;
}

.quiz-title {
  margin-top: 8px;
  font-size: 22px;
  font-weight: 600;
}

.category-title {
  margin: 18px 0 12px;
  font-size: 20px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

/* ===============================
   QUIZ CARDS & PLAYER LAYOUT
================================ */
.quiz-card,
.quiz-player-card,
.result-card,
.review-wrapper {
  margin-top: 24px;
  margin-bottom: 30px;
  width: 92%;
  max-width: 420px;
  background: var(--card-bg);
  padding: 26px;
  border-radius: 22px;
  border: 1px solid var(--card-border);
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.55),
    0 0 28px rgba(180, 0, 255, 0.22);
}

/* Review Card Charcoal Override */
.review-card {
  margin-top: 24px;
  margin-bottom: 30px;
  width: 92%;
  max-width: 420px;
  background: var(--review-card-bg);
  padding: 26px;
  border-radius: 22px;
  border: 1px solid var(--card-border);
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.55),
    0 0 28px rgba(180, 0, 255, 0.22);
}

.quiz-question,
.question-statement,
.review-question {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.65;
  margin-bottom: 18px;
  text-align: left;
}

/* ===============================
   BADGE SECTION (Chrome iOS WebKit Fix)
================================ */
#badgeSection {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 18px 0;
  min-height: 120px;
  text-align: center;
}

#badgeImg {
  width: 90px !important;
  height: 90px !important;
  display: block !important;
  margin: 0 auto 10px auto;
  object-fit: contain;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  will-change: transform, opacity;
}

#badgeTitle {
  font-size: 16px;
  font-weight: 700;
  margin-top: 6px;
}

/* ===============================
   PROGRESS & METADATA
================================ */
.quiz-meta-container {
  margin-bottom: 18px;
}

.progress-text {
  font-size: 13px;
  color: var(--primary);
  margin-bottom: 6px;
  font-weight: 600;
  text-align: left;
}

.progress-bar-bg {
  height: 8px;
  background: #222;
  border-radius: 10px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 0.45s cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ===============================
   OPTIONS & CHOICE CARDS
================================ */
.options-container,
.quiz-options,
.review-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quiz-options .option,
.review-option,
.option {
  background: var(--option-bg);
  border: 1px solid var(--option-border);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 16px;
  line-height: 1.55;
  cursor: pointer;
  text-align: left;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.quiz-options .option:hover,
.option:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 0 16px rgba(255, 78, 205, 0.25);
  background: var(--option-hover-bg);
}

.option:active {
  transform: scale(0.98);
}

.option.correct,
.review-option.correct {
  border-color: var(--success) !important;
  background: var(--success-bg) !important;
  color: var(--success);
  animation: correctPulse 0.35s ease;
}

.option.wrong,
.review-option.wrong {
  border-color: var(--danger) !important;
  background: var(--danger-bg) !important;
  color: var(--danger);
}

@keyframes correctPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

/* ===============================
   EXPLANATION BOX
================================ */
.explanation-box,
.review-explanation,
.explanation {
  margin-top: 18px;
  font-size: 14px;
  color: var(--text-subtle);
  line-height: 1.5;
  padding-left: 12px;
  border-left: 3px solid var(--primary);
  text-align: left;
}

.feedback-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}

.feedback-title.success-text { color: var(--success); }
.feedback-title.error-text { color: var(--danger); }

/* ===============================
   BUTTONS & NAVIGATION
================================ */
.next-btn,
.primary-btn {
  width: 100%;
  padding: 14px;
  margin-top: 16px;
  border-radius: 30px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  color: #000;
  box-shadow: 0 0 16px rgba(255, 78, 205, 0.5);
  transition: opacity 0.2s ease, transform 0.2s ease;
  text-decoration: none;
  display: inline-block;
}

.next-btn:hover,
.primary-btn:hover {
  transform: scale(1.02);
  opacity: 0.95;
}

.primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.ghost-btn,
.secondary-btn {
  padding: 11px 20px;
  border-radius: 30px;
  border: 1px solid #333;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.ghost-btn:hover,
.secondary-btn:hover {
  border-color: var(--text-main);
  color: var(--text-main);
}

.review-nav,
.action-grid {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 22px;
}

/* ===============================
   LOADING & SPINNER
================================ */
.loading-box,
.loading-text {
  padding: 30px 0;
  color: var(--text-main);
  font-size: 15px;
}

.spinner {
  width: 42px;
  height: 42px;
  border: 4px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 18px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ===============================
   UTILITY ANIMATIONS
================================ */
.fade-in {
  animation: fadeIn 0.25s ease forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===============================
   RESULT & SCORECARD PAGE
================================ */
.score {
  font-size: 36px;
  font-weight: 700;
  color: var(--primary);
}

.score-label {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 20px 0;
}

.stat-box {
  background: var(--option-bg);
  padding: 14px;
  border-radius: 14px;
  border: 1px solid #222;
}

.stat-label { font-size: 12px; color: var(--text-muted); }
.stat-value { font-size: 18px; font-weight: bold; margin-top: 4px; }

/* =========================================================
   PRIMARY LANDING CONTROL BUTTONS (FULL WIDTH)
========================================================= */

/* 1. Flatpickr Outer Wrapper Alignment */
.date-picker-wrapper,
.flatpickr-wrapper {
  width: 92% !important;
  max-width: 370px !important;
  height: 54px !important;
  margin: 12px auto !important;
  padding: 0 !important;
  display: block !important;
  box-sizing: border-box !important;
}

/* 2. Target Main Control Buttons ONLY */
.menu-btn,
.date-input-btn,
#dailyBtn,
#gsBtn,
#quizDatePicker {
  width: 92% !important;
  max-width: 370px !important;
  height: 54px !important;
  min-height: 54px !important;
  max-height: 54px !important;
  
  margin: 12px auto !important;
  padding: 0 16px !important;
  
  border: none !important;
  outline: none !important;
  box-sizing: border-box !important;
  appearance: none !important;
  -webkit-appearance: none !important;

  background: linear-gradient(90deg, #ff44ee, #b200ff) !important;
  color: #ffffff !important;
  font-size: 18px !important;
  font-weight: 600 !important;
  font-family: inherit !important;
  border-radius: 40px !important;
  box-shadow: 0 4px 16px rgba(178, 0, 255, 0.4) !important;
  
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  line-height: 1 !important;
  cursor: pointer !important;
  transition: transform 0.2s ease, box-shadow 0.2s ease !important;
}

/* Flatpickr Internal Input Fit */
.flatpickr-wrapper #quizDatePicker,
.date-picker-wrapper #quizDatePicker {
  width: 100% !important;
  margin: 0 !important;
}

.menu-btn:hover,
.date-input-btn:hover {
  transform: scale(1.02) !important;
  box-shadow: 0 6px 20px rgba(178, 0, 255, 0.6) !important;
}

.menu-btn.active {
  outline: 2px solid #ff8cff !important;
  box-shadow: 0 0 20px rgba(255, 68, 238, 0.6) !important;
}

/* =========================================================
   SUBMENU LAYOUT FIXES (BACK BUTTON, TOPIC CARDS, SET GRID)
========================================================= */

/* Keep Submenu Centered */
#subMenu {
  width: 100%;
  max-width: 420px;
  margin: 16px auto;
  text-align: center;
}

/* Small, Compact Back Button */
#subMenu .back-btn {
  width: auto !important;
  height: auto !important;
  min-height: unset !important;
  max-height: unset !important;
  padding: 8px 18px !important;
  font-size: 14px !important;
  background: transparent !important;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
  color: #e0e0e0 !important;
  border-radius: 20px !important;
  box-shadow: none !important;
  display: inline-block !important;
  margin: 10px auto !important;
  cursor: pointer !important;
}

#subMenu .back-btn:hover {
  border-color: #ffffff !important;
  color: #ffffff !important;
}

/* Topic / Subject Grid Buttons (2-Column Grid) */
#subMenu .set-grid {
  display: grid !important;
  grid-template-columns: repeat(2, 1fr) !important;
  gap: 12px !important;
  width: 92% !important;
  max-width: 370px !important;
  margin: 16px auto !important;
  padding: 0 !important;
}

#subMenu .set-btn {
  width: 100% !important;
  height: 48px !important;
  min-height: 48px !important;
  font-size: 15px !important;
  border-radius: 30px !important;
  margin: 0 !important;
  background: linear-gradient(90deg, #ff44ee, #b200ff) !important;
  color: white !important;
  border: none !important;
  cursor: pointer !important;
  box-shadow: 0 4px 14px rgba(178, 0, 255, 0.35) !important;
  transition: transform 0.2s ease, opacity 0.2s ease !important;
}

#subMenu .set-btn:hover {
  transform: scale(1.04) !important;
  opacity: 0.95 !important;
}

/* ===============================
   RESPONSIVE LAYOUT
================================ */
@media (max-width: 480px) {
  .set-grid {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 360px) {
  .quiz-card,
  .review-card,
  .quiz-player-card,
  .result-card {
    padding: 20px;
  }

  .quiz-question,
  .review-question,
  .question-statement {
    font-size: 16px;
  }

  .quiz-options .option,
  .review-option,
  .option {
    font-size: 15px;
  }
}