:root {
  --ink: #2a2118;
  --muted: #534033;
  --cream: #fffdf4;
  --lemon: #ffe27a;
  --mint: #b8f0d0;
  --peach: #ffd4c4;
  --pink: #ff9ec4;
  --edu-font: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html,
body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: var(--edu-font);
  font-weight: 700;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  background: #f3e2b0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage {
  position: relative;
  width: min(100vw, calc(100dvh * 0.557));
  height: min(100dvh, calc(100vw / 0.557));
  max-width: 420px;
  border-radius: 22px;
  overflow: hidden;
  background:
    radial-gradient(circle at 16% 10%, rgba(255, 255, 255, 0.7), transparent 28%),
    radial-gradient(circle at 90% 14%, rgba(184, 240, 208, 0.7), transparent 30%),
    linear-gradient(180deg, #fff3b0 0%, #d9f7e4 48%, #ffe8d2 100%);
  box-shadow: 0 18px 44px rgba(74, 55, 40, 0.18);
}

.hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.icon-btn,
.icon-play {
  appearance: none;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  min-height: 52px;
  padding: 0;
  border-radius: 16px;
  font-size: 24px;
  text-decoration: none;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 5px 0 rgba(201, 138, 62, 0.28);
  cursor: pointer;
}

.icon-btn.lg {
  min-width: 64px;
  min-height: 64px;
  font-size: 28px;
}

.icon-play {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  font-size: 36px;
  color: #fff;
  background: linear-gradient(180deg, #ffb347, #ff8c42);
  box-shadow: 0 8px 0 #d96a28;
}

.icon-play:active,
.icon-btn:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 rgba(201, 138, 62, 0.28);
}

.progress-pill {
  margin: 0;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  font-size: 17px;
  font-weight: 800;
}

.play {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 72px 14px 16px;
}

.jamo {
  margin: 0 0 6px;
  font-family: var(--edu-font);
  font-weight: 900;
  font-size: clamp(72px, 22vw, 108px);
  line-height: 1;
  color: #c94a16;
  text-shadow: 0 3px 0 #fff;
}

.prompt {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.choices {
  flex: 1;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-content: start;
}

.choices.letters {
  grid-template-columns: repeat(2, 1fr);
  align-content: center;
  gap: 10px;
}

.choices.words {
  align-content: center;
}

.choice {
  appearance: none;
  border: 4px solid rgba(255, 255, 255, 0.9);
  border-radius: 22px;
  min-height: 96px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 6px 0 rgba(201, 138, 62, 0.22);
  cursor: pointer;
  font-family: inherit;
  color: inherit;
}

.choice img {
  width: 78px;
  height: 78px;
  flex: none;
}

.choice .word {
  font-size: 22px;
  color: var(--ink);
}

.choice.letter {
  min-height: 88px;
  font-family: var(--edu-font);
  font-weight: 900;
  font-size: clamp(36px, 11vw, 48px);
  color: #c94a16;
}

.choice:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 rgba(201, 138, 62, 0.22);
}

.choice.correct {
  animation: bounce 0.7s ease;
  border-color: #6fd6b0;
  background: #e8fff4;
}

.choice.hint {
  animation: glow 0.9s ease-in-out infinite;
}

.choice.shake {
  animation: shake 0.35s ease;
}

.speaker {
  appearance: none;
  border: 0;
  width: 120px;
  height: 120px;
  margin: 8px 0 16px;
  border-radius: 50%;
  font-size: 56px;
  background: linear-gradient(180deg, #fff, #ffe27a);
  box-shadow: 0 8px 0 rgba(201, 138, 62, 0.28);
  cursor: pointer;
}

.speaker:active {
  transform: translateY(4px);
  box-shadow: 0 4px 0 rgba(201, 138, 62, 0.28);
}

.speaker.hint {
  animation: glow 0.9s ease-in-out infinite;
}

.picture {
  width: 120px;
  height: 120px;
  margin: 4px 0 10px;
  object-fit: contain;
}

.picture[hidden] {
  display: none;
}

.picture.bounce {
  animation: bounce 0.7s ease;
}

.blank-word {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  font-family: var(--edu-font);
  font-weight: 900;
  font-size: clamp(36px, 11vw, 48px);
  color: #c94a16;
}

.blank-word .slot-syl {
  min-width: 48px;
  text-align: center;
  border-bottom: 5px solid #c98a3e;
  line-height: 1.1;
}

.blank-word .slot-syl.empty {
  color: transparent;
}

.drop-pad {
  width: 88%;
  min-height: 140px;
  margin: 8px 0 12px;
  border-radius: 28px;
  border: 4px dashed rgba(201, 138, 62, 0.45);
  background: rgba(255, 255, 255, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--edu-font);
  font-weight: 900;
  font-size: 56px;
  color: #c94a16;
}

.drop-pad.ready {
  border-style: solid;
  background: #e8fff4;
  animation: pop 0.45s ease;
}

.blocks {
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: auto;
  padding-bottom: 8px;
}

.block {
  min-width: 72px;
  min-height: 72px;
  border-radius: 18px;
  border: 4px solid #fff;
  background: #ffe27a;
  box-shadow: 0 6px 0 rgba(201, 138, 62, 0.28);
  font-family: var(--edu-font);
  font-weight: 900;
  font-size: 36px;
  color: #4a3728;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  cursor: grab;
}

.block.jung {
  background: #b8f0d0;
}

.block.jong {
  background: #ffd4c4;
}

.block.ghost {
  opacity: 0.35;
}

.block.dragging {
  position: fixed;
  z-index: 8;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1.08);
}

.hint-line {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}

.assoc {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.assoc.show {
  display: flex;
  animation: pop 0.45s ease;
}

.assoc img {
  width: 88px;
  height: 88px;
}

.assoc span {
  font-size: 20px;
}

.mem-grid {
  flex: 1;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  align-content: center;
}

.mem-card {
  appearance: none;
  border: 4px solid rgba(255, 255, 255, 0.9);
  border-radius: 16px;
  min-height: 92px;
  padding: 6px;
  background: #ffb347;
  box-shadow: 0 5px 0 rgba(201, 138, 62, 0.28);
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mem-card .face {
  display: none;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.mem-card.open,
.mem-card.matched {
  background: rgba(255, 255, 255, 0.94);
}

.mem-card.open .face,
.mem-card.matched .face {
  display: flex;
}

.mem-card.matched {
  animation: pop 0.4s ease;
  border-color: #6fd6b0;
  pointer-events: none;
}

.mem-card img {
  width: 54px;
  height: 54px;
}

.mem-card .word {
  font-size: 18px;
  text-align: center;
  line-height: 1.15;
}

.mem-card.shake {
  animation: shake 0.35s ease;
}

.mem-grid.pairs-5 {
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}

.mem-grid.pairs-5 .mem-card {
  min-height: 78px;
  padding: 4px;
}

.mem-grid.pairs-5 .mem-card img {
  width: 42px;
  height: 42px;
}

.mem-grid.pairs-5 .mem-card .word {
  font-size: 15px;
  margin-top: 2px;
}

.sent-hero {
  width: 92px;
  height: 92px;
  object-fit: contain;
  margin: 0 0 6px;
}

.sent-hero.bounce {
  animation: bounce 0.7s ease;
}

.sent-line {
  min-height: 28px;
  margin: 0 0 8px;
  font-size: 20px;
  color: #c94a16;
  text-align: center;
}

.sent-slots {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.sent-slot {
  min-height: 118px;
  padding: 6px 4px;
  border-radius: 18px;
  border: 4px dashed rgba(201, 138, 62, 0.45);
  background: rgba(255, 255, 255, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.sent-slot.filled {
  border-style: solid;
  background: rgba(255, 255, 255, 0.94);
}

.sent-slot.ready {
  border-color: #6fd6b0;
  background: #e8fff4;
  animation: pop 0.45s ease;
}

.sent-slot.shake {
  animation: shake 0.35s ease;
}

.sent-slot img {
  width: 48px;
  height: 48px;
  background: #fff8e8;
  border-radius: 12px;
}

.sent-slot .word,
.sent-chunk .word {
  font-size: 16px;
  line-height: 1.15;
  text-align: center;
}

.sent-chunks {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}

.sent-chunk {
  appearance: none;
  border: 4px solid #fff;
  border-radius: 18px;
  min-height: 68px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #ffe27a;
  box-shadow: 0 5px 0 rgba(201, 138, 62, 0.28);
  font-family: inherit;
  color: inherit;
  touch-action: none;
  cursor: grab;
}

.sent-chunk img {
  width: 46px;
  height: 46px;
  flex: none;
  background: #fff8e8;
  border-radius: 12px;
}

.sent-chunk.ghost {
  opacity: 0.28;
  pointer-events: none;
}

.sent-chunk.dragging {
  position: fixed;
  z-index: 8;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1.06);
}

.sent-chunk:nth-child(2) {
  background: #b8f0d0;
}

.sent-chunk:nth-child(3) {
  background: #ffd4c4;
}

@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@keyframes glow {
  0%, 100% { box-shadow: 0 6px 0 rgba(201, 138, 62, 0.22), 0 0 0 0 rgba(255, 179, 71, 0.7); }
  50% { box-shadow: 0 6px 0 rgba(201, 138, 62, 0.22), 0 0 0 8px rgba(255, 179, 71, 0.25); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-14px) scale(1.08); }
  55% { transform: translateY(0) scale(1); }
  75% { transform: translateY(-7px); }
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px 18px;
  text-align: center;
  background: rgba(255, 248, 230, 0.94);
}

.overlay.hidden {
  display: none;
}

.badge {
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: #ffe27a;
  font-size: 14px;
}

.badge.soft {
  background: #b8f0d0;
}

.hero {
  width: 140px;
  height: 140px;
}

.hero.small {
  width: 110px;
  height: 110px;
}

h1, h2,
.edu-play h1,
.edu-play h2,
.edu-play .overlay h1,
.edu-play .overlay h2 {
  margin: 0;
  font-family: var(--edu-font) !important;
  font-weight: 900 !important;
  font-size: 34px;
}

.lead,
.learned {
  margin: 0;
  font-size: 18px;
  line-height: 1.4;
}

.learned {
  font-size: 28px;
  color: #c94a16;
}

.parent-note {
  margin: 0;
  max-width: 280px;
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  line-height: 1.5;
}

.done-actions {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-top: 8px;
}

.home-link {
  margin-top: 6px;
  font-size: 28px;
  text-decoration: none;
}

.play-trace {
  padding-bottom: 10px;
}

.trace-wrap {
  position: relative;
  width: 88%;
  aspect-ratio: 1;
  max-height: 44%;
  flex: 0 0 auto;
  border-radius: 22px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.78);
  border: 4px dashed rgba(201, 138, 62, 0.4);
  touch-action: none;
}

.trace-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.trace-wrap #guide-canvas {
  z-index: 1;
}

.trace-wrap #draw-canvas {
  z-index: 2;
}

.trace-pop {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 72px;
  pointer-events: none;
  z-index: 3;
}

.trace-pop[hidden] {
  display: none;
}

.trace-pop.show {
  animation: pop 0.65s ease;
}

.trace-tools {
  display: flex;
  gap: 8px;
  width: 88%;
  margin: 8px 0 4px;
}

.trace-tools .icon-btn {
  flex: 1;
  min-height: 48px;
  font-size: 16px;
}

.trace-tools .trace-done {
  background: #b8f0d0;
}

.picker-label {
  margin: 4px 0 6px;
  font-size: 13px;
  color: var(--muted);
}

.trace-picker {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}

.trace-letter {
  appearance: none;
  aspect-ratio: 1;
  border: 3px solid #fff;
  border-radius: 10px;
  background: #ffe27a;
  box-shadow: 0 3px 0 rgba(201, 138, 62, 0.22);
  font-family: var(--edu-font);
  font-weight: 900;
  font-size: 15px;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
}

.trace-letter.on {
  background: #b8f0d0;
  border-color: #6fd6b0;
}

.trace-letter.done {
  opacity: 0.42;
}

.trace-letter:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(201, 138, 62, 0.22);
}
