@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;600;700&family=Lora:ital,wght@0,400;0,600;1,400&display=swap');

:root {
  --bg: #191c1b;
  --bg-grad: none;
  --card: #272c2a;
  --card-2: #383f3c;
  --text: #f4f8f6;
  --muted: #95a09b;
  --primary: #d97706; /* Amber Gold for PSSSB */
  --primary-d: #b45309;
  --green: #10b981;
  --green-bg: rgba(16, 185, 129, 0.18);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.18);
  --border: color-mix(in srgb, #f4f8f6 16%, transparent);
  --radius: 14px;
  --shadow: 0 10px 30px color-mix(in srgb, #000 30%, transparent);
  --font-heading: "Cormorant Garamond", Georgia, serif;
  --font-body: "Lora", Georgia, serif;
}

/* Light theme overrides */
body.light {
  --bg: #f5f4f0;
  --bg-grad: none;
  --card: #eae8e1;
  --card-2: #fcfbf8;
  --text: #1c1b18;
  --muted: #5e5b54;
  --primary: #d97706;
  --primary-d: #b45309;
  --green: #059669;
  --green-bg: rgba(5, 150, 105, 0.14);
  --red: #dc2626;
  --red-bg: rgba(220, 38, 38, 0.12);
  --border: color-mix(in srgb, #1c1b18 16%, transparent);
  --shadow: 0 10px 30px color-mix(in srgb, #272c2a 16%, transparent);
}

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

body {
  font-family: var(--font-body), -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  padding: 16px;
  transition: background 0.25s, color 0.25s;
}

h1, h2, h3, h4 { font-family: var(--font-heading); font-weight: 600; }

.app { max-width: 780px; margin: 0 auto; }

.topbar { text-align: center; padding: 18px 0 22px; position: relative; }
.hub-link {
  position: absolute; top: 12px; left: 0;
  background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 99px;
  padding: 8px 14px; font-size: 0.88rem; font-weight: 600; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
  box-shadow: var(--shadow); transition: transform 0.1s, border-color 0.2s;
}
.hub-link:hover { transform: scale(1.04); border-color: var(--primary); }
.theme-toggle {
  position: absolute; top: 12px; right: 0;
  background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 50%;
  width: 40px; height: 40px; font-size: 1.1rem; cursor: pointer;
  display: grid; place-items: center;
  box-shadow: var(--shadow); transition: transform 0.1s, background 0.2s;
}
.theme-toggle:hover { transform: scale(1.06); }
.theme-toggle:active { transform: scale(0.96); }
.topbar h1 { font-size: 1.75rem; letter-spacing: -0.02em; }
.tagline { color: var(--muted); font-size: 0.92rem; margin-top: 4px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
}

.screen { animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none;} }

h2 { font-size: 1.25rem; margin-bottom: 10px; }
.muted { color: var(--muted); font-size: 0.92rem; }
.hidden { display: none !important; }

.field { margin: 20px 0; }
.field > label, .field > .field-label { display: block; font-weight: 600; margin-bottom: 8px; font-size: 0.95rem; }

.subject-actions { display: flex; gap: 8px; margin-bottom: 10px; }
.btn-select-toggle {
  background: var(--card-2); color: var(--text); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 6px; font-size: 0.8rem; cursor: pointer;
}
.btn-select-toggle:hover { border-color: var(--primary); }

.subject-list { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 560px) { .subject-list { grid-template-columns: 1fr 1fr; } }

.subj {
  display: flex; align-items: center; gap: 10px;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: border-color 0.15s, background 0.15s;
}
.subj:hover { border-color: var(--primary); }
.subj input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.subj .cnt { margin-left: auto; color: var(--muted); font-size: 0.8rem; font-weight: 600; }

select {
  width: 100%; padding: 11px 12px;
  background: var(--card-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 0.95rem;
}

.row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 18px; }

.btn {
  border: none; border-radius: 10px;
  padding: 12px 20px; font-size: 0.98rem; font-weight: 600;
  cursor: pointer; transition: transform 0.05s, background 0.15s, opacity 0.15s;
  color: #fff;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-d); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--primary); }
.btn-danger { background: var(--red); }
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: 7px 12px; font-size: 0.85rem; }

.error { color: var(--red); margin-top: 12px; font-size: 0.9rem; }

/* ---- Quiz ---- */
.quiz-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.progress { color: var(--muted); font-size: 0.9rem; display: flex; gap: 8px; align-items: center; }
.progress .dot { opacity: 0.5; }
#scoreLabel { color: var(--text); font-weight: 600; }

.progress-bar { height: 6px; background: var(--card-2); border-radius: 99px; overflow: hidden; margin-bottom: 20px; }
.progress-fill { height: 100%; width: 0%; background: var(--primary); border-radius: 99px; transition: width 0.3s ease; }

.tags-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.subject-tag {
  display: inline-block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--primary); background: rgba(217,119,6,0.14);
  padding: 3px 9px; border-radius: 99px; font-weight: 600;
}
.topic-tag {
  display: inline-block; font-size: 0.72rem;
  color: var(--muted); background: var(--card-2);
  padding: 3px 9px; border-radius: 99px;
}
.question { font-size: 1.18rem; line-height: 1.45; margin-bottom: 22px; }

.options { display: flex; flex-direction: column; gap: 12px; }
.option {
  text-align: left; width: 100%;
  background: var(--card-2); color: var(--text);
  border: 1.5px solid var(--border); border-radius: 12px;
  padding: 14px 16px; font-size: 1rem; cursor: pointer;
  display: flex; align-items: center; gap: 12px;
  transition: border-color 0.15s, background 0.15s;
}
.option:hover:not(:disabled) { border-color: var(--primary); }
.option:disabled { cursor: default; }
.option .key {
  flex: 0 0 26px; height: 26px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--border);
  display: grid; place-items: center; font-size: 0.85rem; font-weight: 700; color: var(--muted);
}

/* states */
.option.correct { border-color: var(--green); background: var(--green-bg); }
.option.correct .key { background: var(--green); color: #fff; border-color: var(--green); }
.option.wrong { border-color: var(--red); background: var(--red-bg); }
.option.wrong .key { background: var(--red); color: #fff; border-color: var(--red); }

.blink-green { animation: blinkGreen 0.4s ease 0s 2; }
.blink-red { animation: blinkRed 0.4s ease 0s 2; }
@keyframes blinkGreen {
  0%,100% { background: var(--green-bg); }
  50% { background: var(--green); color: #fff; }
}
@keyframes blinkRed {
  0%,100% { background: var(--red-bg); }
  50% { background: var(--red); color: #fff; }
}

.quiz-foot { margin-top: 22px; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.feedback { font-weight: 600; font-size: 0.95rem; }
.feedback.ok { color: var(--green); }
.feedback.no { color: var(--red); }

/* ---- Result ---- */
.result-score { font-size: 2.6rem; font-weight: 800; text-align: center; margin: 14px 0 4px; }
#finalPercent { text-align: center; margin-bottom: 18px; }
.breakdown { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.breakdown .brow { display: flex; justify-content: space-between; font-size: 0.9rem; background: var(--card-2); padding: 9px 12px; border-radius: 8px; }
.breakdown .brow b { color: var(--text); }

/* ---- Review ---- */
.review-list { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; max-height: 70vh; overflow-y: auto; }
.rev-item { background: var(--card-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.rev-q { font-weight: 600; margin-bottom: 8px; }
.rev-opt { font-size: 0.9rem; padding: 4px 0; color: var(--muted); }
.rev-opt.correct { color: var(--green); }
.rev-opt.chosen-wrong { color: var(--red); text-decoration: line-through; }
.rev-badge { font-size: 0.72rem; padding: 2px 8px; border-radius: 99px; margin-left: 8px; }
.rev-badge.ok { background: var(--green-bg); color: var(--green); }
.rev-badge.no { background: var(--red-bg); color: var(--red); }

.footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 22px 0; display: flex; flex-direction: column; gap: 4px; }
.footer .credit { font-size: 0.82rem; }
.footer .credit b { color: var(--primary); font-weight: 700; }

