/* ===========================
   PSPO I Quiz Trainer — Style
   =========================== */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0d0f18;
  --surface: #161929;
  --surface2: #1e2235;
  --border: #2a2f4a;
  --accent: #6366f1;
  /* indigo */
  --accent2: #818cf8;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #f59e0b;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --radius: 14px;
  --shadow: 0 4px 32px rgba(0, 0, 0, .45);
}

html,
body {
  min-height: 100vh;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ── Screens ─────────────────────────────────────── */
.screen {
  display: none;
  min-height: 100vh;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* ── HOME ─────────────────────────────────────────── */
.home-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
  gap: 1.5rem;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(99, 102, 241, .25) 0%, transparent 70%),
    var(--bg);
}

.logo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .12em;
  padding: .35rem 1rem;
  border-radius: 99px;
}

.home-hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  line-height: 1.2;
  background: linear-gradient(135deg, #fff 40%, var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
}

/* Mode Cards */
.mode-cards {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
  max-width: 1040px;
}

.mode-card {
  flex: 1 1 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.75rem;
  cursor: pointer;
  text-align: left;
  transition: transform .2s, border-color .2s, box-shadow .2s;
  position: relative;
  overflow: hidden;
}

.mode-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(99, 102, 241, .08), transparent);
  opacity: 0;
  transition: opacity .2s;
}

.mode-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 8px 40px rgba(99, 102, 241, .25);
}

.mode-card:hover::before {
  opacity: 1;
}

.mode-icon {
  font-size: 2rem;
  margin-bottom: .75rem;
  display: block;
}

.mode-card h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: .5rem;
}

.mode-card p {
  color: var(--text-muted);
  font-size: .9rem;
  margin-bottom: 1rem;
}

.mode-tag {
  display: inline-block;
  background: rgba(99, 102, 241, .15);
  color: var(--accent2);
  font-size: .78rem;
  font-weight: 600;
  padding: .2rem .7rem;
  border-radius: 99px;
  border: 1px solid rgba(99, 102, 241, .3);
}

/* Recent Attempts panel */
.stats-bar {
  width: 100%;
  max-width: 680px;
}

.attempts-heading {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: .65rem;
  text-align: left;
}

.attempts-list {
  display: flex;
  flex-direction: column;
  gap: .55rem;
}

.attempt-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .75rem 1rem;
  border-left-width: 3px;
  transition: transform .15s;
}

.attempt-card:hover {
  transform: translateX(3px);
}

.attempt-pass {
  border-left-color: var(--green);
}

.attempt-fail {
  border-left-color: var(--red);
}

.attempt-left {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-width: 0;
}

.attempt-mode-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.attempt-info {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  min-width: 0;
}

.attempt-mode-label {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.attempt-date {
  font-size: .75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.attempt-right {
  display: flex;
  align-items: center;
  gap: .65rem;
  flex-shrink: 0;
}

.attempt-score {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
}

.attempt-badge {
  font-size: .72rem;
  font-weight: 700;
  padding: .2rem .6rem;
  border-radius: 99px;
  letter-spacing: .04em;
  white-space: nowrap;
}

.badge-pass {
  background: rgba(34, 197, 94, .14);
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, .3);
}

.badge-fail {
  background: rgba(239, 68, 68, .12);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, .3);
}


/* ── QUIZ HEADER ───────────────────────────────────── */
.quiz-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.quiz-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
}

#q-counter {
  font-size: .85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.progress-bar {
  width: 100%;
  max-width: 480px;
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 99px;
  width: 0%;
  transition: width .4s ease;
}

.timer {
  font-size: .9rem;
  font-weight: 700;
  color: var(--yellow);
  background: rgba(245, 158, 11, .1);
  border: 1px solid rgba(245, 158, 11, .3);
  padding: .35rem .9rem;
  border-radius: 99px;
  white-space: nowrap;
}

.timer.urgent {
  color: var(--red);
  background: rgba(239, 68, 68, .1);
  border-color: rgba(239, 68, 68, .3);
  animation: pulse 1s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1
  }

  50% {
    opacity: .6
  }
}

/* ── QUIZ MAIN ─────────────────────────────────────── */
.quiz-main {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1.5rem;
}

.question-card {
  width: 100%;
  max-width: 760px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.q-type-badge {
  display: inline-flex;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: .25rem .75rem;
  border-radius: 99px;
  width: fit-content;
}

.badge-single {
  background: rgba(99, 102, 241, .15);
  color: var(--accent2);
  border: 1px solid rgba(99, 102, 241, .3);
}

.badge-multi {
  background: rgba(245, 158, 11, .12);
  color: var(--yellow);
  border: 1px solid rgba(245, 158, 11, .3);
}

.badge-truefalse {
  background: rgba(34, 197, 94, .1);
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, .3);
}

.question-text {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.65;
  color: var(--text);
}

/* Options */
.options-list {
  display: flex;
  flex-direction: column;
  gap: .65rem;
}

.option-btn {
  display: flex;
  align-items: flex-start;
  gap: .85rem;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: .9rem 1.1rem;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-size: .95rem;
  line-height: 1.5;
  transition: border-color .15s, background .15s, transform .1s;
  width: 100%;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: rgba(99, 102, 241, .06);
  transform: translateX(3px);
}

.option-btn.selected {
  border-color: var(--accent);
  background: rgba(99, 102, 241, .12);
}

.option-btn.correct {
  border-color: var(--green);
  background: rgba(34, 197, 94, .1);
}

.option-btn.wrong {
  border-color: var(--red);
  background: rgba(239, 68, 68, .1);
}

.option-btn:disabled {
  cursor: default;
  transform: none !important;
}

.option-marker {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  margin-top: 1px;
  transition: border-color .15s, background .15s;
}

.option-btn.selected .option-marker {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.option-btn.correct .option-marker {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.option-btn.wrong .option-marker {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}

/* Checkbox-style markers for multi */
.marker-square {
  border-radius: 5px !important;
}

/* Feedback */
.feedback-box {
  border-radius: 10px;
  padding: 1rem 1.25rem;
  font-size: .92rem;
  line-height: 1.6;
  animation: fadeIn .3s ease;
}

.feedback-correct {
  background: rgba(34, 197, 94, .1);
  border: 1px solid rgba(34, 197, 94, .35);
  color: #86efac;
}

.feedback-wrong {
  background: rgba(239, 68, 68, .1);
  border: 1px solid rgba(239, 68, 68, .35);
  color: #fca5a5;
}

.feedback-partial {
  background: rgba(245, 158, 11, .1);
  border: 1px solid rgba(245, 158, 11, .3);
  color: #fcd34d;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* Action row */
.action-row {
  display: flex;
  gap: .85rem;
  flex-wrap: wrap;
}

/* ── BUTTONS ───────────────────────────────────────── */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: .75rem 1.75rem;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .2s, transform .1s, box-shadow .2s;
  box-shadow: 0 2px 16px rgba(99, 102, 241, .3);
}

.btn-primary:hover:not(:disabled) {
  opacity: .9;
  transform: translateY(-1px);
  box-shadow: 0 4px 24px rgba(99, 102, 241, .45);
}

.btn-primary:disabled {
  opacity: .4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: .75rem 1.75rem;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .2s, transform .1s;
}

.btn-secondary:hover {
  border-color: var(--accent2);
  transform: translateY(-1px);
}

.btn-ghost {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: .88rem;
  cursor: pointer;
  padding: .4rem .6rem;
  border-radius: 8px;
  transition: color .2s, background .2s;
  white-space: nowrap;
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--surface2);
}

/* ── RESULTS ───────────────────────────────────────── */
.results-wrap {
  max-width: 580px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  text-align: center;
}

.results-medal {
  font-size: 4rem;
  line-height: 1;
}

#results-title {
  font-size: 2rem;
  font-weight: 800;
}

#results-subtitle {
  color: var(--text-muted);
  font-size: 1rem;
}

/* Score circle */
.score-circle {
  position: relative;
  width: 160px;
  height: 160px;
}

.score-circle svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.score-track {
  fill: none;
  stroke: var(--border);
  stroke-width: 10;
}

.score-arc {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 339.3;
  stroke-dashoffset: 339.3;
  transition: stroke-dashoffset 1s ease;
}

.score-arc.pass {
  stroke: var(--green);
}

.score-arc.fail {
  stroke: var(--red);
}

.score-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .1rem;
}

.score-pct {
  font-size: 2rem;
  font-weight: 800;
}

.score-label {
  font-size: .75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.result-stats {
  display: flex;
  gap: 2rem;
}

.rstat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
}

.rstat span {
  font-size: 1.75rem;
  font-weight: 700;
}

.rstat label {
  font-size: .78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

#pass-fail-banner {
  padding: .6rem 1.5rem;
  border-radius: 99px;
  font-weight: 600;
  font-size: .9rem;
}

.banner-pass {
  background: rgba(34, 197, 94, .12);
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, .35);
}

.banner-fail {
  background: rgba(239, 68, 68, .1);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, .3);
}

.results-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* ── Home Footer ────────────────────────────────────── */
.home-footer {
  margin-top: auto;
  padding-top: 2rem;
  display: flex;
  justify-content: center;
}

.home-footer-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: .45;
  transition: opacity .25s, transform .25s;
  border-radius: 8px;
  outline-offset: 4px;
}

.home-footer-link:hover {
  opacity: 1;
  transform: scale(1.08);
}

.home-footer-link:focus-visible {
  opacity: 1;
  outline: 2px solid var(--accent2);
}

.home-footer-logo {
  height: 48px;
  width: auto;
  display: block;
  /* keep monochrome SVGs readable on dark bg */
  /*filter: brightness(0) invert(1);*/
}

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 520px) {
  .mode-card {
    flex: 1 1 100%;
  }

  .quiz-header {
    padding: .75rem 1rem;
    gap: .6rem;
  }

  .question-card {
    padding: 1.25rem;
  }

  .action-row {
    flex-direction: column;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
    text-align: center;
  }
}