/* Splash Festa — 물감 풍선 축제
   분위기: 맑은 하늘 아래 축제 마당. 삼각 깃발, 하얀 캔버스, 색색의 물감 풍선.
   풍선이 터지면 캔버스에 물감 자국이 남고, 판을 다 비우면 그 자국이 그림 한 장이 된다. */

:root {
  --sky-1: #8fd8ff;
  --sky-2: #fff3d1;
  --ink: #3a2a55;
  --ink-soft: #6e5f8c;
  --paper: #fffaf0;
  --frame: #ffffff;
  --frame-edge: #e6dcf5;
  --cream: #fffdf7;
  --accent: #ff4f9a;
  --accent-dark: #c41e6a;
  --gold: #ffc928;
  --good: #2fbf71;
  --shadow: 0 6px 18px rgba(58, 42, 85, 0.22);
  --cell: 56px;
  --speed: 1;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 95, 162, 0.18) 0 6px, transparent 7px) 0 0 / 90px 110px,
    radial-gradient(circle at 70% 60%, rgba(255, 201, 40, 0.22) 0 5px, transparent 6px) 0 0 / 120px 90px,
    radial-gradient(circle at 40% 85%, rgba(61, 130, 240, 0.16) 0 5px, transparent 6px) 0 0 / 100px 130px,
    linear-gradient(180deg, var(--sky-1) 0%, var(--sky-2) 70%) fixed;
  font: 16px/1.5 "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.app { max-width: 480px; margin: 0 auto; min-height: 100%; position: relative; overflow-x: hidden; }
.screen { padding: 12px 16px 24px; }

/* ── 공통 ── */
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 0;
  background: rgba(255, 255, 255, 0.85); box-shadow: 0 2px 0 rgba(58, 42, 85, 0.22);
  font-size: 18px; display: grid; place-items: center;
}
.icon-btn:active { transform: translateY(2px); box-shadow: none; }
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.85); font-size: 14px; color: var(--ink-soft);
}
.pill b { color: var(--ink); }
/* 글 속 작은 풍선(색 이름 대신) */
.chip {
  display: inline-grid; place-items: center; width: 1.35em; height: 1.5em; vertical-align: -0.35em; margin: 0 1px;
  border-radius: 50% 50% 47% 47% / 56% 56% 44% 44%; font-style: normal; font-size: 0.95em; font-weight: 900; line-height: 1;
  background: radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.75) 0 10%, transparent 11%), var(--c);
  color: rgba(255, 255, 255, 0.95); box-shadow: inset -1px -2px 3px rgba(0, 0, 0, 0.18);
  font-family: "Segoe UI Symbol", "Apple Symbols", "Noto Sans Symbols 2", sans-serif;
}

/* ── 지도 ── */
.map-head { text-align: center; padding: 12px 0 8px; }
.logo { display: inline-flex; align-items: center; gap: 10px; }
.logo h1 {
  margin: 0; font-size: clamp(30px, 10vw, 44px); letter-spacing: 0.01em; font-weight: 900; line-height: 1.05;
  color: #fff; text-shadow: 0 3px 0 var(--accent-dark), 0 6px 0 rgba(58, 42, 85, 0.25);
}
.logo-sub { display: block; margin-top: 4px; font-size: 14px; font-weight: 800; letter-spacing: 0.3em; color: var(--ink); text-shadow: none; }
.logo-balloons { position: relative; width: 46px; height: 46px; }
.logo-balloons i {
  position: absolute; width: 24px; height: 28px; top: 4px;
  border-radius: 50% 50% 47% 47% / 56% 56% 44% 44%; box-shadow: inset -2px -3px 5px rgba(0, 0, 0, 0.2);
  animation: bob 2.4s ease-in-out infinite;
}
.logo-balloons i::after { content: ""; position: absolute; left: 50%; bottom: -12px; width: 1px; height: 12px; background: rgba(58, 42, 85, 0.5); }
.logo-balloons .c0 { left: 0; background: #ef4b45; }
.logo-balloons .c1 { left: 20px; top: 0; background: #3d82f0; animation-delay: -1.2s; }
@keyframes bob { 50% { transform: translateY(-4px) rotate(3deg); } }
.tagline { margin: 6px 0 12px; color: var(--ink-soft); font-size: 14px; }
.map-stats { display: flex; justify-content: center; align-items: center; gap: 8px; }

.daily-card {
  width: 100%; margin: 12px 0 8px; padding: 14px 16px; border: 0; border-radius: 18px; text-align: left;
  background: linear-gradient(135deg, #5b3fa8, #8a5be6); color: #fff; box-shadow: var(--shadow);
  display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center;
}
.daily-card .d-icon { font-size: 32px; text-align: center; }
.daily-card .d-title { font-weight: 800; font-size: 17px; }
.daily-card .d-sub { font-size: 13px; opacity: 0.85; }
.daily-card .d-go {
  padding: 8px 14px; border-radius: 999px; background: var(--gold); color: var(--ink); font-weight: 800; font-size: 14px;
}
.daily-card.done .d-go { background: #ffffff33; color: #fff; }
.parade-card { background: linear-gradient(135deg, #ff4f9a, #ff8a2a); }

.chapter {
  margin-top: 18px; border-radius: 20px; overflow: hidden; background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
}
.chapter.locked { filter: grayscale(0.85); opacity: 0.7; }
.chapter-sign {
  position: relative; padding: 26px 16px 12px; color: #fff;
  background: linear-gradient(135deg, var(--ch1, #3d82f0), var(--ch2, #8a5be6));
}
/* 삼각 깃발 */
.chapter-sign::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 16px;
  background:
    conic-gradient(from 135deg at 50% 0, #ff4f9a 0 90deg, transparent 90deg) 0 0 / 28px 16px repeat-x,
    conic-gradient(from 135deg at 50% 0, #ffc928 0 90deg, transparent 90deg) 14px 0 / 28px 16px repeat-x;
}
.chapter[data-ch="1"] .chapter-sign { --ch1: #ff6b6b; --ch2: #ff9f43; }
.chapter[data-ch="2"] .chapter-sign { --ch1: #e07a5f; --ch2: #b5523b; }
.chapter[data-ch="3"] .chapter-sign { --ch1: #4d96ff; --ch2: #6a5be6; }
.chapter[data-ch="4"] .chapter-sign { --ch1: #2fbf71; --ch2: #158f8a; }
.chapter-sign h2 { margin: 0; font-size: 19px; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.15); }
.chapter-sign p { margin: 2px 0 0; font-size: 13px; opacity: 0.92; }
.chapter-sign .ch-stars { position: absolute; right: 14px; top: 26px; font-size: 13px; font-weight: 700; }
.levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px 8px; padding: 16px 12px 22px; }
/* 레벨 버튼 = 풍선 */
.lv {
  position: relative; justify-self: center; width: 54px; height: 60px; border: 0;
  border-radius: 50% 50% 47% 47% / 56% 56% 44% 44%;
  background: radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.8) 0 9%, transparent 10%),
              radial-gradient(circle at 45% 40%, #ff9ec7, #ff4f9a 55%, #c41e6a);
  box-shadow: inset -3px -5px 8px rgba(0, 0, 0, 0.18), 0 4px 6px rgba(58, 42, 85, 0.2);
  font-weight: 900; font-size: 19px; color: #fff; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
}
.lv::before { content: ""; position: absolute; left: 50%; bottom: -6px; width: 10px; height: 7px; transform: translateX(-50%); background: inherit; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.lv:active { transform: translateY(3px) scale(0.96); }
.lv.boss { width: 60px; height: 66px; background: radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.8) 0 9%, transparent 10%), radial-gradient(circle at 45% 40%, #fff1a8, #ffc928 55%, #c48f00); color: var(--ink); text-shadow: none; }
.lv.boss::after { content: "👑"; position: absolute; top: -16px; left: 50%; transform: translateX(-50%); font-size: 16px; }
.lv.locked { background: radial-gradient(circle at 45% 40%, #ece6f5, #cfc6de 60%, #a99fbd); color: #8a7fa2; text-shadow: none; cursor: default; }
.lv.current { animation: nudge 1.4s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px) rotate(-3deg); } }
.lv .stars { position: absolute; bottom: -19px; left: 50%; transform: translateX(-50%); font-size: 11px; letter-spacing: -1px; white-space: nowrap; color: #e0a400; text-shadow: none; }
.lv .stars .off { color: rgba(0, 0, 0, 0.15); }
.map-foot { margin: 24px 0 8px; text-align: center; font-size: 12px; color: var(--ink-soft); opacity: 0.8; }

/* ── 게임 HUD ── */
.hud { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 10px; }
.hud-title { line-height: 1.2; }
.hud-title b { font-size: 20px; }
.hud-title > span { margin-left: 4px; font-size: 12px; color: var(--ink-soft); }
/* 점수 막대: 막대 끝이 ★★★, 가운데 눈금이 ★★ */
.rev { display: flex; align-items: center; gap: 13px; margin-top: 5px; }
.rev-bar { position: relative; flex: 1 1 auto; max-width: 170px; height: 9px; border-radius: 99px; background: rgba(255, 255, 255, 0.85); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15); }
.rev-bar .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; background: linear-gradient(90deg, #ff4f9a, #ffc928); transition: width calc(0.25s * var(--speed)); }
.rev-bar .mark { position: absolute; top: 50%; transform: translate(-50%, -50%); font-style: normal; font-size: 13px; line-height: 1; color: #c9bfd9; text-shadow: 0 1px 0 #fff; }
.rev-bar .mark.m3 { font-size: 15px; }
.rev-bar .mark.on { color: var(--gold); text-shadow: 0 1px 0 #9a6208, 0 0 6px rgba(255, 200, 60, 0.9); }
.rev-num { font-size: 14px; white-space: nowrap; }
.rev-num.tick { animation: tick calc(0.25s * var(--speed)) ease-out; }
.card .lose-rev b { color: var(--ink); }

/* 남은 칠하기 = 스프레이 캔 */
.cans { display: flex; gap: 5px; align-items: flex-end; }
.can {
  width: 16px; height: 26px; border-radius: 4px 4px 3px 3px; position: relative;
  background: linear-gradient(90deg, #ff4f9a 0 30%, #ff7ab6 30% 45%, #ff4f9a 45%);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.18), 0 2px 0 rgba(0, 0, 0, 0.2);
  transition: transform 0.3s, opacity 0.3s;
}
.can::before { content: ""; position: absolute; top: -7px; left: 4px; width: 8px; height: 7px; border-radius: 3px 3px 0 0; background: #e8e2f2; box-shadow: inset 0 -2px 0 #c9bfd9; }
.can::after { content: ""; position: absolute; top: -10px; left: 9px; width: 4px; height: 3px; border-radius: 1px; background: #8a7fa2; }
.can.used { opacity: 0.22; transform: translateY(4px) scale(0.9); filter: grayscale(1); }
.can.pulse { animation: canPulse 0.5s ease-out; }
@keyframes canPulse { 30% { transform: rotate(-14deg) scale(1.2); } 60% { transform: rotate(8deg); } }

.goal {
  margin: 10px 0 8px; padding: 8px 14px; border-radius: 14px; background: rgba(255, 255, 255, 0.88);
  display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; min-height: 42px;
  box-shadow: 0 2px 0 rgba(58, 42, 85, 0.15); white-space: nowrap;
}
.goal .g-icon { font-size: 22px; }
.goal .g-bar { flex: 0 1 120px; min-width: 40px; height: 10px; border-radius: 99px; background: #ece6f5; overflow: hidden; }
.goal .g-bar i { display: block; height: 100%; background: var(--good); border-radius: 99px; transition: width 0.4s; }
.goal.bump { animation: bump 0.35s; }
@keyframes bump { 40% { transform: scale(1.06); } }
/* 남은 풍선 카운터: 터질 때마다 툭툭 떨어진다 */
.goal .stock b { display: inline-block; font-size: 22px; line-height: 1; min-width: 1.4em; text-align: center; }
.goal .stock b.tick { animation: tick calc(0.25s * var(--speed)) ease-out; }
@keyframes tick { 0% { transform: translateY(-8px) scale(1.3); color: var(--accent); } }
@media (max-width: 380px) { .goal { font-size: 14px; gap: 6px; padding: 8px 10px; } }

/* ── 캔버스와 판 ── */
.stall { position: relative; margin: 8px auto 0; width: fit-content; }
/* 삼각 깃발 줄 */
.bunting {
  position: relative; height: 26px; margin: 0 -12px;
  background:
    linear-gradient(#6e5f8c, #6e5f8c) 0 3px / 100% 2px no-repeat,
    conic-gradient(from 135deg at 50% 0, #ff4f9a 0 90deg, transparent 90deg) 0 5px / 72px 21px repeat-x,
    conic-gradient(from 135deg at 50% 0, #ffc928 0 90deg, transparent 90deg) 24px 5px / 72px 21px repeat-x,
    conic-gradient(from 135deg at 50% 0, #3d82f0 0 90deg, transparent 90deg) 48px 5px / 72px 21px repeat-x;
}
.board-wrap {
  position: relative; padding: 10px; border-radius: 18px;
  background: var(--frame); box-shadow: var(--shadow), inset 0 0 0 3px var(--frame-edge);
}
.board-wrap.shake { animation: shake calc(0.4s * var(--speed)); }
@keyframes shake { 20% { transform: translate(-4px, 2px); } 40% { transform: translate(4px, -2px); } 60% { transform: translate(-3px, 1px); } 80% { transform: translate(2px, 0); } }
.board-wrap.shake-big { animation: shakeBig calc(0.55s * var(--speed)); }
@keyframes shakeBig { 10% { transform: translate(-9px, 4px) rotate(-0.6deg); } 25% { transform: translate(8px, -5px) rotate(0.6deg); } 40% { transform: translate(-7px, 3px); } 55% { transform: translate(6px, -2px); } 70% { transform: translate(-3px, 1px); } 85% { transform: translate(2px, 0); } }

/* 카메라: 남은 풍선이 줄면 cam이 다가간다. 다가갔을 때만 판 밖을 잘라 낸다 */
.viewport { position: relative; border-radius: 10px; }
.viewport.zoomed { overflow: hidden; }
/* cam = 종이 캔버스(바탕 + 옅은 칸 자리) · 물감 자국 캔버스 · 풍선 판 · 효과 */
.cam {
  position: relative; transform-origin: 0 0; border-radius: 10px;
  transition: transform calc(0.6s * var(--speed)) cubic-bezier(0.3, 0.7, 0.3, 1);
  background:
    radial-gradient(circle, rgba(110, 95, 140, 0.09) 0 calc(var(--cell) * 0.34), transparent calc(var(--cell) * 0.35)) 0 0 / var(--cell) var(--cell),
    linear-gradient(135deg, rgba(255, 255, 255, 0.6), rgba(240, 232, 220, 0.6)),
    var(--paper);
}
.cam.no-anim { transition: none; }
.paint { position: absolute; left: 0; top: 0; pointer-events: none; border-radius: 10px; }
.board {
  position: relative; width: calc(var(--cols) * var(--cell)); height: calc(var(--rows) * var(--cell));
  border-radius: 10px; touch-action: none;
}
.fx { position: absolute; inset: 0; pointer-events: none; }
.chain {
  position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%) scale(0.6); pointer-events: none;
  font-weight: 900; font-size: 34px; color: #fff; text-shadow: 0 3px 0 var(--accent-dark), 0 0 18px rgba(58, 42, 85, 0.35); opacity: 0;
  white-space: nowrap; z-index: 5;
}
.chain.show { animation: chainPop calc(0.9s * var(--speed)) ease-out; }
.chain[data-tier="1"] { font-size: 30px; text-shadow: 0 3px 0 #1f8f52, 0 0 18px rgba(58, 42, 85, 0.35); }
.chain[data-tier="2"] { font-size: 40px; color: #fff3b0; text-shadow: 0 3px 0 #c48f00, 0 0 22px rgba(255, 170, 30, 0.8); }
.chain[data-tier="3"] { font-size: 42px; color: #fff; text-shadow: 0 3px 0 var(--accent-dark), 0 0 26px rgba(255, 79, 154, 0.9); }
@keyframes chainPop { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); } 25% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); } 70% { opacity: 1; transform: translate(-50%, -60%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -80%) scale(1); } }

/* 콤보 숫자: 깃발 위 가운데. 흰색 → 노랑 → 주황(불꽃) → 빨강 → 무지개 */
.combo {
  position: absolute; left: 50%; top: -20px; z-index: 6; transform: translateX(-50%); pointer-events: none;
  display: flex; align-items: baseline; gap: 5px; white-space: nowrap; line-height: 1;
  padding: 3px 14px 5px; border-radius: 999px; background: rgba(58, 42, 85, 0.9); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2);
  --tone: #fff; --edge: #6e5f8c; --grow: 1;
}
.combo small { font-size: 13px; font-weight: 800; color: var(--tone); opacity: 0.9; }
.combo b { font-size: calc(26px + var(--grow) * 1.4px); font-weight: 900; color: var(--tone); text-shadow: 0 2px 0 var(--edge); }
.combo[data-tier="yellow"] { --tone: #ffe066; --edge: #a8700a; }
.combo[data-tier="orange"] { --tone: #ffad3a; --edge: #9a4a08; }
.combo[data-tier="red"] { --tone: #ff6b8e; --edge: #7a1640; }
.combo[data-tier="rainbow"] b {
  background: linear-gradient(90deg, #ff5a46, #ffad3a, #ffe066, #52d36a, #4fa3ff, #b06bff, #ff5a46) 0 0 / 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; text-shadow: none;
  filter: drop-shadow(0 3px 0 #2a1a45); animation: rainbow 1.2s linear infinite;
}
.combo[data-tier="rainbow"] small { --tone: #fff; }
@keyframes rainbow { to { background-position: 200% 0; } }
.combo.flame b { animation: flame 0.5s ease-in-out infinite alternate; }
.combo.flame[data-tier="rainbow"] b { animation: rainbow 1.2s linear infinite, flameRainbow 0.5s ease-in-out infinite alternate; }
@keyframes flame { from { text-shadow: 0 3px 0 var(--edge), 0 0 8px #ff8a1f, 0 -4px 14px #ffb03a; } to { text-shadow: 0 3px 0 var(--edge), 0 0 14px #ff5a1f, 0 -8px 22px #ffd36a; } }
@keyframes flameRainbow { from { filter: drop-shadow(0 3px 0 #2a1a45) drop-shadow(0 -4px 8px #ffb03a); } to { filter: drop-shadow(0 3px 0 #2a1a45) drop-shadow(0 -8px 14px #ff5a1f); } }
.combo.bump { animation: comboBump calc(0.25s * var(--speed)) ease-out; }
@keyframes comboBump { 40% { transform: translateX(-50%) scale(1.35); } }
/* 헛수: 숫자가 금 가며 깨진다 */
.combo.break b, .combo.break small { animation: comboCrack calc(0.7s * var(--speed)) ease-in forwards; }
@keyframes comboCrack { 0% { filter: none; } 20% { transform: translateX(-3px) rotate(-6deg); filter: grayscale(1) brightness(0.8); } 35% { transform: translateX(3px) rotate(4deg); } 100% { transform: translateY(40px) rotate(18deg); opacity: 0; filter: grayscale(1); } }
.combo .shard {
  position: absolute; left: 50%; top: 50%; width: 8px; height: 12px; background: #d9d4e6;
  clip-path: polygon(50% 0, 100% 60%, 30% 100%, 0 40%); animation: shard calc(0.7s * var(--speed)) ease-in forwards;
}
@keyframes shard { to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; } }

/* 번쩍임 · 작품 완성 도장 */
.flash { position: absolute; inset: 0; border-radius: inherit; background: #fff; opacity: 0; pointer-events: none; z-index: 4; }
.flash.on { animation: flash calc(0.32s * var(--speed)) ease-out; }
@keyframes flash { 0% { opacity: var(--flash, 0.7); } 100% { opacity: 0; } }
.stamp {
  position: absolute; left: 50%; top: 46%; z-index: 5; pointer-events: none; white-space: nowrap;
  padding: 6px 18px; border: 5px solid var(--accent); border-radius: 14px; color: var(--accent); background: rgba(255, 253, 247, 0.85);
  font-size: 40px; font-weight: 900; letter-spacing: 0.04em; transform: translate(-50%, -50%) rotate(-10deg);
  box-shadow: 0 6px 18px rgba(58, 42, 85, 0.3);
}
.stamp.show { animation: stampIn calc(0.38s * var(--speed)) cubic-bezier(0.3, 1.5, 0.5, 1) both; }
@keyframes stampIn { from { transform: translate(-50%, -50%) rotate(-24deg) scale(2.6); opacity: 0; } 60% { opacity: 1; } }

/* 작품 완성 피날레: 배경이 살짝 어두워지고 캔버스가 다가온다 */
.game.finale::before { content: ""; position: fixed; inset: 0; z-index: 1; background: rgba(42, 26, 69, 0.28); pointer-events: none; animation: fadeIn 0.3s; }
.game .stall, .game .hud { position: relative; z-index: 2; }
.stall { transition: transform calc(0.5s * var(--speed)) ease-out, opacity calc(0.35s * var(--speed)); }
/* 퍼레이드: 캔버스가 옆으로 빠지고 새 캔버스가 밀려 들어온다 */
.stall.slide-out { transform: translateX(-120%) rotate(-3deg); opacity: 0; transition: transform calc(0.3s * var(--speed)) ease-in, opacity calc(0.3s * var(--speed)); }
.stall.slide-from { transform: translateX(120%) rotate(3deg); opacity: 0; transition: none; }
.game.finale .stall { transform: scale(1.04); }

/* 칸 하나 = 타일 하나. 위치는 transform, 떨어질 때 transition */
.tile {
  position: absolute; left: 0; top: 0; width: var(--cell); height: var(--cell);
  transition: transform calc(0.22s * var(--speed)) cubic-bezier(0.5, 0, 0.9, 0.6);
  display: grid; place-items: center; pointer-events: none;
}
.tile.no-anim { transition: none; }
/* 물감 풍선: 색 + 흰 기호(색을 못 가려도 모양으로 구분) + 아래 매듭 */
.ball {
  width: 80%; height: 90%; margin-bottom: 6%; display: grid; place-items: center; position: relative;
  border-radius: 50% 50% 47% 47% / 56% 56% 44% 44%;
  background: radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.85) 0 9%, rgba(255, 255, 255, 0) 10%),
              radial-gradient(circle at 45% 38%, color-mix(in srgb, var(--c) 65%, #fff) 0, var(--c) 45%, color-mix(in srgb, var(--c) 65%, #000) 100%);
  box-shadow: inset -3px -5px 8px rgba(0, 0, 0, 0.16), 0 3px 4px rgba(58, 42, 85, 0.18);
  line-height: 1; transition: transform calc(0.15s * var(--speed)), filter 0.15s;
}
.ball::after {
  content: ""; position: absolute; left: 50%; bottom: -8%; width: 18%; height: 10%; transform: translateX(-50%);
  background: color-mix(in srgb, var(--c) 70%, #000); clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.ball .e {
  font-size: calc(var(--cell) * 0.34); font-weight: 900; color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.22); transform: translateY(-4%);
  font-family: "Segoe UI Symbol", "Apple Symbols", "Noto Sans Symbols 2", sans-serif;
}
.tile.selected .ball { transform: translateY(-6px) scale(1.07); filter: brightness(1.1); box-shadow: inset -3px -5px 8px rgba(0, 0, 0, 0.16), 0 0 0 3px #fff, 0 0 16px 5px rgba(255, 255, 255, 0.9); }
.tile.dim .ball { filter: saturate(0.5) brightness(0.85); }
.tile.hint .ball { animation: hintPulse 0.9s ease-in-out infinite; }
@keyframes hintPulse { 50% { transform: scale(1.12); box-shadow: 0 0 0 3px var(--gold), 0 0 20px 6px var(--gold); } }

/* 포장 풍선: 반짝이는 비닐 + 리본 — 색이 안 바뀐다. 옆이 터지면 포장이 찢어진다 */
.tile.lock .ball::before {
  content: ""; position: absolute; inset: -5%; border-radius: 30%;
  background: linear-gradient(125deg, rgba(255, 255, 255, 0.55) 0 18%, rgba(255, 255, 255, 0.08) 22% 60%, rgba(255, 255, 255, 0.4) 64% 70%, rgba(255, 255, 255, 0.05) 74%);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.85), 0 0 0 1px rgba(110, 95, 140, 0.35);
}
.tile.lock .badge, .tile.bomb .badge {
  position: absolute; right: 2%; bottom: 4%; font-size: calc(var(--cell) * 0.28); line-height: 1;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.45));
}
.tile.unlock .ball::before { animation: wrapTear calc(0.35s * var(--speed)) forwards; }
@keyframes wrapTear { to { transform: scale(1.35) rotate(10deg); opacity: 0; } }
/* 폭죽 풍선: 반짝이는 점선 테두리 */
.tile.bomb .ball { box-shadow: inset -3px -5px 8px rgba(0, 0, 0, 0.16), 0 0 0 3px #fff, 0 0 0 5px #ff8a2a, 0 0 12px 4px rgba(255, 138, 42, 0.7); }
.tile.bomb .badge { font-size: calc(var(--cell) * 0.34); right: -2%; bottom: 0; }

/* 벽돌 */
.stone {
  width: 92%; height: 92%; border-radius: 12%;
  background:
    linear-gradient(#eadfd2, #eadfd2) 0 32% / 100% 6% no-repeat,
    linear-gradient(#eadfd2, #eadfd2) 0 66% / 100% 6% no-repeat,
    linear-gradient(90deg, transparent 48%, #eadfd2 48% 54%, transparent 54%) 0 0 / 100% 32% no-repeat,
    linear-gradient(90deg, transparent 22%, #eadfd2 22% 28%, transparent 28% 72%, #eadfd2 72% 78%, transparent 78%) 0 50% / 100% 30% no-repeat,
    linear-gradient(90deg, transparent 48%, #eadfd2 48% 54%, transparent 54%) 0 100% / 100% 30% no-repeat,
    linear-gradient(160deg, #d0694a, #a8452f);
  box-shadow: 0 3px 0 #7c3322, inset 0 -3px 5px rgba(0, 0, 0, 0.2);
}
/* 선물 상자(바닥까지 내려보낸다) */
.gift { width: 84%; height: 84%; display: grid; place-items: center; border-radius: 18%; background: rgba(255, 255, 255, 0.92); box-shadow: 0 3px 0 #c9bfd9, 0 0 12px 3px rgba(255, 201, 40, 0.75); font-size: calc(var(--cell) * 0.5); }

/* 칠하기: 스프레이가 지나가며 풍선이 뒤집혀 다른 색이 된다 */
.tile.flip .ball { animation: ballFlip calc(0.32s * var(--speed)) ease-in-out; }
@keyframes ballFlip { 0% { transform: rotateY(0); } 50% { transform: rotateY(90deg) scale(1.1); } 100% { transform: rotateY(0); } }
.mist { position: absolute; width: calc(var(--cell) * 1.1); height: calc(var(--cell) * 1.1); border-radius: 50%; transform: translate(-50%, -50%); background: radial-gradient(circle, var(--c) 0, transparent 70%); opacity: 0; animation: mist calc(0.45s * var(--speed)) ease-out; pointer-events: none; }
@keyframes mist { 30% { opacity: 0.45; } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.4); } }

/* 팡 */
.tile.pop .ball, .tile.pop .stone, .tile.pop .gift { animation: pop calc(0.26s * var(--speed)) ease-in forwards; }
.tile.pop-slow .ball, .tile.pop-slow .stone, .tile.pop-slow .gift { animation: pop calc(0.55s * var(--speed)) ease-in forwards; }
.tile.pop .badge, .tile.pop-slow .badge { display: none; }
@keyframes pop { 0% { transform: scale(1); } 55% { transform: scale(1.3, 1.22); filter: brightness(1.2); opacity: 1; } 70% { transform: scale(1.45); opacity: 0; } 100% { transform: scale(1.45); opacity: 0; } }
.tile.gem-out .gift { animation: gemOut calc(0.5s * var(--speed)) ease-in forwards; }
@keyframes gemOut { to { transform: translateY(80%) scale(0.4); opacity: 0; } }

/* 미리보기: 칠해질 칸에 그 색 고스트, 터질 칸 깜빡임, 물들 칸은 보랏빛 점선 */
.tile .ghost {
  position: absolute; inset: 7%; border-radius: 50% 50% 47% 47% / 56% 56% 44% 44%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--g) 80%, transparent); font-size: calc(var(--cell) * 0.34); font-weight: 900; color: #fff;
  font-family: "Segoe UI Symbol", "Apple Symbols", "Noto Sans Symbols 2", sans-serif;
  border: 2px dashed #fff; opacity: 0.9; animation: ghostIn 0.15s ease-out;
}
@keyframes ghostIn { from { transform: scale(0.6); opacity: 0; } }
.tile.will-pop .ball, .tile.will-pop .ghost { animation: willPop 0.5s ease-in-out infinite alternate; }
@keyframes willPop { to { transform: scale(0.88); filter: brightness(1.3); } }
.tile .ghost.dye { border: 2px dotted #fff; box-shadow: 0 0 0 2px rgba(176, 107, 255, 0.85), 0 0 12px 3px rgba(176, 107, 255, 0.6); opacity: 0.85; }
/* 물감 번짐: 물드는 풍선에 반짝임 */
.tile.dye .ball { box-shadow: 0 0 0 3px #fff, 0 0 16px 6px rgba(176, 107, 255, 0.8); }

/* 효과 */
.particle { position: absolute; width: 8px; height: 8px; border-radius: 50% 50% 50% 0; animation: particle calc(0.55s * var(--speed)) ease-out forwards; }
@keyframes particle { to { transform: translate(var(--dx), var(--dy)) rotate(180deg) scale(0.3); opacity: 0; } }
.shred { position: absolute; width: 10px; height: 5px; border-radius: 3px; animation: shred calc(0.6s * var(--speed)) ease-out forwards; }
@keyframes shred { to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; } }
.drop { position: absolute; width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.7); pointer-events: none; z-index: 3; }
.float-text { position: absolute; font-weight: 900; color: #fff; text-shadow: 0 2px 0 rgba(58, 42, 85, 0.55); animation: floatUp calc(0.9s * var(--speed)) ease-out forwards; pointer-events: none; font-size: 17px; white-space: nowrap; z-index: 3; }
.float-text.t1 { font-size: 20px; color: #fff6c8; }
.float-text.t2 { font-size: 24px; color: #ffe066; text-shadow: 0 2px 0 #9a6208; }
.float-text.t3 { font-size: 28px; color: #ffe066; text-shadow: 0 3px 0 var(--accent-dark), 0 0 12px rgba(255, 200, 60, 0.9); }
.float-text.spread { font-size: 18px; color: #f3e6ff; text-shadow: 0 2px 0 #6a2fb0, 0 0 10px rgba(176, 107, 255, 0.9); }
@keyframes floatUp { from { transform: translate(-50%, -50%) scale(0.7); } 20% { transform: translate(-50%, -60%) scale(1.1); opacity: 1; } to { transform: translate(-50%, -150%); opacity: 0; } }
.blast { position: absolute; border-radius: 50%; background: radial-gradient(circle, #fff6b0, #ff8a1f 45%, rgba(255, 79, 154, 0) 70%); animation: blast calc(0.4s * var(--speed)) ease-out forwards; }
@keyframes blast { from { transform: scale(0.3); opacity: 1; } to { transform: scale(1.3); opacity: 0; } }
/* 색종이 */
.confetti { position: fixed; z-index: 25; width: 8px; height: 13px; border-radius: 2px; pointer-events: none; }

/* ── 팔레트와 버튼 ── */
.prompt { margin: 12px 0 4px; min-height: 22px; text-align: center; font-size: 14px; color: var(--ink-soft); }
.prompt b { color: var(--ink); }
.palette { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; min-height: 64px; padding: 6px 0; touch-action: none; }
.pal {
  position: relative; width: 50px; height: 56px; border: 0; padding: 0; background: none; --cell: 56px;
  transition: transform calc(0.15s * var(--speed));
}
.pal .ball { width: 100%; height: 92%; }
.pal .ball .e { font-size: 22px; }
.pal .count { position: absolute; right: -6px; top: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px; background: var(--ink); color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center; }
.pal.selected { transform: translateY(-8px); }
.pal.selected .ball { box-shadow: 0 0 0 3px #fff, 0 0 16px 4px rgba(255, 255, 255, 0.9); }
.pal.fixed .ball { filter: saturate(0.55); }
.pal.fixed::after { content: "🎀"; position: absolute; left: -6px; top: -6px; font-size: 14px; }
.pal.hint .ball { animation: hintPulse 0.9s ease-in-out infinite; }
.pal.target .ball { box-shadow: 0 0 0 3px var(--gold), 0 0 16px 4px var(--gold); }

.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.act {
  border: 0; border-radius: 14px; padding: 10px 6px; background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 3px 0 rgba(58, 42, 85, 0.2); font-weight: 700; font-size: 14px; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.act span { font-size: 20px; line-height: 1; }
.act:active { transform: translateY(3px); box-shadow: none; }
.act:disabled { opacity: 0.4; cursor: default; }

/* ── 겹창 ── */
.overlay {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px;
  background: rgba(42, 26, 69, 0.45); animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } }
.card {
  width: min(360px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 22px 20px 18px; border-radius: 24px; text-align: center;
  background: var(--cream); box-shadow: 0 20px 40px rgba(42, 26, 69, 0.4); animation: cardIn 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes cardIn { from { transform: translateY(30px) scale(0.9); opacity: 0; } }
.card h2 { margin: 0 0 4px; font-size: 26px; }
.card p { margin: 6px 0; color: var(--ink-soft); }
.card .big { font-size: 56px; line-height: 1.1; margin: 4px 0; }
.card .row { display: flex; gap: 8px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.btn {
  border: 0; border-radius: 14px; padding: 11px 18px; font-weight: 800; background: #ece6f5; box-shadow: 0 3px 0 #c9bfd9;
}
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 3px 0 var(--accent-dark); }
.btn.gold { background: var(--gold); box-shadow: 0 3px 0 #b8841b; }
.btn:active { transform: translateY(3px); box-shadow: none; }
.result-stars { font-size: 44px; letter-spacing: 6px; margin: 6px 0; }
.result-stars i { display: inline-block; font-style: normal; color: rgba(0, 0, 0, 0.12); }
.result-stars i.on { color: var(--gold); animation: starIn 0.4s cubic-bezier(0.2, 1.6, 0.4, 1) backwards; text-shadow: 0 2px 0 #b8841b; }
@keyframes starIn { from { transform: scale(0) rotate(-40deg); } }
/* 이번 판 그림(터뜨린 자국): 액자에 걸린다 */
.artwork {
  display: inline-block; margin: 4px auto 6px; padding: 7px; border-radius: 8px; transform: rotate(-2deg);
  background: linear-gradient(135deg, #ffd96a, #e0a400); box-shadow: 0 6px 14px rgba(58, 42, 85, 0.3), inset 0 0 0 2px rgba(255, 255, 255, 0.5);
  animation: hang calc(0.6s * var(--speed)) cubic-bezier(0.3, 1.6, 0.5, 1) backwards;
}
.artwork img { display: block; max-width: 220px; max-height: 170px; border-radius: 3px; background: var(--paper); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1); }
@keyframes hang { from { transform: translateY(-30px) rotate(-12deg); opacity: 0; } }
.artist { font-size: 40px; display: inline-block; animation: bounce 0.8s ease-in-out infinite alternate; }
@keyframes bounce { to { transform: translateY(-6px) rotate(-4deg); } }
.artist.jump { animation: jump 0.5s cubic-bezier(0.3, 1.6, 0.5, 1) 3, bounce 0.8s ease-in-out 1.5s infinite alternate; }
@keyframes jump { 50% { transform: translateY(-22px) scale(1.08) rotate(6deg); } }

/* 점수판: 줄이 하나씩 찍히고 점수가 촤라락 올라간다 */
.receipt {
  margin: 8px auto 4px; padding: 10px 14px 8px; max-width: 290px; text-align: left; font-size: 14px;
  background: #fff; border-radius: 10px; box-shadow: 0 2px 0 #e6dcf5, inset 0 0 0 2px #ece6f5;
}
.receipt .r-head { text-align: center; font-weight: 900; letter-spacing: 0.3em; color: var(--ink-soft); font-size: 12px; border-bottom: 2px dotted #e6dcf5; padding-bottom: 4px; margin-bottom: 4px; }
.receipt .r-line, .receipt .r-total { display: grid; grid-template-columns: 32px 1fr auto; gap: 6px; align-items: baseline; padding: 2px 0; }
.receipt .r-line .r-no { color: var(--ink-soft); font-weight: 700; }
.receipt .r-line .r-what { color: var(--ink-soft); font-size: 13px; }
.receipt .r-line.miss .r-what { color: #c4344f; }
.receipt .r-total { grid-template-columns: 1fr auto; border-top: 2px dotted #e6dcf5; margin-top: 4px; padding-top: 6px; font-weight: 900; font-size: 16px; }
.receipt .r-total b { font-size: 20px; color: var(--accent); }
.receipt.printing .r-line, .receipt.printing .r-total { opacity: 0; transform: translateY(-6px); }
.receipt .r-line.on, .receipt .r-total.on { opacity: 1; transform: none; transition: opacity 0.15s, transform 0.15s; }
.card .meta { font-size: 13px; }
.card .parade-total { margin: 8px 0; font-size: 18px; }
.card .parade-total b { font-size: 34px; color: var(--accent); }
.card .new-best { display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 99px; background: var(--gold); color: var(--ink); font-size: 13px; font-weight: 900; vertical-align: middle; }
.intro-demo { display: flex; justify-content: center; align-items: center; gap: 8px; margin: 12px 0 4px; font-size: 30px; }
.big .stone { display: inline-block; width: 56px; height: 56px; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid #ece6f5; text-align: left; }
.setting small { display: block; color: var(--ink-soft); }

/* 퍼레이드 */
.hearts { color: var(--accent); font-size: 14px; letter-spacing: 1px; }
.hearts .off { color: rgba(0, 0, 0, 0.18); }
.hearts.lost { display: inline-block; animation: heartLost calc(0.6s * var(--speed)) ease-out; }
@keyframes heartLost { 20% { transform: scale(1.5) rotate(-8deg); } 40% { transform: scale(0.9) rotate(6deg); } }
.rev-bar.fever-bar .fill { background: linear-gradient(90deg, #8a5be6, #ff4f9a); }
.rev-bar.fever-bar.on .fill { background: linear-gradient(90deg, #ff5a46, #ffad3a, #ffe066, #52d36a, #4fa3ff, #b06bff, #ff5a46) 0 0 / 200% 100%; animation: rainbow 0.8s linear infinite; }
/* 무지개 타임: 캔버스 테두리가 무지개로 돌고 풍선에 금테 — 색 구분은 그대로 */
.game.fever .board-wrap { animation: feverGlow calc(0.7s * var(--speed)) linear infinite; }
@keyframes feverGlow {
  0% { box-shadow: var(--shadow), inset 0 0 0 4px #ff5a46, 0 0 18px 6px rgba(255, 90, 70, 0.55); }
  25% { box-shadow: var(--shadow), inset 0 0 0 4px #ffe066, 0 0 18px 6px rgba(255, 224, 102, 0.55); }
  50% { box-shadow: var(--shadow), inset 0 0 0 4px #52d36a, 0 0 18px 6px rgba(82, 211, 106, 0.55); }
  75% { box-shadow: var(--shadow), inset 0 0 0 4px #4fa3ff, 0 0 18px 6px rgba(79, 163, 255, 0.55); }
  100% { box-shadow: var(--shadow), inset 0 0 0 4px #b06bff, 0 0 18px 6px rgba(176, 107, 255, 0.55); }
}
.game.fever .tile .ball { box-shadow: inset -3px -5px 8px rgba(0, 0, 0, 0.16), 0 0 0 2px #ffd34d, 0 0 8px 2px rgba(255, 200, 60, 0.6); }
.game.fever .combo { background: linear-gradient(135deg, #6a2fb0, #ff4f9a); box-shadow: 0 0 14px 3px rgba(255, 79, 154, 0.7); }

/* 손가락 가이드 */
.hand {
  position: fixed; z-index: 15; font-size: 40px; pointer-events: none; transform: translate(-30%, 10%);
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.35)); animation: handTap 1s ease-in-out infinite;
}
@keyframes handTap { 50% { transform: translate(-30%, 25%) scale(0.9); } }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 30; transform: translate(-50%, 20px); opacity: 0;
  padding: 10px 16px; border-radius: 999px; background: rgba(42, 26, 69, 0.88); color: #fff; font-size: 14px;
  transition: opacity 0.2s, transform 0.2s; pointer-events: none; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .lv.current, .artist, .logo-balloons i { animation: none; }
}
