@import url('https://fonts.googleapis.com/css2?family=Black+Han+Sans&family=IBM+Plex+Sans+KR:wght@400;600&family=Nanum+Square+Round:wght@400;700&display=swap');

:root {
  --bg: #f5f1e8;
  --ink: #1c1b19;
  --accent: #ff6b4a;
  --accent-dark: #e45232;
  --mint: #64c4b8;
  --card: #fffaf1;
  --muted: #6a655c;
  --shadow: 0 20px 60px rgba(28, 27, 25, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'IBM Plex Sans KR', sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top, #fff6db 0%, #f5f1e8 40%, #f0e8d8 100%);
  overflow-x: hidden;
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.blob {
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(12px);
  opacity: 0.5;
}

.blob--one {
  top: -120px;
  left: -80px;
  background: #ffd4b0;
}

.blob--two {
  bottom: -140px;
  right: -40px;
  background: #c9f5ee;
}

.grid {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(28, 27, 25, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(28, 27, 25, 0.06) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: 0.25;
}

.site-header {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  padding: 48px 8vw 24px;
}

.site-header h1 {
  margin: 8px 0 12px;
  font-family: 'Black Han Sans', sans-serif;
  font-size: clamp(2.4rem, 4vw, 3.4rem);
  letter-spacing: -1px;
}

.eyebrow {
  font-weight: 700;
  color: var(--accent-dark);
  margin: 0;
}

.subtitle {
  color: var(--muted);
  max-width: 520px;
  margin: 0;
}

.header-badge {
  background: #1c1b19;
  color: #fff6db;
  padding: 20px 26px;
  border-radius: 18px;
  box-shadow: var(--shadow);
  min-width: 180px;
}

.header-badge p {
  margin: 0 0 6px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.layout {
  position: relative;
  z-index: 1;
  padding: 0 8vw 48px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

.card {
  background: var(--card);
  border-radius: 24px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 16px;
  font-size: 1.4rem;
}

.intro ol {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}

.intro li {
  margin-bottom: 8px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.chips span {
  background: #1c1b19;
  color: #fff6db;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
}

.game {
  grid-column: span 2;
}

.story-lab {
  grid-column: span 2;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.story-lab__header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.selection-status {
  background: #fff2db;
  padding: 16px 20px;
  border-radius: 16px;
  min-width: 160px;
  text-align: center;
}

.selection-status p {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

.selection-status strong {
  font-size: 1.4rem;
}

.selection-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.story-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.story-controls label {
  font-weight: 600;
}

.story-controls select {
  padding: 8px 12px;
  border-radius: 12px;
  border: 2px solid #e5d8c4;
  background: #fff;
  font-family: 'IBM Plex Sans KR', sans-serif;
}

.selection-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.word-pool {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.word-card {
  background: #fff;
  border: 2px solid #f0dfca;
  border-radius: 16px;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.word-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 107, 74, 0.2);
  transform: translateY(-2px);
}

.word-card h4 {
  margin: 0 0 6px;
  font-size: 1.1rem;
}

.word-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.storybook {
  border-top: 2px dashed #e6d7c6;
  padding-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.storybook.hidden {
  display: none;
}

.storybook-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.storybook-toolbar h3 {
  margin: 6px 0 0;
}

.listen-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.storybook-panel {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) 1.2fr;
  gap: 20px;
  align-items: stretch;
}

.illustration {
  background: #1c1b19;
  color: #fff6db;
  border-radius: 18px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 220px;
}

.illustration-shape {
  width: 100%;
  height: 140px;
  border-radius: 16px;
  background: linear-gradient(120deg, #ffb48a, #ffe5b0, #b4f0e7);
  margin-bottom: 12px;
}

.story-text {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.story-lines {
  background: #fff2db;
  border-radius: 18px;
  padding: 18px;
  min-height: 180px;
}

.story-line-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.story-line {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.5;
}

.story-line.active {
  background: #1c1b19;
  color: #fff6db;
  padding: 6px 10px;
  border-radius: 12px;
}

.vocab {
  color: var(--accent-dark);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline wavy rgba(255, 107, 74, 0.4);
}

.meaning-box {
  background: #fff;
  border-radius: 16px;
  padding: 14px 16px;
  border: 2px dashed #e2b9ac;
}

.recording-panel {
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  border: 2px solid #f0dfca;
}

.record-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.record-controls button {
  border-radius: 12px;
  border: 2px solid #1c1b19;
  background: #fff6db;
  padding: 8px 14px;
  font-weight: 600;
  cursor: pointer;
}

.record-controls button.active {
  background: #1c1b19;
  color: #fff6db;
}

.page-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.quiz {
  background: #fff8eb;
  border-radius: 18px;
  padding: 20px;
}

.quiz-question {
  margin-bottom: 16px;
}

.quiz-question p {
  margin: 0 0 8px;
  font-weight: 600;
}

.quiz-question label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
}

.game-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.label {
  margin: 0 0 8px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

#word {
  margin: 0;
  font-size: 2.2rem;
}

.meaning {
  margin: 4px 0 0;
  color: var(--accent-dark);
  font-weight: 600;
}

.scoreboard {
  display: grid;
  grid-auto-flow: column;
  gap: 18px;
  text-align: center;
}

.scoreboard p {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.8rem;
}

.scoreboard strong {
  font-size: 1.4rem;
}

.sentence-box {
  background: #fff2db;
  border-radius: 18px;
  padding: 18px 20px;
  margin: 20px 0 16px;
}

.sentence {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.hint {
  margin: 10px 0 0;
  color: var(--muted);
}

.answer-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

input[type='text'] {
  flex: 1 1 220px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px solid #e5d8c4;
  font-size: 1rem;
  background: #fff;
  font-family: 'Nanum Square Round', sans-serif;
}

input[type='text']:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 107, 74, 0.2);
}

.primary,
.ghost {
  border-radius: 14px;
  border: none;
  font-size: 1rem;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 20px rgba(255, 107, 74, 0.3);
}

.primary:disabled {
  background: #f2b6a5;
  cursor: not-allowed;
  box-shadow: none;
}

.primary:hover:not(:disabled) {
  transform: translateY(-2px);
}

.ghost {
  background: #fff;
  border: 2px dashed #e2b9ac;
  color: var(--accent-dark);
}

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

.feedback {
  margin: 0 0 16px;
  font-weight: 600;
}

.feedback.good {
  color: #1a7f61;
}

.feedback.bad {
  color: #c13c2f;
}

.progress-bar {
  height: 12px;
  background: #f0dfca;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #64c4b8, #ffcf7a);
  transition: width 0.3s ease;
}

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

.story {
  margin-top: 20px;
  background: #1c1b19;
  color: #fff6db;
  padding: 18px;
  border-radius: 18px;
}

.story h3 {
  margin-top: 0;
}

.site-footer {
  text-align: center;
  padding: 24px 8vw 36px;
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 960px) {
  .game {
    grid-column: auto;
  }

  .story-lab {
    grid-column: auto;
  }

  .scoreboard {
    grid-auto-flow: row;
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 640px) {
  .site-header {
    padding: 32px 6vw 12px;
  }

  .layout {
    padding: 0 6vw 36px;
  }

  .header-badge {
    width: 100%;
  }

  .answer-row {
    flex-direction: column;
    align-items: stretch;
  }

  .storybook-panel {
    grid-template-columns: 1fr;
  }

  .story-line-row {
    grid-template-columns: 1fr;
  }
}
