:root {
  color-scheme: light;
  --ink: #2b2020;
  --muted: #7a5f5d;
  --surface: #fffafc;
  --surface-strong: #ffffff;
  --outline: #f4c3bf;
  --pink: #ff9aa2;
  --pink-strong: #ef6f79;
  --mint: #ffc7c2;
  --blue: #ffd9d4;
  --lemon: #ffe6e2;
  --lavender: #ffcfd0;
  --green: #d46b72;
  --red: #c95b65;
  --shadow: 0 18px 45px rgba(142, 79, 76, 0.14);
  --soft-shadow: 0 8px 24px rgba(142, 79, 76, 0.1);
}

html {
  background: #ffd8d2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Google Sans", "Noto Sans KR", system-ui, sans-serif;
  color: var(--ink);
  background: #ffd8d2;
}

.chinese-page {
  font-family: "Google Sans", "Noto Sans SC", system-ui, sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
}

.loading-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  gap: 16px;
  color: var(--muted);
}

.loader-dot {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: conic-gradient(from 90deg, var(--pink), var(--mint), var(--blue), var(--pink));
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0 18px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.language-switch {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border: 1px solid var(--outline);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: var(--soft-shadow);
}

.language-switch a {
  min-width: 68px;
  min-height: 34px;
  display: grid;
  place-items: center;
  padding: 0 11px;
  border-radius: 14px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 800;
}

.language-switch a.active {
  color: #873f45;
  background: #ffe4e0;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #ff9aa2, #ffd8d2);
  display: grid;
  place-items: center;
  color: white;
  font-weight: 800;
  box-shadow: var(--soft-shadow);
}

.brand h1 {
  margin: 0;
  font-size: 1.3rem;
  letter-spacing: 0;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  box-shadow: var(--soft-shadow);
  white-space: nowrap;
}

.hero {
  position: relative;
  display: block;
  min-height: auto;
  margin-bottom: 22px;
  overflow: hidden;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: var(--shadow);
}

.hero-copy {
  position: relative;
  z-index: 2;
  padding: clamp(28px, 5vw, 54px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  max-width: 840px;
}

.eyebrow {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: #fff0f7;
  color: var(--pink-strong);
  font-weight: 700;
  font-size: 0.88rem;
}

.hero h2 {
  margin: 0;
  max-width: 680px;
  font-size: clamp(2.1rem, 5vw, 4.2rem);
  line-height: 1.08;
  letter-spacing: 0;
}

.hero p {
  margin: 0;
  max-width: 620px;
  color: var(--muted);
  font-size: 1.06rem;
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.app-shell > .pet-bunny {
  position: fixed;
  right: 20px;
  bottom: 18px;
  z-index: 20;
}

.pet-bunny {
  width: min(260px, calc(100vw - 30px));
  display: grid;
  justify-items: center;
  gap: 8px;
  pointer-events: none;
}

.pet-bunny.compact {
  width: 100%;
}

.pet-bubble {
  position: relative;
  max-width: min(238px, calc(100vw - 30px));
  min-height: 0;
  display: flex;
  align-items: center;
  padding: 10px 13px;
  border-radius: 20px 20px 7px 20px;
  background: #fffdfc;
  color: #7f3c58;
  border: 1px solid #ffd0dc;
  box-shadow: 0 12px 28px rgba(126, 65, 91, 0.16);
  font-size: 0.86rem;
  line-height: 1.35;
  font-weight: 800;
}

.pet-bubble::after {
  content: "";
  position: absolute;
  right: 24px;
  bottom: -8px;
  width: 18px;
  height: 18px;
  border-radius: 0 0 18px 0;
  background: #fffdfc;
  border-right: 1px solid #ffd0dc;
  border-bottom: 1px solid #ffd0dc;
  transform: rotate(45deg);
}

.mimi-pet-art {
  width: 170px;
  max-width: 70vw;
  display: block;
  filter: drop-shadow(0 14px 18px rgba(126, 65, 91, 0.14));
  animation: petFloat 2.8s ease-in-out infinite;
}

.pet-body {
  position: relative;
  width: 118px;
  height: 118px;
  border-radius: 46% 46% 50% 50%;
  background:
    radial-gradient(circle at 34% 22%, rgba(255,255,255,0.92), transparent 20%),
    linear-gradient(180deg, #fffafa, #ffe8ef);
  border: 4px solid #fff;
  box-shadow: 0 16px 30px rgba(126, 65, 91, 0.18), inset 0 -12px 18px rgba(255, 172, 194, 0.18);
  animation: petFloat 2.8s ease-in-out infinite;
}

.pet-ear {
  position: absolute;
  top: -54px;
  width: 38px;
  height: 78px;
  border-radius: 999px;
  background: linear-gradient(180deg, #fffafa, #ffe6ee);
  border: 4px solid #fff;
  transform-origin: bottom center;
  box-shadow: inset 0 -12px 16px rgba(255, 160, 188, 0.16);
  animation: earWiggle 3.4s ease-in-out infinite;
}

.pet-ear::after {
  content: "";
  position: absolute;
  inset: 14px 9px 13px;
  border-radius: 999px;
  background: #ffc5d8;
  opacity: 0.7;
}

.pet-ear.left {
  left: 21px;
  transform: rotate(-13deg);
}

.pet-ear.right {
  right: 21px;
  transform: rotate(13deg);
  animation-delay: 0.22s;
}

.pet-face {
  position: absolute;
  inset: 0;
}

.pet-eye {
  position: absolute;
  top: 48px;
  width: 13px;
  height: 15px;
  border-radius: 50%;
  background: #5c343b;
  animation: petBlink 4s ease-in-out infinite;
}

.pet-eye.left { left: 35px; }
.pet-eye.right { right: 35px; }

.pet-cheek {
  position: absolute;
  top: 66px;
  width: 18px;
  height: 12px;
  border-radius: 50%;
  background: #ffafc5;
  opacity: 0.68;
}

.pet-cheek.left { left: 22px; }
.pet-cheek.right { right: 22px; }

.pet-mouth {
  position: absolute;
  left: 50%;
  top: 66px;
  width: 24px;
  height: 13px;
  transform: translateX(-50%);
  border-bottom: 4px solid #7b4650;
  border-radius: 0 0 999px 999px;
}

.pet-paw {
  position: absolute;
  bottom: 12px;
  width: 26px;
  height: 22px;
  border-radius: 999px;
  background: #fff8fa;
  border: 3px solid #fff;
}

.pet-paw.left { left: 19px; transform: rotate(14deg); }
.pet-paw.right { right: 19px; transform: rotate(-14deg); }

.pet-bow {
  position: absolute;
  z-index: 2;
  top: 7px;
  width: 30px;
  height: 24px;
}

.pet-bow::before,
.pet-bow::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 20px;
  border-radius: 16px 16px 8px 16px;
  background: #ff88b2;
  border: 3px solid #fff1f6;
}

.pet-bow::before { left: 0; transform: rotate(-28deg); }
.pet-bow::after { right: 0; transform: rotate(28deg); }

.pet-bow.left { left: 18px; transform: rotate(-14deg); }
.pet-bow.right { right: 18px; transform: rotate(14deg); }

@keyframes petFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-7px) scale(1.025); }
}

@keyframes earWiggle {
  0%, 100% { rotate: 0deg; }
  45% { rotate: 4deg; }
  70% { rotate: -2deg; }
}

@keyframes petBlink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.12); }
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  margin-bottom: 18px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(14px);
  box-shadow: var(--soft-shadow);
}

.tab {
  min-height: 46px;
  border-radius: 18px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.tab:hover {
  background: #fff1f7;
}

.tab.active {
  color: #7b3157;
  background: linear-gradient(135deg, #ffe2df, #fff5f3);
  transform: translateY(-1px);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.section-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
}

.surface,
.card {
  border: 1px solid var(--outline);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--soft-shadow);
}

.surface {
  border-radius: 24px;
  padding: 18px;
}

.card {
  border-radius: 18px;
  padding: 16px;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-head h3 {
  margin: 0;
  font-size: 1.36rem;
  letter-spacing: 0;
}

.section-head p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.section-actions,
.entry-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.search-row,
.translator-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.field,
.textarea {
  width: 100%;
  border: 1px solid var(--outline);
  border-radius: 16px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border 160ms ease, box-shadow 160ms ease;
}

.field {
  min-height: 48px;
  padding: 0 15px;
}

.textarea {
  min-height: 132px;
  padding: 14px 15px;
  resize: vertical;
}

.field:focus,
.textarea:focus {
  border-color: var(--pink);
  box-shadow: 0 0 0 4px rgba(255, 139, 187, 0.18);
}

.button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--soft-shadow);
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
  text-decoration: none;
}

.button.primary {
  color: #fff;
  background: linear-gradient(135deg, #ef6f79, #ff9aa2);
}

.button.ghost {
  background: #fff6fb;
  box-shadow: none;
  border: 1px solid var(--outline);
}

.voice-toggle.active {
  color: #8b3158;
  background: linear-gradient(135deg, #ffe0dd, #fff7f5);
  border: 1px solid #ffc1d9;
}

.tiny-read {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: #fff4f8;
  color: #9b2f62;
  border: 1px solid #ffd3e3;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 900;
}

.tiny-read.active {
  background: #ffe5ee;
}

.entry-grid,
.character-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.entry-card {
  min-height: 230px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.entry-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.word {
  font-family: "Noto Sans KR", system-ui, sans-serif;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
}

.roman {
  color: var(--muted);
  font-size: 0.93rem;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  background: #fff1ee;
  color: #9b4c51;
  font-size: 0.8rem;
  font-weight: 800;
}

.tag.pink {
  background: #fff0f7;
  color: #9b2f62;
}

.meaning {
  font-weight: 800;
  line-height: 1.35;
}

.example {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px dashed var(--outline);
  color: var(--muted);
  line-height: 1.55;
}

.example strong {
  display: block;
  color: var(--ink);
  font-family: "Noto Sans KR", system-ui, sans-serif;
  font-size: 1.04rem;
}

.side-art {
  display: grid;
  gap: 12px;
  align-content: start;
}

.side-art img {
  width: 100%;
  border-radius: 22px;
  box-shadow: var(--soft-shadow);
}

.mini-stat {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mini-stat .card {
  min-height: 86px;
}

.stat-number {
  display: block;
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--pink-strong);
}

.flashcard-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: stretch;
}

.flashcard {
  min-height: 430px;
  display: grid;
  place-items: center;
  text-align: center;
  cursor: pointer;
}

.flash-word {
  font-family: "Noto Sans KR", system-ui, sans-serif;
  font-size: clamp(3.2rem, 10vw, 7rem);
  font-weight: 900;
  line-height: 1;
}

.flash-answer {
  display: grid;
  gap: 12px;
  max-width: 560px;
}

.review-row,
.quiz-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.quiz-card {
  min-height: 370px;
  display: grid;
  gap: 14px;
  align-content: center;
}

.quiz-prompt {
  text-align: center;
  font-family: "Noto Sans KR", system-ui, sans-serif;
  font-size: clamp(2rem, 7vw, 4.8rem);
  font-weight: 900;
}

.quiz-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.option {
  min-height: 62px;
  border-radius: 18px;
  border: 1px solid var(--outline);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  padding: 10px;
  line-height: 1.35;
}

.option.correct {
  background: #fff0ed;
  border-color: var(--pink-strong);
}

.option.wrong {
  background: #fff0f2;
  border-color: var(--red);
}

.score-line {
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
}

.dessert-stage {
  min-height: 560px;
  display: flex;
  flex-direction: column;
}

.dessert-preview {
  position: relative;
  flex: 1;
  min-height: 430px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 28px;
  background: #ffd8d2;
}

.dessert-shadow {
  position: absolute;
  width: min(480px, 82%);
  height: 66px;
  bottom: 70px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(124, 70, 98, 0.22), transparent 68%);
}

.dessert-stack {
  position: relative;
  width: min(660px, 98%);
  aspect-ratio: 760 / 560;
  z-index: 2;
  transform: translateY(4px);
}

.dessert-piece {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  animation: layerPop 260ms ease both;
  pointer-events: none;
}

.layer-base { z-index: 1; }
.layer-cream { z-index: 2; }
.layer-topping { z-index: 3; }
.layer-drizzle { z-index: 4; }
.layer-charm { z-index: 5; }

@keyframes layerPop {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.dessert-empty-bowl {
  position: absolute;
  left: 50%;
  bottom: 72px;
  width: min(350px, 78%);
  height: 160px;
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  border-radius: 0 0 90px 90px;
  background: linear-gradient(180deg, rgba(255,255,255,0.52), rgba(222,244,255,0.5));
  border: 7px solid rgba(255,255,255,0.74);
  box-shadow: inset 0 -22px 34px rgba(142, 200, 255, 0.2), var(--soft-shadow);
}

.dessert-empty-bowl span {
  display: inline-flex;
  padding: 8px 12px;
  border-radius: 999px;
  color: #8b6074;
  background: rgba(255,255,255,0.82);
  font-weight: 800;
}

.dessert-recipe {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.recipe-chip {
  min-height: 74px;
  padding: 11px;
  border: 1px solid var(--outline);
  border-radius: 18px;
  background: #fff;
  overflow: hidden;
}

.recipe-chip img {
  width: 54px;
  height: 42px;
  float: right;
  object-fit: contain;
  margin-left: 6px;
}

.recipe-chip span,
.recipe-chip strong {
  display: block;
}

.recipe-chip span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.recipe-chip strong {
  margin-top: 5px;
  line-height: 1.25;
}

.recipe-chip.active {
  border-color: var(--pink);
  background: #fff3f8;
}

.recipe-chip.done {
  border-color: var(--pink);
  background: #fff0ed;
}

.game-controls {
  display: grid;
  gap: 12px;
  align-content: start;
}

.game-controls img {
  width: min(210px, 100%);
  justify-self: center;
  border-radius: 24px;
}

.game-message {
  padding: 13px 15px;
  border-radius: 18px;
  background: #fff3f8;
  color: #853659;
  font-weight: 800;
  line-height: 1.45;
}

.game-question h4 {
  margin: 10px 0 4px;
  font-family: "Noto Sans KR", system-ui, sans-serif;
  font-size: clamp(2rem, 6vw, 3rem);
}

.game-question p {
  margin: 0 0 12px;
  color: var(--muted);
}

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

.ingredient-button {
  min-height: 128px;
  display: grid;
  grid-template-rows: 72px auto auto;
  align-items: center;
  justify-items: center;
  gap: 3px;
  padding: 10px 8px;
  border-radius: 26px;
  border: 1px solid var(--outline);
  background: linear-gradient(180deg, #fffdfd, #fff0f4);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 8px 18px rgba(99, 70, 107, 0.08);
  transition: transform 160ms ease, border 160ms ease, box-shadow 160ms ease;
}

.ingredient-button:hover {
  transform: translateY(-2px);
  border-color: var(--pink);
  box-shadow: 0 12px 24px rgba(99, 70, 107, 0.13);
}

.ingredient-button img {
  width: 100%;
  height: 76px;
  object-fit: contain;
}

.ingredient-button span {
  line-height: 1.2;
}

.ingredient-button small {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.25;
  font-weight: 700;
}

.translate-result {
  display: grid;
  gap: 12px;
}

.match-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}

.character-card {
  min-height: 168px;
}

.character-symbol {
  font-family: "Noto Sans KR", system-ui, sans-serif;
  font-size: 3rem;
  font-weight: 900;
}

.chinese-word,
.chinese-flash-word,
.chinese-symbol,
.chinese-quiz-prompt {
  font-family: "Noto Sans SC", "Google Sans", system-ui, sans-serif;
}

.chinese-word {
  font-size: 2.65rem;
}

.chinese-flash-word,
.chinese-quiz-prompt {
  font-size: clamp(4rem, 12vw, 8rem);
  line-height: 1;
}

.chinese-grid-card {
  cursor: pointer;
}

.source-note {
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.source-note a {
  color: #c75460;
  font-weight: 800;
}

.empty {
  padding: 34px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
  }

  .pet-bunny {
    width: min(210px, calc(100vw - 24px));
  }

  .mimi-pet-art {
    width: 132px;
  }

  .topbar,
  .section-head {
    align-items: start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .hero,
  .section-grid,
  .flashcard-wrap,
  .game-layout {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
  }

  .tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    position: static;
  }

  .search-row,
  .translator-row,
  .hero-actions {
    flex-direction: column;
  }

  .button {
    width: 100%;
  }

  .quiz-options {
    grid-template-columns: 1fr;
  }

  .dessert-recipe {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .hero-copy {
    padding: 24px;
  }

  .hero h2 {
    font-size: 2.2rem;
  }

  .word {
    font-size: 1.7rem;
  }

  .flashcard {
    min-height: 360px;
  }
}
