@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;700&display=swap");
body {
  margin: 0;
  min-height: 100vh;
  background: #f3f8ff;
  font-family: Arial, sans-serif;
  color: #1f2937;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 18px 40px;
}

h1 {
  margin: 0 0 12px;
  font-size: clamp(1.9rem, 2.5vw, 2.7rem);
  text-align: center;
}

.tabs {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0 28px;
}

.tab-button {
  border: 1px solid #b2becd;
  background: white;
  color: #334155;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease;
}

.fc.tab-button.active {
  background: #8702bc;
  color: white;
  border-color: #8702bc;
}

.tab-button.active {
  background: #2563eb;
  color: white;
  border-color: #2563eb;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.section-note {
  text-align: center;
  margin: 0 0 20px;
  color: #475569;
  font-size: 0.98rem;
}

.card-set-selector {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.card-set-selector label {
  font-weight: bold;
}

.card-set-selector select {
  padding: 5px 10px;
  border: 1px solid #b2becd;
  border-radius: 4px;
  background: white;
}

.flashcard-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  perspective: 1000px;
  gap: 18px;
}

.flashcard {
  width: 200px;
  height: 260px;
  position: relative;
  transition: transform 0.6s;
  transform-style: preserve-3d;
  cursor: pointer;
  margin: 0;
}

.flashcard.flipped {
  transform: rotateY(180deg);
}

.flashcard .front,
.flashcard .back {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 16px;
  border: 2px solid #cbd5e1;
  background: white;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
  box-sizing: border-box;
}

.flashcard .front img {
  width: 84%;
  height: auto;
  margin-bottom: 12px;
}

.flashcard .front p,
.flashcard .back p {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.flashcard .back {
  background-color: #e0f2fe;
  transform: rotateY(180deg);
  font-size: 1.1rem;
  font-family:
    "Noto Sans JP", "Yu Gothic", "Hiragino Kaku Gothic Pro", Meiryo, sans-serif;
  gap: 6px;
  text-align: center;
}

.flashcard .back span {
  display: block;
  color: #0f172a;
}

.flashcard-instructions {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding: 16px 20px;
  background: white;
  border: 1px solid #cbd5e1;
  border-radius: 18px;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.05);
}

.exercise-title {
  color: #1d4ed8;
  font-weight: bold;
}

.exercise-instructions {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding: 16px 20px;
  background: white;
  border: 1px solid #cbd5e1;
  border-radius: 18px;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.05);
}

.exercise-instructions p {
  margin: 0;
  font-size: 1rem;
  color: #334155;
}

.reset-button {
  border: none;
  background: #2563eb;
  color: white;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  transition: background-color 0.2s ease;
}

.reset-button:hover {
  background: #1d4ed8;
}

.exercise-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

.drag-container,
.drop-container {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 8px;
  background: white;
  border: 1px solid #cbd5e1;
  border-radius: 18px;
  min-height: 220px;
  justify-content: center;
}

.draggable-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 120px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid #94a3b8;
  background: #f8fafc;
  cursor: grab;
  font-weight: 700;
  color: #0f172a;
  user-select: none;
}

.draggable-item img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 8px;
  background: white;
  border: 1px solid #e2e8f0;
}

.drop-zone {
  width: 100%;
  min-width: 120px;
  max-width: 180px;
  padding: 10px 10px;
  border: 2px dashed #64748b;
  border-radius: 12px;
  background: #f8fafc;
  color: #0f172a;
  font-weight: 700;
  text-align: center;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.drop-zone.correct {
  border-color: #16a34a;
  background-color: #dcfce7;
}

.drop-zone.incorrect {
  border-color: #dc2626;
  background-color: #fee2e2;
}

.exercise-feedback {
  margin: 18px auto 0;
  text-align: center;
  color: #334155;
  font-size: 1rem;
  min-height: 1.2rem;
}

.drop-zone span {
  font-size: 0.95rem;
  color: #475569;
}

@media (max-width: 860px) {
  .exercise-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .flashcard {
    width: 170px;
    height: 230px;
  }

  .flashcard .front img {
    width: 78%;
  }

  .draggable-item {
    min-width: 100px;
    padding: 10px 12px;
  }
}

/* Tile Game Styles */
.tile-game-board {
  display: grid;
  gap: 10px;
  justify-content: center;
  grid-template-columns: repeat(5, minmax(70px, 1fr));
  max-width: 800px;
  margin: 20px auto;
}

.tile-card {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  border-radius: 10px;
  user-select: none;
  transition:
    transform 0.2s,
    background-color 0.3s;
  overflow: hidden;
  position: relative;
  font-family:
    "Noto Sans JP", "Yu Gothic", "Hiragino Kaku Gothic Pro", Meiryo, sans-serif;
  font-weight: 700;
}

.tile-card:hover {
  transform: scale(1.05);
}

.tile-card img {
  max-width: 80%;
  max-height: 80%;
  object-fit: contain;
}

.tile-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}

.tile-japanese {
  font-size: 1.1rem;
}

.tile-romaji {
  font-size: 0.85rem;
  color: #1e3a8a;
}

.tile-card.matched {
  background: #dcfce7;
  pointer-events: none;
  border: 2px solid #16a34a;
}

.tile-card.flipped {
  background: #fff;
  border: 2px solid #2563eb;
}

.word-search-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
  align-items: flex-start;
}

.word-list {
  width: min(280px, 100%);
  padding: 18px;
  border: 1px solid #2563eb;
  border-radius: 16px;
  background: #f0f8ff;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.05);
  text-align: left;
}

.word-list strong {
  display: block;
  margin-bottom: 12px;
  color: #1e40af;
}

.word-list ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.word-list li {
  padding: 8px 10px;
  border-radius: 10px;
  background: white;
  border: 1px solid #cbd5e1;
}

.word-list li.found {
  text-decoration: line-through;
  color: #16a34a;
  font-weight: bold;
  background: #dcfce7;
}

.puzzle-area {
  width: min(520px, 100%);
}

.grid {
  display: grid;
  grid-template-columns: repeat(10, 40px);
  justify-content: center;
  gap: 4px;
  margin-top: 20px;
}

.cell {
  width: 40px;
  height: 40px;
  border: 1px solid #94a3b8;
  text-transform: uppercase;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  cursor: pointer;
  background: white;
}

.cell.selected {
  background-color: #bde0fe;
}

.cell.found {
  background-color: #caffbf;
}

.wordsearch-button {
  margin-top: 14px;
}

.wordsearch-feedback {
  margin-top: 12px;
  text-align: center;
  font-weight: bold;
}

.hangman-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  background: white;
  border: 1px solid #cbd5e1;
  border-radius: 18px;
  max-width: 720px;
  margin: 0 auto;
}

.hangman-hint {
  font-size: 1rem;
  color: #1d4ed8;
  font-weight: 700;
}

.hangman-word {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  font-size: 2rem;
  letter-spacing: 0.25rem;
  font-weight: 700;
  color: #0f172a;
}

.hangman-status {
  text-align: center;
  font-size: 1rem;
  min-height: 1.3rem;
  font-weight: 700;
}

.hangman-letters {
  display: grid;
  grid-template-columns: repeat(13, minmax(38px, 1fr));
  gap: 10px;
  justify-items: center;
}

.hangman-letter {
  width: 38px;
  height: 38px;
  border: 1px solid #64748b;
  border-radius: 10px;
  background: #f8fafc;
  color: #0f172a;
  font-weight: 700;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    transform 0.2s ease;
}

.hangman-letter:hover:not(:disabled) {
  background: #e2e8f0;
  transform: translateY(-1px);
}

.hangman-letter:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.hangman-letter.wrong {
  background: #fee2e2;
  border-color: #ef4444;
  color: #b91c1c;
}

.hangman-stage {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 12px 0;
}

.hangman-step {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  background: #f8fafc;
  color: #64748b;
}

.hangman-step.active {
  border-color: #ef4444;
  background: #fee2e2;
  color: #b91c1c;
}

.hangman-used {
  text-align: center;
  margin-top: 10px;
  font-size: 0.95rem;
  color: #334155;
}

#hangman-canvas {
  background-color: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 16px;
  display: block;
  margin: 0 auto 16px;
}

@media (max-width: 640px) {
  .tile-game-board {
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 8px;
  }

  .tile-card {
    font-size: 0.9rem;
    border-radius: 8px;
  }
}

/* Word Scramble Styles */
.scramble-hint {
  text-align: center;
  margin: 20px 0;
}

.scramble-hint img {
  max-width: 150px;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.scramble-letters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 20px 0;
}

.scramble-letter {
  padding: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e0f2fe;
  border: 2px solid #0ea5e9;
  border-radius: 8px;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: grab;
  user-select: none;
  transition: background-color 0.2s;
}

.scramble-letter:focus-visible {
  outline: 3px solid #f59e0b;
  outline-offset: 3px;
}

.scramble-letter.used {
  opacity: 0.4;
  cursor: not-allowed;
}

.scramble-letter:hover {
  background: #bae6fd;
}

.scramble-answer {
  min-height: 60px;
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  margin: 20px 0;
}

.scramble-answer span {
  font-size: 1.2rem;
  font-weight: bold;
  color: #1e293b;
}

.scramble-feedback {
  text-align: center;
  font-weight: bold;
  font-size: 1.1rem;
  margin: 10px 0;
}

.check-button {
  background: #16a34a;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  margin-left: 10px;
  transition: background-color 0.2s;
}

.check-button:hover {
  background: #15803d;
}

.try-again-button {
  background: #dc2626;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  margin-left: 10px;
  transition: background-color 0.2s;
}

.try-again-button:hover {
  background: #b91c1c;
}

/* Mixed Quiz Styles */
.mixed-quiz-type {
  text-align: center;
  color: #475569;
  font-weight: 700;
}

.mixed-quiz-score {
  text-align: center;
  margin: 12px 0 0;
  color: #1e293b;
  font-weight: 700;
}

.mixed-quiz-board {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 12px;
  max-width: 720px;
  margin: 24px auto;
  padding: 24px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #ffffff;
}

.mixed-quiz-board h3 {
  flex-basis: 100%;
  margin: 0 0 8px;
  text-align: center;
}

.mixed-quiz-board h3.mixed-quiz-prompt {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mixed-quiz-prompt-romaji {
  color: #475569;
  font-size: 0.85rem;
  font-weight: 400;
}

.mixed-quiz-image {
  flex-basis: 100%;
  width: 120px;
  height: 120px;
  object-fit: contain;
  border-radius: 8px;
}

.mixed-quiz-option,
.mixed-quiz-input {
  min-width: 120px;
  padding: 10px 14px;
  border: 1px solid #94a3b8;
  border-radius: 6px;
  background: #f8fafc;
  color: #1e293b;
  font: inherit;
  cursor: pointer;
}

.mixed-quiz-option {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.mixed-quiz-romaji {
  color: #475569;
  font-size: 0.85rem;
  font-weight: 400;
}

.mixed-quiz-option:hover,
.mixed-quiz-option.selected {
  border-color: #2563eb;
  background: #dbeafe;
}

.mixed-quiz-option:disabled {
  cursor: default;
  opacity: 0.55;
}

.mixed-quiz-input {
  cursor: text;
}

.mixed-quiz-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 150px;
}
