:root {
  --brand: #b30000;
  --brand-dark: #7a0000;
  --bg: #f8f9fa;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: #0f172a;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body[data-screen="quizScreen"] .mobile-nav {
  display: none;
}

.desktop-nav {
  display: none !important;
}
@media (min-width: 640px) {
  .desktop-nav {
    display: flex !important;
  }
}

.mobile-nav {
  display: grid;
}
@media (min-width: 640px) {
  .mobile-nav {
    display: none !important;
  }
}

@media (hover: none) and (pointer: coarse) {
  button, a {
    -webkit-tap-highlight-color: transparent;
  }
}

.hidden {
  display: none !important;
}

.card {
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.08);
}

@media (max-width: 639px) {
  .card {
    border-radius: 22px;
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.07);
  }
}

.fade-in {
  animation: fadeIn 0.34s ease both;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.nav-link,
.tab-button {
  border-radius: 999px;
  padding: 0.65rem 0.95rem;
  color: #475569;
  font-weight: 800;
  transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease;
  border: none;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
  font-size: 0.9rem;
}

.mobile-nav {
  position: fixed;
  right: 0.75rem;
  bottom: calc(0.75rem + env(safe-area-inset-bottom));
  left: 0.75rem;
  z-index: 60;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.95);
  padding: 0.4rem;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.16);
  backdrop-filter: blur(14px);
}

.mobile-nav .nav-link {
  min-height: 44px;
  padding: 0.65rem 0.35rem;
  text-align: center;
}

.mobile-tab-row .tab-button {
  flex: 1;
  min-height: 44px;
  text-align: center;
}

@media (max-width: 639px) {
  .settings-actions .primary-button,
  .settings-actions .secondary-button {
    width: 100%;
  }
}

@media (min-width: 640px) {
  .nav-link,
  .tab-button {
    padding: 0.75rem 1rem;
    font-size: 1rem;
  }
}

.nav-link:hover,
.tab-button:hover {
  color: var(--brand);
  transform: translateY(-1px);
}

.nav-link.active,
.tab-button.active {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 12px 24px rgba(179, 0, 0, 0.18);
}

.section-kicker {
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

@media (max-width: 639px) {
  .section-kicker {
    font-size: 0.68rem;
    letter-spacing: 0.16em;
  }
}

.drop-zone {
  display: grid;
  min-height: 250px;
  cursor: pointer;
  place-items: center;
  border: 2px dashed rgba(179, 0, 0, 0.32);
  border-radius: 28px;
  background: linear-gradient(180deg, #fff 0%, #fff5f5 100%);
  padding: 1.5rem;
  text-align: center;
  transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}
@media (min-width: 640px) {
  .drop-zone {
    min-height: 300px;
    padding: 2rem;
  }
}

.drop-zone.drag-over {
  border-color: var(--brand);
  background: #fff0f0;
  transform: scale(1.01);
}

.field {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  background: #fff;
  padding: 0.85rem 1rem;
  color: #0f172a;
  font-weight: 700;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  font-size: 16px;
  min-height: 44px;
}

@media (min-width: 640px) {
  .field {
    padding: 0.95rem 1rem;
    font-size: 1rem;
  }
}

.field:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(179, 0, 0, 0.1);
}

.field:disabled {
  background: #f1f5f9;
  color: #94a3b8;
}

.label {
  margin-bottom: 0.5rem;
  display: block;
  color: #334155;
  font-size: 0.9rem;
  font-weight: 900;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-radius: 18px;
  background: #f8fafc;
  padding: 1rem;
  color: #334155;
  font-weight: 800;
}

@media (max-width: 639px) {
  .check-row {
    padding: 0.9rem;
  }
}

.check-row input {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--brand);
}

.primary-button,
.secondary-button,
.danger-button {
  border-radius: 999px;
  padding: 0.8rem 1.2rem;
  font-weight: 900;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
}

@media (min-width: 640px) {
  .primary-button,
  .secondary-button,
  .danger-button {
    padding: 0.9rem 1.35rem;
    font-size: 1rem;
  }
}

.primary-button {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 14px 28px rgba(179, 0, 0, 0.18);
}

.primary-button:hover:not(:disabled) {
  background: var(--brand-dark);
  transform: translateY(-1px);
  box-shadow: 0 18px 34px rgba(179, 0, 0, 0.24);
}

.secondary-button {
  background: #f1f5f9;
  color: #0f172a;
}

.secondary-button:hover {
  background: #e2e8f0;
  transform: translateY(-1px);
}

.danger-button {
  background: #fff1f2;
  color: #be123c;
}

.danger-button:hover {
  background: #ffe4e6;
}

.history-open-button {
  border-radius: 999px;
  background: #fff1f1;
  padding: 0.65rem 1rem;
  color: var(--brand);
  font-weight: 900;
  transition: background 0.2s ease, transform 0.2s ease;
}

@media (max-width: 767px) {
  .history-open-button {
    width: 100%;
    min-height: 44px;
  }
}

.history-open-button:hover {
  background: #ffe1e1;
  transform: translateY(-1px);
}

.option-button {
  width: 100%;
  border: 2px solid #e2e8f0;
  border-radius: 22px;
  background: #fff;
  padding: 0.9rem 1rem;
  text-align: left;
  font-weight: 800;
  font-size: 0.95rem;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
  min-height: 44px;
  display: flex;
  align-items: center;
}

@media (min-width: 640px) {
  .option-button {
    padding: 1rem 1.1rem;
    font-size: 1rem;
  }
}

.option-button:hover {
  border-color: rgba(179, 0, 0, 0.35);
  transform: translateX(3px);
}

.option-button.selected {
  border-color: var(--brand);
  background: #fff1f1;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--brand);
  transition: width 0.3s ease;
}

.timer-box {
  border-radius: 999px;
  background: #0f172a;
  color: #fff;
  padding: 0.85rem 1.2rem;
  font-size: 1.1rem;
  font-weight: 950;
  letter-spacing: 0.06em;
}

@media (max-width: 639px) {
  .timer-box {
    width: fit-content;
    padding: 0.65rem 1rem;
  }
}

.flag-button {
  min-width: 3rem;
  border-radius: 18px;
  background: #f8fafc;
  padding: 0.55rem 0.8rem;
  color: #94a3b8;
  font-size: 1.8rem;
  line-height: 1;
  transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.flag-button.active {
  background: #fff7ed;
  color: #f59e0b;
}

.flag-button:hover {
  transform: rotate(-6deg) scale(1.04);
}

.dot-button {
  position: relative;
  display: grid;
  height: 2.35rem;
  min-width: 2.35rem;
  place-items: center;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 0.85rem;
  font-weight: 900;
}

@media (max-width: 639px) {
  .question-dots {
    flex-wrap: nowrap !important;
    margin-right: -1rem;
    padding-right: 1rem;
    scrollbar-width: thin;
  }

  .dot-button {
    height: 2.2rem;
    min-width: 2.2rem;
    flex: 0 0 auto;
    font-size: 0.8rem;
  }

  .quiz-actions {
    position: sticky;
    bottom: calc(0.5rem + env(safe-area-inset-bottom));
    z-index: 20;
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.96);
    padding: 0.65rem;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
    backdrop-filter: blur(12px);
  }
}

.dot-button.answered {
  background: #dcfce7;
  color: #166534;
}

.dot-button.current {
  background: var(--brand);
  color: #fff;
}

.dot-button.flagged::after {
  content: '';
  position: absolute;
  top: -0.2rem;
  right: -0.2rem;
  height: 0.7rem;
  width: 0.7rem;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #f59e0b;
}

.answer-correct {
  border-color: #22c55e !important;
  background: #f0fdf4 !important;
  color: #166534;
}

.answer-wrong {
  border-color: #ef4444 !important;
  background: #fef2f2 !important;
  color: #991b1b;
}