:root {
  --blue: #002868;
  --red: #bf0a30;
  --white: #ffffff;
  --light-gray: #f5f5f5;
  --dark-gray: #333333;
  --card-height: 580px;
  --card-width: 600px; /* Reduced from 800px to be more reasonable on medium screens */
  --card-max-width: 600px; /* Reduced from 800px to be more reasonable on medium screens */

  /* Softer colors for modern UI */
  --soft-blue: #3a5f94;
  --soft-red: #c84e61;
  --soft-navy: #2c4a7e;
  --pale-blue: #e8f0ff;
  
  /* New dark colors for header/footer */
  --header-bg: #212529;
  --header-text: #f8f9fa;
  --header-border: #343a40;
  --footer-bg: #212529;
  --footer-text: #e9ecef;
  --footer-border: #343a40;
  --subtle-accent: #495057;
}

/* Fira Sans Font Styles */
.fira-sans-thin {
  font-family: "Fira Sans", sans-serif;
  font-weight: 100;
  font-style: normal;
}

.fira-sans-extralight {
  font-family: "Fira Sans", sans-serif;
  font-weight: 200;
  font-style: normal;
}

.fira-sans-light {
  font-family: "Fira Sans", sans-serif;
  font-weight: 300;
  font-style: normal;
}

.fira-sans-regular {
  font-family: "Fira Sans", sans-serif;
  font-weight: 400;
  font-style: normal;
}

.fira-sans-medium {
  font-family: "Fira Sans", sans-serif;
  font-weight: 500;
  font-style: normal;
}

.fira-sans-semibold {
  font-family: "Fira Sans", sans-serif;
  font-weight: 600;
  font-style: normal;
}

.fira-sans-bold {
  font-family: "Fira Sans", sans-serif;
  font-weight: 700;
  font-style: normal;
}

.fira-sans-extrabold {
  font-family: "Fira Sans", sans-serif;
  font-weight: 800;
  font-style: normal;
}

.fira-sans-black {
  font-family: "Fira Sans", sans-serif;
  font-weight: 900;
  font-style: normal;
}

.fira-sans-thin-italic {
  font-family: "Fira Sans", sans-serif;
  font-weight: 100;
  font-style: italic;
}

.fira-sans-extralight-italic {
  font-family: "Fira Sans", sans-serif;
  font-weight: 200;
  font-style: italic;
}

.fira-sans-light-italic {
  font-family: "Fira Sans", sans-serif;
  font-weight: 300;
  font-style: italic;
}

.fira-sans-regular-italic {
  font-family: "Fira Sans", sans-serif;
  font-weight: 400;
  font-style: italic;
}

.fira-sans-medium-italic {
  font-family: "Fira Sans", sans-serif;
  font-weight: 500;
  font-style: italic;
}

.fira-sans-semibold-italic {
  font-family: "Fira Sans", sans-serif;
  font-weight: 600;
  font-style: italic;
}

.fira-sans-bold-italic {
  font-family: "Fira Sans", sans-serif;
  font-weight: 700;
  font-style: italic;
}

.fira-sans-extrabold-italic {
  font-family: "Fira Sans", sans-serif;
  font-weight: 800;
  font-style: italic;
}

.fira-sans-black-italic {
  font-family: "Fira Sans", sans-serif;
  font-weight: 900;
  font-style: italic;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Ensure the body takes up at least the full viewport height */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

/* Fix for iOS scroll jump issue */
html {
  overflow: hidden;
}

body {
  font-family: 'Fira Sans', sans-serif;
  line-height: 1.6;
  color: var(--dark-gray);
  background-color: var(--light-gray);
  display: flex;
  flex-direction: column;
  min-height: 100vh; /* Minimum height of 100% viewport height */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch; /* Enable smooth scrolling on iOS */
}

a {
  color: var(--blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Header Styles */
header {
  background-color: var(--header-bg);
  color: var(--header-text);
  padding: 1rem 0; /* Reduced padding for smaller header */
  text-align: center;
  position: relative;
  border-bottom: 1px solid var(--header-border);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

/* Subtle accent line at bottom of header */
header::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--blue); /* Changed from gradient to solid blue color */
  opacity: 0.8;
}

.header-container {
  max-width: var(--card-max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  position: relative;
  z-index: 1;
}

.logo {
  font-family: 'Fira Sans', sans-serif;
  font-size: 1.6rem; /* Reduced from 2rem */
  font-weight: 700;
  margin-bottom: 0.1rem; /* Reduced from 0.3rem to 0.1rem for less spacing */
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  position: relative; /* Added for positioning the flying eagle */
  padding-left: 3rem; /* Increased from 2.2rem to add more space between eagle and text */
}

/* Eagle emoji animation */
.logo::before {
  content: '🦅';
  position: absolute;
  left: 0;
  display: inline-block;
  animation: eagleFly 2s ease-in-out infinite;
  filter: drop-shadow(0 0 3px #bf0a30) 
          drop-shadow(0 0 3px #ffffff) 
          drop-shadow(0 0 5px #002868);
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
  font-size: 1.7rem;
}

.logo span {
  color: var(--white);
}

.tagline {
  font-size: 0.9rem; /* Reduced from 1rem */
  color: #adb5bd; /* Lighter gray for dark background */
  font-weight: 400;
  max-width: 600px;
  margin: 0 auto;
}

/* Add keyframes for flying eagle animation */
@keyframes eagleFly {
  0% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
  100% { transform: translateY(0); }
}

/* Main Content */
main {
  width: var(--card-width); /* Use var(--card-width) for fluid width (e.g., 90%) */
  max-width: var(--card-max-width); /* Use var(--card-max-width) as an absolute cap (e.g., 550px) */
  margin: 1.5rem auto 0.5rem auto; /* Reduced margins to fit content on page */
  padding: 0; /* Removed horizontal padding */
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 1 auto; /* Changed from flex: 1 to allow shrinking */
  position: relative;
  z-index: 1;
  box-sizing: border-box; /* Ensure consistent box model */
}

/* Counter Styles */
.counter-container {
  display: flex;
  justify-content: space-between; /* Back to space-between for proper alignment */
  flex-wrap: wrap;  gap: 1rem; /* Uniform gap between all counters */
  margin-bottom: 1.5rem; /* Reduced from 2rem to save space */
  width: 100%; /* Occupy full width of the correctly sized main container */
  max-width: var(--card-width); /* Match the flashcard max-width constraint */
  padding: 0;
  box-sizing: border-box; /* Ensure consistent box model */
}

.counter {
  background-color: var(--white);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  flex: 1 1 calc(25% - 0.75rem); /* 4 counters per row, accounting for gap */
  min-width: 120px; /* Minimum size to prevent too small */
  max-width: 180px; /* Maximum size to prevent too large */
  aspect-ratio: 1/1; /* Keep square shape */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-top: 4px solid;
}

.counter:nth-child(1) {
  border-top-color: #28a745; /* green */
}

.counter:nth-child(2) {
  border-top-color: var(--blue);
}

.counter:nth-child(3) {
  border-top-color: #ffc107; /* yellow */
}

.counter:nth-child(4) {
  border-top-color: var(--red);
}

.counter span {
  font-size: 2.5rem;
  font-weight: bold;
  display: block;
}

.counter p {
  font-size: 0.9rem;
  color: #666;
  margin-top: 0.5rem;
}

/* View questions button in counters */
.view-questions-btn {
  background-color: transparent;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 4px;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  font-family: 'Fira Sans', sans-serif;
  margin-top: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #555;
  width: 80%; /* Make button wider */
}

.view-questions-btn:hover {
  background-color: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.2);
}

/* Counter colors for view buttons */
.counter:nth-child(1) .view-questions-btn:hover {
  background-color: rgba(40, 167, 69, 0.1);
}

.counter:nth-child(2) .view-questions-btn:hover {
  background-color: rgba(0, 40, 104, 0.1);
}

.counter:nth-child(3) .view-questions-btn:hover {
  background-color: rgba(255, 193, 7, 0.1);
}

.counter:nth-child(4) .view-questions-btn:hover {
  background-color: rgba(191, 10, 48, 0.1);
}

/* Flashcard Styles */
.flashcard-container {
  width: 100%; /* Occupy full width of the correctly sized main container */
  display: flex;
  justify-content: center;  perspective: 1000px;
  margin-bottom: 1.5rem; /* Reduced from 2rem to save space */
  /* max-width: var(--card-width); REMOVED - main container now handles max-width */
  padding: 0; /* Explicitly set padding to 0 */
  position: relative; /* Added for stack positioning */
  box-sizing: border-box; /* Ensure consistent box model */
}

/* Stack effect - adding pseudo-elements for cards underneath */
.flashcard-container::before,
.flashcard-container::after {
  content: "";
  position: absolute;
  width: calc(100% - 10px); /* Use container width minus small offset */
  max-width: calc(var(--card-width) - 10px);
  height: calc(var(--card-height) - 5px);
  border-radius: 12px;
  background-color: white;
  z-index: -1;
  left: 50%;
  top: 50%;
  transform-origin: center;
  transition: transform 0.3s ease-out;
}

.flashcard-container::before {
  transform: translate(-50%, -50%) scale(0.98) translateY(6px);
  background-color: #f8f8f8;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.flashcard-container::after {
  transform: translate(-50%, -50%) scale(0.96) translateY(12px);
  background-color: #f0f0f0;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
}

.flashcard {
  width: 100%; /* Use full width of container instead of fixed card-width */
  max-width: var(--card-width); /* Constrain maximum width */
  height: var(--card-height);
  position: relative;
  transition: transform 0.6s;
  transform-style: preserve-3d;
  z-index: 1; /* Ensure main card stays on top */
}

.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.4s ease; /* Reduced from 0.6s to 0.4s and added easing */
}

.flashcard.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flashcard.loading .card-content {
  opacity: 0;
  transition: opacity 0.1s ease; /* Reduced from 0.2s to 0.1s */
}

.flashcard.loading {
  opacity: 0 !important; /* Use !important to override any other opacity settings */
  transition: opacity 0.05s ease;
}

.flashcard-front, .flashcard-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden; /* Ensure no overflow outside the card */
}

.flashcard-front {
  background-color: var(--white);
  border-top: 10px solid var(--blue);
  border-bottom: 10px solid var(--blue);
  background-image: linear-gradient(to bottom, #ffffff, #f0f8ff);
}

.flashcard-back {
  background-color: #fff6f6;
  transform: rotateY(180deg);
  border-top: 10px solid var(--red);
  border-bottom: 10px solid var(--red);
  background-image: linear-gradient(to bottom, #fff6f6, #ffe6e6);
  overflow-y: hidden; /* Changed from auto to hidden */
}

/* Empty state card - for when all questions are completed */
.empty-state-card {
  width: var(--card-width);
  height: var(--card-height);
  background-color: #f0f0f0;
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  position: relative;
  z-index: -1;
}

.empty-state-text {
  color: #888;
  font-size: 1.5rem;
  font-weight: 500;
  text-align: center;
  font-style: italic;
}

/* Content wrapper to keep question and tags together at the top */
.card-content {
  display: flex;
  flex-direction: column;
  overflow-y: auto; /* Only this section can scroll if needed */
  flex-grow: 1; /* Take up available space */
  margin-bottom: 1rem; /* Space between content and buttons */
}

.tags {
  display: flex;
  gap: 0.3rem; /* Changed from 10px to 0.3rem to match button spacing */
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.section-tag {
  background-color: var(--blue);
  color: var(--white);
  padding: 0.3rem 0.8rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: bold;
  border: 1px solid #001e4c; /* Darker blue border */
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.subsection-tag {
  background-color: var(--light-gray);
  color: var(--dark-gray);
  padding: 0.3rem 0.8rem;
  border-radius: 4px;
  font-size: 0.8rem;
  border: 1px solid #d0d0d0; /* Light gray border */
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.question-number {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 1rem;
}

.question-text {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem; /* Reduced from 1.5rem to 1rem to bring answers closer */
  flex-grow: 0; /* Changed from 1 to 0 to prevent pushing content down */
}

.answer-container {
  margin-bottom: 1.5rem;
  flex-grow: 1;
  max-height: 280px; /* Increased from 220px to give more room for answers */
  overflow-y: auto; /* Add scrolling if content overflows */
  display: flex; /* Added flex display */
  flex-direction: column; /* Stack items vertically */
  align-items: flex-start; /* Align items to the top */
  justify-content: flex-start; /* Start items from the top */
  width: 100%; /* Ensure container takes full width */
}

.answer-container ul {
  margin-left: 0; /* Remove default margin */
  list-style-type: none; /* Remove default bullets */
  padding: 0;
  width: 100%; /* Make the list take full width */
}

.answer-container li {
  margin-bottom: 0.75rem;
  font-size: 1.1rem;
  padding: 0.5rem 0.75rem;
  background-color: rgba(255, 255, 255, 0.6);
  border-radius: 6px;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #e6c0c0; /* Light red/pink border to match the back card theme */
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); /* Subtle shadow similar to subtags */
}

/* Custom scrollbar for the answer container */
.answer-container::-webkit-scrollbar {
  width: 6px;
}

.answer-container::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.5);
  border-radius: 10px;
}

.answer-container::-webkit-scrollbar-thumb {
  background: var(--red);
  border-radius: 10px;
}

.answer-container::-webkit-scrollbar-thumb:hover {
  background: #a00a29;
}

/* Button Styles */
.btn {
  background-color: var(--blue);
  color: var(--white);
  border: none;
  border-radius: 4px;
  padding: 0.8rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: 'Fira Sans', sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-right: 0; /* Removed margin-right */
}

.btn:hover {
  background-color: #001e4c;
}

.btn-secondary {
  background-color: #6c757d;
}

.btn-secondary:hover {
  background-color: #5a6268;
}

.btn-reset {
  background-color: var(--red);
}

.btn-reset:hover {
  background-color: #a00a29;
}

.action-buttons, .front-buttons {
  display: flex;
  flex-direction: row;
  gap: 0.3rem; /* Already 0.3rem, keeping it the same */
  margin-top: 1.5rem;
  justify-content: flex-start;
}

.controls {
  margin: 1.5rem 0; /* Reduced from 2rem to save space while maintaining balance */
  text-align: center;
}

/* Questions list overlay */
.questions-list-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.8);
  z-index: 99999;
  display: none;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100vh;
}

/* Questions list container */
.questions-list-container {
  background-color: var(--white);
  border-radius: 8px;
  width: 95%;
  max-width: 1200px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

/* Questions list header */
.questions-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background-color: var(--header-bg);
  color: var(--header-text);
  border-bottom: 1px solid var(--header-border);
  z-index: 2;
}

.questions-list-header h2 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 600;
}

#close-questions-list-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--white);
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

#close-questions-list-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Questions list content area */
.questions-list-content {
  padding: 0;
  overflow-y: auto;
  max-height: calc(90vh - 60px);
  position: relative;
  background-color: var(--white);
  /* Adding a new stacking context to properly contain the table headers */
  isolation: isolate;
}

/* Table styles with fixed headers */
#questions-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  position: relative; /* Position relative to create a positioning context */
}

#questions-table thead {
  position: sticky;
  top: 0;
  z-index: 20; /* Increased z-index */
  background-color: var(--light-gray);
}

#questions-table th {
  background-color: var(--light-gray);
  position: sticky;
  top: 0;
  z-index: 20; /* Increased z-index to match thead */
  font-weight: 600;
  color: var(--dark-gray);
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 2px solid #ddd;
  /* Add box shadow for visual separation */
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Column widths */
#questions-table th:first-child,
#questions-table td:first-child {
  width: 60%;
  padding-left: 1.5rem;
}

#questions-table th:nth-child(2),
#questions-table td:nth-child(2),
#questions-table th:nth-child(3),
#questions-table td:nth-child(3) {
  width: 20%;
}

#questions-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid #eee;
  word-wrap: break-word;
  background-color: var(--white);
}

/* Fix for table header borders */
#questions-table::before {
  content: "";
  height: 2px;
  background-color: var(--light-gray);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 6;
}

/* Message for no questions */
.no-questions-message {
  padding: 2rem;
  text-align: center;
  color: #888;
  font-style: italic;
  background-color: var(--white);
}

/* Back button for mobile */
.back-button {
  background: transparent;
  border: none;
  color: var(--header-text);
  padding: 0.5rem 0;
  margin-right: 1rem;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.back-button:hover {
  text-decoration: underline;
}

/* When overlay is active, prevent scrolling the body */
body.overlay-active {
  overflow: hidden;
}

/* Questions table styling */
#questions-table th, 
#questions-table td {
  padding: 0.6rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid #eee;
  word-wrap: break-word;
}

#questions-table th:nth-child(1),
#questions-table td:nth-child(1) {
  width: 60%;
}

#questions-table th:nth-child(2),
#questions-table td:nth-child(2),
#questions-table th:nth-child(3),
#questions-table td:nth-child(3) {
  width: 20%;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Footer Styles */
footer {
  background-color: var(--footer-bg);
  color: var(--footer-text);
  padding: 2rem 0 1.5rem;
  margin-top: auto; /* Changed from 2.5rem to auto to stick to bottom */
  position: relative;
  border-top: 1px solid var(--footer-border);
  box-shadow: 0 -3px 10px rgba(0, 0, 0, 0.1);
  width: 100%;
}

/* Add safe area padding at the bottom for iOS devices */
@supports (-webkit-touch-callout: none) {
  footer {
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0));
  }
}

footer::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--red); /* Changed from gradient to solid red color */
  opacity: 0.8;
}

.disclaimer {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1.5rem;
  text-align: center;
  position: relative;
  z-index: auto; /* Change from 1 to auto to inherit parent's z-index */
}

.disclaimer h3 {
  margin-bottom: 1.2rem;
  font-weight: 600;
  font-size: 1.2rem;
  color: var(--white);
}

.disclaimer p {
  margin-bottom: 0.8rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #adb5bd; /* Lighter gray for better contrast on dark */
}

.disclaimer a {
  color: #8bb9fe; /* Lighter blue for better visibility on dark background */
  text-decoration: underline;
  transition: all 0.2s ease;
  font-weight: 500;
}

.disclaimer a:hover {
  color: var(--white);
}

.attribution {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.9rem;
  padding-top: 1rem;
  border-top: 1px solid var(--subtle-accent);
  color: #adb5bd; /* Lighter gray for better contrast on dark */
}

.attribution a {
  color: #8bb9fe; /* Lighter blue for better visibility on dark background */
  text-decoration: underline;
  transition: all 0.2s ease;
  font-weight: 500;
}

.attribution a:hover {
  color: var(--white);
}

/* Responsive Design */
/* Large tablets and small desktops */
@media (max-width: 1200px) {
  :root {
    --card-width: 700px;
    --card-max-width: 700px;
    --card-height: 560px;
  }
}

/* Medium tablets */
@media (max-width: 1000px) {
  :root {
    --card-width: 600px;
    --card-max-width: 600px;
    --card-height: 540px;
  }
}

@media (max-width: 900px) {
  :root {
    --card-width: 90%;
    --card-max-width: 550px;
    --card-height: 520px;
  }
    .counter {
    flex: 1 1 calc(50% - 0.5rem); /* Two counters per row, accounting for gap properly */
    max-width: none; /* Remove max-width constraint for 2x2 layout */
  }
}

/* Small tablets */
@media (max-width: 800px) {
  :root {
    --card-width: 90%;
    --card-max-width: 500px;
    --card-height: 580px;
  }
}

@media (max-width: 700px) {
  :root {
    --card-width: 90%;
    --card-max-width: 90%;
    --card-height: 650px; /* Increased from 550px to 650px to make cards taller on mobile */
  }

  .logo {
    font-size: 1.8rem;
  }

  .flashcard-front, .flashcard-back {
    padding: 1.5rem;
  }

  .question-text {
    font-size: 1.3rem;
  }

  /* Adjust the answer container to take advantage of the extra space */
  .answer-container {
    max-height: 470px; /* Increased from 370px to 470px to use the additional card height */
  }

  .front-buttons, .action-buttons {
    flex-direction: column;
    width: 100%;
  }
  
  .btn {
    margin-right: 0;
    margin-bottom: 0.5rem;
    width: 100%;
  }
}

@media (max-width: 650px) {
  .questions-list-container {
    width: 95%;
  }
  
  #questions-table th:nth-child(3),
  #questions-table td:nth-child(3),
  #questions-table th:nth-child(4),
  #questions-table td:nth-child(4) {
    display: none;
  }
}

@media (max-width: 600px) {
  :root {
    --card-width: 95%;
    --card-max-width: 95%;
    --card-height: 620px;
  }
  
  .counter-container {
    gap: 0.8rem;
  }
  
  .counter {
    flex: 1 1 calc(50% - 0.8rem);
    padding: 0.9rem;
  }
  
  .counter span {
    font-size: 2.2rem;
  }
}

@media (max-width: 500px) {
  .counter-container {
    gap: 1rem;
    justify-content: space-between; /* Maintain consistent layout */
  }

  .counter {
    flex: 1 1 calc(50% - 0.5rem); /* Keep two per row, proper gap calculation */
    padding: 0.8rem;
    min-width: 120px;
    max-width: none; /* Remove the max-width constraint */
  }

  .counter span {
    font-size: 2rem;
  }
}

/* Very large screens - allow larger cards for big monitors */
@media (min-width: 1400px) {
  :root {
    --card-width: 800px;
    --card-max-width: 800px;
    --card-height: 600px;
  }
}

/* Large screens - medium sized cards */
@media (min-width: 1100px) and (max-width: 1399px) {
  :root {
    --card-width: 700px;
    --card-max-width: 700px;
    --card-height: 580px;
  }
}

/* Keyframes for card animations */
@keyframes cardPulse {
  0% { transform: scale(1); }
  50% { transform: scale(0.98); }
  100% { transform: scale(1); }
}

/* Animation for newly loaded card - reducing the bounce effect */
@keyframes cardFadeIn {
  0% { 
    transform: translateY(-5px);
    opacity: 0;
  }
  100% { 
    transform: translateY(0);
    opacity: 1; 
  }
}

/* Simple animations for card tosses */
@keyframes tossRight {
  0% { 
    transform: translateX(0) rotate(0); 
    opacity: 1;
  }
  100% { 
    transform: translateX(150%) rotate(10deg); 
    opacity: 0;
  }
}

@keyframes tossLeft {
  0% { 
    transform: translateX(0) rotate(0); 
    opacity: 1;
  }
  100% { 
    transform: translateX(-150%) rotate(-10deg); 
    opacity: 0;
  }
}

/* New animation for earmarked cards being tossed down */
@keyframes tossDown {
  0% { 
    transform: translateY(0) rotate(0); 
    opacity: 1;
  }
  100% { 
    transform: translateY(150%) rotate(5deg); 
    opacity: 0;
  }
}

/* Apply toss animations to inner card element */
.flashcard.toss-right .flashcard-inner {
  animation: tossRight 0.5s ease-out forwards;
  transform-origin: center left;
}

.flashcard.toss-left .flashcard-inner {
  animation: tossLeft 0.5s ease-out forwards;
  transform-origin: center right;
}

/* Apply toss-down animation to inner card element */
.flashcard.toss-down .flashcard-inner {
  animation: tossDown 0.5s ease-out forwards;
  transform-origin: center top;
}

/* Hide the flashcard during loading (between animations) */
.flashcard.loading {
  opacity: 0;
  transition: opacity 0.1s ease;
}

/* Congratulations modal styles */
.congratulations-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

.congratulations-content {
  background-color: var(--header-bg);
  color: var(--header-text);
  border-radius: 8px;
  padding: 2rem;
  width: 90%;
  max-width: 500px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  position: relative;
  animation: modalAppear 0.4s ease-out;
  border: 1px solid var(--header-border);
  /* Add gradient border effect using pseudo-elements */
  position: relative;
  z-index: 1;
  overflow: hidden;
}

/* Gradient border around the entire modal content - more subtle version */
.congratulations-content::before {
  content: "";
  position: absolute;
  top: -1px;
  left: -1px;
  right: -1px;
  bottom: -1px;
  background: var(--soft-blue); /* Changed from gradient to solid blue color */
  z-index: -1;
  border-radius: 9px;
  opacity: 0.2; /* Reduced opacity for subtle look */
}

/* Remove the old bottom-only gradient */
.congratulations-content::after {
  display: none;
}

.congratulations-content h2 {
  color: var(--white);
  font-size: 1.8rem;
  margin-bottom: 1rem;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

/* Create an emoji wrapper for celebration modals */
.emoji-glow {
  display: inline-block;
  font-size: 2rem;
  margin: 0 0.3rem;
  filter: drop-shadow(0 0 5px #bf0a30) 
          drop-shadow(0 0 5px #002868) 
          drop-shadow(0 0 10px #ffffff);
  animation: emojiPulse 2s infinite ease-in-out;
}

@keyframes emojiPulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.9; }
  100% { transform: scale(1); opacity: 1; }
}

.congratulations-content p {
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
  line-height: 1.4;
  color: #adb5bd;
}

/* Dialog buttons without motion effects */
.congratulations-content .btn {
  margin-top: 1rem;
  font-size: 1.1rem;
  padding: 0.8rem 1.8rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: background-color 0.2s ease;
}

.congratulations-content .btn:hover {
  /* Remove transform and keep just color changes */
  background-color: #001e4c;
  border-color: rgba(255, 255, 255, 0.4);
}

.congratulations-content .btn.btn-reset:hover {
  background-color: #a00a29;
}

@keyframes modalAppear {
  from { 
    transform: translateY(20px); 
    opacity: 0; 
  }
  to { 
    transform: translateY(0); 
    opacity: 1; 
  }
}

@media (max-width: 500px) {
  .congratulations-content {
    padding: 1.5rem;
  }
  .congratulations-content h2 {
    font-size: 1.5rem;
  }
  .congratulations-content p {
    font-size: 1rem;
  }
}