/* SECTION: Design Tokens */
:root {
  /* Colors */
  --color-bg-primary: #050816;
  --color-bg-secondary: #070b1f;
  --color-surface: #0b1220;
  --color-surface-soft: #0f172a;
  --color-text: #e5e7eb;
  --color-text-muted: #9ca3af;
  --color-border-subtle: #1f2937;
  --color-accent: #38bdf8;
  --color-accent-soft: rgba(56, 189, 248, 0.12);
  --color-accent-strong: #0ea5e9;
  --color-danger: #fb7185;
  --color-danger-soft: rgba(248, 113, 113, 0.12);
  --color-success: #4ade80;

  /* Typography */
  --font-sans: "Space Grotesk", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;

  /* Sizing & layout */
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-pill: 999px;
  --shadow-soft:
    0 1px 2px rgba(15, 23, 42, 0.4),
    0 18px 40px rgba(15, 23, 42, 0.9);
  --transition-fast: 150ms ease-out;
  --transition-med: 220ms ease-out;

  /* Timer */
  --timer-ok: #22c55e;
  --timer-warning: #facc15;
  --timer-danger: #fb7185;

  /* Accent RGB for glows */
  --accent-rgb: 56, 189, 248;
}

/* SECTION: Global Layout */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: var(--font-sans);
  background-color: var(--color-bg-primary);
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-shell {
  position: relative;
  width: 100%;
  max-width: 860px;
  padding: 32px 20px 40px;
  margin: 0 auto;
  z-index: 1;
}

@media (min-width: 720px) {
  .app-shell {
    padding: 40px 28px 56px;
  }
}

/* SECTION: Background Effects */
.gradient-mesh {
  background:
    radial-gradient(at 20% 0%, rgba(56, 189, 248, 0.2) 0, transparent 55%),
    radial-gradient(at 80% 10%, rgba(129, 140, 248, 0.24) 0, transparent 50%),
    radial-gradient(at 0% 60%, rgba(45, 212, 191, 0.16) 0, transparent 55%),
    radial-gradient(at 100% 80%, rgba(244, 63, 94, 0.16) 0, transparent 55%),
    #020617;
}

.floating-shape {
  position: fixed;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.35;
  z-index: 0;
  pointer-events: none;
  animation: float 12s ease-in-out infinite alternate;
}

.floating-shape--left {
  background: radial-gradient(circle at 30% 30%, #38bdf8, transparent);
  top: -80px;
  left: -80px;
}

.floating-shape--right {
  background: radial-gradient(circle at 70% 70%, #f97316, transparent);
  bottom: -120px;
  right: -100px;
}

@keyframes float {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(12px, -18px, 0) scale(1.05);
  }
  100% {
    transform: translate3d(-10px, -8px, 0) scale(1.03);
  }
}

/* SECTION: Header */
.app-header {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 28px;
}

@media (min-width: 720px) {
  .app-header {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 32px;
  }
}

.app-title {
  font-size: 2.2rem;
  letter-spacing: -0.04em;
  margin: 0 0 6px;
}

.app-subtitle {
  margin: 0 0 10px;
  color: var(--color-text-muted);
  font-size: 0.98rem;
}

.accent-line {
  width: 72px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--color-accent), transparent);
}

.app-header__meta {
  display: flex;
  gap: 10px;
}

.meta-pill {
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: radial-gradient(circle at 0 0, rgba(148, 163, 184, 0.3), transparent),
    rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(14px);
}

.meta-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-text-muted);
}

.meta-value {
  font-weight: 600;
  font-size: 0.95rem;
}

/* SECTION: Quiz Card */
.quiz-card {
  position: relative;
  border-radius: var(--radius-lg);
  padding: 20px 18px 18px;
  background:
    linear-gradient(135deg, rgba(148, 163, 184, 0.2), transparent 40%),
    radial-gradient(circle at 100% 0, rgba(56, 189, 248, 0.14), transparent 55%),
    rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-soft);
}

@media (min-width: 720px) {
  .quiz-card {
    padding: 22px 24px 22px;
  }
}

/* Gradient border wrapper from design system */
.gradient-border {
  border: 1px solid transparent;
  background:
    linear-gradient(var(--color-surface-soft), var(--color-surface-soft)) padding-box,
    linear-gradient(120deg, rgba(56, 189, 248, 0.7), rgba(244, 63, 94, 0.9))
      border-box;
}

.shadow-soft {
  box-shadow: var(--shadow-soft);
}

.quiz-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.progress-group {
  flex: 1;
}

.status-label {
  display: inline-block;
  margin-bottom: 6px;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--color-text-muted);
}

.progress-bar {
  position: relative;
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 1);
}

.progress-bar__inner {
  position: absolute;
  inset: 0;
  width: 0%;
  background: linear-gradient(90deg, var(--color-accent), #22c55e);
  border-radius: inherit;
  transition: width var(--transition-med);
}

.status-value {
  margin: 6px 0 0;
  font-size: 0.88rem;
  color: var(--color-text-muted);
}

/* SECTION: Timer */
.timer {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.timer-label {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--color-text-muted);
}

.timer-display {
  min-width: 72px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  background: radial-gradient(circle at 0 0, rgba(56, 189, 248, 0.24), transparent),
    rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(148, 163, 184, 0.7);
}

.timer-display--ok {
  color: var(--timer-ok);
}

.timer-display--warning {
  color: var(--timer-warning);
}

.timer-display--danger {
  color: var(--timer-danger);
}

/* SECTION: Question */
.question-area {
  padding: 16px 0 10px;
}

.question-category {
  margin: 0 0 6px;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.question-text {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.5;
}

/* SECTION: Options */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 14px 0 0;
}

.option {
  list-style: none;
}

.option-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.option-button {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid rgba(148, 163, 184, 0.45);
  background:
    linear-gradient(120deg, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0.88));
  color: inherit;
  text-align: left;
  padding: 11px 13px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  cursor: pointer;
  transition:
    border-color var(--transition-fast),
    background var(--transition-fast),
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
}

@media (min-width: 720px) {
  .option-button {
    padding: 12px 14px;
  }
}

.option-key {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.65);
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
}

.option-label {
  font-size: 0.96rem;
}

.option-state-pill {
  min-width: 70px;
  text-align: right;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--color-text-muted);
}

/* Hover / focus */
.option-button:hover {
  border-color: var(--color-accent);
  background:
    radial-gradient(circle at 0 0, rgba(56, 189, 248, 0.15), transparent 60%),
    rgba(15, 23, 42, 0.96);
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.6);
}

.option-button:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 1),
    0 0 0 3px rgba(56, 189, 248, 0.8);
}

/* States: selected / correct / incorrect */
.option-button--selected {
  border-color: var(--color-accent-strong);
  background:
    radial-gradient(circle at 0 0, rgba(56, 189, 248, 0.18), transparent 60%),
    rgba(15, 23, 42, 0.96);
}

.option-button--correct {
  border-color: var(--color-success);
  background:
    radial-gradient(circle at 0 0, rgba(52, 211, 153, 0.2), transparent 60%),
    rgba(15, 23, 42, 0.96);
}

.option-button--incorrect {
  border-color: var(--color-danger);
  background:
    radial-gradient(circle at 0 0, rgba(248, 113, 113, 0.2), transparent 60%),
    rgba(15, 23, 42, 0.96);
}

.option-key--correct {
  border-color: var(--color-success);
  color: var(--color-success);
}

.option-key--incorrect {
  border-color: var(--color-danger);
  color: var(--color-danger);
}

.option-state-pill--correct {
  color: var(--color-success);
}

.option-state-pill--incorrect {
  color: var(--color-danger);
}

/* Disabled options after answering */
.option-button[disabled] {
  cursor: default;
  opacity: 0.9;
  transform: none;
  box-shadow: none;
}

/* SECTION: Footer, feedback & controls */
.quiz-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.feedback {
  min-height: 20px;
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.feedback--correct {
  color: var(--color-success);
}

.feedback--incorrect {
  color: var(--color-danger);
}

.feedback--timeout {
  color: var(--color-danger);
}

.controls-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* SECTION: Buttons */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.94rem;
  cursor: pointer;
  transition:
    transform var(--transition-fast),
    box-shadow var(--transition-fast),
    background var(--transition-fast),
    border-color var(--transition-fast),
    color var(--transition-fast);
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-accent-strong), #22c55e);
  color: #020617;
  border-color: transparent;
  box-shadow:
    0 12px 30px rgba(56, 189, 248, 0.45),
    0 0 0 1px rgba(15, 23, 42, 0.4);
}

.btn-primary:hover {
  transform: translateY(-1px) scale(1.01);
  box-shadow:
    0 18px 45px rgba(56, 189, 248, 0.55),
    0 0 0 1px rgba(15, 23, 42, 0.4);
}

.btn-secondary {
  background: rgba(15, 23, 42, 0.8);
  color: var(--color-text);
  border-color: rgba(148, 163, 184, 0.7);
}

.btn-secondary:hover {
  background: rgba(15, 23, 42, 0.95);
  border-color: var(--color-accent);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.btn:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 1),
    0 0 0 3px rgba(56, 189, 248, 0.9);
}

.btn-full {
  width: 100%;
}

/* SECTION: Results */
.results-card {
  margin-top: 20px;
  padding: 18px 18px 18px;
  border-radius: var(--radius-lg);
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(148, 163, 184, 0.35);
  backdrop-filter: blur(18px);
}

@media (min-width: 720px) {
  .results-card {
    padding: 20px 22px 22px;
  }
}

.results-title {
  margin: 0 0 4px;
  font-size: 1.25rem;
}

.results-score {
  margin: 0 0 2px;
  font-weight: 600;
}

.results-detail {
  margin: 0 0 16px;
  color: var(--color-text-muted);
  font-size: 0.94rem;
}

.results-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.results-stat {
  flex: 1 1 30%;
  min-width: 120px;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(30, 64, 175, 0.9);
}

.results-stat__label {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-text-muted);
}

.results-stat__value {
  display: block;
  font-size: 1.05rem;
  margin-top: 4px;
}

/* SECTION: Hint */
.hint {
  margin: 14px 2px 0;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* SECTION: Utility */
[hidden] {
  display: none !important;
}

@media (max-width: 520px) {
  .quiz-status-row {
    align-items: flex-start;
  }

  .timer-display {
    min-width: 64px;
  }

  .controls-row {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .btn {
    width: 100%;
  }
}
