/* =========================================================
   EtymoQuest — Modern Scholar's Atelier Theme
   ========================================================= */

:root {
  --bg: #f6f2ea;
  --bg-accent: #ede6d8;
  --surface: #fffdf9;
  --surface-muted: #f2ece0;
  --ink: #1e2430;
  --ink-muted: #5b6475;
  --border: #dfd6c5;
  --border-strong: #c8bca6;

  --primary: #2d4b73;
  --primary-hover: #213959;
  --gold: #b8860b;
  --gold-soft: #f7eed6;

  --correct: #2e7d5b;
  --correct-bg: #dff3ea;
  --present: #c9861d;
  --present-bg: #fbf0d9;
  --absent: #7c8492;
  --absent-bg: #e4e7ec;

  --prefix-color: #3a6ea5;
  --prefix-bg: #e7f0fa;
  --root-color: #9e472a;
  --root-bg: #fbece7;
  --suffix-color: #5b4b8a;
  --suffix-bg: #efeafd;

  --shadow-sm: 0 2px 8px rgba(30, 36, 48, 0.05);
  --shadow-md: 0 10px 30px rgba(30, 36, 48, 0.08);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --font-display: "Fraunces", Georgia, serif;
  --font-sans: "Plus Jakarta Sans", "Noto Sans KR", -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}

[data-theme="dark"] {
  --bg: #12161f;
  --bg-accent: #1a202c;
  --surface: #1b2230;
  --surface-muted: #232b3b;
  --ink: #eef2f7;
  --ink-muted: #9aa5b8;
  --border: #2e3748;
  --border-strong: #3f4b61;

  --primary: #5b8fd1;
  --primary-hover: #71a1df;
  --gold: #e5b84b;
  --gold-soft: #2e2615;

  --correct: #389e72;
  --correct-bg: #17382b;
  --present: #d99b26;
  --present-bg: #362914;
  --absent: #4a5363;
  --absent-bg: #272e3b;

  --prefix-color: #7ab3ef;
  --prefix-bg: #1b2b3f;
  --root-color: #ee8a6b;
  --root-bg: #38221c;
  --suffix-color: #b19df0;
  --suffix-bg: #29223f;

  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 14px 36px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background: radial-gradient(circle at top right, var(--bg-accent), var(--bg) 60%);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.5;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 20px 40px;
}

/* ================= TOPBAR ================= */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-seal {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #1d314d);
  color: #fff;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(45, 75, 115, 0.25);
}

.brand-text h1 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.mode-tabs {
  display: flex;
  gap: 6px;
  background: var(--surface-muted);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.tab-btn:hover {
  color: var(--ink);
}

.tab-btn.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.codex-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  font-size: 0.85rem;
}

.rank-pill strong {
  color: var(--primary);
  font-family: var(--font-mono);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.15s ease, background 0.15s ease;
}

.icon-btn:hover {
  background: var(--surface-muted);
  transform: translateY(-1px);
}

.lang-btn {
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--primary);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.lang-btn:hover {
  background: var(--surface-muted);
  transform: translateY(-1px);
}

/* ================= VIEWS & CARDS ================= */
.view {
  display: none;
}

.view.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}

/* ================= GAME CONTROLS BAR ================= */
.game-controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.mode-selector {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
}

.pill-toggle {
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.pill-toggle.active {
  background: var(--primary);
  color: #fff;
}

.filter-group {
  display: flex;
  gap: 8px;
  transition: opacity 0.2s ease;
}

.filter-group.hidden {
  opacity: 0.4;
  pointer-events: none;
}

.filter-group select {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}

/* ================= PLAY LAYOUT ================= */
.play-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 920px) {
  .play-layout {
    grid-template-columns: 1fr;
  }
}

/* Left Dossier */
.dossier-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.origin-tag {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold);
}

.difficulty-tag {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--ink-muted);
}

.meaning-box {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 18px;
}

.box-label {
  display: block;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  margin-bottom: 4px;
}

.korean-meaning {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 8px;
}

.pos-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-muted);
}

/* Morpheme Blueprint */
.morpheme-blueprint {
  margin-bottom: 18px;
}

.blueprint-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.86rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.blueprint-sub {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--primary);
}

.morpheme-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.morpheme-card {
  flex: 1 1 100px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1.5px dashed var(--border-strong);
  background: var(--surface-muted);
  transition: all 0.25s ease;
}

.morpheme-card.unlocked {
  border-style: solid;
  transform: translateY(-1px);
}

.morpheme-card.type-prefix.unlocked {
  background: var(--prefix-bg);
  border-color: var(--prefix-color);
}

.morpheme-card.type-root.unlocked {
  background: var(--root-bg);
  border-color: var(--root-color);
}

.morpheme-card.type-suffix.unlocked {
  background: var(--suffix-bg);
  border-color: var(--suffix-color);
}

.morpheme-type {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}

.morpheme-part {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  margin: 2px 0;
  letter-spacing: 0.04em;
}

.morpheme-meaning {
  font-size: 0.78rem;
  color: var(--ink);
  font-weight: 600;
}

/* Hints Panel */
.hints-panel {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.hints-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.86rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.hint-unlock-btn {
  border: 1px solid var(--gold);
  background: var(--gold-soft);
  color: var(--gold);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.hint-unlock-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.hint-unlock-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.hint-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hint-item {
  font-size: 0.83rem;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--surface-muted);
  border-left: 3px solid var(--primary);
  line-height: 1.45;
}

.hint-item strong {
  color: var(--primary);
}

/* ================= GUESS ARENA ================= */
.guess-arena {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  overflow: hidden;
}

.arena-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.attempt-counter {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink-muted);
}

.ghost-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink-muted);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ghost-btn:hover {
  background: var(--surface-muted);
  color: var(--ink);
}

.guess-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  width: 100%;
  align-items: center;
}

.guess-row {
  display: flex;
  gap: clamp(3px, 0.7vw, 6px);
  justify-content: center;
  width: 100%;
  max-width: calc(var(--word-len, 8) * 52px + 16px);
}

.guess-row.shake {
  animation: shake 0.36s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.tile {
  flex: 1 1 0;
  min-width: 0;
  max-width: 46px;
  aspect-ratio: 46 / 52;
  height: auto;
  border: 2px solid var(--border-strong);
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: clamp(0.8rem, calc(18vw / var(--word-len, 8)), 1.35rem);
  font-weight: 700;
  text-transform: uppercase;
  background: var(--surface);
  color: var(--ink);
  transition: transform 0.12s ease, border-color 0.12s ease;
  user-select: none;
}

.tile.filled {
  border-color: var(--primary);
  animation: popIn 0.12s ease;
}

.tile.morpheme-end {
  margin-right: clamp(3px, 0.7vw, 6px);
}

@keyframes popIn {
  0% { transform: scale(0.9); }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.tile.correct {
  background: var(--correct);
  border-color: var(--correct);
  color: #fff;
}

.tile.present {
  background: var(--present);
  border-color: var(--present);
  color: #fff;
}

.tile.absent {
  background: var(--absent);
  border-color: var(--absent);
  color: #fff;
}

.tile.reveal {
  animation: flipTile 0.42s ease forwards;
}

@keyframes flipTile {
  0% { transform: rotateX(0deg); }
  50% { transform: rotateX(90deg); }
  100% { transform: rotateX(0deg); }
}

.feedback-banner {
  min-height: 26px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 10px;
  text-align: center;
}

.feedback-banner.error {
  color: #c94a38;
}

.feedback-banner.success {
  color: var(--correct);
}

/* Keyboard */
.keyboard {
  width: 100%;
  max-width: 540px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kb-row {
  display: flex;
  justify-content: center;
  gap: 5px;
}

.kb-key {
  flex: 1;
  min-width: 28px;
  height: 44px;
  border: none;
  border-radius: 8px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.14s ease;
  display: grid;
  place-items: center;
}

.kb-key:hover {
  background: var(--bg-accent);
}

.kb-key.wide {
  flex: 1.6;
  font-family: var(--font-sans);
  font-size: 0.78rem;
}

.kb-key.correct {
  background: var(--correct);
  border-color: var(--correct);
  color: #fff;
}

.kb-key.present {
  background: var(--present);
  border-color: var(--present);
  color: #fff;
}

.kb-key.absent {
  background: var(--absent);
  border-color: var(--absent);
  color: #fff;
  opacity: 0.72;
}

/* ================= MORPHEME FORGE ================= */
.forge-container {
  max-width: 780px;
  margin: 0 auto;
}

.forge-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.forge-title {
  font-family: var(--font-display);
  font-size: 1.45rem;
  margin-top: 6px;
}

.forge-score-pill {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  font-size: 0.85rem;
}

.forge-target-card {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 18px;
  text-align: center;
}

.forge-meaning {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.forge-story-hint {
  font-size: 0.88rem;
  color: var(--ink-muted);
}

.anvil-area {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 20px;
  min-height: 112px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
  background: var(--bg);
}

.anvil-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.anvil-preview {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
}

.morpheme-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 20px;
}

.tray-chip {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 96px;
  transition: all 0.16s ease;
}

.tray-chip:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.tray-chip.selected {
  opacity: 0.35;
  pointer-events: none;
}

.tray-chip .chip-part {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
}

.tray-chip .chip-meaning {
  font-size: 0.74rem;
  color: var(--ink-muted);
}

.anvil-chip {
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 700;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.forge-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

/* ================= CODEX VIEW ================= */
.codex-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.codex-header h2 {
  font-family: var(--font-display);
  font-size: 1.45rem;
}

.codex-header p {
  font-size: 0.88rem;
  color: var(--ink-muted);
}

.codex-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.codex-controls input[type="search"] {
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  min-width: 220px;
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}

.codex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.codex-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.codex-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.codex-card.locked {
  opacity: 0.6;
  background: var(--surface-muted);
  cursor: default;
}

.codex-card.locked:hover {
  transform: none;
  box-shadow: none;
}

.codex-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.codex-word {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
}

.codex-root {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--primary);
  font-weight: 700;
}

/* ================= BUTTONS ================= */
.primary-btn {
  border: none;
  background: var(--primary);
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.primary-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.primary-btn.full-width {
  width: 100%;
  margin-top: 14px;
}

.secondary-btn {
  border: 1px solid var(--border-strong);
  background: var(--surface-muted);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
}

.secondary-btn:hover {
  background: var(--bg-accent);
}

/* ================= MODALS ================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 30, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  place-items: center;
  padding: 20px;
  z-index: 100;
}

.modal-backdrop.open {
  display: grid;
  animation: fadeIn 0.2s ease;
}

.modal-card {
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px;
  position: relative;
  box-shadow: var(--shadow-md);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

.modal-status-badge {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--correct-bg);
  color: var(--correct);
  margin-bottom: 10px;
}

.modal-status-badge.failed {
  background: var(--root-bg);
  color: var(--root-color);
}

.modal-word-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 6px;
}

#modal-word-title {
  font-family: var(--font-display);
  font-size: 2rem;
  line-height: 1.1;
}

.modal-phonetic-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

#modal-phonetic {
  font-family: var(--font-mono);
  font-size: 0.86rem;
  color: var(--ink-muted);
}

.audio-btn {
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.audio-btn:hover {
  border-color: var(--primary);
}

.modal-origin-pill {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold);
}

.modal-korean-meaning {
  font-size: 1.12rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.modal-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.breakdown-pill {
  flex: 1 1 130px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
}

.breakdown-pill .bp-part {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary);
}

.breakdown-pill .bp-origin {
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.breakdown-pill .bp-ko {
  font-size: 0.84rem;
  font-weight: 700;
  margin-top: 2px;
}

.modal-story-box,
.modal-example-box,
.modal-cognates-box {
  background: var(--surface-muted);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}

.modal-story-box h4,
.modal-example-box h4,
.modal-cognates-box h4 {
  font-size: 0.84rem;
  margin-bottom: 6px;
}

.modal-story-box p {
  font-size: 0.88rem;
  line-height: 1.55;
}

.example-en {
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 3px;
}

.example-ko {
  font-size: 0.83rem;
  color: var(--ink-muted);
}

.cognates-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cognate-item {
  font-size: 0.84rem;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.cognate-item strong {
  font-family: var(--font-mono);
  color: var(--primary);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

/* Help Modal */
.help-sections {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 14px;
}

.help-item h3 {
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.help-item p {
  font-size: 0.86rem;
  color: var(--ink-muted);
}

.help-tiles-demo {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 8px 10px;
  align-items: center;
  margin: 8px 0;
  font-size: 0.84rem;
}

.demo-tile {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-weight: 700;
  color: #fff;
}

.demo-tile.correct { background: var(--correct); }
.demo-tile.present { background: var(--present); }
.demo-tile.absent { background: var(--absent); }

.help-tip {
  color: var(--primary) !important;
  font-weight: 600;
}

@media (max-width: 600px) {
  .app-shell { padding: 10px 12px 28px; }
  .topbar { padding: 10px 12px; }
  .card { padding: 16px; }
  .kb-key { height: 40px; font-size: 0.8rem; }
}
