body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.card {
  /* remove cursor: pointer; from here */
  user-select: text; /* lets users highlight/copy text freely */
}

button {
  cursor: pointer;
}

input[type="checkbox"] {
  accent-color: #172554;
  cursor: pointer;
}

/* 3D Flashcard Flip Styles */
.perspective-1000 {
  perspective: 1200px;
}

.preserve-3d {
  transform-style: preserve-3d;
}

.backface-hidden {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.rotate-y-180 {
  transform: rotateY(180deg);
}

/* Front & Back Face Stacking & Pointer Control */
.card-front-face {
  transform: rotateY(0deg);
  z-index: 2;
}

/* Grounded drop shadow on card wrapper rather than inner card faces */
.card-wrapper {
  box-shadow: 0 10px 22px -6px rgba(15, 23, 42, 0.24), 0 4px 10px -2px rgba(15, 23, 42, 0.14);
  transition: box-shadow 0.2s ease;
}

.card-wrapper:hover {
  box-shadow: 0 16px 28px -6px rgba(15, 23, 42, 0.30), 0 6px 12px -2px rgba(15, 23, 42, 0.18);
}

.question-card .card-front-face,
.question-card .card-back-face {
  box-shadow: none;
  transition: transform 0.2s ease;
}

.question-card:hover .card-front-face,
.question-card:hover .card-back-face {
  box-shadow: none;
}

.flip-inner.rotate-y-180 .card-front-face {
  pointer-events: none;
}

.card-back-face {
  pointer-events: none;
}

.flip-inner.rotate-y-180 .card-back-face {
  pointer-events: auto;
  z-index: 3;
}

/* Disable Flip Animation when toggled in Voice Control */
body.no-card-animation .flip-inner {
  transition: none !important;
}

/* Active Speaking Card Highlight */
.question-card.card-speaking .card-front-face,
.question-card.card-speaking .card-back-face {
  border-color: #fbbf24 !important;
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.55);
}

/* Custom Scrollbar for Long Answer Lists */
.answer-scroll::-webkit-scrollbar {
  width: 5px;
}

.answer-scroll::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
}

.answer-scroll::-webkit-scrollbar-thumb {
  background-color: rgba(253, 224, 71, 0.55);
  border-radius: 9999px;
}

.answer-scroll::-webkit-scrollbar-thumb:hover {
  background-color: rgba(253, 224, 71, 0.85);
}

/* Card Front Background using stars.svg with seamless royal-blue starry fallback */
.stars-card-bg {
  background-color: #16149c;
  background-image: url('../pictures/stars.svg');
  background-repeat: repeat;
}

/* Card Back Background: same navy + stars.svg flipped vertically */
.stars-card-back-bg {
  background-color: #16149c;
  background-image: none;
}

.stars-card-back-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background-color: #16149c;
  background-image: url('../pictures/stars.svg');
  background-repeat: repeat;
  transform: scaleY(-1);
  pointer-events: none;
  z-index: 0;
}

.stars-card-back-bg > * {
  position: relative;
  z-index: 1;
}

/* Single Non-Repeating Left Bunting Strip using banner.svg */
.left-banner-strip {
  position: relative;
  background-color: #16149c;
  background-image: url('../pictures/banner.svg');
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center top;
}

/* Restore left & right red borders on Civics Test banners (cropped by cover on portrait strip) */
.question-card .left-banner-strip {
  border-right-width: 0 !important;
  box-shadow: inset 10px 0 0 #B22234, inset -10px 0 0 #B22234;
}

/* Rotate Answer (back face) banner background 180deg while keeping badge & Play upright */
.question-card .card-back-face .left-banner-strip {
  background-image: none;
  box-shadow: none;
  overflow: hidden;
}

.question-card .card-back-face .left-banner-strip::before {
  content: "";
  position: absolute;
  inset: 0;
  background-color: #16149c;
  background-image: url('../pictures/banner.svg');
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center top;
  box-shadow: inset 10px 0 0 #B22234, inset -10px 0 0 #B22234;
  transform: rotate(180deg);
  pointer-events: none;
  z-index: 0;
}

.question-card .card-back-face .left-banner-strip > * {
  position: relative;
  z-index: 1;
}

/* High-contrast white badge holding QUESTION #X / ANSWER #X inside the banner */
.banner-qa-badge {
  background: #ffffff;
  color: #172554;
  border: 1.5px solid rgba(253, 224, 71, 0.95);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* High-contrast Play button inside the banner */
.banner-play-btn {
  background: linear-gradient(180deg, #fde047 0%, #f59e0b 100%);
  color: #172554;
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45);
  transition: transform 0.14s ease, filter 0.14s ease, box-shadow 0.14s ease;
}

.banner-play-btn:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.55);
}

.banner-play-btn:active {
  transform: translateY(0);
}

/* Remove gap between range pagination and questions container */
#range-pagination {
  margin-bottom: 0;
}

#questions-container {
  margin-top: 0;
}

/* Quiz Mode: Blur only question text until hovered directly on the text */
#questions-container.quiz-mode .question-card h2 {
  filter: blur(6px);
  user-select: none;
  transition: filter 0.22s ease;
}

#questions-container.quiz-mode .question-card h2:hover,
#questions-container.quiz-mode .question-card h2:focus {
  filter: blur(0);
  user-select: text;
}

/* Ensure answer text is never blurred in Quiz mode */
#questions-container.quiz-mode .question-card .card-back-face .answer-scroll {
  filter: none;
  user-select: text;
}

/* ==========================================================================
   "Show Answer Without Hiding Question":
   PC: 1) Shrink question to 1/2 width -> 2) Flip -> 3) Slide answer left-to-right
   Mobile: Flip -> Slide answer below question
   ========================================================================== */
.question-card .flip-inner {
  transition: transform 0.5s ease, width 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@media (min-width: 640px) {
  .question-card.shrinking-half .flip-inner {
    width: calc(50% - 5px);
  }
}

@keyframes answerSlideRight {
  0% {
    opacity: 0.92;
    transform: translateX(-100%);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes answerSlideBelow {
  0% {
    opacity: 0.92;
    transform: translateY(-100%);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.question-card.question-with-answer-open .flip-inner {
  transition: none !important;
  transform: none !important;
  width: 100%;
  height: auto;
  min-height: 188px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (min-width: 640px) {
  .question-card.question-with-answer-open .flip-inner {
    flex-direction: row;
    align-items: stretch;
  }

  /* Question stays in place on the left; answer slides left-to-right into the right slot */
  .question-card.question-with-answer-open .card-front-face,
  .question-card.question-with-answer-open .card-back-face {
    flex: 0 0 calc(50% - 5px);
    max-width: calc(50% - 5px);
  }

  /* When checkbox is toggled onto already-open answers: shrink answer to half & put question on left */
  .question-card.question-with-answer-open.answer-left-for-open .card-front-face {
    order: -1;
    flex: 0 0 calc(50% - 5px);
    max-width: calc(50% - 5px);
  }

  .question-card.question-with-answer-open.answer-left-for-open .card-back-face {
    order: 1;
    flex: 0 0 calc(50% - 5px);
    max-width: calc(50% - 5px);
  }
}

.question-card.question-with-answer-open .card-front-face,
.question-card.question-with-answer-open .card-back-face {
  position: relative;
  inset: auto;
  transition: none !important;
  backface-visibility: visible;
  -webkit-backface-visibility: visible;
  pointer-events: auto;
  min-width: 0;
  height: 188px;
  max-height: 188px;
  overflow: hidden;
  z-index: 1;
}

.question-card.question-with-answer-open .card-front-face {
  transform: none !important;
}

.question-card.question-with-answer-open .card-back-face {
  z-index: 2;
}

.question-card.question-with-answer-open .card-front-face > div:last-child,
.question-card.question-with-answer-open .card-back-face > div:last-child {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.question-card.question-with-answer-open .answer-scroll {
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
}

.question-card.question-with-answer-open .card-back-face:not(.split-answer-visible) {
  display: none;
}

.question-card.question-with-answer-open .card-back-face.split-answer-visible {
  display: flex;
  animation: answerSlideBelow 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@media (min-width: 640px) {
  .question-card.question-with-answer-open .card-back-face.split-answer-visible {
    animation: answerSlideRight 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  }
}

/* Respect Disable Animation setting in Voice Control */
body.no-card-animation .question-card.shrinking-half .flip-inner {
  transition: none !important;
  width: calc(50% - 5px);
}

body.no-card-animation .question-card.question-with-answer-open .card-back-face,
body.no-card-animation .question-card.question-with-answer-open .card-back-face.split-answer-visible {
  transition: none !important;
  animation: none !important;
  transform: none !important;
}

/* Hide flip buttons when question and answer are displayed together */
.question-card.question-with-answer-open [data-action="flip-to-answer"],
.question-card.question-with-answer-open [data-action="flip-to-question"] {
  display: none;
}

/* 65/20 */
.banner-6520-badge {
  background-color: #ffffff;
  color: #172554;
  border: 1.5px solid #b91c1c;
}

/* New Quiz Button: Stitched Satin-Weave Federal Navy Style Matching Top Menu */
.new-quiz-ribbon-btn {
  position: relative;
  overflow: hidden;
  background-color: rgba(23, 37, 84, 0.90);
  background-image:
    repeating-linear-gradient(135deg,
      rgba(255, 255, 255, 0.05) 0px,
      rgba(255, 255, 255, 0.05) 2px,
      transparent 2px,
      transparent 6px),
    linear-gradient(180deg, rgba(30, 58, 138, 0.90) 0%, rgba(23, 37, 84, 0.93) 55%, rgba(19, 30, 71, 0.95) 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(251, 191, 36, 0.55);
  box-shadow:
    0 8px 18px -4px rgba(15, 23, 42, 0.35),
    inset 0 1px 0 rgba(251, 191, 36, 0.55),
    inset 0 -1px 0 rgba(251, 191, 36, 0.55);
  transition: transform 0.15s ease, filter 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.new-quiz-ribbon-btn::before {
  content: "";
  position: absolute;
  inset: 3px 6px;
  pointer-events: none;
  border-top: 1px dashed rgba(253, 224, 71, 0.55);
  border-bottom: 1px dashed rgba(253, 224, 71, 0.55);
}

.new-quiz-ribbon-btn:active {
  transform: scale(0.98);
}

/* Compact Range Group Buttons: Smaller Stitched Satin-Weave Navy Style Matching New Quiz */
.range-ribbon-btn {
  position: relative;
  overflow: hidden;
  background-color: rgba(23, 37, 84, 0.84);
  background-image:
    repeating-linear-gradient(135deg,
      rgba(255, 255, 255, 0.05) 0px,
      rgba(255, 255, 255, 0.05) 2px,
      transparent 2px,
      transparent 6px),
    linear-gradient(180deg, rgba(30, 58, 138, 0.84) 0%, rgba(23, 37, 84, 0.88) 55%, rgba(19, 30, 71, 0.90) 100%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(251, 191, 36, 0.42);
  box-shadow:
    0 3px 8px -2px rgba(15, 23, 42, 0.25),
    inset 0 1px 0 rgba(251, 191, 36, 0.4),
    inset 0 -1px 0 rgba(251, 191, 36, 0.4);
  opacity: 0.78;
  transition: transform 0.14s ease, filter 0.14s ease, opacity 0.14s ease, color 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}

.range-ribbon-btn::before {
  content: "";
  position: absolute;
  inset: 2px 4px;
  pointer-events: none;
  border-top: 1px dashed rgba(253, 224, 71, 0.45);
  border-bottom: 1px dashed rgba(253, 224, 71, 0.45);
}

.range-ribbon-btn:active {
  transform: scale(0.97);
}

.range-ribbon-btn.is-active {
  opacity: 1;
  border-color: rgba(253, 224, 71, 0.95);
  box-shadow:
    0 5px 12px -2px rgba(15, 23, 42, 0.38),
    0 0 0 2px rgba(251, 191, 36, 0.65),
    inset 0 1px 0 rgba(253, 224, 71, 0.75),
    inset 0 -1px 0 rgba(253, 224, 71, 0.75);
}

/* Unified Hover Style for Navy Ribbon Buttons (matches top menu hover: white/10 sheen, white/40 border, amber-200 text) */
.new-quiz-ribbon-btn:hover,
.range-ribbon-btn:hover {
  opacity: 1;
  color: #fde68a;
  border-color: rgba(255, 255, 255, 0.4);
  filter: brightness(1.1);
  box-shadow:
    0 8px 18px -4px rgba(15, 23, 42, 0.4),
    inset 0 0 0 9999px rgba(255, 255, 255, 0.1);
}

.new-quiz-ribbon-btn:hover svg,
.range-ribbon-btn:hover svg {
  color: #fde68a;
}

/* Keep short test-mode explanation capped to 2 lines to match button height on mobile */
.mode-explanation-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

/* ==========================================================================
   Light Card Theme: Replaces decorative star/bunting graphics with calm gradients
   ========================================================================== */
body.light-card-theme .card-wrapper {
  background-color: #f7f3eb;
  border-color: #e4d9c5;
  box-shadow: 0 6px 16px -6px rgba(15, 23, 42, 0.12), 0 2px 6px -2px rgba(15, 23, 42, 0.08);
}

body.light-card-theme .card-wrapper:hover {
  box-shadow: 0 10px 22px -6px rgba(15, 23, 42, 0.16), 0 4px 10px -2px rgba(15, 23, 42, 0.10);
}

/* Front face (Question): calm cool parchment-sky gradient */
body.light-card-theme .card-front-face.stars-card-bg {
  background-color: #f4f7fb;
  background-image: linear-gradient(135deg, #fdfcf9 0%, #f1f5f9 55%, #e6eef8 100%);
  border-color: #cbd5e1;
}

body.light-card-theme .card-front-face .left-banner-strip {
  background-color: #e8eff7;
  background-image: linear-gradient(180deg, #e1eaf5 0%, #eef3f9 100%);
  border-right: 1px solid #cbd5e1 !important;
  box-shadow: none;
}

/* Back face (Answer): calm soft sage-cream gradient */
body.light-card-theme .card-back-face.stars-card-back-bg {
  background-color: #f2f8f4;
  background-image: linear-gradient(135deg, #fcfdfb 0%, #eef6f1 55%, #e1f0e7 100%);
  border-color: #b7d8c5;
}

body.light-card-theme .card-back-face.stars-card-back-bg::before {
  display: none;
}

body.light-card-theme .card-back-face .left-banner-strip {
  background-color: #e2f0e8;
  background-image: linear-gradient(180deg, #d8ece0 0%, #eaf4ee 100%);
  border-right: 1px solid #b7d8c5 !important;
  box-shadow: none;
}

body.light-card-theme .card-back-face .left-banner-strip::before {
  display: none;
}

/* Crisp dark typography on calm light cards */
body.light-card-theme .card-front-face h2 {
  color: #0f172a;
}

body.light-card-theme .card-front-face .flex-1 > div:first-child span {
  color: #475569;
}

body.light-card-theme .card-back-face .flex-1 > div:first-child span {
  color: #3f6250;
}

body.light-card-theme .card-back-face .answer-scroll li {
  color: #1e293b;
}

body.light-card-theme .card-back-face .answer-scroll li > span:first-child {
  color: #0f766e;
}

/* Softened badges & controls inside light cards */
body.light-card-theme .banner-qa-badge {
  background: rgba(255, 255, 255, 0.92);
  border-color: #cbd5e1;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

body.light-card-theme .card-back-face .banner-qa-badge {
  border-color: #a7d3bc;
}

body.light-card-theme .banner-play-btn {
  background: linear-gradient(180deg, #fef3c7 0%, #fde68a 100%);
  color: #78350f;
  border-color: #e5b961;
  box-shadow: 0 1px 3px rgba(120, 53, 15, 0.14);
}

body.light-card-theme .banner-6520-badge {
  background-color: #fff5f5;
  color: #991b1b;
  border-color: #fca5a5;
}

body.light-card-theme [data-action="flip-to-answer"],
body.light-card-theme [data-action="flip-to-question"] {
  background-color: #fef3c7;
  border-color: #e5c47a;
  color: #451a03;
}

body.light-card-theme [data-action="flip-to-answer"]:hover,
body.light-card-theme [data-action="flip-to-question"]:hover {
  background-color: #fde68a;
}

/* Subtle scrollbar for light cards */
body.light-card-theme .answer-scroll::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.05);
}

body.light-card-theme .answer-scroll::-webkit-scrollbar-thumb {
  background-color: rgba(100, 116, 139, 0.35);
}

body.light-card-theme .answer-scroll::-webkit-scrollbar-thumb:hover {
  background-color: rgba(100, 116, 139, 0.55);
}

/* Active speaking highlight in light theme */
body.light-card-theme .question-card.card-speaking .card-front-face,
body.light-card-theme .question-card.card-speaking .card-back-face {
  border-color: #d97706 !important;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.35);
}

/* Saved State & Officials answer styling in Light Card Theme */
body.light-card-theme .card-back-face .saved-official-answer {
  color: #065f46;
}

body.light-card-theme .card-back-face .saved-official-note {
  background-color: rgba(255, 253, 249, 0.92);
  border-color: #cbd5e1;
  color: #334155;
}

body.light-card-theme .card-back-face .saved-official-meta {
  color: #0f766e;
}

body.light-card-theme .card-back-face .saved-official-warning {
  color: #92400e;
}

body.light-card-theme .card-back-face .saved-official-link {
  color: #1e3a8a;
}

body.light-card-theme .card-back-face .saved-official-link:hover {
  color: #92400e;
}