/* Global Vocabulary Exercise Styles */
:root {
  --primary-color: #e50914;
  --primary-rgb: 229, 9, 20;
  --primary-hover: #b2070f;
  --bg-color-dark: #121212;
  --text-color-dark: #f0f0f0;
  --bg-color-light: #f5f5f5;
  --text-color-light: #333;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", Segoe UI Symbol, "Noto Color Emoji";
  transition: background-color 0.3s, color 0.3s;
}

body:not(.light-mode) {
  background-color: var(--bg-color-dark);
  color: var(--text-color-dark);
}

body.light-mode {
  background-color: var(--bg-color-light);
  color: var(--text-color-light);
}

/* Allow sticky elements to reference viewport */
.content-container {
  overflow: visible !important;
}

.vocab-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
  text-align: center;
  overflow: visible;
}

.vocab-container-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 40px;
  overflow: visible;
  position: relative;
}

.flashcards-tab-shell > h2:first-child {
  margin-left: 40px;
  margin-right: 40px;
}

.flashcards-tab-shell > .vocab-container-inner-embedded {
  max-width: none;
  margin: 0;
  padding: 0 40px 40px;
}

.embedded-flashcards-shell > h2:first-child {
  margin-left: 0;
  margin-right: 0;
}

.embedded-flashcards-shell > .vocab-container-inner-embedded {
  padding-left: 0;
  padding-right: 0;
}

.flashcards-tab-shell .flashcard-instructions {
  margin: 0 0 15px;
}

/* Remove padding for games that need full width */
.vocab-container-inner:has(#word-search-game-container),
.vocab-container-inner:has(#crossword-game-container),
.vocab-container-inner:has(#hangman-game-container) {
  padding: 0;
  max-width: none;
}

.vocab-header h1 {
  font-size: 2.5rem;
  margin-bottom: 30px;
  color: var(--primary-color);
  text-transform: uppercase;
}

/* Flashcard Display Toggle */
.vocab-display-toggle {
  --toggle-padding: 6px;
  --toggle-highlight-x: var(--toggle-padding);
  --toggle-highlight-width: 104px;
  display: grid;
  grid-template-columns: repeat(2, auto);
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 20px;
  padding: var(--toggle-padding);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  position: relative;
  overflow: hidden;
}

body.light-mode .vocab-display-toggle {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.15);
}

.vocab-display-toggle::before {
  content: "";
  position: absolute;
  top: var(--toggle-padding);
  bottom: var(--toggle-padding);
  left: 0;
  width: var(--toggle-highlight-width);
  border-radius: 999px;
  background: var(--primary-color);
  box-shadow: 0 8px 18px rgba(229, 9, 20, 0.28);
  transform: translateX(var(--toggle-highlight-x));
  transition: transform 0.28s cubic-bezier(0.22, 0.8, 0.2, 1), width 0.28s cubic-bezier(0.22, 0.8, 0.2, 1);
}

.vocab-display-toggle .toggle-btn {
  border: 0;
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  color: inherit;
  background: transparent;
  transition: color 0.2s ease;
  position: relative;
  z-index: 1;
}

.vocab-display-toggle .toggle-btn.active {
  color: #fff;
}

/* Flashcards Grid */
.flashcard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 30px;
  padding: 10px;
}

@media (min-width: 900px) {
  .flashcard-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.flashcard {
  background-color: transparent;
  height: 220px;
  perspective: 1000px;
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  opacity: 1;
  transform: scale(1);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.flashcard.is-filtered-out {
  opacity: 0;
  transform: scale(0.92);
  pointer-events: none;
}

.flashcard.is-reappearing {
  animation: flashcardPopIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes flashcardPopIn {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.flashcard:hover .flashcard-inner {
  transform: translateY(-10px);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
}

.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s;
  transform-style: preserve-3d;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  border-radius: 15px;
}

.flashcard.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-radius: 15px;
  padding: 30px;
  box-sizing: border-box;
  text-align: center;
}

.flashcard-front {
  background: linear-gradient(135deg, var(--primary-color), #b2070f);
  color: white;
  font-size: 1.8em;
  font-weight: 800;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.flashcard-front p {
  margin: 0 0 16px;
  width: 100%;
  line-height: 1.1;
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

.flashcard-back {
  background: linear-gradient(135deg, #f5f5f5, #e0e0e0);
  color: #333;
  transform: rotateY(180deg);
  font-size: 1.1em;
  line-height: 1.5;
  font-weight: 500;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.1);
  overflow-y: auto;
  overflow-x: hidden;
}

body.light-mode .flashcard-back {
  background: white;
  color: #333;
  border: 2px solid #ddd;
}

.flashcard-back-text {
  margin: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  opacity: 1;
  transform: translateY(0);
}

.flashcard-back-image {
  display: block;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.96);
  max-width: 130px;
  max-height: 130px;
  width: auto;
  height: auto;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  filter: brightness(0) invert(0);
}

.flashcard.image-mode .flashcard-back-image {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.flashcard.image-mode[data-image-kind="uploaded"] .flashcard-back-image {
  transform: none;
}

.flashcard.image-mode .flashcard-back-text {
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
}

.noun-project-icon {
  filter: brightness(0) invert(1);
}

body.light-mode .noun-project-icon {
  filter: brightness(0) invert(0);
}

.flashcard-back-image {
  filter: brightness(0) invert(0) !important;
}

.flashcard-back-image-uploaded {
  inset: 0;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: cover;
  transform: none;
  border-radius: inherit;
  filter: none !important;
}

.flashcard.image-mode[data-image-kind="uploaded"] .flashcard-back {
  padding: 0;
  background: #111;
  box-shadow: none;
}

body.light-mode .flashcard.image-mode[data-image-kind="uploaded"] .flashcard-back {
  background: #fff;
}

/* Audio Button */
.audio-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  margin-top: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, background-color 0.3s;
  z-index: 20;
  position: absolute;
  bottom: 20px;
  transform: translateZ(60px);
  /* Increased lift to prevent flickering */
}

.audio-btn:hover {
  transform: scale(1.1);
  background: rgba(255, 255, 255, 0.4);
}

.audio-btn svg {
  width: 20px;
  height: 20px;
  fill: white;
}

/* Scrollbar for back content */
.flashcard-back::-webkit-scrollbar {
  width: 6px;
}

.flashcard-back::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.3);
  border-radius: 3px;
}

/* --- BUTTONS --- */
.action-btn {
  background-color: var(--primary-color);
  color: #fff;
  border: none;
  padding: 14px 35px;
  font-size: 1.2rem;
  font-weight: bold;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  text-transform: uppercase;
  letter-spacing: 1px;
  display: inline-block;
}

.action-btn:hover {
  background-color: var(--primary-hover);
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 10px 20px rgba(229, 9, 20, 0.4);
}

.action-btn:active {
  transform: translateY(1px) scale(0.98);
}

.flashcards-generator-icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 0;
  right: 0;
  z-index: 4;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f5f5f5;
  text-decoration: none;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.flashcards-generator-icon-link:hover {
  transform: translateY(-2px);
  background: rgba(229, 9, 20, 0.16);
  border-color: rgba(229, 9, 20, 0.38);
  box-shadow: 0 12px 24px rgba(229, 9, 20, 0.18);
}

.flashcards-generator-icon-link svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

body.light-mode .flashcards-generator-icon-link {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.12);
  color: #333;
}

.linked-vocab-cta {
  margin-top: 24px;
  padding: 18px 20px;
  border: 1px solid rgba(229, 9, 20, 0.25);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(229, 9, 20, 0.14), rgba(229, 9, 20, 0.05));
  text-align: center;
}

.linked-vocab-cta-copy {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 600;
}

.linked-vocab-cta-link {
  color: #ff7b7b;
  font-weight: 700;
  text-decoration: underline;
}

.linked-vocab-cta-meta {
  margin: 8px 0 0;
  font-size: 0.92rem;
  color: rgba(255, 255, 255, 0.75);
}

body.light-mode .linked-vocab-cta {
  background: linear-gradient(135deg, rgba(229, 9, 20, 0.08), rgba(229, 9, 20, 0.03));
  border-color: rgba(229, 9, 20, 0.18);
}

body.light-mode .linked-vocab-cta-link {
  color: #c30f18;
}

body.light-mode .linked-vocab-cta-meta {
  color: rgba(0, 0, 0, 0.6);
}

.flashcards-link-action-row {
  margin-top: 18px;
  display: flex;
  width: 100%;
  justify-content: flex-start;
  align-items: flex-start;
  overflow: visible;
}

.flashcards-link-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 999px;
  background: #e50914;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(229, 9, 20, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.flashcards-link-icon-btn:hover {
  transform: translateY(-2px);
  background: #f21a25;
  box-shadow: 0 14px 24px rgba(229, 9, 20, 0.38);
}

.flashcards-link-icon-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.flashcards-link-icon-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(20, 20, 20, 0.96);
  color: #fff;
  font-size: 0.82rem;
  line-height: 1.2;
  white-space: nowrap;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
  z-index: 20;
}

.flashcards-link-icon-btn::before {
  content: "";
  position: absolute;
  left: 14px;
  bottom: calc(100% + 4px);
  width: 10px;
  height: 10px;
  background: rgba(20, 20, 20, 0.96);
  transform: rotate(45deg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
  z-index: 19;
}

.flashcards-link-icon-btn:hover::after,
.flashcards-link-icon-btn:hover::before,
.flashcards-link-icon-btn:focus-visible::after,
.flashcards-link-icon-btn:focus-visible::before {
  opacity: 1;
  transform: translateY(0);
}

body.light-mode .flashcards-link-icon-btn::after,
body.light-mode .flashcards-link-icon-btn::before {
  background: rgba(33, 33, 33, 0.96);
}

.linked-vocab-modal-content {
  max-width: 920px;
  width: min(920px, calc(100vw - 32px));
  max-height: min(82vh, 760px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.linked-vocab-modal-header {
  flex: 0 0 auto;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.linked-vocab-modal-header h3 {
  margin-bottom: 8px;
}

.linked-vocab-modal-subtitle {
  margin: 0;
  color: #ddd;
  line-height: 1.5;
}

.linked-vocab-modal-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding-right: 6px;
  margin-top: 18px;
}

.linked-vocab-modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 15px;
  flex: 0 0 auto;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: inherit;
  position: sticky;
  bottom: 0;
  z-index: 1;
}

.linked-vocab-modal-actions #linked-vocab-sync-btn {
  margin-left: auto;
  margin-right: 0;
}

.linked-vocab-current,
.linked-vocab-lookup-status {
  margin: 14px 0 0;
  text-align: left;
  font-size: 0.95rem;
}

.linked-vocab-recent {
  margin-top: 16px;
}

.linked-vocab-recent-list {
  display: grid;
  gap: 12px;
}

.linked-vocab-recent-option {
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.linked-vocab-recent-option-trigger {
  width: 100%;
  padding: 14px 16px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.18s ease, background-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.linked-vocab-recent-option:hover,
.linked-vocab-recent-option:focus-within {
  border-color: rgba(229, 9, 20, 0.38);
}

.linked-vocab-recent-option-trigger:hover,
.linked-vocab-recent-option-trigger:focus-visible {
  background: rgba(229, 9, 20, 0.08);
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.18);
}

.linked-vocab-recent-option.is-selected {
  border-color: rgba(229, 9, 20, 0.48);
  background: rgba(229, 9, 20, 0.08);
}

.linked-vocab-recent-option-title {
  font-size: 1rem;
  font-weight: 700;
}

.linked-vocab-recent-option-meta {
  margin-top: 6px;
  font-size: 0.9rem;
  color: #aaa;
}

.linked-vocab-recent-option-body {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.22s ease, padding 0.22s ease;
  padding: 0 16px;
}

.linked-vocab-recent-option-body.is-open {
  max-height: 720px;
  opacity: 1;
  padding: 0 16px 16px;
}

.linked-vocab-recent-option-vocab-list {
  list-style: none;
  margin: 0;
  padding: 12px 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.linked-vocab-recent-option-vocab-list li {
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  line-height: 1.35;
  font-size: 0.95rem;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  overflow-wrap: anywhere;
}

.linked-vocab-recent-option-vocab-list li.is-long {
  font-size: 0.88rem;
}

.linked-vocab-recent-option-vocab-list li.is-very-long {
  font-size: 0.8rem;
}

.linked-vocab-current {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.linked-vocab-unlink-btn {
  margin-left: auto;
  margin-right: 0 !important;
  padding: 8px 18px;
  font-size: 0.9rem;
  flex: 0 0 auto;
}

.linked-vocab-lookup-status.is-error {
  color: #ff8d8d;
}

.linked-vocab-lookup-status.is-success {
  color: #8ee1b0;
}

.linked-vocab-preview {
  margin-top: 16px;
  padding: 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  text-align: left;
  overflow: hidden;
}

.linked-vocab-preview h4 {
  margin: 0 0 6px;
}

.linked-vocab-preview-meta {
  margin: 0 0 12px;
  color: #aaa;
}

.linked-vocab-preview-list {
  margin: 0;
  padding-left: 18px;
  max-height: 280px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.linked-vocab-preview-list li {
  margin-bottom: 10px;
}

.linked-vocab-preview-list strong {
  color: #fff;
}

.linked-vocab-sync-warning {
  margin-top: 18px;
  padding: 18px 20px;
  border-radius: 14px;
  border: 1px solid rgba(229, 9, 20, 0.35);
  background: linear-gradient(135deg, rgba(229, 9, 20, 0.18), rgba(229, 9, 20, 0.06));
  text-align: left;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.linked-vocab-sync-warning.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.linked-vocab-sync-warning h4 {
  margin: 0 0 8px;
  color: #ffb3b3;
}

.linked-vocab-sync-warning p {
  margin: 0;
  font-weight: 700;
  line-height: 1.55;
}

.linked-vocab-sync-animation {
  margin-top: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  position: relative;
}

.linked-vocab-sync-column {
  min-width: 0;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.linked-vocab-sync-animation.is-left-visible #linked-vocab-current-sync-column,
.linked-vocab-sync-animation.is-arrow-visible .linked-vocab-sync-arrow,
.linked-vocab-sync-animation.is-right-visible #linked-vocab-target-sync-column {
  opacity: 1;
  transform: translateY(0);
}

.linked-vocab-sync-current-stage {
  display: none;
}

.linked-vocab-sync-label {
  margin-bottom: 10px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
}

.linked-vocab-sync-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.linked-vocab-sync-list li {
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  line-height: 1.35;
}

.linked-vocab-sync-list li:last-child {
  border-bottom: 0;
}

.linked-vocab-sync-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 999px;
  background: rgba(229, 9, 20, 0.14);
  border: 1px solid rgba(229, 9, 20, 0.24);
  color: #ff8d8d;
  transition: opacity 0.22s ease, transform 0.22s ease, background-color 0.18s ease, box-shadow 0.18s ease;
  opacity: 0;
  transform: scale(0.92);
}

.linked-vocab-sync-arrow svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body.light-mode .linked-vocab-modal-subtitle,
body.light-mode .linked-vocab-preview-meta {
  color: rgba(0, 0, 0, 0.6);
}

body.light-mode .linked-vocab-preview {
  background: rgba(0, 0, 0, 0.04);
}

body.light-mode .linked-vocab-recent-option {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .linked-vocab-recent-option:hover,
body.light-mode .linked-vocab-recent-option:focus-within,
body.light-mode .linked-vocab-recent-option.is-selected {
  border-color: rgba(229, 9, 20, 0.28);
}

body.light-mode .linked-vocab-recent-option-meta {
  color: rgba(0, 0, 0, 0.6);
}

body.light-mode .linked-vocab-recent-option-vocab-list {
  border-top-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .linked-vocab-recent-option-vocab-list li {
  background: rgba(0, 0, 0, 0.04);
}

body.light-mode .linked-vocab-modal-header,
body.light-mode .linked-vocab-modal-actions {
  border-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .linked-vocab-sync-warning {
  background: linear-gradient(135deg, rgba(229, 9, 20, 0.1), rgba(229, 9, 20, 0.04));
  border-color: rgba(229, 9, 20, 0.24);
}

body.light-mode .linked-vocab-sync-warning h4 {
  color: #b42318;
}

body.light-mode .linked-vocab-sync-list {
  background: rgba(0, 0, 0, 0.04);
}

body.light-mode .linked-vocab-sync-list li {
  border-bottom-color: rgba(0, 0, 0, 0.06);
}

body.light-mode .linked-vocab-sync-label {
  color: rgba(0, 0, 0, 0.58);
}

body.light-mode .linked-vocab-sync-arrow {
  color: #c30f18;
  background: rgba(229, 9, 20, 0.1);
  border-color: rgba(229, 9, 20, 0.18);
}

body.light-mode .linked-vocab-preview-list strong {
  color: #111;
}

body.light-mode .linked-vocab-lookup-status.is-error {
  color: #b42318;
}

body.light-mode .linked-vocab-lookup-status.is-success {
  color: #067647;
}

@media (max-width: 860px) {
  .linked-vocab-recent-option-vocab-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .linked-vocab-sync-animation {
    grid-template-columns: 1fr;
  }

  .linked-vocab-sync-arrow {
    width: 56px;
    height: 56px;
    margin: 0 auto;
    transform: rotate(90deg);
  }
}

@media (max-width: 560px) {
  .linked-vocab-recent-option-vocab-list {
    grid-template-columns: 1fr;
  }
}

/* --- MATCHING GAME STYLES --- */
.matching-wrapper {
  width: 100%;
}

.matching-grid-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
  margin-top: 20px;
}

.match-item {
  background-color: #2a2a2a;
  border: 2px solid #444;
  border-radius: 8px;
  padding: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-weight: 500;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.3s;
  min-height: 80px;
  position: relative;
  z-index: 1;
  color: var(--text-color-dark);
}

.defs-col .match-item {
  font-size: 0.9em;
}

.match-item-image {
  width: 72px;
  height: 72px;
  object-fit: contain;
  filter: brightness(0) invert(1) !important;
}

.match-item-image-uploaded {
  object-fit: cover;
  filter: none !important;
}

body.light-mode .match-item-image {
  filter: brightness(0) invert(0) !important;
}

body.light-mode .match-item-image-uploaded {
  filter: none !important;
}


body.light-mode .match-item {
  background-color: #fff;
  border-color: #ddd;
  color: var(--text-color-light);
}

.match-item:hover {
  transform: scale(1.02);
  border-color: #888;
  z-index: 2;
}

.match-item.selected {
  border-color: var(--primary-color);
  background-color: rgba(229, 9, 20, 0.1);
  transform: scale(1.05);
  box-shadow: 0 5px 15px rgba(229, 9, 20, 0.2);
  z-index: 3;
}

.match-item.matched {
  background-color: rgba(46, 204, 113, 0.2) !important;
  border-color: #2f9246 !important;
  opacity: 0.8;
  pointer-events: none;
  z-index: 1;
}

.match-item.match-error {
  animation: shake 0.6s, wrongFlash 0.8s;
  background-color: rgba(229, 9, 20, 0.2);
  border-color: var(--primary-color);
}

/* Exercise Instructions */
.exercise-instructions {
  background: linear-gradient(135deg, rgba(229, 9, 20, 0.1), rgba(229, 9, 20, 0.05));
  border-left: 4px solid var(--primary-color);
  padding: 15px 20px;
  margin-bottom: 25px;
  border-radius: 0 10px 10px 0;
  font-size: 1.1rem;
  color: inherit;
}

body.light-mode .exercise-instructions {
  background: linear-gradient(135deg, rgba(229, 9, 20, 0.08), rgba(229, 9, 20, 0.02));
}

.exercise-instructions p {
  margin: 0;
}

.exercise-instructions strong {
  color: var(--primary-color);
}

/* Enhanced Wrong Animation - More dramatic feedback */
@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translateX(-8px);
  }

  20%,
  40%,
  60%,
  80% {
    transform: translateX(8px);
  }
}

@keyframes wrongFlash {
  0% {
    background-color: rgba(231, 76, 60, 0.3);
    box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7);
  }

  25% {
    background-color: rgba(231, 76, 60, 0.6);
    box-shadow: 0 0 20px 5px rgba(231, 76, 60, 0.5);
  }

  50% {
    background-color: rgba(231, 76, 60, 0.3);
    box-shadow: 0 0 30px 10px rgba(231, 76, 60, 0.3);
  }

  75% {
    background-color: rgba(231, 76, 60, 0.5);
    box-shadow: 0 0 15px 3px rgba(231, 76, 60, 0.4);
  }

  100% {
    background-color: transparent;
    box-shadow: 0 0 0 0 rgba(231, 76, 60, 0);
  }
}

@keyframes wrongPulse {

  0%,
  100% {
    transform: scale(1);
  }

  25% {
    transform: scale(1.05);
  }

  50% {
    transform: scale(0.95);
  }

  75% {
    transform: scale(1.03);
  }
}

.match-group {
  display: grid;
  gap: 15px;
}

.group-separator {
  grid-column: 1 / -1;
  border: none;
  height: 2px;
  background-color: var(--primary-color);
  margin: 20px 0;
  opacity: 0.3;
}

/* --- GAP FILL STYLES --- */
.floating-word-bank-container {
  position: -webkit-sticky;
  position: sticky;
  top: 10px;
  /* Reduced top offset */
  z-index: 999;
  /* Higher z-index to ensure it stays on top */
  margin-bottom: 30px;
  background: var(--bg-color-dark);
  padding: 15px;
  border-radius: 10px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
  border: 1px solid #444;
  transition: background-color 0.3s;
  /* Ensure it works within flex/grid parents */
  align-self: start;
}

body.light-mode .floating-word-bank-container {
  background: #fdfdfd;
  border-color: #ddd;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.word-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  min-height: 40px;
}

.draggable-word {
  background: var(--primary-color);
  color: white;
  padding: 8px 16px;
  border-radius: 50px;
  /* More rounded modern look */
  cursor: grab;
  user-select: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.draggable-word:active {
  cursor: grabbing;
  transform: scale(0.95);
}

.draggable-word:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.draggable-word.mobile-selected {
  background: #ffd166;
  color: #1b1b1b;
  box-shadow: 0 0 0 3px rgba(255, 209, 102, 0.3), 0 8px 18px rgba(0, 0, 0, 0.25);
  animation: selectedPillWiggle 0.45s ease, selectedPillPulse 1.15s ease-in-out infinite;
}

@keyframes selectedPillWiggle {
  0% {
    transform: translateY(0) scale(1);
  }

  25% {
    transform: translateY(-1px) rotate(-2deg) scale(1.04);
  }

  50% {
    transform: translateY(-2px) rotate(2deg) scale(1.06);
  }

  75% {
    transform: translateY(-1px) rotate(-1deg) scale(1.03);
  }

  100% {
    transform: translateY(0) rotate(0deg) scale(1.02);
  }
}

@keyframes selectedPillPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 209, 102, 0.5), 0 8px 18px rgba(0, 0, 0, 0.25);
  }

  70% {
    box-shadow: 0 0 0 10px rgba(255, 209, 102, 0), 0 10px 22px rgba(0, 0, 0, 0.28);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(255, 209, 102, 0), 0 8px 18px rgba(0, 0, 0, 0.25);
  }
}

/* Modern Input Styling */
.gap-input {
  background: transparent;
  border: none;
  border-bottom: 2px solid #666;
  color: inherit;
  font-size: inherit;
  text-align: center;
  width: 140px;
  margin: 0 5px;
  padding: 5px 0;
  transition: all 0.3s ease;
  border-radius: 0;
  /* Remove default radius */
}

body.light-mode .gap-input {
  border-bottom-color: #aaa;
}

.gap-input:focus {
  outline: none;
  border-bottom-color: var(--primary-color);
  background: rgba(229, 9, 20, 0.05);
  /* Very subtle tint on focus */
}

body.mobile-word-selected .gap-input:not(.correct):not(.incorrect):not(:disabled) {
  border-bottom-color: rgba(var(--primary-rgb), 0.75);
  background: rgba(var(--primary-rgb), 0.1);
  box-shadow: 0 0 0 1px rgba(var(--primary-rgb), 0.38);
  border-radius: 6px;
  padding: 5px 8px;
  animation: targetBlankPulse 1.1s ease-in-out infinite;
}

body.light-mode.mobile-word-selected .gap-input:not(.correct):not(.incorrect):not(:disabled) {
  background: rgba(var(--primary-rgb), 0.08);
  box-shadow: 0 0 0 1px rgba(var(--primary-rgb), 0.28);
}

.gap-input.correct {
  border-bottom-color: #2ecc71;
  color: #2ecc71;
  background: transparent;
}

.gap-input.incorrect {
  border-bottom-color: #e74c3c;
  color: #e74c3c;
  background: rgba(231, 76, 60, 0.1);
  animation: shake 0.6s, wrongPulse 0.6s;
}


.drop-zone {
  display: inline-flex;
  /* Use flex to center content properly */
  align-items: center;
  justify-content: center;
  min-width: 120px;
  height: 34px;
  /* Slightly taller */
  border-bottom: 2px dashed #777;
  vertical-align: middle;
  margin: 4px 6px;
  /* Ensure spacing around items */
  color: var(--primary-color);
  font-weight: 600;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  line-height: normal;
  /* Reset line height inside */
  padding: 0 12px;
  border-radius: 4px;
  position: relative;
  background: rgba(255, 255, 255, 0.02);
  /* Subtle background */
}

.gap-answer-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  margin: 4px 6px;
  padding: 6px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #e50914, #b2070f);
  color: #fff;
  font-weight: 700;
  line-height: 1.2;
  box-shadow: 0 8px 18px rgba(229, 9, 20, 0.24);
  vertical-align: middle;
}

body.light-mode .gap-answer-pill {
  color: #fff;
  box-shadow: 0 8px 18px rgba(178, 7, 15, 0.18);
}

body.light-mode .drop-zone {
  border-bottom-color: #bbb;
  background: rgba(0, 0, 0, 0.02);
}

.drop-zone.filled {
  border-bottom: 2px solid transparent;
  /* Hide dashed border */
  background: rgba(var(--primary-rgb), 0.15);
  color: var(--text-color-dark);
}

body.light-mode .drop-zone.filled {
  color: var(--text-color-light);
}

.drop-zone.correct {
  color: white !important;
  background-color: #2ecc71 !important;
  border: none !important;
  /* Remove borders to prevent clash */
  box-shadow: 0 2px 10px rgba(46, 204, 113, 0.3);
  animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.drop-zone.incorrect {
  color: white !important;
  background-color: #e74c3c !important;
  border: none !important;
  animation: shake 0.6s, wrongFlash 0.8s, wrongPulse 0.6s;
  box-shadow: 0 0 20px 5px rgba(231, 76, 60, 0.4);
}

body.mobile-word-selected .drop-zone:not(.correct):not(.incorrect):not(.filled) {
  border-bottom: 2px dashed rgba(var(--primary-rgb), 0.75);
  background: rgba(var(--primary-rgb), 0.12);
  box-shadow: 0 0 0 1px rgba(var(--primary-rgb), 0.34);
  border-radius: 6px;
  animation: targetBlankPulse 1.1s ease-in-out infinite;
}

body.light-mode.mobile-word-selected .drop-zone:not(.correct):not(.incorrect):not(.filled) {
  background: rgba(var(--primary-rgb), 0.08);
  box-shadow: 0 0 0 1px rgba(var(--primary-rgb), 0.24);
}

@keyframes popIn {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes targetBlankPulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.03);
  }

  100% {
    transform: scale(1);
  }
}

/* Gap Fill Item Layout */
.gapfill-item {
  background: rgba(255, 255, 255, 0.03);
  padding: 25px;
  margin-bottom: 25px;
  border-radius: 12px;
  text-align: left;
  font-size: 1.2rem;
  line-height: 1.8;
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-wrap: wrap;
  /* Allow wrapping */
  align-items: center;
  /* Vertically align check button */
  justify-content: space-between;
  /* Push button to right if it fits */
  gap: 15px;
}

body.edit-mode-enabled .gapfill-item {
  position: relative;
  padding-right: 96px;
}

body.light-mode .gapfill-item {
  background: white;
  border: 1px solid #e0e0e0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

.gapfill-sentence-text {
  flex: 1 1 70%;
  /* Take up most space */
  min-width: 300px;
}

.item-check-btn {
  margin-top: 0 !important;
  /* Override inline style from JS */
  padding: 10px 25px !important;
  font-size: 0.9rem !important;
  flex: 0 0 auto;
  /* Don't shrink */
  margin-left: auto;
  /* Push to right */
}

body.edit-mode-enabled .item-check-btn {
  display: none !important;
}

.gapfill-empty-state {
  text-align: center;
  font-size: 1.05rem;
  color: #aaa;
  padding: 18px 22px;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  margin: 20px 0;
}

body.light-mode .gapfill-empty-state {
  color: #666;
  border-color: rgba(0, 0, 0, 0.14);
}

.unscramble-sentences-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.unscramble-item {
  align-items: stretch;
}

.unscramble-item.complete {
  box-shadow: 0 14px 34px rgba(46, 204, 113, 0.16);
  border-color: rgba(46, 204, 113, 0.28);
}

.unscramble-item.entering.entering-from-right {
  animation: unscrambleSlideInFromRight 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.unscramble-item.entering.entering-from-left {
  animation: unscrambleSlideInFromLeft 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.unscramble-item.leaving.leaving-to-left {
  animation: unscrambleSlideOutToLeft 0.35s ease-in forwards;
}

.unscramble-item.leaving.leaving-to-right {
  animation: unscrambleSlideOutToRight 0.35s ease-in forwards;
}

.unscramble-sentence-shell {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.unscramble-sentence-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 700;
}

.unscramble-step-label {
  font-size: 1.05rem;
}

.unscramble-progress {
  font-size: 0.95rem;
  color: #9fb3c8;
  font-weight: 700;
}

body.light-mode .unscramble-progress {
  color: #526070;
}

.unscramble-word-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  min-height: 54px;
}

.unscramble-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  margin-top: 20px;
}

.unscramble-nav-btn {
  min-width: 112px;
  padding: 10px 18px;
  border: 1px solid rgba(114, 196, 255, 0.28);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(17, 77, 125, 0.98), rgba(10, 50, 87, 1));
  color: #f3fbff;
  box-shadow: 0 10px 22px rgba(7, 31, 52, 0.34);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease, color 0.2s ease, opacity 0.18s ease;
}

.unscramble-nav-btn:hover:not([disabled]) {
  background: linear-gradient(180deg, rgba(28, 97, 150, 0.98), rgba(14, 63, 104, 1));
  border-color: rgba(144, 213, 255, 0.42);
  box-shadow: 0 14px 26px rgba(7, 31, 52, 0.4);
  transform: translateY(-2px);
}

.unscramble-nav-btn:active:not([disabled]) {
  transform: translateY(0);
  background: linear-gradient(180deg, rgba(14, 66, 108, 0.98), rgba(8, 43, 75, 1));
  box-shadow: 0 8px 18px rgba(7, 31, 52, 0.26);
}

.unscramble-nav-prev {
  margin-right: auto;
}

.unscramble-nav-next {
  margin-left: auto;
}

.unscramble-nav-btn[disabled] {
  background: linear-gradient(180deg, rgba(70, 82, 96, 0.62), rgba(50, 60, 72, 0.72));
  border-color: rgba(137, 152, 168, 0.22);
  box-shadow: none;
  cursor: not-allowed;
  color: rgba(234, 242, 251, 0.72);
  opacity: 0.72;
  transform: none;
}

.unscramble-nav-btn[disabled]:hover,
.unscramble-nav-btn[disabled]:active {
  background: linear-gradient(180deg, rgba(70, 82, 96, 0.62), rgba(50, 60, 72, 0.72));
  border-color: rgba(137, 152, 168, 0.22);
  box-shadow: none;
  transform: none;
}

.unscramble-nav-next.just-enabled {
  animation: unscrambleNextUnlockPop 0.48s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.unscramble-word-pill {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(135deg, rgba(229, 9, 20, 0.96), rgba(178, 7, 15, 0.96));
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  cursor: grab;
  user-select: none;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.1;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.25s ease, border-color 0.25s ease, opacity 0.18s ease;
}

.unscramble-drop-placeholder {
  height: 46px;
  min-width: 42px;
  border-radius: 999px;
  border: 2px dashed rgba(var(--primary-rgb), 0.38);
  background: rgba(var(--primary-rgb), 0.1);
  box-sizing: border-box;
  flex: 0 0 auto;
  animation: unscramblePlaceholderIn 0.16s ease-out;
}

.unscramble-word-pill:hover:not(.locked) {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.24);
}

.unscramble-word-pill.mobile-selected {
  background: linear-gradient(135deg, #ffd166, #f4b942);
  border-color: rgba(255, 209, 102, 0.4);
  color: #1b1b1b;
  box-shadow: 0 0 0 3px rgba(255, 209, 102, 0.22), 0 14px 28px rgba(0, 0, 0, 0.24);
}

.unscramble-word-row.mobile-dragging .unscramble-word-pill {
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

.unscramble-word-row.desktop-dragging {
  user-select: none;
}

.unscramble-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  margin-top: 20px;
}

.unscramble-nav-btn {
  min-width: 112px;
  padding: 10px 18px;
  border: 1px solid rgba(114, 196, 255, 0.28);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(17, 77, 125, 0.98), rgba(10, 50, 87, 1));
  color: #f3fbff;
  box-shadow: 0 10px 22px rgba(7, 31, 52, 0.34);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease, color 0.2s ease, opacity 0.18s ease;
}

.unscramble-nav-btn:hover:not([disabled]) {
  background: linear-gradient(180deg, rgba(28, 97, 150, 0.98), rgba(14, 63, 104, 1));
  border-color: rgba(144, 213, 255, 0.42);
  box-shadow: 0 14px 26px rgba(7, 31, 52, 0.4);
  transform: translateY(-2px);
}

.unscramble-nav-btn:active:not([disabled]) {
  transform: translateY(0);
  background: linear-gradient(180deg, rgba(14, 66, 108, 0.98), rgba(8, 43, 75, 1));
  box-shadow: 0 8px 18px rgba(7, 31, 52, 0.26);
}

.unscramble-nav-prev {
  margin-right: auto;
}

.unscramble-nav-next {
  margin-left: auto;
}

.unscramble-nav-btn[disabled] {
  background: linear-gradient(180deg, rgba(70, 82, 96, 0.62), rgba(50, 60, 72, 0.72));
  border-color: rgba(137, 152, 168, 0.22);
  box-shadow: none;
  cursor: not-allowed;
  color: rgba(234, 242, 251, 0.72);
  opacity: 0.72;
  transform: none;
}

.unscramble-nav-btn[disabled]:hover,
.unscramble-nav-btn[disabled]:active {
  background: linear-gradient(180deg, rgba(70, 82, 96, 0.62), rgba(50, 60, 72, 0.72));
  border-color: rgba(137, 152, 168, 0.22);
  box-shadow: none;
  transform: none;
}

.unscramble-nav-next.just-enabled {
  animation: unscrambleNextUnlockPop 0.48s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.unscramble-word-pill.mobile-drag-origin {
  opacity: 0.1;
  transform: scale(0.9);
}

.unscramble-word-pill.drag-origin-hidden {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  transform: scale(0.7);
  width: 0;
  min-width: 0;
  height: 0;
  min-height: 0;
  padding-left: 0;
  padding-right: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin-left: 0;
  margin-right: 0;
  margin-top: 0;
  margin-bottom: 0;
  border-width: 0;
  overflow: hidden;
  pointer-events: none;
}

.mobile-drag-clone {
  position: fixed;
  z-index: 10001;
  pointer-events: none;
  margin: 0;
  opacity: 0.96;
  box-shadow: 0 18px 32px rgba(0, 0, 0, 0.28);
  transform: rotate(-3deg) scale(1.04);
 }

.unscramble-word-pill:active:not(.locked),
.unscramble-word-pill.dragging {
  cursor: grabbing;
  transform: scale(0.96);
  opacity: 0.8;
}

.unscramble-word-pill.correct,
.unscramble-word-pill.locked {
  background: linear-gradient(135deg, #2ecc71, #1f9d57);
  border-color: rgba(46, 204, 113, 0.35);
  color: #fff;
  cursor: default;
}

.unscramble-word-pill.just-correct {
  animation: unscrambleCorrectPop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.unscramble-reset-btn {
  margin-left: auto;
}

.unscramble-complete-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: flex-start;
}

.unscramble-complete-card p {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.6;
}

@keyframes unscrambleCorrectPop {
  0% {
    transform: scale(0.88);
  }

  60% {
    transform: scale(1.14);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes unscrambleNextUnlockPop {
  0% {
    transform: scale(0.86);
    box-shadow: 0 0 0 rgba(17, 77, 125, 0);
  }

  55% {
    transform: scale(1.12);
    box-shadow: 0 14px 28px rgba(17, 77, 125, 0.34);
  }

  100% {
    transform: scale(1);
    box-shadow: 0 8px 18px rgba(10, 50, 87, 0.24);
  }
}

@keyframes unscramblePlaceholderIn {
  0% {
    opacity: 0;
    transform: scaleX(0.65);
  }

  100% {
    opacity: 1;
    transform: scaleX(1);
  }
}

@keyframes unscrambleNextUnlockPop {
  0% {
    transform: scale(0.86);
    box-shadow: 0 0 0 rgba(17, 77, 125, 0);
  }

  55% {
    transform: scale(1.12);
    box-shadow: 0 14px 28px rgba(17, 77, 125, 0.34);
  }

  100% {
    transform: scale(1);
    box-shadow: 0 8px 18px rgba(10, 50, 87, 0.24);
  }
}

@keyframes unscrambleSlideInFromRight {
  0% {
    opacity: 0;
    transform: translateX(32px) scale(0.98);
  }

  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes unscrambleSlideInFromLeft {
  0% {
    opacity: 0;
    transform: translateX(-32px) scale(0.98);
  }

  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes unscrambleSlideOutToLeft {
  0% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateX(-34px) scale(0.98);
  }
}

@keyframes unscrambleSlideOutToRight {
  0% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateX(34px) scale(0.98);
  }
}

.gap-fill-text-editor-shell {
  position: relative;
}

body.edit-mode-enabled .gap-fill-text-editor-shell {
  padding-top: 10px;
}

body.edit-mode-enabled .gapfill-item > .edit-controls,
body.edit-mode-enabled .gap-fill-text-editor-shell > .edit-controls {
  opacity: 0;
  pointer-events: none;
}

body.edit-mode-enabled .gapfill-item:hover > .edit-controls,
body.edit-mode-enabled .gap-fill-text-editor-shell:hover > .edit-controls,
body.edit-mode-enabled .gap-fill-text-editor-shell.editing > .edit-controls {
  opacity: 1;
  pointer-events: auto;
}

body.edit-mode-enabled .gap-fill-text-editor-shell > .edit-controls {
  top: 10px;
  bottom: auto;
}

.gapfill-item.saving,
.gap-fill-text-editor-shell.saving {
  filter: blur(1.8px) saturate(0.8);
  opacity: 0.52;
  transform: scale(0.992);
  box-shadow: 0 0 0 2px rgba(229, 9, 20, 0.28), 0 14px 28px rgba(0, 0, 0, 0.18);
  background-color: rgba(229, 9, 20, 0.08);
  pointer-events: none;
}

body.light-mode .gapfill-item.saving,
body.light-mode .gap-fill-text-editor-shell.saving {
  background-color: rgba(229, 9, 20, 0.12);
}

.question-wheel-editor {
  width: 100%;
  max-width: 980px;
  margin-top: 16px;
}

.wheel-question-item {
  display: block;
  padding: 22px 96px 22px 24px;
}

.wheel-question-text {
  display: block;
  line-height: 1.6;
}

.gap-editor-modal .modal-content {
  max-width: 860px;
  display: flex;
  flex-direction: column;
  max-height: min(88vh, 820px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.gap-editor-helper {
  margin: 0 0 16px;
  color: #bbb;
  line-height: 1.45;
}

body.light-mode .gap-editor-helper {
  color: #666;
}

.gap-editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.gap-editor-toolbar .action-btn {
  padding: 10px 18px;
  font-size: 0.9rem;
}

.gap-editor-selection-hint {
  color: #bbb;
  font-size: 0.95rem;
}

body.light-mode .gap-editor-selection-hint {
  color: #666;
}

.gap-editor-selection-hint.has-selection {
  color: #ffd166;
}

body.light-mode .gap-editor-selection-hint.has-selection {
  color: #b2070f;
}

.gap-editor-surface {
  min-height: 180px;
  max-height: min(42vh, 440px);
  overflow-y: auto;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  padding: 18px;
  line-height: 1.85;
  white-space: pre-wrap;
  outline: none;
  font-size: 1.05rem;
}

body.light-mode .gap-editor-surface {
  border-color: rgba(0, 0, 0, 0.12);
  background: rgba(0, 0, 0, 0.02);
}

.gap-editor-modal .modal-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin-top: 20px;
  padding-top: 18px;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(18, 18, 18, 0) 0%, rgba(18, 18, 18, 0.94) 24%);
}

body.light-mode .gap-editor-modal .modal-actions {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(247, 247, 247, 0.96) 24%);
}

.gap-editor-surface.single-line {
  min-height: 120px;
}

.gap-editor-surface:focus {
  border-color: rgba(var(--primary-rgb), 0.6);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

.gap-editor-token {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 3px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(var(--primary-rgb), 0.18);
  border: 1px solid rgba(var(--primary-rgb), 0.4);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  vertical-align: baseline;
}

body.light-mode .gap-editor-token {
  color: #5a0a0f;
  background: rgba(var(--primary-rgb), 0.12);
}

.gap-editor-token::after {
  content: "Remove";
  font-size: 0.72rem;
  font-weight: 600;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.gap-editor-preview-wrap {
  margin-top: 20px;
  display: grid;
  gap: 14px;
}

.gap-editor-preview-card {
  border-radius: 16px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

body.light-mode .gap-editor-preview-card {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.08);
}

.gap-editor-preview-card h4 {
  margin: 0 0 12px;
  color: var(--primary-color);
}

.gap-editor-preview-sentence,
.gap-editor-preview-text {
  line-height: 1.85;
  font-size: 1rem;
}

.gap-editor-preview-blank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 110px;
  min-height: 34px;
  margin: 0 4px;
  padding: 0 10px;
  border-bottom: 2px dashed rgba(var(--primary-rgb), 0.7);
  border-radius: 4px;
  color: transparent;
  background: rgba(var(--primary-rgb), 0.08);
  user-select: none;
}

.gap-editor-preview-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.gap-editor-empty {
  color: #888;
}

body.light-mode .gap-editor-empty {
  color: #666;
}

/* Flying animation clone style */
.flying-word {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  transition: all 0.5s cubic-bezier(0.19, 1, 0.22, 1);
}

@keyframes pulseGreen {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.1);
  }

  100% {
    transform: scale(1);
  }
}

/* Highlight Instructions Animation */
@keyframes highlight-text {
  0% {
    color: inherit;
    transform: scale(1);
  }

  50% {
    color: var(--primary-color);
    transform: scale(1.05);
  }

  100% {
    color: inherit;
    transform: scale(1);
  }
}

.instruction-highlight {
  animation: highlight-text 0.5s ease-in-out;
}

/* =========================================================================
   MOBILE RESPONSIVE STYLES
   ========================================================================= */
@media (max-width: 768px) {

  /* Content container - edge-to-edge on mobile */
  .content-container {
    margin: 0 !important;
    padding: 15px !important;
    border-radius: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Main wrapper adjustments */
  .main-wrapper {
    padding: 0;
  }

  /* Header adjustments */
  .header {
    padding: 0 15px !important;
  }

  .page-top {
    padding-bottom: 40px;
  }

  .main-title {
    font-size: 1.8em !important;
    padding: 15px !important;
  }

  /* Inner container padding */
  .vocab-container-inner {
    padding: 10px 5px;
  }

  .flashcards-tab-shell > h2:first-child {
    margin-left: 0;
    margin-right: 0;
  }

  .flashcards-tab-shell > .vocab-container-inner-embedded {
    padding: 0 0 10px;
  }

  .vocab-container {
    padding: 20px 10px;
  }

  /* Exercise instructions */
  .exercise-instructions {
    padding: 12px 15px;
    font-size: 1rem;
    margin-bottom: 20px;
  }

  /* Word bank - compact on mobile */
  .floating-word-bank-container {
    position: -webkit-sticky;
    position: sticky;
    top: var(--mobile-sticky-top, max(8px, env(safe-area-inset-top)));
    z-index: 1000;
    padding: 10px;
    margin-bottom: 20px;
    border-radius: 8px;
  }

  .floating-word-bank-container.keyboard-open {
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.28);
  }

  .word-bank {
    gap: 8px;
  }

  .draggable-word {
    padding: 6px 12px;
    font-size: 0.85rem;
    touch-action: manipulation;
  }

  /* Gap fill items */
  .gapfill-item {
    padding: 15px;
    margin-bottom: 15px;
    font-size: 1rem;
    flex-direction: column;
    align-items: stretch;
  }

  body.edit-mode-enabled .gapfill-item {
    padding-right: 15px;
    padding-top: 58px;
  }

  .gapfill-sentence-text {
    min-width: auto;
    flex: 1 1 100%;
  }

  .gap-input {
    width: 100px;
    font-size: 0.9rem;
  }

  .item-check-btn {
    margin-top: 15px !important;
    width: 100%;
    margin-left: 0 !important;
  }

  .unscramble-sentence-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .unscramble-word-row {
    gap: 10px;
  }

  .unscramble-nav {
    gap: 10px;
  }

  .unscramble-nav-btn {
    min-width: 96px;
    padding: 9px 14px;
    font-size: 0.82rem;
  }

  .unscramble-word-pill {
    width: auto;
    max-width: 100%;
    justify-content: flex-start;
    text-align: center;
    touch-action: manipulation;
    padding: 10px 14px;
    font-size: 0.95rem;
  }

  /* Drop zones for drag and drop */
  .drop-zone {
    min-width: 80px;
    height: 30px;
    padding: 0 8px;
    font-size: 0.9rem;
    cursor: pointer;
  }

  /* Text container for gap fill text */
  .text-container {
    font-size: 1rem;
    line-height: 1.8;
    margin-top: 15px !important;
  }

  .gap-editor-modal .modal-content {
    width: calc(100% - 24px);
    max-height: calc(100vh - 20px);
    padding: 18px;
    border-radius: 18px;
  }

  .gap-editor-surface {
    min-height: 160px;
    max-height: 34vh;
    padding: 14px;
    font-size: 0.98rem;
  }

  .gap-editor-toolbar {
    align-items: flex-start;
  }

  .gap-editor-modal .modal-actions {
    margin-top: 16px;
    margin-left: -18px;
    margin-right: -18px;
    margin-bottom: -18px;
    padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }

  body.light-mode .gap-editor-modal .modal-actions {
    border-top-color: rgba(0, 0, 0, 0.08);
  }

  body.edit-mode-enabled .gap-fill-text-editor-shell > .edit-controls {
    top: 0;
  }

  /* Flashcard grid */
  .flashcard-grid {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 5px;
  }

  .flashcard {
    height: 180px;
  }

  .flashcard-front {
    font-size: 1.4em;
  }

  .flashcard-back {
    font-size: 0.95em;
  }

  /* Matching game - keep two columns on mobile for word/definition matching */
  .matching-grid-layout {
    grid-template-columns: 1fr 1fr;
    /* Keep two columns! */
    gap: 8px;
  }

  .match-group {
    gap: 8px;
  }

  .match-item {
    padding: 10px 8px;
    min-height: 50px;
    font-size: 0.85rem;
    line-height: 1.3;
  }

  .defs-col .match-item {
    font-size: 0.8rem;
  }

  /* Action buttons */
  .action-btn {
    padding: 12px 25px;
    font-size: 1rem;
  }

  /* Exercise subtitle */
  .exercise-subtitle {
    font-size: 1.5em !important;
    margin-bottom: 15px !important;
  }

  .flashcards-generator-icon-link {
    top: 2px;
    right: 0;
    width: 38px;
    height: 38px;
  }

  /* Footer adjustments */
  .footer {
    padding: 15px !important;
  }
}
