:root {
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  color: #26352f;
  background: #fcfbf8;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
main { overflow-x: clip; }
button {
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
button:focus-visible, .word-slot:focus-visible {
  outline: 3px solid #668c79;
  outline-offset: 4px;
}
button:disabled { cursor: default; }
.exercise {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto auto;
  justify-items: center;
  gap: 10px;
  width: min(900px, 100%);
  height: 100svh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom));
  text-align: center;
}
.mobile-header { display: none; }
.exercise:focus { outline: none; }
.exercise-title {
  margin: 0;
  font-size: clamp(18px, 4.3vw, 26px);
  font-weight: 600;
  line-height: 1.35;
}
.exercise-title:focus { outline: none; }
.exercise-image {
  display: block;
  width: min(480px, 100%);
  height: 100%;
  min-height: 0;
  object-fit: contain;
}
.phrase-editor { width: min(720px, 100%); }
.selected-words {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.word-slot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 60px;
  padding: 0;
  border: 1px dashed #a6b9ac;
  border-radius: 12px;
  background: #f4f5f0;
}
.word-slot.is-filled {
  border-style: solid;
  border-color: #668c79;
  background: #eaf2e9;
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.word-slot.is-locked { cursor: default; touch-action: auto; }
.word-slot.is-drag-source { opacity: 0.35; }
.word-slot.is-drop-target { border: 2px solid #315b49; background: #d7e7d7; }
.slot-word {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 58px;
  align-self: stretch;
  padding: 6px;
  border: 0;
  border-radius: inherit;
  color: inherit;
  background: transparent;
  cursor: grab;
  touch-action: none;
  font-size: clamp(15px, 3.8vw, 21px);
  font-weight: 500;
  line-height: 1.3;
  text-align: center;
  overflow-wrap: anywhere;
}
.slot-word:disabled { cursor: default; }
.drag-preview {
  position: fixed;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border: 2px solid #315b49;
  border-radius: 12px;
  background: #eaf2e9;
  box-shadow: 0 5px 16px #26352f30;
  font-size: clamp(15px, 3.8vw, 21px);
  font-weight: 500;
  text-align: center;
  pointer-events: none;
}
.keywords {
  display: flex;
  flex-wrap: wrap;
  align-content: start;
  gap: 6px;
  width: 100%;
}
.keyword {
  flex: 1 1 auto;
  width: calc(20% - 4.8px);
  cursor: grab;
  touch-action: none;
  min-width: 0;
  min-height: 56px;
  max-width: 100%;
  padding: 8px 6px;
  border: 1px solid #a6b9ac;
  border-radius: 10px;
  color: #26352f;
  background: #fff;
  font-size: clamp(14px, 4vw, 20px);
  font-weight: 500;
  line-height: 1.3;
  white-space: normal;
  overflow-wrap: anywhere;
  transition: border-color 140ms ease, background-color 140ms ease;
}
.keyword:hover:not(:disabled) { border-color: #315b49; background: #f0f5ee; }
.keyword:disabled { color: #78847d; border-color: #d6ddd5; background: #f4f4ef; }
.keyword.is-drag-source { opacity: 0.35; }
.answer-area { display: flex; flex-direction: column; justify-content: center; align-items: center; width: 100%; min-height: 56px; }
.action {
  min-width: 0;
  min-height: 44px;
  padding: 8px 20px;
  border: 1px solid #aab9af;
  border-radius: 10px;
  color: #35483d;
  background: #fcfbf8;
  font-size: 18px;
  font-weight: 500;
  transition: border-color 140ms ease, background-color 140ms ease;
}
.action:hover:not(:disabled) { border-color: #668c79; background: #f1f5f0; }
.primary { width: min(260px, 100%); border-color: #315b49; color: #fff; background: #315b49; }
.primary:hover:not(:disabled) { color: #fff; background: #264b3b; }
.primary:disabled { border-color: #d6ddd5; color: #727e76; background: #e7ebe4; }
.action.is-confirmed { border-color: #173b2b; color: #fff; background: #173b2b; }
.answer-feedback { margin: 0; font-size: 20px; font-weight: 500; line-height: 1.35; }
.answer-feedback:empty { display: none; }
.answer-feedback.is-correct { color: #245ba6; }
.answer-feedback.is-incorrect { color: #864536; }
.answer-example { margin: 4px 0 0; font-size: 16px; line-height: 1.4; }
.answer-example-label { display: inline-block; margin-right: 8px; color: #616b65; font-size: 13px; }
.exercise-actions { display: flex; justify-content: center; gap: 12px; width: min(420px, 100%); }
.exercise-actions > .action { flex: 1; padding-right: 12px; padding-left: 12px; }
.exercise-actions > .next { flex: 0 1 240px; }
.slide-out-left { animation: slide-out-left 360ms ease both; }
.slide-in-from-right { animation: slide-in-from-right 360ms ease both; }
.question-enter { animation: question-enter 220ms ease-out both; }
.answer-enter { animation: answer-enter 200ms ease-out both; }
@keyframes slide-out-left { from { transform: translateX(0); } to { transform: translateX(-100vw); } }
@keyframes slide-in-from-right { from { transform: translateX(100vw); } to { transform: translateX(0); } }
@keyframes question-enter { from { opacity: 0.45; transform: translateX(12px); } to { opacity: 1; transform: translateX(0); } }
@keyframes answer-enter { from { opacity: 0.3; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 480px) {
  .exercise { gap: 6px; padding-right: 12px; padding-left: 12px; }
  .selected-words { gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Single-word answers stay in the choice bank; there is no editor row. */
.exercise.is-word-question {
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
}
.exercise.is-word-question .keyword { cursor: pointer; touch-action: manipulation; }
.exercise.is-word-question .keyword:disabled { cursor: default; }
.preview-progress {
  display: block;
  margin-bottom: 3px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.3;
}
.slide-out-left { pointer-events: none; }
