* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --ink: #4a3b35; --cream: #fff8ee; --mint: #8fd9b6; --mint-d: #3e9e76;
  --red: #e5664f; --soft: #f3e9dc;
}
html, body { height: 100%; background: #efe4d4; }
body {
  font-family: -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  color: var(--ink); user-select: none; overflow: hidden;
}
#app { max-width: 420px; height: 100%; margin: 0 auto; display: flex; flex-direction: column; background: var(--cream); }
svg { display: block; width: 100%; height: 100%; overflow: visible; }

/* 위쪽 점수판 */
.hud { display: flex; gap: 6px; padding: 8px 10px 6px; }
.hud-box { flex: 1; background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: 4px 6px; text-align: center; }
.hud-label { display: block; font-size: 11px; opacity: .7; }
.hud-box b { font-size: 18px; }
.pile-box.warn { background: #ffe1da; }
.pile-box.warn b { color: var(--red); }

/* 집 장면 */
.scene {
  position: relative; flex: 1 1 auto; min-height: 210px; margin: 0 10px; border: 2px solid var(--ink); border-radius: 18px;
  background: linear-gradient(#fdf3e3 0 62%, #e8cfae 62% 100%); overflow: hidden; transition: filter .4s;
}
.scene::after { /* 바닥 무늬 */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 38%;
  background: repeating-linear-gradient(90deg, transparent 0 38px, rgba(74,59,53,.08) 38px 40px);
}
.window { position: absolute; left: 14px; top: 16px; width: 64px; height: 52px; border: 2px solid var(--ink); border-radius: 8px;
  background: linear-gradient(#cfeefc, #eaf8ff); }
.window::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; border-left: 2px solid var(--ink); }
.shelf { position: absolute; right: 14px; top: 30px; width: 74px; height: 8px; border: 2px solid var(--ink); border-radius: 4px; background: #d9b48a; }
.shelf::before { content: ""; position: absolute; left: 8px; bottom: 8px; width: 16px; height: 20px; border: 2px solid var(--ink); border-radius: 4px 4px 2px 2px; background: #9fe0c0; }
.shelf::after { content: ""; position: absolute; right: 10px; bottom: 8px; width: 22px; height: 14px; border: 2px solid var(--ink); border-radius: 50% 50% 4px 4px; background: #ffd27a; }
.dirt { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.dirt i { position: absolute; border-radius: 50%; background: rgba(120, 90, 60, .22); transition: opacity .6s; }
.scene.messy-3 { filter: saturate(.8); }
.scene.messy-4 { filter: saturate(.6) brightness(.96); }

.pile { position: absolute; left: 8px; bottom: 6px; width: 110px; height: 90px; z-index: 2; }
.pile .junk { position: absolute; width: 44px; height: 44px; animation: drop .45s ease-out; }
@keyframes drop { from { transform: translateY(-120px) rotate(0); opacity: 0; } }

.timer { position: absolute; left: 12px; right: 12px; top: 8px; height: 6px; border-radius: 3px; background: rgba(74,59,53,.12); z-index: 3; }
.timer-bar { height: 100%; width: 100%; border-radius: 3px; background: var(--mint-d); transform-origin: left; }
.timer-bar.low { background: var(--red); }

.item-wrap { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -46%); width: 170px; text-align: center; z-index: 4; }
.item-name { display: inline-block; font-size: 14px; font-weight: 700; background: #fff; border: 2px solid var(--ink); border-radius: 999px; padding: 2px 10px; margin-bottom: 2px; white-space: nowrap; }
.item { width: 150px; height: 150px; margin: 0 auto; cursor: pointer; }
.item.in { animation: popin .35s ease-out; }
.item.shake { animation: shake .4s; }
.item.wobble { animation: wobble .3s; }
.item.fly { animation: fly .55s ease-in forwards; }
.item.fall { animation: fall .55s ease-in forwards; }
@keyframes popin { from { transform: scale(.3) translateY(40px); opacity: 0; } 70% { transform: scale(1.08); } }
@keyframes shake { 20%,60% { transform: translateX(-10px) rotate(-5deg); } 40%,80% { transform: translateX(10px) rotate(5deg); } }
@keyframes wobble { 30% { transform: rotate(-14deg) scale(1.05); } 70% { transform: rotate(12deg) scale(1.05); } }
@keyframes fly { to { transform: translateY(260px) scale(.2); opacity: 0; } }
@keyframes fall { to { transform: translate(-90px, 70px) scale(.35) rotate(-30deg); opacity: 0; } }

.todo { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin-top: 2px; min-height: 22px; }
.todo span { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: #fff; border: 1.5px dashed rgba(74,59,53,.5); }
.todo span.done { background: var(--mint); border: 1.5px solid var(--ink); }
.todo span.region { background: #fff1c9; border: 1.5px solid #d7a93a; }
.scrub { font-size: 13px; font-weight: 700; color: #2b7fae; margin-top: 2px; }

/* 효과 */
.fx { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.bubbleFx { position: absolute; border-radius: 50%; border: 2px solid #7cc4e8; background: rgba(255,255,255,.75); animation: rise 1s ease-out forwards; }
@keyframes rise { to { transform: translateY(-70px) scale(1.4); opacity: 0; } }
.spark { position: absolute; width: 14px; height: 14px; animation: spark .8s ease-out forwards; }
.spark::before, .spark::after { content: ""; position: absolute; left: 6px; top: 0; width: 2px; height: 14px; background: #ffc93c; border-radius: 1px; }
.spark::after { transform: rotate(90deg); }
@keyframes spark { from { transform: translate(0,0) scale(.4); opacity: 1; } to { transform: translate(var(--dx), var(--dy)) scale(1.3) rotate(90deg); opacity: 0; } }
.plus { position: absolute; left: 50%; top: 24%; transform: translateX(-50%); font-size: 26px; font-weight: 900; color: var(--mint-d);
  text-shadow: 0 2px 0 #fff, 0 -2px 0 #fff, 2px 0 0 #fff, -2px 0 0 #fff; animation: plus 1s ease-out forwards; white-space: nowrap; }
.plus.soft { color: #e08a3c; font-size: 22px; }
@keyframes plus { to { transform: translate(-50%, -50px); opacity: 0; } }
.shine { position: absolute; inset: 0; background: radial-gradient(circle at 50% 50%, rgba(255,255,255,.9), transparent 60%); animation: shine .6s ease-out forwards; }
@keyframes shine { from { opacity: 1; } to { opacity: 0; } }

/* 통이와 말풍선 */
.talk { display: flex; align-items: center; gap: 6px; padding: 6px 10px 2px; }
.mascot { width: 54px; height: 54px; flex: none; }
.mascot.bounce { animation: wobble .4s; }
.bubble { flex: 1; position: relative; background: #fff; border: 2px solid var(--ink); border-radius: 14px; padding: 7px 10px; font-size: 14.5px; line-height: 1.4; min-height: 46px; display: flex; align-items: center; }
.bubble::before { content: ""; position: absolute; left: -9px; top: 50%; margin-top: -6px; border: 6px solid transparent; border-right: 8px solid var(--ink); border-left: 0; }
.bubble.bad { background: #ffe9e4; }
.bubble.good { background: #e6f8ee; }
.bubble .tag { display: inline-block; font-size: 11px; font-weight: 700; background: #fff1c9; border: 1.5px solid #d7a93a; border-radius: 6px; padding: 0 5px; margin-left: 4px; }

/* 아래 버튼 */
.panel { padding: 4px 10px 10px; }
.panel-title { font-size: 12px; font-weight: 700; margin: 4px 2px 4px; opacity: .8; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.act { display: flex; align-items: center; justify-content: center; gap: 4px; height: 50px; padding: 0 4px; font: inherit; font-size: 15px; white-space: nowrap; letter-spacing: -0.3px; font-weight: 700; color: var(--ink);
  background: #fff; border: 2px solid var(--ink); border-radius: 12px; box-shadow: 0 3px 0 var(--ink); cursor: pointer; }
.act i { width: 26px; height: 26px; flex: none; }
.act:active { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
.act.used { background: var(--mint); }
.bins { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.bin { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 66px; padding: 3px 2px 5px; font: inherit; font-size: 13px; letter-spacing: -0.4px; font-weight: 700; color: var(--ink);
  background: #fff; border: 2px solid var(--ink); border-radius: 12px; box-shadow: 0 3px 0 var(--ink); cursor: pointer; line-height: 1.15; }
.bin i { width: 36px; height: 36px; }
.bin:active { transform: translateY(3px); box-shadow: none; }
.bin.hit .lid { transform: rotate(-25deg); transform-origin: 8px 14px; }
.bin.ok { background: #e6f8ee; }
.bin.no { background: #ffe1da; animation: shake .4s; }

/* 시작/끝 화면 */
.overlay { position: fixed; inset: 0; background: rgba(74,59,53,.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.overlay.hidden { display: none; }
.card { width: 100%; max-width: 340px; max-height: 100%; overflow: auto; background: var(--cream); border: 3px solid var(--ink); border-radius: 22px; padding: 16px 16px 18px; text-align: center; }
.big-mascot { width: 96px; height: 96px; margin: 0 auto 4px; }
.card h1 { font-size: 24px; }
.sub { font-size: 14px; opacity: .75; margin: 2px 0 10px; }
.how { text-align: left; font-size: 16px; line-height: 1.5; padding-left: 22px; margin-bottom: 14px; }
.how li { margin: 3px 0; }
.btn-main { width: 100%; height: 50px; font: inherit; font-size: 18px; font-weight: 800; color: #fff; background: var(--mint-d); border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 4px 0 var(--ink); cursor: pointer; }
.btn-main:active { transform: translateY(4px); box-shadow: none; }
.note { font-size: 11px; opacity: .6; margin-top: 10px; }
.end-score { background: #fff; border: 2px solid var(--ink); border-radius: 14px; padding: 6px; margin: 8px 0; }
.end-score span { display: block; font-size: 12px; opacity: .7; }
.end-score b { font-size: 34px; color: var(--mint-d); }
.end-stats { display: flex; gap: 6px; margin-bottom: 8px; }
.end-stats div { flex: 1; background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: 4px; font-size: 12px; }
.end-stats b { display: block; font-size: 18px; }
.learn { text-align: left; font-size: 13px; line-height: 1.45; margin-bottom: 12px; }
.learn h3 { font-size: 14px; margin: 6px 0 4px; }
.learn li { list-style: none; background: #fff; border: 1.5px solid rgba(74,59,53,.35); border-radius: 10px; padding: 6px 8px; margin-bottom: 5px; }
.learn li b { display: block; }

/* 스크린샷 모드: 움직임 멈춤 */
body.shot *, body.shot *::before, body.shot *::after { animation: none !important; transition: none !important; }

/* 큰 글씨·큰 버튼 (초등학생 눈높이) */
.panel-title { font-size: 13.5px; }
.item-name { font-size: 15px; }
.todo span { font-size: 12.5px; padding: 3px 8px; }
.edition { display: inline-block; font-size: 12px; font-weight: 700; color: var(--mint-d); background: #e6f8ee; border: 1.5px solid var(--mint-d); border-radius: 999px; padding: 2px 10px; margin-bottom: 10px; }

/* 틀렸을 때 '이렇게 하면 돼요' 카드 */
.hint-wrap { position: fixed; inset: 0; z-index: 40; background: rgba(74,59,53,.35); display: flex; align-items: center; justify-content: center; padding: 14px; }
.hint-wrap.hidden { display: none; }
.hint { width: 100%; max-width: 360px; background: #fff;
  border: 3px solid var(--ink); border-radius: 18px; padding: 12px 14px 14px; box-shadow: 0 6px 0 rgba(74,59,53,.25); animation: popin .3s ease-out; }
.hint-head { font-size: 19px; font-weight: 900; color: var(--mint-d); margin-bottom: 4px; }
.hint p { font-size: 15px; line-height: 1.45; margin: 4px 0; }
.hint-what { font-size: 14px !important; opacity: .75; }
.hint-how { font-weight: 800; }
.hint-why { background: #f1f8ff; border-radius: 10px; padding: 5px 8px; }
.hint-tip { font-size: 13.5px !important; background: #fff6e0; border-radius: 10px; padding: 5px 8px; }
.hint-tip.is-region::before { content: "지역마다 달라요 · "; font-weight: 800; color: #b5851d; }
.hint-tip.hidden { display: none; }
.hint-btn { width: 100%; height: 50px; margin-top: 8px; font: inherit; font-size: 17px; font-weight: 800; color: #fff; background: var(--mint-d);
  border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 4px 0 var(--ink); cursor: pointer; }
.hint-btn:active { transform: translateY(4px); box-shadow: none; }
.learn .why { display: block; font-size: 12.5px; opacity: .8; margin-top: 2px; }

/* ---------- 9개 손질 · 9개 통 (3줄씩) ---------- */
.act { height: 44px; font-size: 14.5px; }
.act i { width: 24px; height: 24px; }
.bins { grid-template-columns: repeat(3, 1fr); }
.bin { flex-direction: row; gap: 4px; min-height: 46px; font-size: 14px; padding: 2px 4px; }
.bin i { width: 30px; height: 30px; flex: none; }
.act.demo, .bin.demo { outline: 4px solid #ffc93c; outline-offset: 1px; animation: pulse .6s infinite alternate; }
@keyframes pulse { to { transform: scale(1.05); } }

/* ---------- 말끔이 (게임판) ---------- */
.ed-game .item-wrap { left: 44%; }
.person { position: absolute; right: 4px; bottom: 4px; width: 74px; height: 111px; z-index: 3; pointer-events: none; }
.person.hidden { display: none; }
.person .arm { transform-box: view-box; transition: transform .25s; }
.person .arm-l { transform-origin: 30px 72px; }
.person .arm-r { transform-origin: 70px 72px; }
.person .head { transform-box: view-box; transform-origin: 50px 64px; transition: transform .25s; }
.person.p-idle { animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: translateY(-2px); } }
.person.p-scrub .arm-l { animation: scrubL .18s infinite alternate; }
.person.p-scrub .arm-r { animation: scrubR .18s infinite alternate; }
@keyframes scrubL { from { transform: rotate(10deg); } to { transform: rotate(60deg); } }
@keyframes scrubR { from { transform: rotate(-10deg); } to { transform: rotate(-60deg); } }
.person.p-pour .arm-l { transform: rotate(80deg); }
.person.p-pour .head { transform: rotate(-8deg); }
.person.p-peel .arm-l { transform: rotate(70deg); }
.person.p-peel .arm-r { animation: peel .3s 2 alternate; transform: rotate(-40deg); }
@keyframes peel { to { transform: rotate(-90deg); } }
.person.p-toss .arm-l { transform: rotate(120deg); }
.person.p-toss { animation: hop .35s; }
.person.p-cheer .arm-l { transform: rotate(150deg); }
.person.p-cheer .arm-r { transform: rotate(-150deg); }
.person.p-cheer { animation: hop .4s 2; }
@keyframes hop { 50% { transform: translateY(-8px); } }
.person.p-think .head { transform: rotate(10deg); }
.person.p-think .arm-r { transform: rotate(-130deg); }

/* ---------- 꿀팁 · 피버 ---------- */
.tipbar { position: absolute; left: 8px; right: 8px; top: 20px; z-index: 6; display: flex; gap: 6px; align-items: flex-start;
  background: #fffbe6; border: 2px solid #d7a93a; border-radius: 12px; padding: 5px 8px; font-size: 12.5px; line-height: 1.4; }
.tipbar.hidden { display: none; }
.tipbar.show { animation: popin .3s ease-out; }
.tipbar b { flex: none; background: #ffc93c; color: var(--ink); border-radius: 6px; padding: 0 5px; font-size: 11.5px; }
.fever-tag { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); z-index: 6; font-weight: 900; font-size: 14px;
  color: #fff; background: #e5664f; border: 2px solid var(--ink); border-radius: 999px; padding: 2px 12px; animation: pulse .5s infinite alternate; }
.fever-tag.hidden { display: none; }
.scene.fever { box-shadow: inset 0 0 0 4px #ffc93c, inset 0 0 30px rgba(255, 201, 60, .6); }
.ed-game .fever-tag { left: 44%; }
.demo-btn { background: #ffc93c; color: var(--ink); }
.best { font-weight: 800; color: #e5664f; margin-top: 2px; }
.best.hidden { display: none; }
.bin { flex-direction: column; gap: 0; min-height: 50px; font-size: 13px; white-space: nowrap; letter-spacing: -0.5px; padding: 2px 2px 4px; }
.bin i { width: 26px; height: 26px; }

/* 휴대폰에서 빠르게 톡톡 눌러도 화면이 확대되지 않게 */
button, .item { touch-action: manipulation; }

/* 좁은 화면(퍼플라이트 페이지 안 iframe, 작은 휴대폰)에서도 옆으로 밀리지 않게 */
.actions > *, .bins > * { min-width: 0; overflow: hidden; }
@media (max-width: 370px) {
  .act { font-size: 13px; gap: 2px; padding: 0 2px; letter-spacing: -0.6px; }
  .act i { width: 20px; height: 20px; }
  .bin { font-size: 12px; }
  .panel { padding-left: 8px; padding-right: 8px; }
}
@media (max-width: 330px) {
  .act { font-size: 12px; }
  .act i { display: none; }
  .hud-box b { font-size: 16px; }
}

/* 화면이 낮으면(작은 휴대폰, 낮은 iframe) 잘리지 않고 아래로 내려 볼 수 있게 */
body { overflow-x: hidden; overflow-y: auto; }
#app { height: auto; min-height: 100%; }
.scene { min-height: 220px; }
