/* ==========================================================================
   Latihan Mapak Mukti - Mobile-Friendly Responsive Stylesheet
   Designed for kids: cheerful, clean, high contrast, readable typography
   ========================================================================== */

:root {
  --primary: #4f46e5;
  --primary-light: #6366f1;
  --primary-dark: #3730a3;
  --primary-soft: #eef2ff;
  
  --secondary: #0ea5e9;
  --secondary-soft: #f0f9ff;
  
  --accent: #f59e0b;
  --accent-soft: #fef3c7;
  
  --success: #10b981;
  --success-dark: #059669;
  --success-soft: #ecfdf5;
  
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --danger-soft: #fef2f2;
  
  --warning: #f59e0b;
  --warning-soft: #fffbeb;
  
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-focus: #818cf8;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --header-height: 64px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}

/* App Wrapper */
.app-container {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  position: relative;
}

/* Common Screen Styles */
.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  width: 100%;
  animation: fadeIn 0.25s ease-out;
}

.screen.active {
  display: flex;
}

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

/* ==========================================================================
   Screen 1: Home / Setup Screen
   ========================================================================== */
.home-header {
  padding: 28px 20px 20px;
  text-align: center;
  background: linear-gradient(135deg, #4f46e5 0%, #3b82f6 50%, #06b6d4 100%);
  color: #ffffff;
  border-bottom-left-radius: 28px;
  border-bottom-right-radius: 28px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.home-header::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 140px;
  height: 140px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
}

.home-header::after {
  content: '';
  position: absolute;
  bottom: -30px;
  left: -30px;
  width: 100px;
  height: 100px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
}

.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(8px);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.app-title {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
}

.app-subtitle {
  font-size: 0.95rem;
  opacity: 0.92;
  max-width: 440px;
  margin: 0 auto 12px;
  line-height: 1.4;
}

.quick-stats-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 10px;
}

.quick-stat-chip {
  background: rgba(255, 255, 255, 0.18);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.home-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
}

/* Pool Progress Card */
.progress-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.progress-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.progress-count {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
}

.progress-bar-bg {
  width: 100%;
  height: 10px;
  background: #e2e8f0;
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #06b6d4);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.progress-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-link-reset {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.2s;
}

.btn-link-reset:hover {
  background: var(--danger-soft);
}

/* Student Name Input Box */
.student-name-box {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.student-name-label {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.required-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: #ef4444;
}

.student-name-input {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  border: 2px solid #cbd5e1;
  border-radius: var(--radius-sm);
  outline: none;
  background: #f8fafc;
  transition: all 0.2s;
}

.student-name-input:focus {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.results-student-name {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fef08a;
  margin-top: 4px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.sheet-sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(8px);
  padding: 5px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 10px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Section Title */
.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-hint {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-muted);
}

/* Question Count Selector Cards */
.count-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.count-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  user-select: none;
}

.count-card:active {
  transform: scale(0.98);
}

.count-card.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.count-badge {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.1;
  margin-bottom: 2px;
}

.count-card.selected .count-badge {
  color: var(--primary-dark);
}

.count-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.count-time {
  font-size: 0.8rem;
  font-weight: 700;
  color: #d97706;
  background: #fef3c7;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.count-card.selected .count-time {
  background: #fde68a;
  color: #b45309;
}

.count-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.count-card:last-child {
  grid-column: span 2;
}

/* Feature Toggles & Settings */
.settings-box {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.setting-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
}

.setting-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Custom Switch Toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #cbd5e1;
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

input:checked + .slider {
  background-color: var(--primary);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* Big Start Button */
.btn-start {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1.15rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.2s ease;
  user-select: none;
}

.btn-start:hover {
  background: linear-gradient(135deg, #4338ca 0%, #3730a3 100%);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.45);
}

.btn-start:active {
  transform: scale(0.98);
}

/* Resume Banner */
.resume-banner {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

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

.resume-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #1e40af;
}

.resume-desc {
  font-size: 0.78rem;
  color: #3b82f6;
}

.btn-resume {
  background: #2563eb;
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

/* History Box */
.history-section {
  margin-top: 10px;
}

.history-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-details {
  display: flex;
  flex-direction: column;
}

.history-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.history-mode {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.history-score {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--success-dark);
}

/* ==========================================================================
   Screen 2: Quiz / Practice Screen
   ========================================================================== */
.quiz-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 10px 16px;
}

.quiz-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.btn-icon:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

.quiz-progress-text {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Timer Badge */
.timer-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  color: var(--text-main);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--border);
  transition: all 0.3s ease;
}

.timer-badge.warning {
  background: #fef3c7;
  color: #b45309;
  border-color: #fde68a;
  animation: pulseWarning 1.5s infinite;
}

.timer-badge.danger {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
  animation: pulseDanger 0.8s infinite;
}

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

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

/* Header Linear Progress Bar */
.quiz-progress-bar {
  width: 100%;
  height: 6px;
  background: #e2e8f0;
  border-radius: var(--radius-full);
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4f46e5, #06b6d4);
  width: 0%;
  transition: width 0.3s ease;
  border-radius: var(--radius-full);
}

/* Quiz Content Area */
.quiz-body {
  padding: 20px 16px 120px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Question Card */
.question-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.question-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tag-badge {
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-flag {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-full);
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}

.btn-flag.active {
  background: #fef3c7;
  color: #b45309;
  border-color: #fde68a;
}

.question-text {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.6;
  white-space: pre-line;
}

.question-text.large {
  font-size: 1.35rem;
}

/* Input Area */
.answer-box {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.answer-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.answer-input {
  width: 100%;
  padding: 14px 44px 14px 16px;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
  border: 2px solid #cbd5e1;
  border-radius: var(--radius-md);
  outline: none;
  transition: all 0.2s;
  background: #f8fafc;
}

.answer-input:focus {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.answer-input::placeholder {
  color: #94a3b8;
  font-weight: 400;
  font-size: 0.95rem;
}

.btn-clear-input {
  position: absolute;
  right: 12px;
  background: #cbd5e1;
  color: #475569;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}

.btn-clear-input.visible {
  display: flex;
}

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

/* Sticky Bottom Navigation Bar */
.quiz-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06);
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 25;
}

.footer-nav-container {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.btn-nav {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  user-select: none;
}

.btn-nav:hover:not(:disabled) {
  background: #e2e8f0;
}

.btn-nav:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-nav-primary {
  background: var(--primary);
  color: #ffffff;
  border: none;
  flex: 1;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

.btn-nav-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-grid-drawer {
  background: #f1f5f9;
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   Question Grid Drawer / Modal
   ========================================================================== */
.drawer-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.drawer-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.drawer-content {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 680px;
  margin: 0 auto;
  background: #ffffff;
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  padding: 20px 16px 28px;
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
  z-index: 55;
  box-shadow: var(--shadow-xl);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.drawer-backdrop.active .drawer-content {
  transform: translateY(0);
}

.drawer-handle {
  width: 40px;
  height: 5px;
  background: #cbd5e1;
  border-radius: 3px;
  margin: 0 auto 16px;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.drawer-title {
  font-size: 1.1rem;
  font-weight: 800;
}

.drawer-legend {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot-answered { background: var(--success); }
.dot-flagged { background: var(--accent); }
.dot-unanswered { background: #cbd5e1; }
.dot-current { background: var(--primary); }

.grid-scroll-box {
  overflow-y: auto;
  flex: 1;
  padding-right: 4px;
}

.question-num-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

@media (min-width: 480px) {
  .question-num-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

@media (min-width: 600px) {
  .question-num-grid {
    grid-template-columns: repeat(8, 1fr);
  }
}

.grid-num-btn {
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text-main);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.15s;
}

.grid-num-btn.answered {
  background: var(--success-soft);
  border-color: var(--success);
  color: var(--success-dark);
}

.grid-num-btn.flagged {
  border-color: var(--accent);
}

.grid-num-btn.flagged::after {
  content: '🔖';
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 0.65rem;
}

.grid-num-btn.current {
  box-shadow: 0 0 0 2px var(--primary);
  font-weight: 800;
}

.drawer-actions {
  margin-top: 16px;
}

/* ==========================================================================
   Screen 3: Results / Review Screen
   ========================================================================== */
.results-header {
  padding: 32px 20px 24px;
  text-align: center;
  background: linear-gradient(135deg, #4f46e5 0%, #3b82f6 50%, #06b6d4 100%);
  color: #ffffff;
  border-bottom-left-radius: 28px;
  border-bottom-right-radius: 28px;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.trophy-icon {
  font-size: 3.5rem;
  margin-bottom: 8px;
  display: inline-block;
  animation: bounce 1s ease infinite alternate;
}

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}

.results-title {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.results-msg {
  font-size: 0.95rem;
  opacity: 0.92;
  margin-bottom: 16px;
}

.score-circle-card {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-lg);
  padding: 16px;
  max-width: 280px;
  margin: 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.score-number {
  font-size: 3.2rem;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.score-max {
  font-size: 1.1rem;
  font-weight: 600;
  opacity: 0.85;
}

.results-content {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Stats Breakdown Grid */
.stats-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 8px;
  text-align: center;
}

.stat-box.success {
  background: var(--success-soft);
  border-color: #a7f3d0;
}

.stat-box.danger {
  background: var(--danger-soft);
  border-color: #fecaca;
}

.stat-val {
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1.2;
}

.stat-box.success .stat-val { color: var(--success-dark); }
.stat-box.danger .stat-val { color: var(--danger-dark); }

.stat-lbl {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.time-spent-box {
  grid-column: span 3;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  padding: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
}

/* Action Button Row */
.action-buttons-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-action {
  padding: 14px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}

.btn-action-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.btn-action-retry {
  background: #fff;
  border: 2px solid var(--danger);
  color: var(--danger-dark);
}

.btn-action-share {
  background: #25d366;
  color: #fff;
}

.btn-action-secondary {
  background: #e2e8f0;
  color: var(--text-main);
}

/* Review Filter Tabs */
.review-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tab-filter-bar {
  display: flex;
  gap: 6px;
  background: #e2e8f0;
  padding: 4px;
  border-radius: var(--radius-full);
  overflow-x: auto;
}

.tab-btn {
  background: none;
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.tab-btn.active {
  background: #ffffff;
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

/* Review Cards List */
.review-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.review-item-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.review-item-card.is-correct {
  border-left: 5px solid var(--success);
}

.review-item-card.is-wrong {
  border-left: 5px solid var(--danger);
}

.review-item-card.is-empty {
  border-left: 5px solid #94a3b8;
}

.review-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.review-q-num {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--primary);
}

.badge-status {
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-status.correct {
  background: var(--success-soft);
  color: var(--success-dark);
}

.badge-status.wrong {
  background: var(--danger-soft);
  color: var(--danger-dark);
}

.badge-status.empty {
  background: #f1f5f9;
  color: #64748b;
}

.review-q-text {
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.45;
}

.review-ans-row {
  background: #f8fafc;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
}

.review-user-ans {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.review-key-ans {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  color: var(--success-dark);
  font-weight: 700;
}

.btn-toggle-override {
  align-self: flex-start;
  background: #f1f5f9;
  border: 1px dashed #cbd5e1;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-toggle-override:hover {
  background: #e2e8f0;
}

/* AI Validation Specific Styles */
.badge-status.ai-valid {
  background: linear-gradient(135deg, #ecfdf5 0%, #e0e7ff 100%);
  color: #065f46;
  border: 1px solid #a7f3d0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ai-note-box {
  background: #f0fdf4;
  border-left: 3px solid #10b981;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.82rem;
  color: #065f46;
  line-height: 1.4;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.review-actions-row {
  display: flex;
  align-items: center;
  margin-top: 4px;
}

/* AI Loading Modal */
.ai-loading-box {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  max-width: 360px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  animation: modalPop 0.25s ease-out;
}

.ai-loading-icon {
  font-size: 3rem;
  animation: pulseAi 1.4s infinite ease-in-out;
}

@keyframes pulseAi {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15) rotate(5deg); }
}

.ai-spinner {
  width: 36px;
  height: 36px;
  border: 4px solid #e0e7ff;
  border-top-color: #4f46e5;
  border-radius: 50%;
  animation: spinAi 0.8s linear infinite;
}

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

/* ==========================================================================
   Modals & Dialogs
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  text-align: center;
  animation: modalPop 0.2s ease-out;
}

@keyframes modalPop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.modal-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-btn-row {
  display: flex;
  gap: 10px;
}

.modal-btn-row .btn-nav {
  flex: 1;
  justify-content: center;
}

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

/* Toast Notification */
.toast-notice {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-30px);
  background: #1e293b;
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

.toast-notice.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
