@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;1,9..40,300&display=swap');

:root {
  --bg: #0a0a0f;
  --surface: #12121a;
  --surface2: #1a1a26;
  --border: #2a2a3a;
  --accent: #7c6af7;
  --accent2: #f76a8a;
  --accent3: #6af7c8;
  --text: #f0f0f8;
  --text-muted: #7a7a9a;
  --correct: #4ade80;
  --wrong: #f87171;
  --radius: 16px;
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, .font-display {
  font-family: 'Syne', sans-serif;
}

/* Background orbs */
.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.15;
  pointer-events: none;
  z-index: 0;
}
.orb1 {
  width: 500px; height: 500px;
  background: var(--accent);
  top: -150px; left: -150px;
}
.orb2 {
  width: 400px; height: 400px;
  background: var(--accent2);
  bottom: -100px; right: -100px;
}
.orb3 {
  width: 300px; height: 300px;
  background: var(--accent3);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}

/* Layout */
#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

/* Screens */
.screen {
  display: none;
  width: 100%;
  max-width: 760px;
  animation: fadeUp 0.4s ease;
}
.screen.active {
  display: block;
}

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

/* Home screen */
.home-header {
  text-align: center;
  margin-bottom: 3rem;
}
.home-header .logo-tag {
  display: inline-block;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  font-family: 'Syne', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 0.3rem 0.9rem;
  border-radius: 999px;
  margin-bottom: 1.2rem;
}
.home-header h1 {
  font-size: clamp(2.4rem, 6vw, 3.8rem);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 0.8rem;
}
.home-header h1 span {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.home-header p {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 420px;
  margin: 0 auto;
  line-height: 1.6;
}

/* Category grid */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.category-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.6rem;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}
.category-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  opacity: 0;
  transition: opacity 0.25s ease;
}
.category-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(124, 106, 247, 0.2);
}
.category-card:hover::before {
  opacity: 0.05;
}
.category-card .icon {
  font-size: 2.2rem;
  margin-bottom: 0.8rem;
  display: block;
}
.category-card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}
.category-card .q-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Quiz screen */
.quiz-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
}
.btn-back {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.btn-back:hover {
  border-color: var(--accent);
  background: var(--surface2);
}
.quiz-meta {
  flex: 1;
}
.quiz-meta .cat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.quiz-meta .progress-text {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
}

/* Progress bar */
.progress-bar-wrap {
  height: 4px;
  background: var(--surface2);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 2rem;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* Question card */
.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2rem;
  margin-bottom: 1.5rem;
}
.question-number {
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}
.question-text {
  font-family: 'Syne', sans-serif;
  font-size: clamp(1.1rem, 2.5vw, 1.35rem);
  font-weight: 600;
  line-height: 1.4;
}

/* Options */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.option-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.2rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  line-height: 1.4;
}
.option-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--surface2);
  transform: translateY(-2px);
}
.option-key {
  background: var(--surface2);
  color: var(--text-muted);
  font-family: 'Syne', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  flex-shrink: 0;
  margin-top: 1px;
  letter-spacing: 0.05em;
}

.option-btn.correct {
  border-color: var(--correct);
  background: rgba(74, 222, 128, 0.08);
}
.option-btn.correct .option-key {
  background: var(--correct);
  color: #0a0a0f;
}
.option-btn.wrong {
  border-color: var(--wrong);
  background: rgba(248, 113, 113, 0.08);
}
.option-btn.wrong .option-key {
  background: var(--wrong);
  color: #0a0a0f;
}
.option-btn:disabled {
  cursor: default;
}

/* Feedback */
.feedback-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.2rem;
  margin-bottom: 1.2rem;
  display: none;
  align-items: center;
  gap: 0.75rem;
  animation: fadeUp 0.3s ease;
}
.feedback-box.show { display: flex; }
.feedback-icon { font-size: 1.3rem; }
.feedback-text { font-size: 0.9rem; line-height: 1.5; }
.feedback-text strong { display: block; margin-bottom: 0.35rem; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.75; }
.correct-answer-hint {
  margin-top: 0.55rem;
  padding: 0.45rem 0.7rem;
  background: rgba(74, 222, 128, 0.1);
  border-left: 3px solid var(--correct);
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--correct);
  font-weight: 500;
}

/* Next button */
.btn-next {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  border: none;
  border-radius: 12px;
  padding: 1rem;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: none;
  transition: opacity 0.2s, transform 0.2s;
  letter-spacing: 0.02em;
}
.btn-next.show { display: block; }
.btn-next:hover { opacity: 0.9; transform: translateY(-1px); }

/* Results screen */
.results-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 2.5rem;
  text-align: center;
}
.score-ring {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--score-pct, 0%), var(--surface2) 0%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  position: relative;
}
.score-ring::before {
  content: '';
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: var(--surface);
}
.score-number {
  font-family: 'Syne', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  position: relative;
  z-index: 1;
}
.results-card h2 {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}
.results-card .sub {
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}
.results-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 2rem;
  padding: 1.2rem;
  background: var(--surface2);
  border-radius: 12px;
}
.stat { text-align: center; }
.stat-num { font-family: 'Syne', sans-serif; font-size: 1.5rem; font-weight: 800; }
.stat-num.green { color: var(--correct); }
.stat-num.red { color: var(--wrong); }
.stat-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.2rem; }

.results-btns {
  display: flex;
  gap: 0.75rem;
}
.btn-outline {
  flex: 1;
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 0.85rem;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-outline:hover { border-color: var(--accent); background: var(--surface2); }
.btn-primary {
  flex: 1;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  border: none;
  border-radius: 12px;
  padding: 0.85rem;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-primary:hover { opacity: 0.9; }

/* Responsive */
@media (max-width: 520px) {
  .options-grid { grid-template-columns: 1fr; }
  .results-btns { flex-direction: column; }
  .results-stats { gap: 1.2rem; }
}

/* ======================================================
   SITE HEADER
   ====================================================== */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 64px;
  background: rgba(10, 10, 15, 0.80);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.header-logo {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  color: inherit;
}
.header-logo span {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.header-user {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-right: 0.25rem;
}

.btn-header {
  padding: 0.45rem 1.1rem;
  border-radius: 9px;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.02em;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-login {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  border: none;
}
.btn-login:hover { opacity: 0.88; transform: translateY(-1px); }

.btn-edit-json {
  background: var(--surface2);
  border: 1.5px solid var(--accent);
  color: var(--accent);
}
.btn-edit-json:hover { background: rgba(124,106,247,0.12); }

.btn-logout {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
}
.btn-logout:hover { border-color: var(--wrong); color: var(--wrong); }

/* Push app down below fixed header */
#app {
  padding-top: 64px;
}

/* ======================================================
   LOGIN MODAL
   ====================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(5, 5, 10, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.modal-backdrop.show {
  opacity: 1;
  pointer-events: all;
}

.login-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 2.5rem 2.25rem 2rem;
  width: 100%;
  max-width: 380px;
  position: relative;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(124,106,247,0.1);
  animation: modalIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
  position: absolute;
  top: 1rem; right: 1rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 32px; height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  transition: all 0.2s;
}
.modal-close:hover { border-color: var(--wrong); color: var(--wrong); }

.modal-logo {
  font-size: 1.8rem;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.modal-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.55rem;
  font-weight: 800;
  margin-bottom: 0.3rem;
}
.modal-sub {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 1.75rem;
}

/* Form */
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: 'Syne', sans-serif;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
}
.form-group input {
  width: 100%;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 1rem;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 106, 247, 0.15);
}
.form-group input::placeholder { color: var(--text-muted); opacity: 0.6; }

.form-error {
  font-size: 0.82rem;
  color: var(--wrong);
  min-height: 1.2rem;
  margin-bottom: 0.75rem;
  padding-left: 0.2rem;
}

.btn-login-submit {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  border: none;
  border-radius: 12px;
  padding: 0.9rem;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
  margin-top: 0.25rem;
}
.btn-login-submit:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); }
.btn-login-submit:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── To Quizzes button on home screen ── */
.btn-to-quizzes {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 1.5rem;
  padding: 0.75rem 2rem;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  text-decoration: none;
  border-radius: 12px;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 4px 20px rgba(124,106,247,0.35);
}
.btn-to-quizzes:hover {
  opacity: 0.9;
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(124,106,247,0.45);
}

/* ── Notes button on home screen ── */
.btn-to-notes {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.75rem;
  padding: 0.65rem 1.8rem;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  transition: all 0.2s;
}
.btn-to-notes:hover {
  border-color: var(--accent);
  background: var(--surface2);
  transform: translateY(-1px);
}
