html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

*,
*::before,
*::after {
  min-width: 0;
}

body {
  overflow-wrap: break-word;
}

a,
button,
.option,
.dot,
.course-card,
.drag-block,
.drop-cell {
  touch-action: manipulation;
}

img,
svg,
canvas,
video {
  max-width: 100%;
  height: auto;
}

h1,
h2,
.section-title h2,
.course-card h3,
.big-word,
.sentence,
.quiz-sentence,
.original-sentence,
.rule-line,
.match-word,
.type-name,
.category-title,
.method-card strong,
.completion-word {
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.main-card,
.hero,
.course-card,
.path-card,
.quiz-box,
.rule-box,
.example-item,
.match-card,
.type-box,
.category-card,
.method-card,
.condition-mini-card,
.completion-card,
.rule-card,
.transform-card,
.condition-card {
  max-width: 100%;
}

.subject,
.balance-word,
.hidden-balance,
.content-word,
.complete-word,
.target-word,
mark {
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.label,
.status,
.flow-box,
.subject-pill,
.word-chip,
.word-chip-row span,
.category-words,
.priority-tag {
  white-space: normal;
}

@media (max-width: 980px) {
  .condition-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .main-card,
  .hero {
    min-height: auto;
  }

  .transform-board,
  .condition-board {
    grid-template-columns: 1fr;
  }

  .condition-card {
    min-height: auto;
  }
}

@media (max-width: 760px) {
  .app {
    width: min(94%, calc(100% - 20px));
  }

  h1 {
    font-size: 2.35rem;
    line-height: 1.08;
  }

  h2 {
    font-size: 2rem;
    line-height: 1.16;
  }

  p {
    font-size: 1.02rem;
    line-height: 1.75;
  }

  .big-word {
    max-width: 100%;
    border-radius: 20px;
    font-size: 2.45rem;
    white-space: normal;
  }

  .main-card,
  .hero {
    border-radius: 28px;
    padding: 22px;
  }

  .quiz-box,
  .rule-box,
  .path-card {
    border-radius: 24px;
    padding: 22px;
  }

  .sentence,
  .quiz-sentence,
  .original-sentence {
    font-size: 1.65rem;
    min-height: auto;
  }

  .controls {
    gap: 10px;
  }

  .controls > button {
    flex: 1 1 132px;
  }

  .step-dots {
    max-width: 100%;
    overflow-x: auto;
    padding: 4px 2px 8px;
    scrollbar-width: none;
  }

  .step-dots::-webkit-scrollbar {
    display: none;
  }

  .options {
    align-items: stretch;
    gap: 10px;
  }

  .option {
    flex: 1 1 calc(50% - 10px);
    padding: 12px 16px;
    white-space: normal;
  }

  .quiz-actions,
  .exercise-actions {
    justify-content: stretch;
  }

  .quiz-actions > button,
  .exercise-actions > button {
    flex: 1 1 150px;
  }

  .example-item .label {
    align-self: flex-start;
  }

  .mini-flow {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .app {
    width: calc(100% - 20px);
    padding-top: 14px;
    padding-bottom: 28px;
  }

  .topbar {
    min-height: 54px;
    height: auto;
    margin-bottom: 14px;
  }

  .logo span {
    white-space: nowrap;
  }

  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.7rem;
  }

  p,
  .translation {
    font-size: 0.98rem;
  }

  .tag {
    margin-bottom: 14px;
    font-size: 0.82rem;
  }

  .main-card,
  .hero,
  .course-card {
    border-radius: 24px;
    padding: 18px;
  }

  .hero {
    min-height: auto;
  }

  .course-card {
    min-height: auto;
  }

  .course-card h3 {
    font-size: 1.75rem;
  }

  .course-grid {
    gap: 14px;
  }

  .course-bottom,
  .quiz-top,
  .exercise-title-card {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-btn,
  .secondary-btn,
  .open-btn,
  .small-next-btn,
  .check-btn,
  .reset-btn,
  .grid-next-btn,
  .skip-grid-btn {
    width: 100%;
    min-height: 44px;
    padding: 12px 16px;
  }

  .big-word {
    border-radius: 18px;
    font-size: 2rem;
    padding: 12px 16px;
  }

  .note-text {
    font-size: 1.05rem;
    line-height: 1.65;
  }

  .floating-note {
    margin-top: 28px;
    padding: 18px;
  }

  .floating-note::before {
    left: 28px;
  }

  .quiz-box,
  .rule-box,
  .path-card {
    padding: 18px;
  }

  .quiz-sentence,
  .sentence,
  .original-sentence {
    font-size: 1.45rem;
  }

  .option {
    flex-basis: 100%;
    font-size: 0.98rem;
  }

  .summary-item {
    padding: 14px 16px;
    line-height: 1.55;
  }

  .match-card,
  .category-card,
  .type-box,
  .method-card,
  .transform-card,
  .condition-card {
    border-radius: 22px;
    padding: 18px;
  }

  .match-word,
  .condition-word {
    font-size: 2.3rem;
  }

  .type-symbol,
  .category-icon {
    width: 48px;
    height: 48px;
    border-radius: 18px;
    font-size: 22px;
  }

  .type-name,
  .category-title {
    font-size: 1.35rem;
  }

  .word-chip-row span {
    font-size: 0.94rem;
  }

  .nine-grid {
    min-width: 500px;
  }

  .drop-grid {
    grid-template-columns: 72px repeat(3, minmax(0, 1fr));
    gap: 7px;
    padding-right: 16px;
  }

  .grid-label,
  .grid-cell,
  .drop-row-label,
  .drop-cell {
    border-radius: 15px;
    min-height: 64px;
    padding: 8px;
  }

  .drop-slot {
    min-height: 64px;
  }

  .drag-block {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.92rem;
    line-height: 1.25;
    white-space: normal;
  }

  .block-bank {
    border-radius: 20px;
    gap: 8px;
    padding: 12px;
  }

  .exercise-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .round-badge {
    width: fit-content;
  }
}

@media (max-width: 380px) {
  .app {
    width: calc(100% - 16px);
  }

  h1 {
    font-size: 1.82rem;
  }

  h2 {
    font-size: 1.52rem;
  }

  .main-card,
  .hero,
  .course-card,
  .quiz-box,
  .rule-box,
  .path-card {
    padding: 16px;
  }

  .big-word {
    font-size: 1.75rem;
  }

  .progress-wrap {
    gap: 8px;
  }

  .progress-text {
    font-size: 0.8rem;
  }

  .drop-grid {
    grid-template-columns: 1fr;
    padding-right: 0;
  }

  .drop-row-label {
    min-height: auto;
  }

  .drop-punctuation {
    right: 8px;
  }
}

@media (max-height: 640px) and (orientation: landscape) {
  .app {
    padding-top: 12px;
    padding-bottom: 24px;
  }

  .topbar {
    height: auto;
  }

  .main-card,
  .hero {
    min-height: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
