/* 어썸동산 — 스타일 (색은 모두 아래 토큰으로만 사용) */
:root {
  /* 바탕·표면 */
  --bg: #fff4e6;
  --bg-subtle: #ffe9d1;
  --surface: #fffdf9;
  --surface-2: #fff3e3;
  --surface-edge: #f0dcc3;
  --border: #f1dcc2;
  --border-strong: #e2c39e;
  --text: #3d2c24;
  --text-muted: #7c6558;
  --text-subtle: #a99080;
  --text-on-brand: #ffffff;

  /* 포인트 */
  --brand: #ff7a3d;
  --brand-hover: #f2652a;
  --brand-press: #db5520;
  --brand-subtle: #ffe5d6;
  --brand-shadow: #c9521d;
  --accent: #5b8cff;
  --success: #3fae5a;
  --danger: #e5484d;
  --danger-hover: #cf3b40;
  --hard-shadow: #a8272c;
  --heart: #ff5c7a;
  --coin: #f5b400;
  --star: #ffc21a;
  --star-off: #e8d9c6;

  /* 캐릭터 */
  --ink: #33241f;
  --paper: #ffffff;
  --blush: rgba(255, 105, 135, .5);
  --beak: #ff9a3c;
  --beak-d: #e67a1f;
  --t0: #eab27e; --t0d: #b77a48; --t0l: #fde6cc;
  --t1: #ffadcb; --t1d: #e8769e; --t1l: #ffe1ec;
  --t2: #c4aaff; --t2d: #8e6ee6; --t2l: #eee6ff;
  --t3: #9de381; --t3d: #5aae45; --t3l: #d4f5c8;
  --t4: #ffe066; --t4d: #e3a90a; --t4l: #fff3b8;
  --t5: #7cb9ff; --t5d: #4a87dc; --t5l: #dcebff;
  --wood: #d9a066; --wood-d: #9c6634;
  --metal: #9aa7b8; --metal-d: #6c7a8c;
  --mascot: #7fe3c8; --mascot-d: #3fb397; --mascot-l: #c4f5e7;
  --bow: #7fe0cc; --bow-d: #3fb59c;

  /* 마을 오브젝트 */
  --o-leaf: #8fdc72; --o-leaf-d: #4f9e3f; --o-leaf-l: #c3f0ad;
  --o-pine: #5fc27a; --o-pine-d: #2f8a52;
  --o-trunk: #c99062; --o-trunk-d: #8e5c34;
  --o-wall: #fff3df; --o-wall-d: #cfb08a;
  --o-roof: #ff9393; --o-roof-d: #d4636a;
  --o-mint: #8fe3cf; --o-mint-d: #3fae95;
  --o-brown: #b4785a; --o-brown-d: #7f4f37;
  --o-glass: #c8ecff;
  --o-water: #9adcff; --o-water-d: #4aa6da;
  --o-gold: #ffd45e; --o-gold-d: #d9a21c;
  --o-red: #ff7676; --o-red-d: #cf4b51;
  --o-bread: #f3b860; --o-bread-d: #bd7d2a;
  --o-shell: #ffc6b5; --o-shell-d: #e48b77;
  --o-sand: #f8d79a; --o-sand-d: #d2a55a;
  --o-snow: #ffffff; --o-snow-d: #bccde6;
  --o-brick: #e0806a; --o-brick-d: #a8503e;
  --o-cocoa: #8a5a3c;
  --leaf: #5fc35a; --leaf-d: #3e9b3b;
  --shadow-soft: rgba(60, 40, 30, .14);

  /* 보드 */
  --board-bg: #3f2d66;
  --board-edge: #2a1d47;
  --cell-a: rgba(255, 255, 255, .10);
  --cell-b: rgba(255, 255, 255, .18);
  --jelly: rgba(255, 120, 200, .55);
  --jelly-d: rgba(214, 60, 150, .6);
  --jelly2: rgba(240, 70, 170, .8);
  --sel-ring: rgba(255, 255, 255, .85);
  --glow: rgba(255, 236, 140, .9);
  --beam: rgba(255, 250, 210, .95);
  --tile-shadow: rgba(40, 20, 80, .28);
  --score-text: #ffffff;
  --score-stroke: rgba(70, 30, 120, .7);

  /* 장면 */
  --cloud: rgba(255, 255, 255, .9);
  --stone: #e9dccb;
  --stone-d: #cdb89c;
  --ice: #cfe9ff;
  --ice-d: #a9d2f5;
  --bubble: #ffffff;
  --scrim: rgba(40, 25, 20, .5);

  /* 그림자·모서리·움직임 */
  --shadow-sm: 0 1px 2px rgba(80, 40, 20, .06), 0 2px 6px rgba(80, 40, 20, .06);
  --shadow-md: 0 2px 4px rgba(80, 40, 20, .06), 0 8px 24px rgba(80, 40, 20, .10);
  --shadow-lg: 0 4px 8px rgba(80, 40, 20, .08), 0 24px 48px rgba(80, 40, 20, .18);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);

  --font: 'Pretendard', 'Pretendard Variable', -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  --font-display: 'Jua', 'Pretendard', 'Malgun Gothic', sans-serif;
}

/* 테마별 장면 색 */
.theme-meadow { --sky-top: #8fd6ff; --sky-bot: #e3f6ff; --ground: #a3df7f; --ground-d: #7cc35c; --sea: transparent; --sea-d: transparent; }
.theme-beach  { --sky-top: #7fd0ff; --sky-bot: #eaf8ff; --ground: #ffe3a8; --ground-d: #f2cb80; --sea: #5ccbe8; --sea-d: #2fa6d1; }
.theme-snow   { --sky-top: #aebfec; --sky-bot: #eef2ff; --ground: #f7faff; --ground-d: #d9e4f6; --sea: transparent; --sea-d: transparent; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  color: var(--text);
  background: radial-gradient(120% 80% at 50% 0%, var(--surface-2), var(--bg) 60%, var(--bg-subtle));
  word-break: keep-all;
  overflow-wrap: break-word;
  line-height: 1.6;
  letter-spacing: -0.01em;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
p { max-width: 68ch; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 20px; height: 20px; flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#app { min-height: 100dvh; }
.screen { min-height: 100dvh; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }

/* ───────── 버튼 ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 8px 20px;
  border: 0; border-radius: 999px;
  font-weight: 600; font-size: 16px; cursor: pointer;
  background: var(--surface-2); color: var(--text);
  transition: transform 150ms var(--ease-out), background-color 150ms var(--ease-out), box-shadow 150ms var(--ease-out);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn--primary {
  background: var(--brand); color: var(--text-on-brand);
  box-shadow: inset 0 -4px 0 var(--brand-shadow), var(--shadow-sm);
}
.btn--primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn--primary:active:not(:disabled) { background: var(--brand-press); box-shadow: inset 0 -2px 0 var(--brand-shadow); }
.btn--soft { background: var(--brand-subtle); color: var(--brand-press); }
.btn--soft:hover:not(:disabled) { background: var(--border); }
.btn--ghost { background: transparent; color: var(--text-muted); }
.btn--ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn--danger { background: var(--danger); color: var(--text-on-brand); }
.btn--danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn--sm { min-height: 36px; padding: 4px 12px; font-size: 14px; gap: 4px; }
.btn--sm .ic { width: 16px; height: 16px; }
.btn--lg { min-height: 56px; padding: 12px 32px; font-size: 20px; font-family: var(--font-display); font-weight: 400; }
.btn--block { width: 100%; }
.btn__sub { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; opacity: .9; font-family: var(--font); font-weight: 600; }
.btn__sub .ic { width: 16px; height: 16px; }

.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; border-radius: 999px; cursor: pointer;
  background: var(--surface); color: var(--text-muted); box-shadow: var(--shadow-sm);
  transition: transform 150ms var(--ease-out), color 150ms var(--ease-out);
}
.icon-btn:hover { color: var(--text); transform: translateY(-1px); }
.icon-btn:active { transform: translateY(1px); }

/* ───────── 타이틀 ───────── */
#title { display: grid; place-items: center; position: relative; overflow: hidden; padding-inline: 16px; }
.title-deco svg {
  position: absolute; left: var(--x); top: var(--y); width: clamp(56px, 10vw, 96px);
  animation: floaty 4s ease-in-out var(--d) infinite alternate; opacity: .9;
}
@keyframes floaty { from { transform: translateY(0) rotate(-6deg); } to { transform: translateY(-16px) rotate(6deg); } }
.title-card { position: relative; text-align: center; display: grid; justify-items: center; gap: 8px; }
.title-mascot { width: 128px; height: 128px; animation: floaty 2.4s ease-in-out infinite alternate; }
.logo-big {
  margin: 0; font-family: var(--font-display); font-weight: 400;
  font-size: clamp(48px, 12vw, 88px); line-height: 1.1; letter-spacing: -0.02em;
  color: var(--brand); text-shadow: 0 4px 0 var(--brand-shadow), 0 12px 24px var(--shadow-soft);
}
.tagline { margin: 0 0 24px; color: var(--text-muted); font-size: 18px; }

/* ───────── 마을 상단 ───────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  max-width: 1280px; margin: 0 auto; padding: 16px 24px;
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.logo { font-family: var(--font-display); font-size: 28px; color: var(--brand); line-height: 1.2; }
.chapter-tag { font-size: 14px; color: var(--text-muted); }
.chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 40px; padding: 0 16px 0 8px;
  background: var(--surface); border-radius: 999px; box-shadow: var(--shadow-sm);
  font-variant-numeric: tabular-nums;
}
.chip b { font-size: 16px; font-weight: 600; }
.chip small { font-size: 12px; color: var(--text-subtle); margin-left: 4px; min-width: 32px; }
.chip .ic { width: 24px; height: 24px; }
.chip--heart .ic { color: var(--heart); fill: var(--heart); }
.chip--coin .ic { color: var(--coin); }
.chip--star .ic { color: var(--star); fill: var(--star); }

/* ───────── 마을 본문 ───────── */
.town-main {
  display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px;
  max-width: 1280px; margin: 0 auto; padding: 0 24px 32px;
  align-items: start;
}
.scene-col { position: relative; }
.scene {
  position: relative; aspect-ratio: 16 / 10; container-type: inline-size;
  border-radius: var(--radius-xl); overflow: hidden;
  background: linear-gradient(var(--sky-top), var(--sky-bot) 55%);
  box-shadow: var(--shadow-lg);
}
.cloud {
  position: absolute; left: var(--x); top: var(--y);
  width: calc(var(--w) * 1cqw); height: calc(var(--w) * .34cqw);
  background: var(--cloud); border-radius: 999px;
}
.cloud::before {
  content: ''; position: absolute; left: 22%; bottom: 40%; width: 46%; aspect-ratio: 1;
  background: var(--cloud); border-radius: 50%;
}
.sea {
  position: absolute; left: 0; right: 0; top: 34%; height: 26%;
  background: linear-gradient(var(--sea), var(--sea-d));
}
.ground {
  position: absolute; left: -10%; right: -10%; bottom: -20%; height: 82%;
  border-radius: 50% 50% 0 0 / 16% 16% 0 0;
  background: linear-gradient(var(--ground), var(--ground-d));
}
.theme-beach .ground { height: 68%; }
.items { position: absolute; inset: 0; }

.item {
  position: absolute; transform: translate(-50%, -100%);
  width: calc(var(--s) * 1cqw); line-height: 0;
  background: none; border: 0; padding: 0; cursor: pointer;
  filter: hue-rotate(var(--hue)) drop-shadow(0 .5cqw .3cqw var(--shadow-soft));
  transition: transform 200ms var(--ease-out);
  transform-origin: 50% 100%;
}
.item svg { display: block; width: 100%; height: auto; overflow: visible; }
.item:hover { transform: translate(-50%, -100%) scale(1.02); }
.item.appear { animation: drop 640ms cubic-bezier(.3,.7,.4,1) calc(var(--i, 0) * 120ms) both; transform-origin: 50% 100%; }
@keyframes drop {
  0% { transform: translate(-50%, -100%) translateY(-24cqw) scale(.7, 1.25); opacity: 0; }
  45% { transform: translate(-50%, -100%) translateY(0) scale(.9, 1.12); opacity: 1; }
  62% { transform: translate(-50%, -100%) scale(1.18, .8); }
  80% { transform: translate(-50%, -100%) scale(.95, 1.06); }
  100% { transform: translate(-50%, -100%) scale(1); }
}
@keyframes appear {
  from { transform: translate(-50%, -100%) scale(0); }
  to { transform: translate(-50%, -100%) scale(1); }
}
.item.shape { transform: translate(-50%, -50%); width: calc(var(--s) * 1cqw); aspect-ratio: 2.8; border-radius: 50%; }
.item.shape:hover { transform: translate(-50%, -50%) scale(1.01); }
.item.shape.appear { animation: appear-shape 600ms var(--ease-spring) both; }
@keyframes appear-shape { from { transform: translate(-50%, -50%) scale(0); } to { transform: translate(-50%, -50%) scale(1); } }
.shape-plaza {
  background:
    repeating-radial-gradient(ellipse at center, transparent 0 7%, var(--stone-d) 7% 7.6%),
    var(--stone);
  box-shadow: inset 0 -.6cqw 0 var(--stone-d);
}
.shape-rink {
  background: radial-gradient(ellipse at 40% 35%, var(--paper), var(--ice) 45%, var(--ice-d));
  box-shadow: inset 0 0 0 .5cqw var(--paper), inset 0 -.6cqw 0 var(--ice-d);
}
.mini-shape { display: block; width: 40px; aspect-ratio: 2.8; border-radius: 50%; }
.mini-shape.big { width: 72px; }

.slot {
  position: absolute; transform: translate(-50%, -100%);
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: rgba(255, 255, 255, .55); color: var(--text-muted);
  border: 2px dashed var(--paper);
  transition: transform 200ms var(--ease-out), background-color 200ms var(--ease-out);
}
.slot .ic { width: 20px; height: 20px; }
.slot em {
  position: absolute; bottom: -12px; left: 50%; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 2px; padding: 0 8px; height: 20px;
  font-style: normal; font-size: 12px; font-weight: 600;
  background: var(--surface); color: var(--text); border-radius: 999px; box-shadow: var(--shadow-sm);
}
.slot em .ic { width: 12px; height: 12px; color: var(--star); fill: var(--star); }
.slot.can { background: var(--brand); color: var(--text-on-brand); border-style: solid; animation: breathe 1.6s ease-in-out infinite; }
.slot:hover { transform: translate(-50%, -100%) scale(1.06); }
@keyframes breathe { 50% { box-shadow: 0 0 0 8px rgba(255, 122, 61, .25); } }

.mascot {
  position: absolute; left: 2%; bottom: 2%; width: 13cqw; min-width: 64px;
  background: none; border: 0; padding: 0; cursor: pointer; z-index: 300;
  transition: transform 200ms var(--ease-out);
}
.mascot svg { width: 100%; height: auto; display: block; }
.mascot:hover { transform: translateY(-4px); }
.bubble {
  position: absolute; left: calc(2% + max(13cqw, 64px) + 8px); bottom: 8%; z-index: 300;
  max-width: min(46%, 360px); padding: 12px 16px;
  background: var(--bubble); color: var(--text); border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;
  box-shadow: var(--shadow-md); font-size: 15px; line-height: 1.6;
  opacity: 0; transform: translateY(8px) scale(.96); transform-origin: left bottom; pointer-events: none;
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
}
.bubble.on { opacity: 1; transform: none; }

.play-btn {
  position: absolute; right: 16px; bottom: 16px; z-index: 400;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 64px; padding: 8px 24px 8px 28px;
  border: 0; border-radius: 999px; cursor: pointer;
  background: var(--brand); color: var(--text-on-brand);
  font-family: var(--font-display); font-size: 20px;
  box-shadow: inset 0 -5px 0 var(--brand-shadow), var(--shadow-lg);
  transition: transform 150ms var(--ease-out), background-color 150ms var(--ease-out);
}
.play-btn b { font-weight: 400; font-size: 32px; line-height: 1; }
.play-btn .ic { width: 24px; height: 24px; fill: currentColor; }
.play-btn:hover { background: var(--brand-hover); transform: translateY(-2px); }
.play-btn:active { transform: translateY(1px); box-shadow: inset 0 -2px 0 var(--brand-shadow), var(--shadow-md); }
.play-btn.nudge { animation: nudge 600ms var(--ease-out); }
@keyframes nudge { 20%, 60% { transform: translateX(-6px) scale(1.04); } 40%, 80% { transform: translateX(6px) scale(1.04); } }

.panel {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  padding: 24px;
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.panel-head h2 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 24px; line-height: 1.3; }
.count { font-size: 14px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.progress { height: 12px; margin: 12px 0 16px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress i {
  display: block; height: 100%; width: 100%; transform-origin: left; transform: scaleX(0);
  background: linear-gradient(90deg, var(--t3), var(--success)); border-radius: 999px;
  transition: transform 400ms var(--ease-out);
}
.tasks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.task {
  display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 8px;
  border-radius: var(--radius); background: var(--surface-2);
}
.task__thumb {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center;
  font-size: 24px; line-height: 1; border-radius: var(--radius-sm); background: var(--surface);
  filter: hue-rotate(var(--hue, 0deg));
}
.task__thumb svg { width: 32px; height: 32px; display: block; }
.task__name { flex: 1; font-size: 15px; font-weight: 500; }
.task .btn .ic { color: inherit; fill: currentColor; }
.task.done { background: transparent; }
.task.done .task__name { color: var(--text-muted); }
.task__done { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; color: var(--success); padding-right: 8px; }
.task__done .ic { width: 16px; height: 16px; }
.empty { display: grid; justify-items: center; text-align: center; gap: 8px; padding: 24px 8px; color: var(--text-muted); }
.empty p { margin: 0; font-size: 15px; }
.empty b { color: var(--text); }
.empty__ic { width: 40px; height: 40px; color: var(--star); }

/* ───────── 퍼즐 화면 ───────── */
#game { --cell: min(64px, calc((100vw - 400px) / 8), calc((100dvh - 168px) / 8)); }
.g-top {
  display: flex; align-items: center; gap: 16px;
  max-width: 1080px; margin: 0 auto; padding: 16px 24px 8px;
}
.g-level { font-family: var(--font-display); font-size: 24px; line-height: 1.2; white-space: nowrap; }
.g-level b { font-weight: 400; color: var(--brand); }
.g-score { flex: 1; display: flex; align-items: center; gap: 12px; justify-content: flex-end; }
.g-score__num { font-family: var(--font-display); font-size: 24px; min-width: 88px; text-align: right; font-variant-numeric: tabular-nums; }
.score-bar { position: relative; width: min(280px, 40vw); height: 16px; background: var(--surface); border-radius: 999px; box-shadow: inset 0 1px 3px var(--shadow-soft); }
.score-bar i {
  position: absolute; inset: 0; border-radius: 999px; transform-origin: left; transform: scaleX(0);
  background: linear-gradient(90deg, var(--star), var(--brand));
  transition: transform 300ms var(--ease-out);
}
.score-bar .mk {
  position: absolute; top: 50%; width: 20px; height: 20px; transform: translate(-50%, -50%);
  background: var(--star-off); border: 3px solid var(--surface); border-radius: 50%;
  transition: background-color 200ms var(--ease-out), transform 200ms var(--ease-out);
}
.score-bar .mk.on { background: var(--star); transform: translate(-50%, -50%) scale(1.15); }

.g-main {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 24px; align-items: center;
  max-width: 1080px; margin: 0 auto; padding: 8px 24px 24px;
}
.g-left, .g-right { display: flex; flex-direction: column; gap: 16px; }
.g-left { justify-self: end; align-items: stretch; width: 148px; }
.g-right { justify-self: start; width: 112px; }
.moves {
  display: grid; justify-items: center; padding: 12px 16px;
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
}
.moves small, .goals small { font-size: 13px; color: var(--text-muted); }
.moves b { font-family: var(--font-display); font-weight: 400; font-size: 48px; line-height: 1.1; color: var(--accent); font-variant-numeric: tabular-nums; }
.moves.low b { color: var(--danger); animation: throb 1s ease-in-out infinite; }
@keyframes throb { 50% { transform: scale(1.08); } }
.goals { padding: 12px 16px; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
.goals ul { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 8px; }
.goal { display: flex; align-items: center; gap: 8px; }
.goal b { font-family: var(--font-display); font-weight: 400; font-size: 22px; font-variant-numeric: tabular-nums; display: inline-flex; }
.goal.done b { color: var(--success); }
.goal.done b .ic { width: 24px; height: 24px; stroke-width: 3; }
.goal.bump .gi { animation: bump 300ms var(--ease-spring); }
@keyframes bump { 50% { transform: scale(1.3); } }
.gi { width: 36px; height: 36px; flex: none; display: grid; place-items: center; }
.gi .ic { color: var(--star); fill: var(--star); width: 28px; height: 28px; }
.jelly-ic { border-radius: 30%; background: var(--jelly); box-shadow: inset 0 -4px 0 var(--jelly-d); width: 30px; height: 30px; }

.board-col { display: grid; justify-items: center; gap: 8px; }
.board-frame {
  padding: 8px; border-radius: var(--radius-lg);
  background: var(--board-bg);
  box-shadow: inset 0 -6px 0 var(--board-edge), var(--shadow-lg);
}
.board {
  position: relative; width: calc(var(--cell) * 8); height: calc(var(--cell) * 8);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.cells { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); border-radius: var(--radius); overflow: hidden; }
.cell { position: relative; background: var(--cell-a); }
.cell.alt { background: var(--cell-b); }
.cell.j1::after, .cell.j2::after {
  content: ''; position: absolute; inset: 6%; border-radius: 28%;
  background: var(--jelly); box-shadow: inset 0 -3px 0 var(--jelly-d);
}
.cell.j2::after { background: var(--jelly2); box-shadow: inset 0 -3px 0 var(--jelly-d), inset 0 0 0 3px rgba(255, 255, 255, .5); }
.tiles { position: absolute; inset: 0; overflow: hidden; border-radius: var(--radius); cursor: pointer; }
.fx { position: absolute; inset: 0; pointer-events: none; z-index: 5; }

.tile {
  position: absolute; left: 0; top: 0; width: var(--cell); height: var(--cell);
  transition-property: transform; transition-timing-function: cubic-bezier(.4, 0, .5, 1);
  will-change: transform;
}
.tile .in { position: relative; width: 100%; height: 100%; padding: 4%; transition: transform 150ms var(--ease-out); }
.tile .in svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 2px 0 var(--tile-shadow)); }
.tile.sel::before {
  content: ''; position: absolute; inset: 3%; border-radius: 30%;
  background: rgba(255, 255, 255, .3); box-shadow: inset 0 0 0 3px var(--sel-ring);
}
.tile.sel .in { transform: scale(1.08); }
.tile.hint .in { animation: wiggle 900ms ease-in-out infinite; }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-10deg) scale(1.06); } 75% { transform: rotate(10deg) scale(1.06); } }
.tile .in.pop { animation: pop 220ms var(--ease-out) forwards; }
@keyframes pop { 30% { transform: scale(1.25); opacity: 1; } 100% { transform: scale(0); opacity: 0; } }
.tile .in.born { animation: born 360ms var(--ease-spring); }
@keyframes born { 0% { transform: scale(.3); } 100% { transform: scale(1); } }
.tile .in.spin { animation: spinIn 450ms var(--ease-out); }
@keyframes spinIn { from { transform: rotate(-180deg) scale(.4); } to { transform: none; } }
.tile .in.hurt { animation: hurt 260ms ease-out; }
.tile .in.land { animation: land 320ms var(--ease-out); transform-origin: 50% 90%; }
@keyframes land { 0% { transform: scale(1.12, .84); } 45% { transform: scale(.94, 1.06); } 100% { transform: none; } }
.tile .in.hop { animation: hop 520ms var(--ease-out); transform-origin: 50% 90%; }
@keyframes hop {
  0% { transform: none; } 18% { transform: scale(1.1, .88); } 45% { transform: translateY(-14%) scale(.95, 1.06); }
  75% { transform: scale(1.06, .92); } 100% { transform: none; }
}

/* 표정: 뜬 눈이 기본, 깜빡일 때 감은 눈, 고르거나 터질 때 ^^ */
.tile .e-c, .tile .e-h { display: none; }
.tile.blink .e-o { display: none; }
.tile.blink .e-c { display: inline; }
.tile.sel .e-o, .tile.happy .e-o, .tile.sel .e-c, .tile.happy .e-c { display: none; }
.tile.sel .e-h, .tile.happy .e-h { display: inline; }
@keyframes hurt { 25% { transform: translateX(-4px) rotate(-4deg); } 75% { transform: translateX(4px) rotate(4deg); } }

/* 특수 블록 */
.tile.sp-h .in::after, .tile.sp-v .in::after {
  content: ''; position: absolute; border-radius: 999px;
  background: var(--paper); box-shadow: 0 0 0 2px var(--board-edge), 0 0 12px var(--glow);
}
.tile.sp-h .in::after { left: 2%; right: 2%; top: 46%; height: 12%; }
.tile.sp-v .in::after { top: 2%; bottom: 2%; left: 44%; width: 12%; }
.tile.sp-h .in::before, .tile.sp-v .in::before {
  content: ''; position: absolute; inset: 4%; border-radius: 50%;
  box-shadow: 0 0 14px var(--glow);
}
.tile.sp-b .in::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  border: 4px dashed var(--paper); box-shadow: 0 0 14px var(--glow), inset 0 0 10px var(--glow);
  animation: spin 5s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.tile.sp-r .orb {
  width: 100%; height: 100%; border-radius: 50%; position: relative;
  background: conic-gradient(var(--t1), var(--t4), var(--t3), var(--t5), var(--t2), var(--t1));
  box-shadow: inset 0 0 0 4px var(--paper), 0 0 16px var(--glow);
  animation: spin 6s linear infinite;
}
.tile.sp-r .orb::after {
  content: ''; position: absolute; inset: 30%; border-radius: 50%;
  background: radial-gradient(circle, var(--paper) 30%, rgba(255, 255, 255, 0) 70%);
}
.tile.crate .in { padding: 4%; }

/* 연출 */
.fx-beam-h, .fx-beam-v { position: absolute; background: var(--beam); border-radius: 999px; box-shadow: 0 0 16px var(--glow); }
.fx-beam-h { left: 0; right: 0; top: calc(var(--r) * var(--cell) + var(--cell) * .3); height: calc(var(--cell) * .4); animation: beamH 380ms var(--ease-out) forwards; }
.fx-beam-v { top: 0; bottom: 0; left: calc(var(--c) * var(--cell) + var(--cell) * .3); width: calc(var(--cell) * .4); animation: beamV 380ms var(--ease-out) forwards; }
@keyframes beamH { 0% { transform: scaleX(0); } 50% { transform: scaleX(1); opacity: 1; } 100% { transform: scaleX(1) scaleY(.1); opacity: 0; } }
@keyframes beamV { 0% { transform: scaleY(0); } 50% { transform: scaleY(1); opacity: 1; } 100% { transform: scaleY(1) scaleX(.1); opacity: 0; } }
.fx-blast {
  position: absolute; left: calc((var(--c) + .5) * var(--cell)); top: calc((var(--r) + .5) * var(--cell));
  width: calc(var(--cell) * var(--size, 3)); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle, var(--paper) 0%, var(--glow) 35%, rgba(255, 236, 140, 0) 70%);
  transform: translate(-50%, -50%) scale(.2); animation: blast 480ms var(--ease-out) forwards;
}
@keyframes blast { to { transform: translate(-50%, -50%) scale(1); opacity: 0; } }
.fx-spark {
  position: absolute; left: calc((var(--c) + .5) * var(--cell)); top: calc((var(--r) + .5) * var(--cell));
  width: calc(var(--cell) * .9); aspect-ratio: 1; border-radius: 50%;
  border: 3px solid var(--paper); box-shadow: 0 0 12px var(--glow);
  transform: translate(-50%, -50%) scale(.4); animation: spark 500ms var(--ease-out) forwards;
}
@keyframes spark { 60% { opacity: 1; } to { transform: translate(-50%, -50%) scale(1.2); opacity: 0; } }
.fx-score {
  position: absolute; left: calc((var(--c) + .5) * var(--cell)); top: calc((var(--r) + .5) * var(--cell));
  transform: translate(-50%, -50%); font-family: var(--font-display); font-size: calc(var(--cell) * .42);
  color: var(--score-text); text-shadow: 0 2px 0 var(--score-stroke), 0 0 8px var(--score-stroke);
  white-space: nowrap; animation: rise 700ms var(--ease-out) forwards;
}
@keyframes rise { to { transform: translate(-50%, -150%); opacity: 0; } }
.fx-banner {
  position: absolute; left: 50%; top: 50%; z-index: 6;
  font-family: var(--font-display); font-size: calc(var(--cell) * .8); line-height: 1.2; white-space: nowrap;
  color: var(--score-text); text-shadow: 0 4px 0 var(--score-stroke), 0 0 24px var(--score-stroke);
  animation: banner var(--life, 1100ms) var(--ease-out) forwards;
}
@keyframes banner {
  0% { transform: translate(-50%, -50%) scale(.4); opacity: 0; }
  20% { transform: translate(-50%, -50%) scale(1.08); opacity: 1; }
  30%, 75% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -80%) scale(1); opacity: 0; }
}

.board.tool-mode .tiles { cursor: crosshair; }
.board.tool-mode .tile .in { animation: wiggle 1.4s ease-in-out infinite; }
.tool-tip { margin: 0; padding: 4px 16px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow-sm); font-size: 14px; color: var(--text-muted); }

.tool {
  position: relative; display: grid; justify-items: center; gap: 4px;
  width: 100%; min-height: 96px; padding: 12px 8px 16px;
  border: 0; border-radius: var(--radius-lg); cursor: pointer;
  background: var(--surface); box-shadow: var(--shadow-md);
  transition: transform 150ms var(--ease-out), box-shadow 150ms var(--ease-out), background-color 150ms var(--ease-out);
}
.tool:hover { transform: translateY(-2px); }
.tool:active { transform: translateY(1px); }
.tool.on { background: var(--brand-subtle); box-shadow: inset 0 0 0 3px var(--brand), var(--shadow-md); }
.tool__ic { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); color: var(--brand); }
.tool__ic .ic { width: 24px; height: 24px; }
.tool__name { font-size: 13px; font-weight: 600; }
.tool__badge {
  position: absolute; top: -8px; right: -4px; min-width: 24px; height: 24px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center; gap: 2px;
  border-radius: 999px; background: var(--accent); color: var(--text-on-brand); font-size: 13px; font-weight: 600;
}
.tool__badge.buy { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.tool__badge .ic { width: 14px; height: 14px; color: var(--coin); }

/* ───────── 모달 ───────── */
.modal {
  position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 16px;
  background: var(--scrim); animation: fade 200ms var(--ease-out);
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: min(400px, 100%); max-height: calc(100dvh - 32px); overflow: auto;
  display: grid; gap: 12px; justify-items: center; text-align: center;
  padding: 32px 24px 24px; border-radius: var(--radius-xl);
  background: var(--surface); box-shadow: var(--shadow-lg);
  animation: sheetIn 260ms var(--ease-spring);
}
@keyframes sheetIn { from { transform: scale(.9); opacity: 0; } }
.sheet__title { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 28px; line-height: 1.3; }
.sheet__desc { margin: 0; color: var(--text-muted); font-size: 15px; }
.sheet__desc b { color: var(--text); }
.sheet__label { margin: 8px 0 0; font-size: 13px; color: var(--text-muted); justify-self: start; }
.sheet__hint { margin: 0; font-size: 13px; color: var(--text-subtle); }
.goal-preview { list-style: none; margin: 8px 0; padding: 0; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.goal-preview li {
  display: grid; justify-items: center; gap: 0; min-width: 88px; padding: 12px;
  background: var(--surface-2); border-radius: var(--radius);
}
.goal-preview .gi { width: 44px; height: 44px; }
.goal-preview b { font-family: var(--font-display); font-weight: 400; font-size: 24px; line-height: 1.2; }
.goal-preview span { font-size: 13px; color: var(--text-muted); }
.boosters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; }
.booster {
  display: grid; justify-items: center; gap: 4px; padding: 12px 4px;
  border: 0; border-radius: var(--radius); cursor: pointer; background: var(--surface-2);
  transition: transform 150ms var(--ease-out), box-shadow 150ms var(--ease-out);
}
.booster:hover:not(:disabled) { transform: translateY(-2px); }
.booster:disabled { opacity: .45; cursor: not-allowed; }
.booster.on { background: var(--brand-subtle); box-shadow: inset 0 0 0 3px var(--brand); }
.booster__ic { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: var(--surface); color: var(--brand); }
.booster__name { font-size: 14px; font-weight: 600; }
.booster__cost { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; color: var(--text-muted); }
.booster__cost .ic { width: 14px; height: 14px; color: var(--coin); }
.sheet .btn--block + .btn--block { margin-top: -4px; }

.variants { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; margin: 8px 0; }
.variant {
  display: grid; justify-items: center; gap: 4px; padding: 12px 4px;
  border: 0; border-radius: var(--radius); background: var(--surface-2); cursor: pointer;
  font-size: 14px; font-weight: 600;
  transition: transform 150ms var(--ease-out), box-shadow 150ms var(--ease-out);
}
.variant:hover { transform: translateY(-2px); }
.variant.on { background: var(--brand-subtle); box-shadow: inset 0 0 0 3px var(--brand); }
.variant__art svg { width: 64px; height: 64px; display: block; }
.variant__art {
  font-size: 48px; line-height: 1.2; filter: hue-rotate(var(--hue));
  display: grid; place-items: center; height: 64px;
}

.rstars { display: flex; gap: 4px; align-items: flex-end; margin-bottom: 4px; }
.rstar .ic { width: 56px; height: 56px; color: var(--star-off); fill: var(--star-off); }
.rstar:nth-child(2) .ic { width: 72px; height: 72px; }
.rstar.on .ic { color: var(--star); fill: var(--star); animation: starIn 500ms var(--ease-spring) calc(var(--i) * 180ms) both; }
@keyframes starIn { from { transform: scale(0) rotate(-90deg); } }
.rewards { display: flex; gap: 12px; margin: 4px 0 8px; }
.reward {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 16px;
  border-radius: 999px; background: var(--surface-2); font-weight: 600; margin: 0;
}
.reward .ic { color: var(--coin); }
.reward:first-child .ic { color: var(--star); fill: var(--star); }
.result-art { display: grid; place-items: center; }
.result-ic { width: 64px; height: 64px; color: var(--star); }
.result-ic.heart { color: var(--heart); fill: var(--heart); }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 1100;
  padding: 12px 24px; border-radius: 999px; background: var(--text); color: var(--surface);
  font-size: 15px; box-shadow: var(--shadow-lg); pointer-events: none;
  opacity: 0; transform: translate(-50%, 16px);
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ───────── 반응형 ───────── */
@media (max-width: 960px) {
  .town-main { grid-template-columns: 1fr; padding-inline: 16px; }
  .topbar { padding-inline: 16px; }
}
@media (max-width: 900px) {
  #game { --cell: min(60px, calc((100vw - 32px) / 8), calc((100dvh - 320px) / 8)); }
  .g-top { padding: 12px 16px 4px; gap: 12px; }
  .g-score__num { min-width: 0; font-size: 20px; }
  .score-bar { width: 32vw; }
  .g-main { grid-template-columns: 1fr; gap: 12px; padding: 4px 16px 16px; justify-items: center; }
  .g-left { order: -1; flex-direction: row; width: 100%; justify-self: stretch; gap: 8px; }
  .moves { padding: 8px 16px; }
  .moves b { font-size: 32px; }
  .goals { flex: 1; padding: 8px 12px; }
  .goals ul { grid-auto-flow: column; justify-content: start; gap: 16px; }
  .g-right { flex-direction: row; width: 100%; justify-self: stretch; gap: 8px; }
  .tool { min-height: 72px; padding: 8px 4px; grid-template-columns: auto auto; align-items: center; justify-content: center; gap: 8px; }
  .tool__ic { width: 36px; height: 36px; }
  .brand .chapter-tag { display: none; }
  .play-btn { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); }
  .bubble { font-size: 13px; padding: 8px 12px; max-width: 60%; }
  .chip { padding-right: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}

/* 어려운 레벨 */
.hard-badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px;
  border-radius: 999px; background: var(--danger); color: var(--text-on-brand);
  font-size: 13px; font-weight: 600; line-height: 1.4; font-family: var(--font);
}
.hard-badge .ic { width: 16px; height: 16px; }
.hard-badge--sm { padding: 2px 8px; font-size: 12px; vertical-align: middle; }
.play-btn.hard { background: var(--danger); box-shadow: inset 0 -5px 0 var(--hard-shadow), var(--shadow-lg); }
.play-btn.hard:hover { background: var(--danger-hover); }

/* ───────── 퀄리티: 퍼즐 배경 · 게임풍 HUD ───────── */
#game { position: relative; overflow: hidden; background: linear-gradient(var(--sky-top), var(--sky-bot) 70%); }
.g-bg { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.g-cloud {
  position: absolute; left: var(--x); top: var(--y);
  width: calc(var(--w) * 1vw); height: calc(var(--w) * .34vw); min-width: 64px; min-height: 22px;
  background: var(--cloud); border-radius: 999px; opacity: .85;
}
.g-cloud::before { content: ''; position: absolute; left: 22%; bottom: 40%; width: 46%; aspect-ratio: 1; background: var(--cloud); border-radius: 50%; }
.g-hill { position: absolute; border-radius: 50% 50% 0 0; }
.g-hill--back { left: -30%; right: 20%; bottom: -34vh; height: 64vh; background: var(--ground-d); opacity: .55; }
.g-hill--front { left: 10%; right: -30%; bottom: -40vh; height: 64vh; background: var(--ground); }
.g-top, .g-main { position: relative; z-index: 1; }

.g-level { background: var(--surface); padding: 4px 16px; border-radius: 999px; box-shadow: var(--shadow-sm); }
.g-score { flex: none; margin-left: auto; background: var(--surface); padding: 8px 16px; border-radius: 999px; box-shadow: var(--shadow-sm); }
.moves, .goals, .tool { box-shadow: inset 0 -4px 0 var(--surface-edge), 0 8px 20px var(--shadow-soft); }
.score-bar .mk { width: 28px; height: 28px; background: none; border: 0; color: var(--star-off); display: grid; place-items: center; }
.score-bar .mk .ic { width: 28px; height: 28px; fill: currentColor; stroke: var(--surface); stroke-width: 2; }
.score-bar .mk.on { background: none; color: var(--star); transform: translate(-50%, -50%) scale(1.2); }

/* ───────── 퀄리티: 터짐·콤보·흔들림 ───────── */
.fx-bit {
  position: absolute; left: calc((var(--c) + .5) * var(--cell)); top: calc((var(--r) + .5) * var(--cell));
  width: calc(var(--cell) * .16); height: calc(var(--cell) * .16);
  margin: calc(var(--cell) * -.08) 0 0 calc(var(--cell) * -.08);
  border-radius: 50%; background: var(--col); box-shadow: 0 0 0 1.5px var(--paper);
  animation: bit 620ms var(--ease-out) forwards;
}
.fx-bit.star { border-radius: 2px; background: var(--paper); box-shadow: 0 0 6px var(--glow); }
@keyframes bit {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(calc(var(--dx) * var(--cell)), calc(var(--dy) * var(--cell) + var(--cell) * .35)) scale(.2) rotate(180deg); opacity: 0; }
}
.fx-ring {
  position: absolute; left: calc((var(--c) + .5) * var(--cell)); top: calc((var(--r) + .5) * var(--cell));
  width: var(--cell); aspect-ratio: 1; border-radius: 50%;
  border: 4px solid var(--glow); box-shadow: 0 0 16px var(--glow);
  transform: translate(-50%, -50%) scale(.5); animation: ring 520ms var(--ease-out) forwards;
}
@keyframes ring { to { transform: translate(-50%, -50%) scale(1.9); opacity: 0; } }
.fx-combo {
  position: absolute; left: 50%; top: 10%; z-index: 6; white-space: nowrap;
  font-family: var(--font-display); font-size: calc(var(--cell) * .5); line-height: 1.2;
  color: var(--o-gold); text-shadow: 0 3px 0 var(--score-stroke), 0 0 12px var(--score-stroke);
  animation: comboPop 900ms var(--ease-out) forwards;
}
.fx-combo b { font-weight: 400; font-size: 1.6em; margin-right: 4px; }
@keyframes comboPop {
  0% { transform: translateX(-50%) scale(.3); opacity: 0; }
  20% { transform: translateX(-50%) scale(1.15); opacity: 1; }
  35%, 75% { transform: translateX(-50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -40%); opacity: 0; }
}
.board-frame.shake { animation: shake 320ms ease-out; }
.board-frame.shake2 { animation: shake2 480ms ease-out; }
@keyframes shake { 20% { transform: translate(-4px, 2px); } 40% { transform: translate(4px, -2px); } 60% { transform: translate(-3px, 1px); } 80% { transform: translate(2px, 0); } }
@keyframes shake2 { 15% { transform: translate(-8px, 4px) rotate(-1deg); } 30% { transform: translate(8px, -4px) rotate(1deg); } 45% { transform: translate(-6px, 2px); } 60% { transform: translate(6px, -2px); } 80% { transform: translate(-2px, 0); } }

/* ───────── 퀄리티: 목표로 날아가기 · 꽃가루 ───────── */
.fly-layer { position: fixed; inset: 0; pointer-events: none; z-index: 1050; overflow: hidden; }
.flyer { position: absolute; left: 0; top: 0; will-change: transform; }
.flyer svg { display: block; width: 100%; height: 100%; filter: drop-shadow(0 4px 6px var(--shadow-soft)); }
.confetti {
  position: absolute; top: -24px; left: var(--x); width: 10px; height: 14px; border-radius: 2px;
  background: var(--col); opacity: 0;
  animation: fall var(--d) cubic-bezier(.3, .6, .6, 1) var(--delay) forwards;
}
.confetti.round { width: 10px; height: 10px; border-radius: 50%; }
@keyframes fall {
  0% { opacity: 1; transform: translate(0, 0) rotate(0); }
  100% { opacity: 1; transform: translate(var(--dx), 110vh) rotate(var(--rot)); }
}

/* ───────── 퀄리티: 튜토리얼 코치 ───────── */
.board-col { position: relative; }
.coach {
  position: absolute; left: 50%; bottom: 24px; z-index: 20; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; width: min(440px, calc(100vw - 32px));
  padding: 8px 16px 8px 8px; border: 0; border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: inset 0 -4px 0 var(--surface-edge), var(--shadow-lg);
  text-align: left; font-size: 15px; line-height: 1.5; cursor: pointer;
}
.coach.coach--top { bottom: auto; top: 24px; }
.coach p { margin: 0; color: var(--text); }
.coach__face { width: 52px; height: 52px; flex: none; }
.coach.on { animation: coachIn 320ms var(--ease-spring); }
@keyframes coachIn { from { transform: translate(-50%, 12px) scale(.92); opacity: 0; } }
.tut-hand {
  position: absolute; z-index: 15; pointer-events: none;
  left: calc((var(--c) + .5) * var(--cell)); top: calc((var(--r) + .5) * var(--cell));
  width: calc(var(--cell) * 1.15); height: calc(var(--cell) * 1.15); margin-left: calc(var(--cell) * -.4);
  animation: handMove 1.5s var(--ease-out) infinite;
}
.tut-hand svg { width: 100%; height: 100%; fill: var(--paper); stroke: var(--ink); stroke-width: 1.8; stroke-linejoin: round; filter: drop-shadow(0 3px 4px var(--shadow-soft)); }
@keyframes handMove {
  0% { transform: translate(0, 0); opacity: 0; }
  15% { transform: translate(0, 0) scale(.9); opacity: 1; }
  65% { transform: translate(calc(var(--dc) * var(--cell)), calc(var(--dr) * var(--cell))) scale(.9); opacity: 1; }
  100% { transform: translate(calc(var(--dc) * var(--cell)), calc(var(--dr) * var(--cell))); opacity: 0; }
}
.tut-spot {
  position: absolute; z-index: 14; pointer-events: none;
  left: calc(var(--c) * var(--cell)); top: calc(var(--r) * var(--cell));
  width: var(--cell); height: var(--cell); border-radius: 30%;
  box-shadow: inset 0 0 0 3px var(--paper), 0 0 0 3px var(--o-gold), 0 0 18px var(--glow);
  animation: spot 1.5s ease-in-out infinite;
}
@keyframes spot { 50% { box-shadow: inset 0 0 0 3px var(--paper), 0 0 0 5px var(--o-gold), 0 0 28px var(--glow); } }

/* ───────── 모바일·터치 ───────── */
/* 더블탭 확대 막기 · 길게 눌러 뜨는 메뉴/선택 막기 */
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
#game, .board, .tile, .item, .slot, .play-btn, .tool, .mascot { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.icon-btn { flex: none; }

/* 손가락으로 누르기 쉽게: 작은 장식도 최소 44px 영역 */
.item::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: max(100%, 44px); height: max(100%, 44px); transform: translate(-50%, -50%);
}

/* 터치 기기에서는 hover 들썩임이 눌린 채로 남지 않게 */
@media (hover: none) {
  .btn:hover, .icon-btn:hover, .tool:hover, .booster:hover, .variant:hover, .mascot:hover,
  .btn:hover:not(:disabled), .booster:hover:not(:disabled) { transform: none; }
  .item:hover { transform: translate(-50%, -100%); }
  .item.shape:hover { transform: translate(-50%, -50%); }
  .slot:hover { transform: translate(-50%, -100%); }
  .play-btn:hover { transform: none; background: var(--brand); }
  .play-btn.hard:hover { background: var(--danger); }
}

@media (max-width: 900px) {
  .town-main { padding-bottom: 168px; } /* 떠 있는 플레이·지도 버튼 뒤로 목록이 숨지 않게 */
}

/* 가로로 눕힌 휴대폰: 보드를 화면 높이에 맞추고 정보는 양옆으로 */
@media (orientation: landscape) and (max-height: 520px) {
  #game { --cell: min(52px, calc((100dvh - 48px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) / 8)); }
  .g-top {
    position: absolute; left: 0; right: 0; top: 0; z-index: 2; max-width: none;
    padding: 8px max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); pointer-events: none;
  }
  .g-top > * { pointer-events: auto; }
  .g-score { padding: 4px 12px; gap: 8px; }
  .g-score__num { font-size: 18px; min-width: 0; }
  .score-bar { width: 96px; }
  .g-main {
    grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: center; justify-items: stretch;
    min-height: 100dvh; padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  }
  .g-left { order: 0; flex-direction: column; justify-self: end; width: 140px; margin-top: 48px; gap: 8px; }
  .g-right { flex-direction: column; justify-self: start; width: 104px; margin-top: 48px; gap: 8px; }
  .moves { padding: 4px 12px; }
  .moves b { font-size: 32px; }
  .goals { padding: 8px 12px; }
  .goals ul { grid-auto-flow: row; gap: 4px; }
  .gi { width: 28px; height: 28px; }
  .tool { min-height: 0; padding: 8px; grid-template-columns: auto 1fr; justify-items: start; align-items: center; gap: 8px; }
  .tool__ic { width: 32px; height: 32px; }
  .tool__ic .ic { width: 18px; height: 18px; }
  .coach { bottom: 12px; width: min(400px, 60vw); font-size: 13px; }
  .coach.coach--top { top: 12px; }
  .coach__face { width: 40px; height: 40px; }

  /* 마을: 장면이 화면 높이 안에 다 들어오게 */
  .topbar { padding-block: 8px; }
  .scene-col { width: min(100%, calc((100dvh - 80px) * 1.6)); margin-inline: auto; }
  .play-btn { position: absolute; right: 16px; bottom: 16px; min-height: 52px; font-size: 18px; }
  .play-btn b { font-size: 26px; }
  .town-main { padding-bottom: 32px; }
}

/* ───────── 마을 건설 연출 ───────── */
.build-fx { position: absolute; inset: 0; pointer-events: none; z-index: 250; }
.slot.used { opacity: 0; transform: translate(-50%, -100%) scale(.4); transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out); pointer-events: none; }
.star-fly { position: absolute; left: 0; top: 0; width: 32px; height: 32px; color: var(--star); will-change: transform; }
.star-fly .ic { width: 32px; height: 32px; fill: var(--star); stroke: var(--o-gold-d); stroke-width: 1.5; filter: drop-shadow(0 0 6px var(--glow)); }

.build-site {
  position: absolute; width: calc(var(--w) * 1cqw); transform: translate(-50%, -100%);
  animation: siteIn 260ms var(--ease-spring) both; transform-origin: 50% 100%;
}
.build-site svg { display: block; width: 100%; height: auto; }
.build-site.gone { animation: siteOut 260ms var(--ease-out) forwards; }
@keyframes siteIn { from { transform: translate(-50%, -100%) scale(.3); opacity: 0; } }
@keyframes siteOut { to { transform: translate(-50%, -100%) scale(1.1, .2); opacity: 0; } }
.build-hammer {
  position: absolute; right: -18%; top: -6%; width: 46%; aspect-ratio: 1;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--surface); color: var(--wood-d); box-shadow: var(--shadow-md);
  transform-origin: 80% 80%; animation: hammer 220ms ease-in-out infinite alternate;
}
.build-hammer .ic { width: 62%; height: 62%; }
@keyframes hammer { from { transform: rotate(-30deg); } to { transform: rotate(20deg); } }

.puff {
  position: absolute; width: var(--s); height: var(--s); margin: calc(var(--s) / -2) 0 0 calc(var(--s) / -2);
  border-radius: 50%; background: var(--cloud); box-shadow: inset 0 -.4cqw 0 var(--o-snow-d);
  opacity: 0; animation: puff 900ms var(--ease-out) var(--delay) forwards;
}
@keyframes puff {
  0% { transform: translate(0, 0) scale(.3); opacity: 0; }
  20% { opacity: .95; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1.2); opacity: 0; }
}
.sparkle {
  position: absolute; width: 1.4cqw; height: 1.4cqw; min-width: 6px; min-height: 6px;
  margin: -.7cqw 0 0 -.7cqw; background: var(--col); border-radius: 2px; transform: rotate(45deg);
  box-shadow: 0 0 6px var(--glow); animation: sparkle 900ms var(--ease-out) forwards;
}
.sparkle.big { width: 2.2cqw; height: 2.2cqw; background: var(--o-gold); }
@keyframes sparkle {
  0% { transform: translate(0, 0) rotate(45deg) scale(.2); opacity: 1; }
  60% { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(225deg) scale(1); opacity: 0; }
}
.mascot.cheer { animation: cheer 700ms var(--ease-out); }
@keyframes cheer {
  0% { transform: none; } 15% { transform: scale(1.1, .88); } 40% { transform: translateY(-28%) scale(.94, 1.06) rotate(-6deg); }
  60% { transform: translateY(-12%) rotate(6deg); } 80% { transform: scale(1.06, .94); } 100% { transform: none; }
}

/* ───────── 출석 보상 ───────── */
.daily-btn { position: relative; color: var(--brand); }
.daily-btn.has-dot::after {
  content: ''; position: absolute; top: 6px; right: 6px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--danger); box-shadow: 0 0 0 2px var(--surface);
  animation: dotPulse 1.6s ease-in-out infinite;
}
@keyframes dotPulse { 50% { transform: scale(1.3); } }
.chip.bump { animation: chipBump 280ms var(--ease-spring); }
@keyframes chipBump { 50% { transform: scale(1.12); } }

.sheet--daily { width: min(460px, 100%); }
.daily-grid {
  list-style: none; margin: 8px 0; padding: 0; width: 100%;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
.day {
  position: relative; display: grid; justify-items: center; align-content: start; gap: 4px;
  padding: 8px 4px 12px; border-radius: var(--radius); background: var(--surface-2);
  box-shadow: inset 0 -3px 0 var(--surface-edge);
}
.day--big { grid-column: span 2; background: var(--brand-subtle); }
.day__tag { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.day__art { display: flex; justify-content: center; gap: 2px; min-height: 36px; align-items: center; }
.day__ic { display: grid; place-items: center; }
.day__ic .ic { width: 26px; height: 26px; }
.day__ic--coin { color: var(--coin); }
.day__ic--tool { color: var(--brand); }
.day--big .day__art .ic { width: 40px; height: 40px; color: var(--brand); }
.day__label { font-size: 12px; line-height: 1.4; text-align: center; color: var(--text); word-break: keep-all; }
.day__stamp {
  position: absolute; inset: 0; display: grid; place-items: center; border-radius: inherit;
  background: rgba(255, 253, 249, .72); color: var(--success); opacity: 0;
}
.day__stamp .ic { width: 36px; height: 36px; stroke-width: 3; }
.day--done .day__stamp { opacity: 1; }
.day--done.just .day__stamp { animation: stamp 420ms var(--ease-spring); }
@keyframes stamp { from { transform: scale(2); opacity: 0; } }
.day--today { background: var(--surface); box-shadow: inset 0 0 0 3px var(--brand), 0 6px 16px var(--shadow-soft); animation: todayPulse 1.4s ease-in-out infinite; }
.day--today .day__tag { color: var(--brand); }
@keyframes todayPulse { 50% { transform: translateY(-3px); } }
.day--tomorrow { box-shadow: inset 0 0 0 2px var(--border-strong); }
.day--later { opacity: .7; }

.icon-fly { position: absolute; left: 0; top: 0; width: 28px; height: 28px; will-change: transform; }
.icon-fly .ic { width: 28px; height: 28px; filter: drop-shadow(0 2px 4px var(--shadow-soft)); }
.icon-fly--coin { color: var(--coin); }
.icon-fly--coin .ic { fill: var(--o-gold); stroke: var(--o-gold-d); }

/* ───────── 레벨 지도 ───────── */
#map { background: var(--bg); }
.map-top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10;
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: var(--surface); background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
}
.map-title { margin: 0; flex: 1; font-family: var(--font-display); font-weight: 400; font-size: 24px; line-height: 1.2; }
.map-top .chip small { margin-left: 2px; min-width: 0; }
.map-world { position: relative; width: 100%; overflow: hidden; }
.m-band {
  position: absolute; left: 0; right: 0;
  background:
    radial-gradient(circle at 20% 30%, var(--ground-d) 0 2px, transparent 3px) 0 0 / 48px 48px,
    linear-gradient(var(--ground), var(--ground-d));
}
.m-band.theme-beach { background:
    radial-gradient(circle at 30% 40%, var(--o-sand-d) 0 1.5px, transparent 2.5px) 0 0 / 32px 32px,
    linear-gradient(var(--ground), var(--ground-d)); }
.m-sign {
  position: absolute; left: 16px; z-index: 3; padding: 4px 16px;
  font-family: var(--font-display); font-size: 18px; line-height: 1.4; color: var(--text);
  background: var(--surface); border-radius: 999px; box-shadow: inset 0 -3px 0 var(--surface-edge), var(--shadow-sm);
}
.m-sign small { font-family: var(--font); font-size: 12px; color: var(--text-muted); margin-left: 4px; }
.m-road { position: absolute; left: 0; top: 0; z-index: 1; overflow: visible; }
.m-road path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.m-road__edge { stroke: var(--stone-d); stroke-width: 34; opacity: .6; }
.m-road__base { stroke: var(--stone); stroke-width: 28; }
.m-road__dash { stroke: var(--paper); stroke-width: 4; stroke-dasharray: 2 14; opacity: .9; }
.m-deco { position: absolute; z-index: 2; transform: translate(-50%, -100%); pointer-events: none; }

.node {
  position: absolute; z-index: 4; transform: translate(-50%, -50%);
  width: 56px; height: 56px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  display: grid; place-items: center;
  background: var(--surface); color: var(--text);
  box-shadow: inset 0 -5px 0 var(--surface-edge), 0 0 0 4px var(--paper), 0 6px 12px var(--shadow-soft);
  transition: transform 150ms var(--ease-out);
}
.node:active { transform: translate(-50%, -50%) scale(.94); }
.node__n { font-family: var(--font-display); font-size: 22px; line-height: 1; display: grid; place-items: center; }
.node__n .ic { width: 20px; height: 20px; }
.node--done { background: var(--t3); color: var(--paper); box-shadow: inset 0 -5px 0 var(--t3d), 0 0 0 4px var(--paper), 0 6px 12px var(--shadow-soft); }
.node--done .node__n { text-shadow: 0 2px 0 var(--t3d); }
.node--current {
  width: 72px; height: 72px; background: var(--brand); color: var(--paper);
  box-shadow: inset 0 -6px 0 var(--brand-shadow), 0 0 0 5px var(--paper), 0 0 0 10px rgba(255, 122, 61, .3), 0 8px 16px var(--shadow-soft);
  animation: nodePulse 1.6s ease-in-out infinite;
}
.node--current .node__n { font-size: 28px; text-shadow: 0 2px 0 var(--brand-shadow); }
@keyframes nodePulse { 50% { box-shadow: inset 0 -6px 0 var(--brand-shadow), 0 0 0 5px var(--paper), 0 0 0 16px rgba(255, 122, 61, .15), 0 8px 16px var(--shadow-soft); } }
.node--locked { background: var(--surface-2); color: var(--text-subtle); cursor: default; }
.node--hard.node--current { background: var(--danger); box-shadow: inset 0 -6px 0 var(--hard-shadow), 0 0 0 5px var(--paper), 0 0 0 10px rgba(229, 72, 77, .3), 0 8px 16px var(--shadow-soft); }
.node--hard.node--done { background: var(--danger); box-shadow: inset 0 -5px 0 var(--hard-shadow), 0 0 0 4px var(--paper), 0 6px 12px var(--shadow-soft); }
.node--hard.node--done .node__n { text-shadow: 0 2px 0 var(--hard-shadow); }
.node--hard.node--locked { box-shadow: inset 0 -5px 0 var(--surface-edge), 0 0 0 4px var(--danger), 0 6px 12px var(--shadow-soft); }
.node__hard {
  position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; background: var(--danger); color: var(--paper); box-shadow: 0 0 0 2px var(--paper);
}
.node__hard .ic { width: 14px; height: 14px; }
.node__stars { position: absolute; bottom: -14px; left: 50%; transform: translateX(-50%); display: flex; gap: 0; }
.node__stars i { display: grid; }
.node__stars .ic { width: 18px; height: 18px; fill: var(--star-off); color: var(--star-off); stroke: var(--paper); stroke-width: 2; }
.node__stars i:nth-child(2) { transform: translateY(4px); }
.node__stars i.on .ic { fill: var(--star); color: var(--star); }
.node.nope { animation: nudge 400ms var(--ease-out); }
.m-avatar {
  position: absolute; z-index: 5; width: 56px; transform: translate(-50%, -100%); pointer-events: none;
  animation: avatarBob 1.2s ease-in-out infinite;
}
.m-avatar svg { display: block; width: 100%; height: auto; }
@keyframes avatarBob { 50% { transform: translate(-50%, calc(-100% - 6px)); } }

/* 마을의 지도 버튼 (플레이 버튼 위) */
.map-btn {
  position: absolute; right: 24px; bottom: 92px; z-index: 400;
  display: grid; justify-items: center; gap: 0; width: 56px; height: 56px; padding: 8px 0 4px;
  border: 0; border-radius: 50%; cursor: pointer;
  background: var(--surface); color: var(--accent); font-size: 11px; font-weight: 600; line-height: 1.2;
  box-shadow: inset 0 -4px 0 var(--surface-edge), var(--shadow-lg);
  transition: transform 150ms var(--ease-out);
}
.map-btn .ic { width: 22px; height: 22px; }
.map-btn span:last-child { color: var(--text); }
.map-btn:hover { transform: translateY(-2px); }
@media (max-width: 900px) {
  .map-btn { position: fixed; right: 24px; bottom: calc(92px + env(safe-area-inset-bottom)); }
}
@media (orientation: landscape) and (max-height: 520px) {
  .map-btn { position: absolute; right: 16px; bottom: 80px; width: 48px; height: 48px; }
}

/* ───────── 화면 전환 ───────── */
.screen-in { animation: screenIn 280ms var(--ease-out); }
@keyframes screenIn { from { opacity: 0; transform: scale(.985); } }

/* ───────── 대화 장면 ───────── */
.dlg {
  position: fixed; inset: 0; z-index: 1080; cursor: pointer;
  background: linear-gradient(transparent 45%, rgba(40, 25, 20, .35));
  display: flex; align-items: flex-end; justify-content: center;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
}
.dlg.in { animation: fade 220ms var(--ease-out); }
.dlg__box {
  position: relative; width: min(620px, 100%); min-height: 112px;
  display: flex; align-items: flex-start; gap: 16px; padding: 16px 20px 20px 16px;
  background: var(--surface); border-radius: var(--radius-xl);
  box-shadow: inset 0 -5px 0 var(--surface-edge), 0 0 0 4px var(--who-bg), var(--shadow-lg);
  animation: sheetIn 300ms var(--ease-spring);
}
.dlg__face {
  flex: none; width: 88px; height: 88px; margin-top: -40px; border-radius: 50%;
  display: grid; place-items: center; background: var(--who-bg); box-shadow: 0 0 0 4px var(--surface), var(--shadow-md);
}
.dlg__face svg { width: 76px; height: 76px; }
.dlg__face.pop svg { animation: born 360ms var(--ease-spring); }
.dlg__body { flex: 1; min-width: 0; }
.dlg__name {
  display: inline-block; padding: 2px 12px; margin-bottom: 4px; border-radius: 999px;
  background: var(--who); color: var(--paper); font-size: 14px; font-weight: 600;
}
.dlg__text { margin: 0; font-size: 17px; line-height: 1.6; color: var(--text); min-height: 2lh; }
.dlg__next {
  position: absolute; right: 20px; bottom: 12px; width: 0; height: 0;
  border-left: 7px solid transparent; border-right: 7px solid transparent; border-top: 9px solid var(--who);
  animation: nextBob 800ms ease-in-out infinite;
}
.dlg.typing .dlg__next { opacity: 0; }
@keyframes nextBob { 50% { transform: translateY(4px); } }
.dlg__skip {
  position: absolute; top: calc(16px + env(safe-area-inset-top)); right: 16px;
  min-height: 40px; padding: 8px 16px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--surface); color: var(--text-muted); font-size: 14px; font-weight: 600; box-shadow: var(--shadow-md);
}
.dlg__skip:hover { color: var(--text); }

/* ───────── 동산을 돌아다니는 친구들 ───────── */
.life, .ambient { position: absolute; inset: 0; pointer-events: none; }
.walker {
  position: absolute; width: max(9cqw, 44px); aspect-ratio: 1; padding: 0; border: 0; background: none; cursor: pointer;
  transform: translate(-50%, -100%); pointer-events: auto;
}
.walker__shadow { position: absolute; left: 15%; right: 15%; bottom: -4%; height: 14%; border-radius: 50%; background: var(--shadow-soft); }
.walker__body { position: absolute; inset: 0; transform: scaleX(var(--dir, 1)); transform-origin: 50% 100%; }
.walker__body svg { position: absolute; inset: 0 0 10% 0; width: 100%; height: 90%; display: block; }
.walker__foot {
  position: absolute; bottom: 0; width: 22%; height: 14%; border-radius: 50%;
  background: var(--ink); opacity: .75;
}
.walker__foot--l { left: 26%; }
.walker__foot--r { right: 26%; }
.walker.walking .walker__body { animation: waddle 420ms ease-in-out infinite; }
.walker.walking .walker__foot--l { animation: footL 420ms ease-in-out infinite; }
.walker.walking .walker__foot--r { animation: footL 420ms ease-in-out infinite reverse; }
@keyframes waddle { 0%, 100% { transform: scaleX(var(--dir, 1)) rotate(-4deg); } 50% { transform: scaleX(var(--dir, 1)) rotate(4deg) translateY(-4%); } }
@keyframes footL { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-40%); } }
.walker__body.hop { animation: walkerHop 520ms var(--ease-out); }
@keyframes walkerHop {
  0% { transform: scaleX(var(--dir, 1)); } 20% { transform: scaleX(var(--dir, 1)) scale(1.1, .86); }
  50% { transform: scaleX(var(--dir, 1)) translateY(-30%) scale(.94, 1.08); } 100% { transform: scaleX(var(--dir, 1)); }
}
.walker .e-c, .walker .e-h { display: none; }
.walker.blink .e-o { display: none; }
.walker.blink .e-c { display: inline; }
.walker.happy .e-o, .walker.happy .e-c { display: none; }
.walker.happy .e-h { display: inline; }
.walker__say {
  position: absolute; left: 50%; bottom: 108%; transform: translateX(-50%);
  width: max-content; max-width: 180px; padding: 6px 12px; border-radius: 14px;
  background: var(--bubble); color: var(--text); font-size: 13px; line-height: 1.4; text-align: center;
  box-shadow: var(--shadow-md); pointer-events: none; word-break: keep-all;
}
.walker__say::after {
  content: ''; position: absolute; left: 50%; top: 100%; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: var(--bubble);
}
.walker__say.on { animation: born 320ms var(--ease-spring); }

/* ───────── 테마별 배경 움직임 ───────── */
.cloud { animation: cloudDrift 60s linear infinite alternate; }
.cloud:nth-child(2) { animation-duration: 80s; animation-delay: -20s; }
.cloud:nth-child(3) { animation-duration: 70s; animation-delay: -35s; }
@keyframes cloudDrift { from { transform: translateX(-6cqw); } to { transform: translateX(8cqw); } }

.amb-butterfly {
  position: absolute; left: var(--x); top: var(--y); z-index: 120; width: 4cqw; height: 3cqw; min-width: 18px; min-height: 14px;
  animation: flutterPath var(--d) ease-in-out var(--delay) infinite;
}
.amb-butterfly b {
  position: absolute; top: 0; width: 50%; height: 100%; background: var(--col);
  border-radius: 60% 40% 50% 50%; box-shadow: inset 0 0 0 1.5px var(--paper);
  animation: wing 260ms ease-in-out infinite alternate;
}
.amb-butterfly b:first-child { left: 0; transform-origin: right center; }
.amb-butterfly b:last-child { right: 0; transform-origin: left center; border-radius: 40% 60% 50% 50%; }
@keyframes wing { from { transform: scaleX(1); } to { transform: scaleX(.25); } }
@keyframes flutterPath {
  0% { transform: translate(0, 0); } 25% { transform: translate(8cqw, -4cqw); } 50% { transform: translate(16cqw, 1cqw); }
  75% { transform: translate(7cqw, 4cqw); } 100% { transform: translate(0, 0); }
}
.amb-wave {
  position: absolute; left: -10%; right: -10%; top: var(--y); height: .6cqw; border-radius: 999px;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .7) 0 6cqw, transparent 6cqw 14cqw);
  animation: waveSlide var(--d) linear var(--delay, 0s) infinite; opacity: .7;
}
@keyframes waveSlide { to { transform: translateX(14cqw); } }
.amb-gull {
  position: absolute; left: -8%; top: var(--y); width: 4cqw; height: 1.6cqw;
  animation: gullFly var(--d) linear var(--delay) infinite;
}
.amb-gull::before, .amb-gull::after {
  content: ''; position: absolute; top: 0; width: 50%; height: 100%;
  border-top: .5cqw solid var(--text-muted); border-radius: 50% 50% 0 0; animation: gullFlap 600ms ease-in-out infinite alternate;
}
.amb-gull::before { left: 0; }
.amb-gull::after { right: 0; }
@keyframes gullFly { to { transform: translateX(118cqw); } }
@keyframes gullFlap { to { transform: translateY(.4cqw) scaleY(.6); } }
.amb-snow {
  position: absolute; left: var(--x); top: -4%; z-index: 150; width: var(--s); height: var(--s); border-radius: 50%;
  background: var(--paper); box-shadow: 0 0 4px rgba(255, 255, 255, .9); opacity: .9;
  animation: snowFall var(--d) linear var(--delay) infinite;
}
@keyframes snowFall { to { transform: translate(calc(var(--sway) * 4cqw), 70cqw); } }

/* ───────── 퍼즐 비주얼 고급화 ───────── */
/* 줄 블록: 빛나는 양방향 화살표 */
.tile.sp-h .in::after, .tile.sp-v .in::after,
.tile.sp-h .in::before, .tile.sp-v .in::before {
  content: ''; position: absolute; left: 6%; right: 6%; top: 36%; bottom: auto; width: auto; height: 28%;
  border-radius: 0; box-shadow: none; inset-inline: 6%;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 40'%3E%3Cpath d='M2 20 L24 3 V13 H76 V3 L98 20 L76 37 V27 H24 V37 Z'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 40'%3E%3Cpath d='M2 20 L24 3 V13 H76 V3 L98 20 L76 37 V27 H24 V37 Z'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}
.tile.sp-h .in::before, .tile.sp-v .in::before { background: var(--board-edge); transform: scale(1.14, 1.3); opacity: .85; }
.tile.sp-h .in::after, .tile.sp-v .in::after { background: var(--paper); animation: arrowPulse 1.1s ease-in-out infinite; }
.tile.sp-v .in::before { transform: rotate(90deg) scale(1.14, 1.3); }
.tile.sp-v .in::after { transform: rotate(90deg); }
@keyframes arrowPulse { 50% { scale: 1.1; opacity: .85; } }
.tile.sp-h .in svg, .tile.sp-v .in svg { filter: drop-shadow(0 2px 0 var(--tile-shadow)) drop-shadow(0 0 6px var(--glow)); }

/* 폭탄: 숨 쉬는 빛 */
.tile.sp-b .in::before {
  content: ''; position: absolute; inset: -8%; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 236, 140, .6), rgba(255, 236, 140, 0) 66%);
  animation: aura 1.2s ease-in-out infinite;
}
@keyframes aura { 50% { transform: scale(1.12); opacity: .7; } }

/* 젤리: 반짝 광택 + 말랑 출렁 */
.cell.j1::after, .cell.j2::after {
  background: linear-gradient(155deg, rgba(255, 255, 255, .6) 0 14%, rgba(255, 255, 255, 0) 30%), var(--jelly);
  animation: jellyWobble 2.6s ease-in-out infinite;
}
.cell.j2::after { background: linear-gradient(155deg, rgba(255, 255, 255, .6) 0 14%, rgba(255, 255, 255, 0) 30%), var(--jelly2); }
.cell:nth-child(3n)::after { animation-delay: -.8s; }
.cell:nth-child(3n + 1)::after { animation-delay: -1.6s; }
@keyframes jellyWobble { 50% { transform: scale(1.04, .96); } }

/* 상자: 한 번 맞으면 금이 간다, 부서지면 판자 조각 */
.tile.crate.cracked .in::after {
  content: ''; position: absolute; inset: 8%; background: var(--wood-d);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M28 8 L44 34 L33 50 L56 70 L47 94 M44 34 L68 26 M56 70 L78 76' fill='none' stroke='black' stroke-width='6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M28 8 L44 34 L33 50 L56 70 L47 94 M44 34 L68 26 M56 70 L78 76' fill='none' stroke='black' stroke-width='6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.fx-bit.plank {
  width: calc(var(--cell) * .28); height: calc(var(--cell) * .1); border-radius: 2px;
  background: var(--wood); box-shadow: 0 0 0 1.5px var(--wood-d);
}

/* 안 맞는 교환: 도리도리 */
.tile .in.nope { animation: nope 320ms ease-in-out; }
@keyframes nope { 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }

/* 이동 5번 남음: 보드 테두리가 빨갛게 깜빡 */
.board-frame { position: relative; }
.board-frame.low::after {
  content: ''; position: absolute; inset: -4px; border-radius: calc(var(--radius-lg) + 4px); pointer-events: none;
  box-shadow: 0 0 0 4px var(--danger), 0 0 24px rgba(229, 72, 77, .5);
  animation: lowPulse 1.1s ease-in-out infinite;
}
@keyframes lowPulse { 50% { opacity: .25; } }

/* 목표 하나 완료: 체크가 통 튀어나온다 */
.goal.done b { animation: born 420ms var(--ease-spring); }

/* 작은 화면: 손가락 영역 확보 + 상단 줄 정리 */
@media (pointer: coarse) {
  .btn--sm { min-height: 40px; padding-inline: 14px; }
}
@media (max-width: 400px) {
  .chips { gap: 6px; width: 100%; }
  .chip { height: 36px; padding: 0 10px 0 6px; }
  .chip .ic { width: 20px; height: 20px; }
  .chip small { display: none; }
  .chips .icon-btn { width: 40px; height: 40px; }
}
