@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700&family=Outfit:wght@400;600;700&display=swap');

:root {
  --font-main: 'Kanit', 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  
  /* Color Palette - Modern Deep Blue & Emerald Glow */
  --bg-dark: #0f172a;
  --bg-canvas: #090d16;
  --surface-card: rgba(30, 41, 59, 0.7);
  --surface-card-hover: rgba(51, 65, 85, 0.8);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-highlight: rgba(255, 255, 255, 0.05);

  --primary: #3b82f6;
  --primary-glow: rgba(59, 130, 246, 0.35);
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.3);
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-purple: #8b5cf6;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --radius-xl: 28px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Global Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font-main);
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-canvas);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(59, 130, 246, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(139, 92, 246, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(16, 185, 129, 0.08) 0%, transparent 60%);
  background-attachment: fixed;
}

/* App Shell Container */
.app-viewport {
  width: 100%;
  max-width: 440px;
  height: 100vh;
  max-height: 900px;
  background: var(--bg-dark);
  border-radius: 0;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.7),
              0 0 0 1px rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

@media (min-width: 500px) {
  .app-viewport {
    height: 92vh;
    border-radius: var(--radius-xl);
    margin: 20px;
  }
}

/* Phone Mockup Notch Header */
.app-header-bar {
  padding: 16px 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--glass-border);
  z-index: 20;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.brand-text h1 {
  font-size: 1rem;
  font-weight: 700;
  background: linear-gradient(135deg, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text p {
  font-size: 0.72rem;
  color: var(--accent-emerald);
  font-weight: 500;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.05);
}

/* Main Content Area */
.app-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  scroll-behavior: smooth;
}

.app-content::-webkit-scrollbar {
  width: 5px;
}

.app-content::-webkit-scrollbar-track {
  background: transparent;
}

.app-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}

/* Screens Management */
.screen {
  display: none;
  animation: fadeIn 0.35s ease-out forwards;
}

.screen.active {
  display: block;
}

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

/* ==========================================
   HOME SCREEN STYLES
   ========================================== */
.hero-card {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.95));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  margin-bottom: 24px;
}

.hero-card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.12) 0%, transparent 60%);
  pointer-events: none;
}

.hero-tag {
  display: inline-block;
  padding: 4px 12px;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--primary);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.hero-title {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 8px;
}

.hero-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}

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

.stat-val {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.stat-lbl {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Config Selector Cards */
.section-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.config-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.mode-option {
  background: var(--surface-card);
  border: 2px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: var(--transition-fast);
}

.mode-option:hover {
  background: var(--surface-card-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

.mode-option.selected {
  border-color: var(--primary);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(30, 41, 59, 0.8));
  box-shadow: 0 0 15px var(--primary-glow);
}

.mode-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mode-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.mode-icon.blue { background: rgba(59, 130, 246, 0.2); color: var(--primary); }
.mode-icon.purple { background: rgba(139, 92, 246, 0.2); color: var(--accent-purple); }
.mode-icon.emerald { background: rgba(16, 185, 129, 0.2); color: var(--accent-emerald); }

.mode-info h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.mode-info p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.radio-check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--text-dim);
  position: relative;
  transition: var(--transition-fast);
}

.mode-option.selected .radio-check {
  border-color: var(--primary);
  background: var(--primary);
}

.mode-option.selected .radio-check::after {
  content: '';
  position: absolute;
  top: 5px;
  left: 5px;
  width: 6px;
  height: 6px;
  background: white;
  border-radius: 50%;
}

/* Category Filter Dropdown / Select */
.select-wrapper {
  position: relative;
  margin-bottom: 24px;
}

.custom-select {
  width: 100%;
  padding: 14px 16px;
  background: var(--surface-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
  cursor: pointer;
  appearance: none;

}

.select-wrapper::after {
  content: '▼';
  font-size: 0.7rem;
  color: var(--text-muted);
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

/* Primary Button */
.btn-primary {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), #2563eb);
  color: white;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 20px var(--primary-glow);
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 25px var(--primary-glow);
}

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

/* ==========================================
   QUIZ SCREEN STYLES
   ========================================== */
.quiz-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.question-counter {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.question-counter span {
  color: var(--primary);
  font-size: 1.1rem;
  font-weight: 700;
}

.timer-pill {
  padding: 6px 12px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--accent-amber);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Progress Track */
.progress-container {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 20px;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent-emerald));
  border-radius: 10px;
  transition: width 0.3s ease;
}

/* Question Box */
.question-card {
  background: var(--surface-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.category-tag {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-emerald);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.question-text {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text-main);
}

/* Choices List */
.choices-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.choice-btn {
  background: var(--surface-card);
  border: 2px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  text-align: left;
  transition: var(--transition-fast);
  color: var(--text-main);
  font-size: 0.92rem;
}

.choice-btn:hover {
  background: var(--surface-card-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

.choice-btn.selected {
  border-color: var(--primary);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(30, 41, 59, 0.9));
  box-shadow: 0 0 12px var(--primary-glow);
}

.choice-badge {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: var(--transition-fast);
}

.choice-btn.selected .choice-badge {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.choice-text {
  flex: 1;
  line-height: 1.4;
}

/* Quiz Controls Navigation */
.quiz-nav {
  display: flex;
  gap: 12px;
}

.btn-secondary {
  flex: 1;
  padding: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

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

/* ==========================================
   RESULT SCREEN STYLES
   ========================================== */
.result-header {
  text-align: center;
  padding: 20px 0;
}

.score-circle-container {
  width: 140px;
  height: 140px;
  margin: 0 auto 20px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.score-circle-bg {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: conic-gradient(var(--accent-emerald) 0deg, var(--glass-border) 0deg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 30px var(--accent-emerald-glow);
}

.score-circle-inner {
  width: 116px;
  height: 116px;
  border-radius: 50%;
  background: var(--bg-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.score-number {
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-main);
}

.score-total {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.result-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.result-subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.result-summary-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.summary-card {
  background: var(--surface-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
}

.summary-card.correct { border-left: 4px solid var(--accent-emerald); }
.summary-card.wrong { border-left: 4px solid var(--accent-rose); }

.summary-card h4 {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.summary-card p {
  font-size: 1.2rem;
  font-weight: 700;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ==========================================
   REVIEW SCREEN STYLES
   ========================================== */
.review-filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.filter-chip {
  padding: 6px 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-fast);
}

.filter-chip.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.review-item {
  background: var(--surface-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 14px;
}

.review-item.is-correct {
  border-left: 4px solid var(--accent-emerald);
}

.review-item.is-wrong {
  border-left: 4px solid var(--accent-rose);
}

.review-q-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 10px;
  line-height: 1.4;
}

.review-choices {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.review-choice {
  font-size: 0.85rem;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.review-choice.user-selected {
  border: 1px solid var(--accent-rose);
  background: rgba(244, 63, 94, 0.1);
  color: var(--accent-rose);
}

.review-choice.correct-answer {
  border: 1px solid var(--accent-emerald);
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  font-weight: 600;
}

.review-explanation {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 10px;
  border-radius: var(--radius-sm);
  margin-top: 8px;
  line-height: 1.4;
  border-left: 2px solid var(--primary);
}

/* Toast Message */
.toast {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--glass-border);
  color: white;
  padding: 10px 20px;
  border-radius: 25px;
  font-size: 0.85rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 100;
  pointer-events: none;
}

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