:root {
  color-scheme: light;
  --bg: #fff8ef;
  --surface: #fffdf8;
  --surface-strong: #fff2d5;
  --ink: #26323a;
  --muted: #64717b;
  --line: #efd7b9;
  --accent: #ef8354;
  --accent-strong: #d85d32;
  --blue: #5eb4dc;
  --green: #62bd8f;
  --shadow: 0 20px 60px rgba(55, 42, 28, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top left, #fff1d8 0, transparent 38%), var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
}

button {
  font: inherit;
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.lesson-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.lesson-tab {
  min-height: 42px;
  padding: 0 16px;
  border: 3px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 950;
  cursor: pointer;
}

.lesson-tab.active {
  border-color: var(--accent);
  background: #ffe4c2;
  color: var(--accent-strong);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 800;
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(36px, 5vw, 64px);
  line-height: 1;
  letter-spacing: 0;
}

.lead {
  margin-bottom: 0;
  max-width: 760px;
  color: var(--muted);
  font-size: 18px;
  font-weight: 650;
  line-height: 1.7;
}

.sound-badge {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 156px;
  height: 156px;
  border: 5px solid var(--ink);
  border-radius: 50%;
  background: #ffd08c;
  box-shadow: var(--shadow);
}

.sound-badge span {
  font-size: 54px;
  font-weight: 900;
}

.sound-badge small {
  margin-top: -22px;
  color: var(--muted);
  font-weight: 800;
}

.lesson-grid {
  display: grid;
  grid-template-columns: 390px 1fr;
  gap: 18px;
}

.word-panel,
.practice-panel,
.pair-section {
  border: 4px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.word-panel,
.practice-panel {
  padding: 20px;
}

.pair-section {
  margin-top: 18px;
  padding: 20px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head h2 {
  margin-bottom: 0;
  font-size: 25px;
  line-height: 1.2;
}

.icon-button {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: white;
  cursor: pointer;
}

.word-card {
  min-height: 360px;
  border-radius: 20px;
  background: var(--surface-strong);
  overflow: hidden;
}

.instruction-card,
.spelling-card {
  margin-bottom: 14px;
  padding: 14px 16px;
  border: 3px solid var(--line);
  border-radius: 18px;
  background: #fffaf2;
}

.word-card + .instruction-card {
  margin-top: 14px;
}

.spelling-card {
  margin: 18px 0 0;
}

.instruction-card h3,
.spelling-card h3 {
  margin-bottom: 8px;
  font-size: 18px;
}

.instruction-card ol {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.55;
}

.instruction-card li + li {
  margin-top: 5px;
}

.concept-stack {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.concept-card {
  padding: 14px;
  border: 2px solid #e8d3b3;
  border-radius: 16px;
  background: #f7ffd8;
}

.concept-card h4 {
  margin: 0 0 7px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 950;
}

.concept-card p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.55;
}

.concept-card small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  line-height: 1.45;
}

.concept-groups {
  display: grid;
  gap: 8px;
  margin-top: 11px;
}

.concept-group {
  padding: 10px;
  border: 2px solid rgba(232, 211, 179, 0.9);
  border-radius: 12px;
  background: rgba(255, 250, 242, 0.88);
}

.concept-group > strong {
  display: block;
  margin-bottom: 7px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 950;
}

.concept-group div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.concept-group span {
  padding: 6px 8px;
  border-radius: 999px;
  background: white;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}

.sound-diagram {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(122px, 1fr));
  gap: 10px;
}

.sound-unit {
  display: grid;
  justify-items: center;
  gap: 5px;
  min-width: 0;
}

.sound-unit-button {
  display: grid;
  justify-items: center;
  gap: 5px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.sound-unit-button:hover .sound-pill,
.sound-unit-button:focus-visible .sound-pill {
  outline: 3px solid rgba(239, 131, 84, 0.35);
  transform: translateY(-1px);
}

.sound-unit strong {
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

.sound-unit em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
  text-align: center;
}

.sound-pill {
  display: inline-flex;
  overflow: hidden;
  border-radius: 999px;
  border: 2px solid rgba(51, 125, 32, 0.18);
  background: #41a928;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.08);
  transition: transform 0.16s ease, outline-color 0.16s ease;
}

.sound-pill span {
  display: grid;
  align-content: center;
  gap: 2px;
  min-width: 38px;
  padding: 7px 9px;
  color: white;
  font-size: 21px;
  font-weight: 950;
  line-height: 1;
  text-align: center;
}

.sound-pill span small {
  display: block;
  font-size: 10px;
  font-weight: 950;
  line-height: 1;
  opacity: 0.92;
}

.sound-pill .vowel {
  background: #f47c12;
}

.sound-pill .consonant {
  background: #43a922;
}

.sound-pill .strong {
  background: #f47c12;
  min-width: 58px;
  font-size: 23px;
}

.sound-pill .weak {
  background: #68b241;
  min-width: 48px;
  opacity: 0.88;
}

.layer-table {
  display: grid;
  grid-template-columns: 1.1fr 1.2fr 1.15fr 1.25fr;
  overflow: hidden;
  border: 2px solid #e8d3b3;
  border-radius: 12px;
  background: white;
}

.layer-table > * {
  padding: 8px 7px;
  border-bottom: 1px solid #f0dfc4;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.35;
}

.layer-table > :nth-child(-n + 4) {
  background: #fff1d8;
  color: var(--ink);
  font-size: 11px;
  text-transform: uppercase;
}

.layer-table strong {
  color: var(--ink);
  font-size: 13px;
}

.spelling-card > p {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.55;
}

.spelling-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 9px;
}

.related-spellings {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 2px dashed #ead5b8;
}

.related-spellings h4 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 950;
}

.spelling-pattern {
  padding: 10px;
  border-radius: 14px;
  background: white;
  border: 2px solid #f2e1c9;
}

.spelling-pattern.related {
  background: #fffdf8;
  opacity: 0.86;
}

.spelling-pattern div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.spelling-pattern strong {
  color: var(--accent-strong);
  font-size: 28px;
  line-height: 1;
}

.spelling-pattern.related strong {
  color: var(--muted);
  font-size: 23px;
}

.spelling-pattern span {
  color: var(--muted);
  font-size: 15px;
  font-weight: 900;
}

.spelling-pattern p {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 7px;
}

.spelling-pattern button {
  min-height: 34px;
  padding: 0 10px;
  border: 2px solid #f2e1c9;
  border-radius: 999px;
  background: #fffaf2;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
}

.spelling-pattern button:hover {
  border-color: var(--accent);
  background: #ffe4c2;
}

.spelling-pattern small {
  display: block;
  color: var(--muted);
  font-weight: 750;
  line-height: 1.45;
}

.illustration {
  display: grid;
  place-items: center;
  height: 220px;
  overflow: hidden;
  padding-top: 12px;
}

.illustration-icon {
  display: grid;
  place-items: center;
  width: 168px;
  height: 168px;
  border: 4px solid #ffe0a8;
  border-radius: 38px;
  background: #fff7e8;
  font-size: 82px;
  line-height: 1;
  box-shadow: 0 12px 34px rgba(55, 42, 28, 0.08);
}

.word-meta {
  padding: 0 20px 20px;
}

.word-title {
  display: flex;
  align-items: end;
  gap: 14px;
  margin-bottom: 10px;
}

.word-title strong {
  font-size: 58px;
  line-height: 1;
}

.word-title span {
  padding-bottom: 8px;
  color: var(--muted);
  font-size: 23px;
  font-weight: 850;
}

.tip {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.55;
}

.word-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.word-choice {
  min-height: 50px;
  border: 3px solid var(--line);
  border-radius: 14px;
  background: white;
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
}

.word-choice.active {
  border-color: var(--accent);
  background: #ffe4c2;
}

.state-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: #e7f7ff;
  color: #176986;
  font-size: 14px;
  font-weight: 850;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.notice {
  margin-bottom: 14px;
  border: 3px solid #f1c36f;
  border-radius: 16px;
  background: #fff3d8;
  color: #5f4521;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.55;
}

.notice a {
  color: #935014;
  font-weight: 900;
}

.controls button {
  flex: 1 1 150px;
}

.primary-button,
.secondary-button {
  min-height: 50px;
  padding: 0 18px;
  border-radius: 14px;
  font-weight: 900;
  cursor: pointer;
}

.primary-button {
  border: 0;
  background: var(--accent);
  color: white;
}

.secondary-button {
  border: 3px solid var(--line);
  background: white;
  color: var(--ink);
}

.secondary-button:disabled,
.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.wave-card,
.feedback-card {
  border-radius: 20px;
  background: white;
  border: 3px solid #f2e1c9;
}

.wave-card {
  margin-bottom: 14px;
  overflow: hidden;
}

.wave-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 3px solid #f2e1c9;
  font-weight: 900;
}

.wave-header small {
  color: var(--muted);
  font-weight: 800;
}

.mini-play-button {
  min-height: 34px;
  padding: 0 12px;
  border: 2px solid #d9c3a4;
  border-radius: 999px;
  background: #fffaf2;
  color: var(--ink);
  font-size: 13px;
  font-weight: 950;
  cursor: pointer;
}

canvas {
  display: block;
  width: 100%;
  height: 220px;
  background: #fffaf2;
}

#referenceWaveform {
  height: 150px;
}

.feedback-card {
  padding: 16px;
}

.feedback-card h3 {
  margin-bottom: 12px;
  font-size: 20px;
}

.score-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.score-preview div {
  border-radius: 16px;
  background: #f7f1e8;
  padding: 12px;
}

.score-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.score-preview strong {
  font-size: 28px;
}

.muted {
  color: var(--muted);
}

.phoneme-scores {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.phoneme-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  background: #f7f1e8;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}

.phoneme-chip.practice {
  background: #ffe3d6;
  color: #a63d1f;
}

#mockFeedback {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 750;
  line-height: 1.6;
}

.feedback-step {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.feedback-step:first-child {
  border-top: 0;
  padding-top: 0;
}

.feedback-step span {
  display: block;
  margin-bottom: 4px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

.feedback-step p {
  margin: 0;
  color: var(--ink);
}

.section-note {
  margin: -4px 0 16px;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.6;
}

.pair-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.pair-card {
  border: 3px solid var(--line);
  border-radius: 18px;
  background: white;
  padding: 16px;
}

.pair-card h3 {
  margin-bottom: 8px;
  font-size: 22px;
}

.pair-card p {
  margin-bottom: 12px;
  color: var(--muted);
  font-weight: 750;
  line-height: 1.55;
}

.pair-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
  gap: 10px;
}

.word-option {
  text-align: center;
}

.pair-actions button {
  width: 100%;
  min-height: 56px;
  padding: 8px 6px;
  border: 3px solid transparent;
  border-radius: 12px;
  background: #eaf8ef;
  color: #236247;
  font-weight: 900;
  cursor: pointer;
}

.pair-actions button strong,
.pair-actions button span {
  display: block;
}

.pair-actions button strong {
  font-size: 18px;
  line-height: 1.1;
}

.pair-actions button span {
  margin-top: 3px;
  color: #426b59;
  font-size: 13px;
  font-weight: 850;
}

.pair-actions button.active {
  border-color: var(--green);
  background: #c9f4dc;
  color: #174f38;
}

.word-cue {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 52px;
  margin-top: 7px;
  padding: 0 2px;
}

.word-cue img,
.word-icon {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
}

.word-cue img {
  border-radius: 12px;
  object-fit: cover;
  background: #fff6e3;
}

.word-icon {
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: #fff1d9;
  color: #6f6257;
  font-size: 24px;
  font-weight: 950;
  line-height: 1;
}

.word-meaning {
  color: #8a938d;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.2;
}

.listening-check {
  margin-top: 16px;
}

.quiz-card {
  border: 3px solid var(--line);
  border-radius: 18px;
  background: white;
  padding: 16px;
}

.compact-quiz {
  max-width: 760px;
}

.quiz-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.quiz-card h3 {
  margin-bottom: 8px;
  font-size: 22px;
}

.quiz-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 750;
  line-height: 1.55;
}

.quiz-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.quiz-option {
  text-align: center;
}

.quiz-choice {
  width: 100%;
  min-height: 78px;
  padding: 8px;
  border: 3px solid var(--line);
  border-radius: 16px;
  background: #fffaf2;
  color: var(--ink);
  cursor: pointer;
}

.quiz-choice strong,
.quiz-choice span {
  display: block;
}

.quiz-choice strong {
  font-size: 30px;
  line-height: 1.05;
}

.quiz-choice span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 900;
}

.quiz-choice.correct {
  border-color: var(--green);
  background: #d9f8e6;
}

.quiz-choice.wrong {
  border-color: #e27766;
  background: #ffe0dc;
}

.quiz-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.compact {
  flex: 1 1 150px;
  min-height: 44px;
}

.quiz-result {
  min-height: 54px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #f7f1e8;
  color: var(--muted);
  font-weight: 850;
}

.quiz-result.correct {
  background: #d9f8e6;
  color: #1d6546;
}

.quiz-result.wrong {
  background: #ffe0dc;
  color: #9a3729;
}

svg {
  max-width: 100%;
  height: auto;
}

.illustration img {
  width: min(52%, 220px);
  max-height: 200px;
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
  display: block;
  border-radius: 22px;
  box-shadow: 0 12px 28px rgba(38, 50, 58, 0.12);
}

@media (max-width: 860px) {
  .hero {
    align-items: flex-start;
  }

  .sound-badge {
    width: 112px;
    height: 112px;
  }

  .sound-badge span {
    font-size: 40px;
  }

  .lesson-grid,
  .pair-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .app {
    width: min(100% - 32px, 1180px);
    padding-top: 18px;
  }

  .hero {
    display: block;
  }

  .sound-badge {
    margin-top: 16px;
  }

  .word-list,
  .score-preview,
  .quiz-choices {
    grid-template-columns: 1fr;
  }

  .controls button {
    flex-basis: 100%;
  }

  .lead {
    font-size: 17px;
  }

  .word-card {
    min-height: 330px;
  }

  .illustration {
    height: 190px;
  }
}
