:root {
  /* Design Tokens (Playful Palette) */
  --bg: #f6fbff;
  --card: #ffffff;
  --text: #153243;
  --muted: #6b7b8c;
  --primary: #4f9cf9; /* Blue */
  --accent: #ff6b6b; /* Red */
  --teal: #00c2a8;
  --glass: rgba(79, 156, 249, 0.08);
  --success: #28a745;
  --danger: #e74c3c;
  --shadow-sm: 0 3px 9px rgba(18, 38, 63, 0.05);
  --shadow: 0 6px 18px rgba(18, 38, 63, 0.08);
  --shadow-lg: 0 12px 30px rgba(18, 38, 63, 0.1);
  --radius: 12px;
  --max-width: 1100px;
  --container-pad: 20px;

  /* Typography scale */
  font-size: 16px;
}

/* BASE STYLES */
/* -------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Inter", "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(180deg, var(--bg), #ffffff);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5; /* Slightly increased line height for better readability */
  padding: 1.5rem 1rem;
}

/* LAYOUT & STRUCTURE */
/* -------------------------------------- */
.page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--container-pad);
}

/* HEADER */
/* -------------------------------------- */
.site-header {
  background: linear-gradient(90deg, rgba(79, 156, 249, 0.12), rgba(0, 194, 168, 0.04));
  backdrop-filter: blur(4px);
  border-radius: 1rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.125rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.logo-mark {
  width: 3.5rem;
  height: 3.5rem;
  background: linear-gradient(135deg, var(--primary), var(--teal));
  color: white;
  border-radius: 0.75rem;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.5rem;
  box-shadow: 0 6px 12px rgba(79, 156, 249, 0.18);
  flex-shrink: 0;
}

.site-title {
  margin: 0;
  font-size: 1.25rem;
  color: var(--text);
  font-weight: 700;
}

.credits {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  color: var(--muted);
}

/* Name Input Block */
.name-block {
  min-width: 220px;
}

.name-block .label {
  font-weight: 600;
  color: var(--text);
  display: block;
  margin-bottom: 0.375rem;
}

.req {
  color: var(--accent);
  font-weight: 700;
  margin-left: 0.375rem;
}

.name-block input {
  width: 100%;
  padding: 0.625rem;
  border-radius: 0.625rem;
  border: 1px solid rgba(21, 50, 67, 0.06);
  background: linear-gradient(180deg, #fff, #fbfdff);
  font-size: 0.95rem;
  transition: box-shadow 0.18s, transform 0.12s;
}

.name-block input:focus {
  outline: none;
  box-shadow: 0 8px 24px rgba(79, 156, 249, 0.12);
  transform: translateY(-2px); /* Enhanced focus effect */
}

/* TOP ROW: TIMER & PROGRESS */
/* -------------------------------------- */
.top-row {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.timer-card {
  padding: 0.75rem 0.875rem;
  border-radius: 0.75rem;
  background: var(--card);
  box-shadow: var(--shadow-sm); /* Slightly smaller shadow for utility card */
  color: var(--primary);
  font-weight: 700;
  display: inline-block;
  align-self: flex-start;
}

.progress-wrap {
  margin-top: 0.5rem; /* Separates it visually from the timer on mobile */
}

.progress-bar-track {
  height: 0.75rem;
  background: rgba(21, 50, 67, 0.06);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--teal), var(--primary));
  transition: width 0.5s ease;
}

/* QUIZ CONTENT */
/* -------------------------------------- */
.section {
  margin-bottom: 1.5rem;
}

.section-title {
  background: linear-gradient(90deg, var(--primary), var(--teal));
  color: #fff;
  padding: 0.75rem 0.875rem;
  border-radius: 0.625rem;
  font-size: 1.1rem;
  margin: 0.75rem 0 1rem;
  box-shadow: 0 8px 24px rgba(79, 156, 249, 0.15);
}

/* Questions */
.question-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.question-item {
  background: var(--card);
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 0.875rem;
  border: 1px solid rgba(21, 50, 67, 0.04);
  box-shadow: var(--shadow);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.question-item:hover {
  transform: translateY(-4px); /* Slightly reduced hover lift */
  box-shadow: var(--shadow-lg);
}

.question-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.question-number {
  background: linear-gradient(180deg, var(--teal), var(--primary));
  color: #fff;
  font-weight: 700;
  min-width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.625rem;
  display: grid;
  place-items: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

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

.subtext {
  color: var(--muted);
  margin-top: 0.375rem;
  font-size: 0.9rem;
}

/* Multiple Choice Options */
.mc-options {
  margin-top: 0.75rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

.mc-options label {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem;
  border-radius: 0.625rem;
  border: 1px solid rgba(21, 50, 67, 0.04);
  background: linear-gradient(180deg, #fff, #fcfdff);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.15s;
}

.mc-options label:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(79, 156, 249, 0.06);
}

.mc-options input[type="radio"] {
  width: 1.125rem;
  height: 1.125rem;
  accent-color: var(--primary);
  flex-shrink: 0;
  margin: 0; /* Ensures consistent vertical alignment */
}

/* Locked State */
.mc-options.locked label {
  cursor: default;
  opacity: 0.86;
  transform: none;
  box-shadow: none;
}

.mc-options.locked label:hover {
  transform: none;
}

/* Structured Answers (Text Input) */
.structured-answer-area {
  margin-top: 0.75rem;
}

.structured-answer-area input[type="text"] {
  padding: 0.625rem;
  border-radius: 0.625rem;
  border: 1px solid rgba(21, 50, 67, 0.06);
  width: 100%;
  font-size: 0.98rem;
  background: linear-gradient(180deg, #fff, #fbfeff);
  transition: box-shadow 0.15s;
}

.structured-answer-area input[type="text"]:focus {
  outline: none;
  box-shadow: 0 6px 18px rgba(79, 156, 249, 0.08);
}

.structured-answer-area.locked input[type="text"] {
  background: rgba(21, 50, 67, 0.04);
  cursor: not-allowed;
}

/* FEEDBACK & RESULTS */
/* -------------------------------------- */
.feedback {
  margin-top: 0.75rem;
  padding: 0.625rem;
  border-radius: 0.625rem;
  font-weight: 700;
  display: block;
  font-size: 0.95rem;
}

.feedback.correct {
  background: linear-gradient(90deg, #e9f7ef, #f0fff6);
  color: var(--success);
  border-left: 4px solid var(--success);
}

.feedback.incorrect {
  background: linear-gradient(90deg, #fff6f6, #fff9f9);
  color: var(--danger);
  border-left: 4px solid var(--danger);
}

.feedback .explanation {
  font-weight: 400;
  font-size: 0.925rem; /* Slightly smaller for the explanation text */
  display: block;
  margin-top: 0.375rem;
  color: var(--muted);
}

/* Action Buttons */
.button-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0 2.25rem;
}

.btn {
  padding: 0.75rem 1.125rem;
  border-radius: 0.75rem;
  border: none;
  cursor: pointer;
  font-weight: 700;
  color: #fff;
  min-width: 220px;
  transition: transform 0.14s, box-shadow 0.14s;
}

.btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 30px rgba(18, 38, 63, 0.08);
}

.btn:active {
  transform: translateY(1px);
  box-shadow: 0 4px 12px rgba(18, 38, 63, 0.1); /* Subtle press shadow */
}

.btn-primary {
  background: linear-gradient(90deg, var(--primary), var(--teal));
  box-shadow: 0 10px 30px rgba(79, 156, 249, 0.18);
}

.btn-danger {
  background: linear-gradient(90deg, var(--accent), #ff8f8f);
  box-shadow: 0 8px 24px rgba(255, 107, 107, 0.12);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Final Results Card */
.results {
  padding: 1.375rem;
  border-radius: var(--radius);
  margin: 1.125rem 0;
  background: linear-gradient(180deg, #ffffff, #fbfdff);
  border: 1px solid rgba(21, 50, 67, 0.04);
  box-shadow: var(--shadow);
}

.results h3 {
  margin-top: 0;
  font-size: 1.5rem;
}

.results.excellent {
  border-left: 6px solid #ffd166;
}

.results.good {
  border-left: 6px solid var(--teal); /* Used teal for a cleaner success color */
}

.results.practice {
  border-left: 6px solid #ffb86b;
}

.results.below {
  border-left: 6px solid var(--danger);
}

/* FOOTER */
/* -------------------------------------- */
.site-footer {
  margin-top: auto;
  padding: 1.125rem;
  border-radius: var(--radius);
  background: linear-gradient(90deg, rgba(255, 107, 107, 0.03), rgba(79, 156, 249, 0.03));
  color: var(--muted);
  font-size: 0.925rem;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.footer-links a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.footer-links a:hover {
  text-decoration: underline;
  color: var(--teal);
}

/* ACCESSIBILITY & RESPONSIVENESS */
/* -------------------------------------- */

/* Disable transitions for users with reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .question-item, .btn, .mc-options label, .name-block input {
    transition: none !important;
    transform: none !important;
  }
}

/* Tablets and small desktops */
@media (max-width: 880px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  .name-block {
    width: 100%;
  }
  .top-row {
    gap: 0.625rem;
  }
  .button-container {
    width: 100%;
  }
  .btn {
    width: 100%;
  }
  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Mobile devices */
@media (max-width: 420px) {
  body {
    padding: 1rem 0.625rem;
  }
  .container {
    padding: 0 0.625rem;
  }
  .site-title {
    font-size: 1.15rem;
  }
  .question-text {
    font-size: 0.95rem;
  }
  .question-number {
    min-width: 2rem;
    height: 2rem;
    font-size: 0.85rem;
    border-radius: 0.5rem;
  }
}
