/* 글꼴: 동글 (SIL OFL 1.1, fonts/OFL.txt). 앱에 쓰는 글자만 담아 앱 안에 넣었다 — tools/make-font.py */
@font-face {
  font-family: "Dongle";
  src: url("../fonts/dongle.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  --wall: #FFF3DC;
  --wall-hi: #FFF9EE;
  --ink: #3B2A20;
  --ink-soft: #7A604C;
  --surface: #FFFDF7;
  --surface-edge: #E6D4B0;
  --accent: #E8342E;
  --accent-deep: #A91F1A;
  --go: #2FA84F;
  --go-deep: #1D7535;
  --butter: #FFCF1F;
  --display: "Dongle", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--wall);
  color: var(--ink);
  font-family: var(--display);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
img { -webkit-user-drag: none; }

/* 도톰한 단추 (아래 그림자가 눌리면 쏙) */
.chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 20px; border-radius: 18px;
  background: var(--surface); box-shadow: 0 5px 0 var(--surface-edge);
  font-size: 1.2rem; transition: transform .08s, box-shadow .08s;
}
.chip svg { width: 26px; height: 26px; flex: none; }
.chip:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--surface-edge); }
.chip.primary { background: var(--go); color: #fff; box-shadow: 0 5px 0 var(--go-deep); }
.chip.primary:active { box-shadow: 0 1px 0 var(--go-deep); }

/* ── 처음 화면 ─────────────────────────────────────── */
#home {
  min-height: 100%;
  padding: calc(12px + var(--safe-t)) calc(16px + var(--safe-r)) calc(28px + var(--safe-b)) calc(16px + var(--safe-l));
  background:
    radial-gradient(circle at 12px 12px, rgba(232, 180, 90, .16) 5px, transparent 6px) 0 0 / 24px 24px,
    var(--wall);
}
.home-bar { display: flex; justify-content: flex-end; gap: 10px; max-width: 980px; margin: 0 auto; }
.home-bar .chip { min-height: 44px; padding: 0 14px; font-size: 1rem; text-decoration: none; color: inherit; }
#soundBtn .mute { display: none; }
#soundBtn[aria-pressed="false"] .mute { display: inline; }
#soundBtn[aria-pressed="false"] .wave { display: none; }

.cover {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px;
  max-width: 980px; text-align: center; margin: 4px auto 22px;
}
.cover .title { min-width: 0; }
/* 제목 양옆: 시리즈 대표 모형 넷씩, 둥실둥실 */
.side { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; align-items: center; justify-items: center; }
.side-obj {
  width: 100%; max-width: 116px; aspect-ratio: 1; border-radius: 22px; padding: 4px;
  background: rgba(255, 255, 255, .55); box-shadow: 0 4px 0 rgba(230, 212, 176, .8);
  animation: bob 3.2s calc(var(--n) * -0.4s) ease-in-out infinite;
}
.side-obj:nth-child(even) { margin-top: 28px; }
.side-obj img { width: 100%; height: 100%; object-fit: contain; }
.side-obj:active { transform: scale(.94); }
@keyframes bob { 50% { transform: translateY(-7px) rotate(-3deg); } }
@media (max-width: 560px) {
  /* 폰: 양옆에 한 줄로 넷씩 */
  .side { grid-template-columns: 1fr; gap: 4px; }
  .side-obj { max-width: 62px; border-radius: 16px; padding: 2px; }
  .side-obj:nth-child(even) { margin-top: 0; transform: translateX(8px); }
  #sideR .side-obj:nth-child(even) { transform: translateX(-8px); }
  .cover h1 { font-size: clamp(2rem, 9vw, 2.6rem); }
}
.cover h1 { margin: 10px 0 0; font-size: clamp(2.4rem, 9vw, 3.6rem); font-weight: 400; letter-spacing: -.01em; }
.cover p { margin: 4px 0 0; color: var(--ink-soft); font-size: clamp(1rem, 3.6vw, 1.25rem); word-break: keep-all; }

/* 쌓인 블럭 셋으로 된 로고 */
.logo { display: inline-grid; justify-items: center; gap: 0; }
.logo i {
  position: relative; display: block; height: 26px; border-radius: 6px;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .14);
}
.logo i::before {
  content: ""; position: absolute; left: 6px; right: 6px; top: -7px; height: 8px;
  background: radial-gradient(circle at 50% 100%, var(--c) 6px, transparent 6.5px) 0 0 / 20px 16px repeat-x;
}
.logo i:nth-child(1) { --c: #FFCF1F; width: 44px; background: var(--c); animation: drop .5s .5s both cubic-bezier(.3, 1.4, .5, 1); }
.logo i:nth-child(2) { --c: #2D6FE0; width: 84px; background: var(--c); animation: drop .5s .3s both cubic-bezier(.3, 1.4, .5, 1); }
.logo i:nth-child(3) { --c: #E8342E; width: 124px; background: var(--c); animation: drop .5s .1s both cubic-bezier(.3, 1.4, .5, 1); }
@keyframes drop { from { transform: translateY(-40px); opacity: 0; } }

/* 시리즈 탭: 대표 모형 사진 + 이름 + 완성한 수 */
.series { display: flex; gap: 12px; justify-content: center; max-width: 980px; margin: 0 auto 18px; }
.tab {
  display: flex; align-items: center; gap: 8px; min-height: 64px; padding: 6px 18px 6px 8px; border-radius: 999px;
  background: var(--surface); box-shadow: 0 5px 0 var(--surface-edge); font-size: 1.3rem;
  transition: transform .08s, box-shadow .08s;
}
.tab img { width: 52px; height: 52px; object-fit: contain; }
.tab small { font-size: .9rem; color: var(--ink-soft); }
.tab:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--surface-edge); }
.tab[aria-selected="true"] { background: var(--go); color: #fff; box-shadow: 0 5px 0 var(--go-deep); }
.tab[aria-selected="true"] small { color: rgba(255, 255, 255, .85); }
.tab[aria-selected="true"]:active { box-shadow: 0 1px 0 var(--go-deep); }
@media (max-width: 520px) {
  .series { gap: 8px; }
  .tab { min-height: 50px; padding: 4px 12px 4px 4px; gap: 4px; font-size: 1.05rem; }
  .tab img { width: 42px; height: 42px; }
  .tab small { font-size: .8rem; }
  .lv { min-height: 36px; padding: 0 10px; font-size: .92rem; }
}

.series { flex-wrap: wrap; }
.levels { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 980px; margin: -4px auto 16px; }
.lv {
  min-height: 40px; padding: 0 14px; border-radius: 999px; font-size: 1rem;
  background: rgba(255, 255, 255, .7); box-shadow: inset 0 0 0 2px var(--surface-edge);
}
.lv i, .card .stars { font-style: normal; color: #F2A100; letter-spacing: -1px; }
.lv small { color: var(--ink-soft); }
.lv[aria-pressed="true"] { background: var(--ink); color: #fff; box-shadow: none; }
.lv[aria-pressed="true"] small { color: rgba(255, 255, 255, .75); }

.cards {
  display: grid; gap: 16px; max-width: 980px; margin: 0 auto;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.card {
  position: relative; display: flex; flex-direction: column; align-items: center;
  padding: 10px 10px 14px; border-radius: 24px; text-decoration: none; color: inherit;
  background: var(--surface); box-shadow: 0 6px 0 var(--surface-edge);
  transition: transform .08s, box-shadow .08s;
  animation: rise .45s calc(var(--n) * 50ms) both ease-out;
}
.card:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--surface-edge); }
@keyframes rise { from { transform: translateY(18px); opacity: 0; } }
.card img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.card b { font-weight: 400; font-size: 1.3rem; margin-top: 2px; word-break: keep-all; line-height: 1.15; }
.card b.long { font-size: 1.08rem; }
.card b.longer { font-size: .95rem; }
.card .meta { color: var(--ink-soft); font-size: .92rem; }
.card .stamp, .card .going {
  position: absolute; top: 10px; right: 10px; padding: 4px 10px; border-radius: 999px;
  font-size: .9rem; transform: rotate(8deg);
}
.card .stamp { background: var(--butter); color: #6b4a00; box-shadow: 0 3px 0 #D9A900; }
.card .going { background: #DDF1FF; color: #1f5d8a; box-shadow: 0 3px 0 #b7dcf4; }

/* ── 블럭 상자 ─────────────────────────────────────── */
#box {
  min-height: 100%;
  padding: calc(12px + var(--safe-t)) calc(16px + var(--safe-r)) calc(28px + var(--safe-b)) calc(16px + var(--safe-l));
  background: var(--wall);
}
.box-bar { display: flex; align-items: center; gap: 14px; max-width: 980px; margin: 0 auto 16px; }
.box-bar .round { color: inherit; text-decoration: none; }
.box-bar h2 { margin: 0; font-weight: 400; font-size: 1.9rem; }
.box-bar p { margin: 0; color: var(--ink-soft); }
.pieces { max-width: 980px; margin: 0 auto; }
.piece-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
.box-cat { margin: 22px 4px 10px; font-weight: 400; font-size: 1.3rem; }
.box-cat:first-child { margin-top: 6px; }
.box-cat small { color: var(--ink-soft); font-size: .95rem; }
.box-cat em { display: block; font-style: normal; color: var(--go-deep, #2e8b57); font-size: .95rem; margin-top: 2px; }
.piece-card {
  display: flex; flex-direction: column; align-items: center; padding: 6px 6px 10px; border-radius: 20px;
  background: var(--surface); box-shadow: 0 5px 0 var(--surface-edge);
  animation: rise .4s calc(var(--n) * 30ms) both ease-out;
}
.piece-card img { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 14px; }
.piece-card img:not([src]) { visibility: hidden; }
.piece-card:has(img:not([src])) { background-image: radial-gradient(circle at 50% 40%, rgba(230, 212, 176, .5) 0 22%, transparent 23%); }
.piece-card span { font-size: 1.05rem; text-align: center; line-height: 1.1; word-break: keep-all; }
.piece-card span small { display: block; color: var(--ink-soft); font-size: .85rem; }
.piece-card.nudge { animation: nudge .6s ease-in-out; }
.box-h { max-width: 980px; margin: 24px auto 10px; font-weight: 400; font-size: 1.4rem; }
.swatches { display: grid; gap: 10px; max-width: 980px; margin: 0 auto; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: .95rem; }
.swatch::before {
  content: ""; width: 52px; height: 40px; border-radius: 10px; background: var(--c);
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .14), 0 3px 0 rgba(0, 0, 0, .08);
}
.swatch.clear::before { opacity: .55; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .8), inset 0 -6px 0 rgba(0, 0, 0, .08); }

/* ── 장식장 ───────────────────────────────────────── */
#shelf {
  min-height: 100%;
  padding: calc(12px + var(--safe-t)) calc(16px + var(--safe-r)) calc(28px + var(--safe-b)) calc(16px + var(--safe-l));
  background: #F3E3C4;
}
/* 나무 선반: 칸마다 아래에 두꺼운 판 */
.shelves {
  display: grid; gap: 0 10px; max-width: 980px; margin: 0 auto; padding: 10px 12px 0; border-radius: 18px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  background: linear-gradient(#B98552, #A8743F); box-shadow: inset 0 0 0 8px #8C5A2B;
}
.shelf-item {
  position: relative; display: flex; flex-direction: column; align-items: center; padding: 8px 4px 22px;
  text-decoration: none; color: #fff; font-size: 1rem; text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
  background: linear-gradient(transparent calc(100% - 16px), #7A4A1F calc(100% - 16px), #6A3E17);
}
.shelf-item img { width: 100%; aspect-ratio: 1; object-fit: contain; filter: drop-shadow(0 6px 4px rgba(0, 0, 0, .3)); }
.shelf-item span { margin-top: -4px; word-break: keep-all; text-align: center; }
.shelf-del {
  position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255, 255, 255, .85); color: var(--ink); font-size: 1.2rem; line-height: 1;
}
.shelf-del.armed { background: var(--accent); color: #fff; }
.shelf-empty { grid-column: 1 / -1; padding: 40px 20px; text-align: center; color: #fff; font-size: 1.15rem; word-break: keep-all; }
.free-cta { display: flex; max-width: 980px; margin: 0 auto 16px; font-size: 1.25rem; text-decoration: none; }
.free-cta svg { width: 30px; height: 30px; }

/* ── 자유 조립 (놀이판 위의 도구·쟁반) ───────────────── */
#play:not(.is-free) .free-tools, #play:not(.is-free) .free-tray { display: none; }
#play.is-free .steps, #play.is-free .goal, #play.is-free .tray, #play.is-free .finish { display: none !important; }
#play[data-ground="free"] { background: linear-gradient(#CFEAF9, #EEF7FC 60%, #FFF8EC); }
.free-tools {
  position: absolute; top: calc(10px + var(--safe-t)); right: calc(12px + var(--safe-r)); left: 80px;
  display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap;
}
.round.sm { width: 46px; height: 46px; }
.round.sm svg { width: 24px; height: 24px; }
.round.sm:disabled { opacity: .4; }
.chip.sm { min-height: 46px; padding: 0 12px; font-size: 1rem; }
#freeRotate svg { transform: rotate(var(--rot, 0deg)); transition: transform .2s; }
#freeEraser[aria-pressed="true"] { background: var(--accent); color: #fff; box-shadow: 0 5px 0 var(--accent-deep); }
/* 움직이기: 누르면 만든 것이 움직이고, 쌓기 도구·쟁반은 잠시 숨는다 */
.free-play { background: #FFF1C4; box-shadow: 0 5px 0 #E0B84A; }
.free-play svg { width: 22px; height: 22px; }
.free-play .i-stop { display: none; }
.free-play[aria-pressed="true"] { background: var(--accent); color: #fff; box-shadow: 0 5px 0 var(--accent-deep); }
.free-play[aria-pressed="true"] .i-play { display: none; }
.free-play[aria-pressed="true"] .i-stop { display: block; }
#play.is-playing .free-tray, #play.is-playing #freeUndo, #play.is-playing #freeRotate, #play.is-playing #freeEraser, #play.is-playing #freeClear { display: none; }
#freeClear.armed { background: var(--accent); color: #fff; }
.free-count { min-width: 40px; padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, .8); text-align: center; }
.free-tray {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 10px calc(10px + var(--safe-r)) calc(10px + var(--safe-b)) calc(10px + var(--safe-l));
  background: rgba(255, 253, 247, .95); border-radius: 26px 26px 0 0; box-shadow: 0 -4px 0 rgba(230, 212, 176, .9);
}
.free-cats, .free-shapes, .free-colors { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
.free-cats::-webkit-scrollbar, .free-shapes::-webkit-scrollbar, .free-colors::-webkit-scrollbar { display: none; }
.free-cats { gap: 6px; margin-bottom: 6px; }
.cat-btn {
  flex: none; min-height: 34px; padding: 0 12px; border-radius: 999px; background: #F4EEE2; font-size: .95rem; white-space: nowrap;
  box-shadow: 0 3px 0 var(--surface-edge);
}
.cat-btn.on { background: var(--ink); color: #fff; box-shadow: 0 3px 0 rgba(0, 0, 0, .25); }
.shape-btn {
  flex: none; width: 70px; height: 64px; border-radius: 16px; background: #F4EEE2; touch-action: none;
  box-shadow: 0 4px 0 var(--surface-edge);
}
.shape-btn img { width: 100%; height: 100%; object-fit: contain; padding: 4px; pointer-events: none; }
.shape-btn.on { background: #FFF1C4; box-shadow: 0 4px 0 #E0B84A, inset 0 0 0 3px #F2A100; }
.free-colors { margin-top: 8px; }
.color-btn { flex: none; width: 38px; height: 38px; border-radius: 12px; background: var(--c); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .15); }
.color-btn.clear { opacity: .6; }
.color-btn.on { outline: 3px solid var(--ink); outline-offset: 2px; }
#play.is-erasing #stage { cursor: crosshair; }

/* ── 놀이판 ────────────────────────────────────────── */
#play {
  position: fixed; inset: 0; overflow: hidden;
  background: linear-gradient(#BFE7FF, #EAF7FF 58%, #FFF6E8);
}
#play[data-ground="water"] { background: linear-gradient(#A9DEFF, #E4F6FF 60%, #F2FBFF); }
#play[data-ground="sand"] { background: linear-gradient(#FFD9A8, #FFF0D6 60%, #FFF8EA); }
#play[data-ground="road"] { background: linear-gradient(#CDE8F7, #F2F7FA 60%, #FBF7EF); }
#play[data-ground="table"] { background: linear-gradient(#FFD6E4, #FFF0F5 60%, #FFF8FA); }
#play[data-ground="jungle"] { background: linear-gradient(#B4E3C4, #E6F6E4 60%, #F6FAEC); }
#play[data-ground="space"], #play[data-ground="moon"] { background: radial-gradient(circle at 30% 20%, #3b3f8a, #151838 70%); }
#play[data-ground="pad"] { background: linear-gradient(#2C2F66, #5F63A8 55%, #E9E8F7); }
#stage, #fx { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#stage { touch-action: none; }
#fx { pointer-events: none; }

.topbar {
  position: absolute; left: 0; right: 0; top: 0;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: calc(10px + var(--safe-t)) calc(12px + var(--safe-r)) 8px calc(12px + var(--safe-l));
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.round {
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--surface); box-shadow: 0 5px 0 var(--surface-edge);
}
.round svg { width: 30px; height: 30px; }
.round:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--surface-edge); }

.steps { display: flex; gap: 8px; align-items: center; padding: 10px 14px; border-radius: 999px; background: rgba(255, 255, 255, .7); }
.steps i {
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: inset 0 0 0 3px #D8CBB3; transition: transform .25s, background .25s;
}
.steps i.past { background: var(--go); box-shadow: inset 0 -3px 0 var(--go-deep); }
.steps i.now { transform: scale(1.35); background: var(--butter); box-shadow: inset 0 -3px 0 #D9A900; }
.steps i.ping { animation: ping .6s ease-out; }
@keyframes ping { 40% { transform: scale(1.9); } }

.steps { margin-top: 6px; }
/* 완성 미리보기: 아이가 보고 따라 할 수 있게 크게 */
.goal {
  width: clamp(112px, 30vw, 176px); height: clamp(112px, 30vw, 176px); border-radius: 24px; flex: none; padding: 6px;
  background: var(--surface); box-shadow: 0 5px 0 var(--surface-edge);
  transform-origin: top right; transition: transform .25s;
}
.goal img { width: 100%; height: 100%; object-fit: contain; }
.goal.peek { animation: peek 1.8s ease-in-out; }
.goal { position: relative; }
.goal[data-label]::after {
  content: attr(data-label); position: absolute; left: 50%; bottom: -12px; transform: translateX(-50%);
  padding: 1px 8px; border-radius: 999px; background: var(--ink); color: #fff; font-size: .8rem; white-space: nowrap;
}
@keyframes peek { 15%, 80% { transform: scale(1.9); } }

/* 쟁반: 이번 단계에 끼울 블럭만 */
.tray {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center; align-items: center; gap: 14px; flex-wrap: nowrap;
  min-height: calc(132px + var(--safe-b));
  padding: 14px calc(14px + var(--safe-r)) calc(18px + var(--safe-b)) calc(14px + var(--safe-l));
  background: rgba(255, 253, 247, .92);
  border-radius: 30px 30px 0 0;
  box-shadow: 0 -4px 0 rgba(230, 212, 176, .9);
  overflow-x: auto;
  transition: transform .4s cubic-bezier(.5, 0, .3, 1);
}
.brick-btn {
  position: relative; flex: none; width: 104px; height: 100px; border-radius: 24px;
  background: #F4EEE2; box-shadow: 0 5px 0 var(--surface-edge), inset 0 0 0 4px color-mix(in srgb, var(--c) 35%, transparent);
  touch-action: none; transition: opacity .15s, transform .15s;
}
.brick-btn img { width: 100%; height: 100%; object-fit: contain; padding: 6px; pointer-events: none; }
/* 블럭 가짓수가 많으면 작게, 여러 줄로 */
.tray { flex-wrap: wrap; row-gap: 12px; }
.tray[data-n="some"] .brick-btn { width: 84px; height: 80px; border-radius: 20px; }
.tray[data-n="many"] .brick-btn { width: 70px; height: 66px; border-radius: 18px; }
.tray[data-n="many"] { gap: 10px; }
.tray[data-n] .brick-btn .count { font-size: 1rem; min-width: 34px; }
.brick-btn .count {
  position: absolute; right: -6px; top: -8px; min-width: 38px; padding: 3px 8px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 1.1rem; box-shadow: 0 3px 0 var(--accent-deep);
}
.brick-btn.pop { animation: pop .4s both cubic-bezier(.3, 1.6, .5, 1); }
.brick-btn.pop:nth-child(2) { animation-delay: .08s; }
.brick-btn.pop:nth-child(3) { animation-delay: .16s; }
.brick-btn.pop:nth-child(4) { animation-delay: .24s; }
@keyframes pop { from { transform: scale(.2); opacity: 0; } }
.brick-btn.lifted { opacity: .35; transform: scale(.92); }
.brick-btn.nudge { animation: nudge .6s ease-in-out; }
@keyframes nudge { 20% { transform: rotate(-9deg) scale(1.08); } 45% { transform: rotate(8deg) scale(1.08); } 70% { transform: rotate(-4deg); } }

#play.is-finished .tray, #play.is-view .tray { transform: translateY(110%); }
#play.is-view .steps { visibility: hidden; }

/* 손가락 힌트 (손끝이 좌표에 오도록) */
.hand { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 5; }
.hand svg { display: block; margin: -3px 0 0 -23px; filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .2)); transform-origin: 23px 3px; }

/* 미션 완료 */
.finish {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: center;
  padding: 0 16px calc(18px + var(--safe-b));
}
.finish-card {
  position: relative; width: min(440px, 100%); padding: 44px 18px 18px; border-radius: 30px; text-align: center;
  background: var(--surface); box-shadow: 0 7px 0 var(--surface-edge);
  animation: slideUp .5s both cubic-bezier(.3, 1.3, .5, 1);
}
@keyframes slideUp { from { transform: translateY(120%); } }
.badge { position: absolute; left: 50%; top: -46px; width: 92px; height: 92px; margin-left: -46px; animation: spinIn .8s .2s both cubic-bezier(.3, 1.5, .5, 1); }
@keyframes spinIn { from { transform: scale(0) rotate(-160deg); } }
.finish-title { margin: 0; font-size: 2.1rem; color: var(--accent); }
.finish-name { margin: 2px 0 0; font-size: 1.3rem; }
.finish-count { margin: 2px 0 10px; color: var(--ink-soft); }
/* 완성한 것에 대한 설명 (톡 치면 다시 읽어 줌) */
.finish-info {
  display: flex; align-items: flex-start; gap: 8px; width: 100%; margin: 0 0 14px; padding: 10px 12px;
  border-radius: 16px; background: #FFF4D6; text-align: left; font-size: 1.02rem; line-height: 1.45; word-break: keep-all;
}
.finish-info svg { width: 22px; height: 22px; flex: none; margin-top: 2px; color: #D98A00; }
.finish-info:active { transform: scale(.98); }
.finish-actions { display: flex; gap: 10px; justify-content: center; }
.finish-actions .chip { flex: 1; padding: 0 10px; }
.finish-actions .chip.primary { flex: 1.4; }

/* 가로로 누운 폰: 쟁반을 오른쪽 세로로 */
@media (orientation: landscape) and (max-height: 560px) {
  #play { --tray-side: 1; }
  .tray {
    left: auto; top: 0; bottom: 0; width: calc(132px + var(--safe-r)); min-height: 0;
    flex-direction: column; justify-content: center;
    padding: calc(10px + var(--safe-t)) calc(14px + var(--safe-r)) calc(10px + var(--safe-b)) 14px;
    border-radius: 30px 0 0 30px; box-shadow: -4px 0 0 rgba(230, 212, 176, .9);
    overflow-x: hidden; overflow-y: auto;
  }
  .brick-btn { width: 96px; height: 84px; }
  .tray[data-n="some"], .tray[data-n="many"] { width: calc(200px + var(--safe-r)); flex-direction: row; align-content: center; }
  .tray[data-n="some"] .brick-btn, .tray[data-n="many"] .brick-btn { width: 76px; height: 68px; }
  #play.is-finished .tray, #play.is-view .tray { transform: translateX(110%); }
  .topbar { right: calc(132px + var(--safe-r)); }
  .round { width: 48px; height: 48px; }
  .goal { width: 96px; height: 96px; border-radius: 20px; padding: 4px; }
  .finish { left: auto; top: 0; width: min(400px, 48vw); align-items: center; padding: 0 calc(12px + var(--safe-r)) 0 0; }
  .finish-card { padding-top: 34px; }
  .badge { width: 70px; height: 70px; top: -36px; margin-left: -35px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
}
