:root {
  --bg: #fff8ec;
  --ink: #33415c;
  --muted: #7a8499;
  --coral: #ff8a65;
  --coral-d: #e8684a;
  --mint: #4cc9a6;
  --mint-d: #2fa886;
  --sky: #5aa9f0;
  --sky-d: #3b8bd6;
  --sun: #ffc94d;
  --card: #ffffff;
  --line: #f1dcc8;
  --shadow: 0 6px 0 rgba(51, 65, 92, 0.12);
  --r: 22px;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: clamp(16px, 1.6vw, 22px);
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}
#app { min-height: 100%; padding: 16px clamp(16px, 3vw, 40px) 32px; max-width: 1280px; margin: 0 auto; }
button { font: inherit; color: inherit; border: none; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
.locked { pointer-events: none; }

/* ── 위쪽 막대 ── */
.bar { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; flex-wrap: wrap; }
.home-btn { width: 64px; height: 64px; border-radius: 20px; background: var(--card); box-shadow: var(--shadow); font-size: 30px; }
.home-btn:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(51, 65, 92, 0.12); }
.bar-title { font-weight: 800; font-size: 1.15em; }
.dots { display: flex; gap: 8px; margin-left: auto; }
.dot { width: 16px; height: 16px; border-radius: 50%; background: #eadfd3; }
.dot.done { background: var(--mint); }
.dot.now { background: var(--coral); transform: scale(1.25); }
.star-count { background: var(--card); border-radius: 999px; padding: 8px 18px; box-shadow: var(--shadow); font-size: 1.1em; }
.dots + .star-count { margin-left: 8px; }
.bar-title + .star-count { margin-left: auto; }
.star-count.bump { animation: bump 0.5s; }
@keyframes bump { 50% { transform: scale(1.3); } }

/* ── 첫 화면 ── */
.home { display: flex; flex-direction: column; align-items: center; gap: 12px; min-height: calc(100vh - 48px); justify-content: center; }
.home-head { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.logo { font-weight: 900; font-size: clamp(26px, 3.4vw, 42px); color: var(--coral-d); padding: 6px 4px; border-radius: 14px; transition: background 3s linear; }
.logo.pressing { background: linear-gradient(90deg, #ffe1d6, #ffe1d6) no-repeat; }
.sticker-chip { background: var(--card); border-radius: 999px; padding: 12px 22px; box-shadow: var(--shadow); font-size: 1.05em; }
.hello { font-size: clamp(22px, 2.6vw, 32px); font-weight: 700; margin: 18px 0 6px; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(14px, 2vw, 28px); width: 100%; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: clamp(22px, 3vw, 40px) 12px; border-radius: 32px; color: #fff; box-shadow: 0 10px 0 rgba(0, 0, 0, 0.14); }
.tile:active { transform: translateY(6px); box-shadow: 0 4px 0 rgba(0, 0, 0, 0.14); }
.t-dict { background: var(--coral); }
.t-trace { background: var(--sky); }
.t-math { background: var(--mint); }
.tile-ico { font-size: clamp(56px, 7vw, 92px); line-height: 1.1; }
.tile-name { font-size: clamp(26px, 3vw, 40px); font-weight: 900; }
.tile-sub { font-size: 0.95em; opacity: 0.92; }
.next-sticker { color: var(--muted); margin: 14px 0 0; text-align: center; }

/* ── 문제 화면 ── */
.play { display: flex; flex-direction: column; gap: 14px; position: relative; }
.listen { display: flex; align-items: center; justify-content: center; gap: 22px; margin: 4px 0; }
.speaker { width: clamp(96px, 11vw, 136px); height: clamp(96px, 11vw, 136px); border-radius: 50%; background: var(--sun); font-size: clamp(44px, 5vw, 64px); box-shadow: 0 8px 0 #e0a82a; }
.speaker:active { transform: translateY(5px); box-shadow: 0 3px 0 #e0a82a; }
.speaker.small { width: 76px; height: 76px; font-size: 36px; box-shadow: 0 6px 0 #e0a82a; flex: none; }
.listen-help { font-size: 1.25em; font-weight: 700; line-height: 1.4; }
.msg { text-align: center; font-size: 1.35em; font-weight: 700; min-height: 1.6em; margin: 0; }
.msg.soft { color: var(--coral-d); }

.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: clamp(12px, 2vw, 22px); }
.card { background: var(--card); border: 4px solid var(--line); border-radius: var(--r); padding: clamp(18px, 2.6vw, 34px) 8px; font-size: clamp(36px, 5vw, 64px); font-weight: 800; box-shadow: var(--shadow); }
.card:active { transform: translateY(3px); }
.card.right { background: #e3f8f1; border-color: var(--mint); color: var(--mint-d); animation: pop 0.45s; }
.card.off { opacity: 0.35; transform: scale(0.96); }
@keyframes pop { 40% { transform: scale(1.08); } }

.boxes { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.box { width: clamp(70px, 9vw, 110px); height: clamp(70px, 9vw, 110px); background: var(--card); border: 4px solid var(--line); border-radius: 18px; display: grid; place-items: center; font-size: clamp(40px, 5.6vw, 70px); font-weight: 800; }
.box.now { border-color: var(--coral); animation: blink 1.2s infinite; }
@keyframes blink { 50% { border-color: var(--line); } }
.pad { display: grid; grid-template-columns: auto auto; gap: 8px clamp(16px, 3vw, 40px); justify-content: center; }
.pad-part { display: flex; flex-direction: column; gap: 8px; }
.pad-part .krow { flex-wrap: nowrap; justify-content: flex-start; }
.pad .key:not(.act) { min-width: clamp(44px, 5.2vw, 76px); height: clamp(46px, 10vh, 76px); }
.pad .key.act { height: clamp(50px, 9vh, 68px); }
.pad .acts { grid-column: 1 / -1; margin-top: 4px; }
.play.keypad { gap: 10px; }
.play.keypad .listen { margin: 0; }
.play.keypad .speaker { width: 84px; height: 84px; font-size: 40px; }
.play.keypad .msg { min-height: 1.2em; }
.krow { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.key { min-width: clamp(52px, 6.4vw, 78px); height: clamp(52px, 6.4vw, 72px); border-radius: 16px; font-size: clamp(24px, 3vw, 36px); font-weight: 800; box-shadow: 0 5px 0 rgba(0, 0, 0, 0.12); }
.key:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12); }
.key.c { background: #ffe1d6; color: #b5462c; }
.key.v { background: #dbeeff; color: #23609c; }
.key.small { font-size: clamp(20px, 2.4vw, 30px); }
.key.act { padding: 0 26px; font-size: clamp(20px, 2.2vw, 28px); }
.key.del { background: #eee6dd; }
.key.ok { background: var(--mint); color: #fff; }

.big-btn { border-radius: 18px; padding: 16px 30px; font-size: 1.25em; font-weight: 800; box-shadow: var(--shadow); }
.big-btn:active { transform: translateY(3px); }
.big-btn.ok { background: var(--mint); color: #fff; }
.big-btn.soft { background: var(--card); }
.big-btn.inline { padding: 10px 22px; font-size: 1em; margin-left: 8px; }
.big-btn:disabled { opacity: 0.4; }

.reveal { position: absolute; inset: 70px 0 auto; margin: auto; max-width: 560px; background: var(--card); border-radius: 28px; padding: 26px; text-align: center; box-shadow: 0 16px 40px rgba(51, 65, 92, 0.25); border: 4px solid var(--sun); z-index: 5; }
.reveal p { margin: 0; font-size: 1.2em; color: var(--muted); }
.reveal-word { font-size: clamp(56px, 8vw, 96px); font-weight: 900; color: var(--coral-d); margin: 6px 0 16px; }
.reveal-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

/* ── 따라 쓰기 ── */
.trace-wrap { display: flex; justify-content: center; }
.trace-canvas { touch-action: none; border-radius: 12px; }
.trace-actions { display: flex; gap: 16px; justify-content: center; align-items: center; flex-wrap: wrap; }
.trace-actions .msg { width: 100%; }

/* ── 셈하기 ── */
.q-line { display: flex; align-items: center; justify-content: center; gap: 20px; }
.q-text { font-size: clamp(34px, 5vw, 64px); font-weight: 900; letter-spacing: 0.02em; }
.pic { display: flex; justify-content: center; }
.frames { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.frame { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; background: #fff; border: 3px solid var(--line); border-radius: 14px; padding: 6px; }
.cell { width: clamp(36px, 4.4vw, 54px); height: clamp(36px, 4.4vw, 54px); border-radius: 10px; background: #fdf3e7; display: grid; place-items: center; font-size: clamp(24px, 3.2vw, 38px); position: relative; }
.cell.gone { opacity: 0.35; }
.cell.gone::after { content: "✕"; position: absolute; color: #e8684a; font-weight: 900; font-size: 1.1em; opacity: 1; }
.sum-pic { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center; }
.op { font-size: 48px; font-weight: 900; color: var(--coral-d); }
.nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(10px, 1.6vw, 20px); }
.num { background: var(--card); border: 4px solid var(--line); border-radius: var(--r); padding: clamp(14px, 2vw, 26px) 0; font-size: clamp(38px, 5vw, 64px); font-weight: 900; box-shadow: var(--shadow); }
.num.right, .num.show { background: #e3f8f1; border-color: var(--mint); color: var(--mint-d); animation: pop 0.45s; }
.num.off { opacity: 0.35; }

/* ── 별 터지기 ── */
.burst { position: fixed; left: 50%; top: 45%; font-size: 150px; transform: translate(-50%, -50%); pointer-events: none; animation: burst 1.1s ease-out forwards; z-index: 20; }
@keyframes burst {
  0% { transform: translate(-50%, -50%) scale(0.2); opacity: 0; }
  30% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
  100% { transform: translate(-50%, -160%) scale(0.6); opacity: 0; }
}

/* ── 끝 화면 · 스티커판 ── */
.result { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; min-height: calc(100vh - 48px); gap: 6px; }
.result-emoji { font-size: 110px; animation: pop 0.8s; }
.result h1 { font-size: clamp(36px, 5vw, 60px); margin: 0; }
.result-score { font-size: 1.4em; margin: 6px 0 12px; }
.result-score b { color: var(--coral-d); font-size: 1.3em; }
.new-sticker { background: var(--card); border-radius: 26px; padding: 16px 34px; box-shadow: var(--shadow); margin-bottom: 14px; }
.new-sticker p { margin: 0; font-weight: 800; }
.stk-big { font-size: 80px; }
.result-actions { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(72px, 9vw, 110px), 1fr)); gap: 12px; margin-top: 10px; }
.slot { aspect-ratio: 1; border-radius: 22px; border: 4px dashed #ecd9c5; display: grid; place-items: center; font-size: clamp(40px, 5vw, 64px); }
.slot.full { border: 4px solid var(--sun); background: var(--card); box-shadow: var(--shadow); }

/* ── 하루 시간 안내 ── */
.limit { position: fixed; inset: 0; background: #2d3a5c; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; z-index: 50; padding: 24px; }
.limit h1 { font-size: clamp(40px, 6vw, 72px); margin: 10px 0; }
.limit p { font-size: 1.5em; line-height: 1.6; margin: 0; }
.limit-moon { font-size: 130px; border-radius: 50%; padding: 10px; }
.limit-moon.pressing { background: rgba(255, 255, 255, 0.12); }

/* ── 부모님 화면 ── */
.parent { font-size: 17px; user-select: text; -webkit-user-select: text; }
.p-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.p-card { background: var(--card); border-radius: 20px; padding: 18px 20px; box-shadow: var(--shadow); }
.p-card.wide { grid-column: 1 / -1; }
.p-card h2 { margin: 0 0 8px; font-size: 1.2em; }
.p-note { color: var(--muted); font-size: 0.92em; margin: 8px 0; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 4px; border-bottom: 1px solid #f0e6da; }
th { color: var(--muted); font-weight: 600; }
.weak { display: flex; flex-wrap: wrap; gap: 8px; }
.weak-chip { background: #fff1ea; border-radius: 999px; padding: 6px 14px; font-weight: 700; }
.weak-chip small { color: var(--coral-d); }
.set-row { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid #f4ece3; flex-wrap: wrap; }
.set-label { width: 130px; font-weight: 700; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { background: #f5eee6; border-radius: 12px; padding: 10px 16px; }
.seg button.on { background: var(--coral); color: #fff; font-weight: 800; }
.danger { margin-top: 14px; background: #fff; border: 2px solid #e57373; color: #c62828; border-radius: 12px; padding: 10px 18px; }

/* ── 세로 화면 · 좁은 화면 ── */
@media (max-width: 760px) {
  .tiles { grid-template-columns: 1fr; }
  .tile { flex-direction: row; justify-content: flex-start; padding: 30px 28px; gap: 22px; text-align: left; }
  .tile-sub { display: none; }
  .nums { grid-template-columns: repeat(2, 1fr); }
  .p-grid { grid-template-columns: 1fr; }
  .pad { grid-template-columns: auto; }
  .pad .key:not(.act) { min-width: clamp(40px, 11.5vw, 84px); height: clamp(48px, 6.4vh, 76px); }
  .dots { order: 3; width: 100%; justify-content: center; margin: 0; }
  .bar-title + .star-count, .dots + .star-count { margin-left: auto; }
  .listen { gap: 14px; }
}
