@font-face {
  font-family: 'Jua';
  src: url('fonts/Jua-Regular.ttf') format('truetype');
  font-display: swap;
}

:root {
  --bg-1: #fff4e0;
  --bg-2: #ffe7c7;
  --ink: #4a3426;
  --ink-soft: #8a6f5c;
  --orange: #ff9a3c;
  --orange-dark: #e07a1f;
  --dad: #5b8def;
  --dad-soft: #dce8ff;
  --mona: #ff7aa8;
  --mona-soft: #ffe1ec;
  --friend: #f0a92e;
  --friend-soft: #fff0cf;
  --shadow: rgba(122, 78, 40, 0.18);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg-1);
  color: var(--ink);
  font-family: 'Jua', -apple-system, 'Apple SD Gothic Neo', sans-serif;
  overscroll-behavior: none;
  touch-action: manipulation;
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
}

img {
  -webkit-user-drag: none;
}

/* ── 공통 화면 ── */
.screen {
  position: relative;
  height: 100svh;
  overflow: hidden;
  padding: calc(var(--safe-t) + 16px) calc(var(--safe-r) + 16px) calc(var(--safe-b) + 16px) calc(var(--safe-l) + 16px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: radial-gradient(120% 90% at 50% 0%, var(--bg-1) 0%, var(--bg-2) 100%);
  animation: screen-in 0.35s ease-out;
}
@keyframes screen-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.deco { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.blob { position: absolute; border-radius: 50%; filter: blur(2px); opacity: 0.55; }
.b1 { width: 38vmin; height: 38vmin; left: -10vmin; top: -8vmin; background: #ffd9a8; }
.b2 { width: 30vmin; height: 30vmin; right: -8vmin; bottom: 10vmin; background: #ffe0ec; }
.b3 { width: 18vmin; height: 18vmin; right: 18vmin; top: 6vmin; background: #e3efff; }
.screen > *:not(.deco) { position: relative; z-index: 1; }

.heading {
  margin: 0;
  font-size: clamp(28px, 4.6vmin, 44px);
  font-weight: 400;
  color: var(--ink);
}
.heading.big { font-size: clamp(44px, 9vmin, 84px); color: var(--orange-dark); }

.back {
  position: absolute !important;
  top: calc(var(--safe-t) + 14px);
  left: calc(var(--safe-l) + 14px);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 5px 0 var(--shadow);
  font-size: 40px;
  line-height: 50px;
  color: var(--ink-soft);
}
.back:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--shadow); }

.icon-btn { display: inline-flex; transition: transform 0.12s; }
.icon-btn:active { transform: scale(0.92); }
.icon-img { width: 100%; height: 100%; object-fit: contain; }
.gear {
  position: absolute !important;
  top: calc(var(--safe-t) + 12px);
  right: calc(var(--safe-r) + 12px);
  width: 52px;
  height: 52px;
  opacity: 0.75;
}

/* ── 시작 ── */
.home { gap: 8px; }
.hero {
  width: min(70vmin, 520px);
  max-height: 46svh;
  object-fit: contain;
 
  animation: bob 3.2s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.title {
  margin: 0;
  font-size: clamp(40px, 8vmin, 76px);
  font-weight: 400;
  color: var(--orange-dark);
  text-shadow: 0 4px 0 #fff, 0 6px 12px var(--shadow);
  letter-spacing: 1px;
}
.start {
  width: clamp(110px, 20vmin, 170px);
  height: clamp(110px, 20vmin, 170px);
  animation: pulse 1.8s ease-in-out infinite;
}
.start-img { width: 100%; height: 100%; object-fit: contain; }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}

/* ── 선택 타일 ── */
.tiles {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(14px, 3vmin, 28px);
  justify-content: center;
  align-items: stretch;
}
.tile {
  width: clamp(160px, 24vmin, 230px);
  padding: 16px 14px 14px;
  border-radius: 32px;
  background: #fff;
  box-shadow: 0 9px 0 var(--shadow), 0 14px 24px var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: transform 0.12s, box-shadow 0.12s;
}
.tile.wide { width: clamp(200px, 32vmin, 300px); }
.tile:active { transform: translateY(7px); box-shadow: 0 2px 0 var(--shadow); }
.tile-img {
  width: 100%;
  height: clamp(120px, 20vmin, 190px);
  object-fit: contain;
 
}
.caption { font-size: clamp(20px, 3.2vmin, 28px); color: var(--ink); }

.mini {
  display: grid;
  gap: 6px;
  height: clamp(120px, 20vmin, 190px);
  align-content: center;
  justify-content: center;
}
.mini-2 { grid-template-columns: repeat(2, 40px); }
.mini-3 { grid-template-columns: repeat(3, 40px); }
.mini-6 { grid-template-columns: repeat(4, 34px); }
.mini-card {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 7px;
  box-shadow: 0 2px 0 var(--shadow);
}

/* ── 놀이 ── */
.play {
  justify-content: flex-start;
  padding-top: calc(var(--safe-t) + 14px);
  gap: 14px;
}
.play::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 8px solid transparent;
  pointer-events: none;
  transition: border-color 0.3s;
  z-index: 2;
}
.play[data-turn='dad']::after { border-color: var(--dad); }
.play[data-turn='mona']::after { border-color: var(--mona); }
.play[data-turn='friend']::after { border-color: var(--friend); }

.players, .team {
  display: flex;
  gap: 16px;
  justify-content: center;
  align-items: center;
  min-height: 72px;
}
.team {
  padding: 6px 16px 6px 8px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 5px 0 var(--shadow);
}
.team .chip { box-shadow: none; padding: 4px; background: transparent; }
.chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px 6px 6px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 5px 0 var(--shadow);
  opacity: 0.55;
  transform: scale(0.92);
  transition: all 0.25s;
}
.chip.active { opacity: 1; transform: scale(1.06); }
.chip.dad.active .chip-face { box-shadow: 0 0 0 4px var(--dad); }
.chip.mona.active .chip-face { box-shadow: 0 0 0 4px var(--mona); }
.chip.friend.active .chip-face { box-shadow: 0 0 0 4px var(--friend); }
.chip-face {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-1);
  flex: none;
}
.chip.dad .chip-face { background: var(--dad-soft); }
.chip.mona .chip-face { background: var(--mona-soft); }
.chip.friend .chip-face { background: var(--friend-soft); }
.chip-img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 8%; transform: scale(1.15) translateY(6%); }
.chip { min-width: 0; }
.chip-name { font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
@media (max-width: 480px) {
  /* 뒤로 단추(56px) 자리를 비운다. 넘쳐도 왼쪽으로 새지 않게 safe center */
  .players { gap: 8px; align-self: stretch; padding-left: 58px; justify-content: safe center; }
  .chip { gap: 6px; padding-right: 10px; }
  .chip-face { width: 46px; height: 46px; }
  /* 놀이 중 이름표는 얼굴 그림으로 구분 — 이름은 차례 알림에 나온다. 끝 화면 이름표엔 이름을 둔다 */
  .players .chip-name { display: none; }
  .chip-name { font-size: 18px; }
  .pile-img { width: 28px; height: 28px; margin-left: -16px; border-radius: 8px; padding: 2px; }
}
.pile { display: flex; min-width: 0; padding-left: 8px; }
.pile:empty { padding: 0; }
.pile-img {
  width: 38px;
  height: 38px;
  margin-left: -10px;
  border-radius: 10px;
  border: 2px solid #fff;
  object-fit: contain;
  background: #fffaf2;
  padding: 3px;
  box-shadow: 0 2px 4px var(--shadow);
}
.pile-img.waiting { visibility: hidden; }
.pile-img.landed,
.result .pile-img { animation: pop-in 0.4s ease-out; }
@keyframes pop-in {
  from { transform: scale(0); }
  70% { transform: scale(1.25); }
  to { transform: scale(1); }
}

.grid {
  /* 카드 한 장 너비 = 가로로 나눈 값과 세로(3:4 비율)로 나눈 값 중 작은 쪽 → 어느 방향이든 한 화면에 다 들어간다 */
  --gap: clamp(10px, 2vmin, 18px);
  --avail-w: calc(100vw - 48px - var(--safe-l) - var(--safe-r));
  --avail-h: calc(100svh - 140px - var(--safe-t) - var(--safe-b));
  --cw: min(
    calc((var(--avail-w) - (var(--cols) - 1) * var(--gap)) / var(--cols)),
    calc((var(--avail-h) - (var(--rows) - 1) * var(--gap)) / var(--rows) * 0.75),
    230px
  );
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(var(--cols), var(--cw));
  justify-content: center;
  align-content: center;
  flex: 1;
}
.grid-4 { --cols: 2; --rows: 2; }
.grid-6 { --cols: 3; --rows: 2; }
.grid-12 { --cols: 4; --rows: 3; }
@media (orientation: portrait) {
  .grid-6 { --cols: 2; --rows: 3; }
  .grid-12 { --cols: 3; --rows: 4; }
}

.card {
  position: relative;
  aspect-ratio: 3 / 4;
  perspective: 900px;
}
.card-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transition: transform 0.4s cubic-bezier(0.3, 1.4, 0.5, 1);
  transform-style: preserve-3d;
}
.card:active:not(.up) .card-inner { transform: scale(0.95); }
.card.up .card-inner { transform: rotateY(180deg); }
.card-back,
.card-front {
  position: absolute;
  inset: 0;
  border-radius: clamp(14px, 2.4vmin, 24px);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 7px 0 var(--shadow), 0 10px 18px var(--shadow);
}
.card-back { background: transparent; box-shadow: none; overflow: visible; }
.back-img { width: 100%; height: 100%; object-fit: fill; filter: drop-shadow(0 6px 0 var(--shadow)); }
.card-front { background: #fffaf2; transform: rotateY(180deg); }
.face-img { width: 80%; height: 80%; object-fit: contain; pointer-events: none; filter: drop-shadow(0 6px 6px rgba(122, 78, 40, 0.18)); }
.card.matched .card-inner { animation: matched 0.35s ease-out; }
@keyframes matched {
  0% { transform: rotateY(180deg) scale(1); }
  50% { transform: rotateY(180deg) scale(1.1); }
  100% { transform: rotateY(180deg) scale(1); }
}
/* 짝 맞춘 카드 — 그림은 주인에게 날아가고(main.ts flyToPile) 자리엔 흐린 자국만 남는다 */
.card.matched .card-front {
  background: rgba(255, 250, 242, 0.45);
  box-shadow: inset 0 0 0 3px rgba(138, 111, 92, 0.12);
  transition: background 0.3s 0.35s, box-shadow 0.3s 0.35s;
}
.card.matched .face-img { opacity: 0.13; filter: grayscale(1); transition: opacity 0.1s 0.35s, filter 0.1s 0.35s; }
.flyer {
  position: fixed;
  z-index: 20;
  object-fit: contain;
  pointer-events: none;
  transform-origin: center;
  filter: drop-shadow(0 10px 10px rgba(122, 78, 40, 0.3));
}
.card.wrong .card-inner { animation: wiggle 0.45s 0.4s; }
@keyframes wiggle {
  0%, 100% { transform: rotateY(180deg) rotate(0); }
  25% { transform: rotateY(180deg) rotate(-5deg); }
  75% { transform: rotateY(180deg) rotate(5deg); }
}
.sparkle { position: absolute; inset: 0; pointer-events: none; }
.card.matched .sparkle::before,
.card.matched .sparkle::after {
  content: '✦';
  position: absolute;
  color: #ffd23f;
  font-size: clamp(22px, 4vmin, 38px);
  text-shadow: 0 0 8px #fff;
  animation: twinkle 0.9s ease-out forwards;
}
.card.matched .sparkle::before { top: -10px; left: -6px; }
.card.matched .sparkle::after { bottom: -8px; right: -6px; animation-delay: 0.15s; }
@keyframes twinkle {
  0% { opacity: 0; transform: scale(0) rotate(0); }
  40% { opacity: 1; transform: scale(1.3) rotate(40deg); }
  100% { opacity: 0; transform: scale(0.6) rotate(90deg); }
}

/* 차례 알림 — 캐릭터가 주인 색 이름 리본 위에 선다 */
.turn-banner {
  position: absolute !important;
  left: 50%;
  top: 50%;
  z-index: 5 !important;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: max-content;
  max-width: calc(100vw - 32px);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.4);
}
/* 뒤 카드가 비쳐 산만하지 않게 은은한 빛 */
.turn-banner::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 55%;
  width: 150%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(circle closest-side, rgba(255, 248, 236, 0.96) 50%, rgba(255, 248, 236, 0));
}
.turn-banner.on { animation: banner var(--banner-ms, 0.9s) ease-out forwards; }
@keyframes banner {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  35% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
}
.banner-img {
  position: relative;
  z-index: 1;
  width: clamp(130px, 32vmin, 220px);
  height: clamp(130px, 32vmin, 220px);
  margin-bottom: -16px; /* 발이 리본 위에 올라서게 */
  object-fit: contain;
  filter: drop-shadow(0 8px 10px var(--shadow));
}
.banner-text {
  white-space: nowrap;
  padding: 10px 34px 12px;
  border: 5px solid #fff;
  border-radius: 999px;
  color: #fff;
  font-size: clamp(32px, 6.5vmin, 52px);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.15);
  box-shadow: 0 8px 0 var(--shadow), 0 16px 30px var(--shadow);
}
.turn-banner.dad .banner-text { background: var(--dad); }
.turn-banner.mona .banner-text { background: var(--mona); }
.turn-banner.friend .banner-text { background: var(--friend); }

/* ── 끝 ── */
.done { gap: 18px; }
.done-hero { height: min(30svh, 260px); object-fit: contain; animation: hop 0.9s ease-out 2; }
@keyframes hop {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-24px) rotate(-3deg); }
  60% { transform: translateY(0) rotate(2deg); }
}
.result, .result-row { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; }
.result .chip { opacity: 1; transform: none; padding-right: 20px; }
.result .team { padding: 10px 22px 10px 10px; }
.team-img { height: 110px; object-fit: contain; }
.actions { display: flex; gap: 28px; }
.action { width: clamp(100px, 16vmin, 140px); height: clamp(100px, 16vmin, 140px); }

.confetti { position: absolute !important; inset: 0; pointer-events: none; overflow: hidden; z-index: 0 !important; }
.piece {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 18px;
  border-radius: 3px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110svh) rotate(540deg); }
}

/* ── 부모 확인 / 메뉴 ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(60, 40, 25, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}
.sheet {
  background: #fff;
  border-radius: 28px;
  padding: 24px;
  width: min(100%, 420px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
  text-align: center;
  box-shadow: 0 10px 0 var(--shadow);
}
.gate-title { margin: 0; font-size: 24px; }
.gate-q { margin: 0; font-size: 38px; color: var(--orange-dark); }
.gate-choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.gate-btn,
.menu-btn {
  padding: 14px;
  border-radius: 16px;
  background: #fff1df;
  font-size: 22px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 4px 0 var(--shadow);
}
.gate-close { padding: 10px; color: var(--ink-soft); font-size: 18px; }

/* 부모 메뉴 — 아이 이름 */
.name-field { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.name-label { font-size: 18px; color: var(--ink-soft); }
.name-input {
  font: inherit;
  font-size: 24px;
  color: var(--ink);
  padding: 12px 14px;
  border: 3px solid #ffe0bd;
  border-radius: 16px;
  background: #fffaf2;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}
.name-input:focus { border-color: var(--orange); }
.name-note { font-size: 14px; color: var(--ink-soft); }

/* ── 첫 화면: 놀이 고르기 ── */
.home { justify-content: flex-start; gap: 10px; padding-top: calc(var(--safe-t) + 10px); }
.home-top { display: flex; flex-direction: column; align-items: center; gap: 0; }
.home .hero { width: min(46vmin, 340px); max-height: 26svh; }
.home .title { font-size: clamp(32px, 6.4vmin, 60px); }
.game-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(10px, 2.4vmin, 22px);
  width: min(100%, 900px);
  flex: 1;
  align-content: center;
}
@media (orientation: portrait) { .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.game-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: clamp(8px, 1.6vmin, 16px);
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 8px 0 var(--shadow), 0 12px 22px var(--shadow);
  transition: transform 0.12s, box-shadow 0.12s;
  min-height: 0;
}
.game-tile:active { transform: translateY(6px); box-shadow: 0 2px 0 var(--shadow); }
.game-img { width: 100%; height: clamp(64px, 15svh, 170px); object-fit: contain; }
.game-name { font-size: clamp(17px, 2.8vmin, 26px); }

/* ── 별 ── */
.stars { display: inline-flex; align-items: center; gap: 4px; padding-left: 6px; }
.star-img { width: 34px; height: 34px; object-fit: contain; }
.star-n { font-size: 24px; color: var(--orange-dark); min-width: 1ch; }
.result .star-img { width: 46px; height: 46px; }
.result .star-n { font-size: 34px; }

/* ── 숫자 길 ── */
.path { gap: 10px; }
.board {
  --n: 11;
  flex: 1;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  align-items: center;
  gap: clamp(4px, 1vmin, 10px);
  max-width: 1100px;
}
.sq {
  position: relative;
  aspect-ratio: 1;
  border-radius: 30%;
  background: #fff;
  box-shadow: 0 6px 0 var(--shadow), inset 0 -6px 0 rgba(122, 78, 40, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
}
.sq:nth-child(4n + 2) { background: #ffe9c9; }
.sq:nth-child(4n + 3) { background: #e3f1ff; }
.sq:nth-child(4n) { background: #e9f8dc; }
.sq:nth-child(4n + 1) { background: #ffe3ee; }
.sq.start { background: transparent; box-shadow: none; }
.sq-art { width: 90%; height: 90%; object-fit: contain; opacity: 0.85; }
.sq-n { font-size: clamp(22px, 4.6vmin, 46px); color: var(--ink); }
.sq-flag { position: absolute; right: -14%; top: -58%; width: 70%; pointer-events: none; }
.sq.pulse { animation: sq-pulse 0.45s ease-out; }
@keyframes sq-pulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); box-shadow: 0 0 0 6px #ffd23f, 0 6px 0 var(--shadow); }
  100% { transform: scale(1); }
}
.sq-tokens {
  position: absolute;
  left: 50%;
  bottom: 62%;
  display: flex;
  transform: translateX(-50%);
  pointer-events: none;
}
.token { width: clamp(38px, 8vmin, 80px); height: clamp(38px, 8vmin, 80px); margin: 0 -18%; animation: hop-in 0.42s ease-out; }
.token-img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 4px 3px var(--shadow)); }
@keyframes hop-in {
  0% { transform: translateY(0); }
  45% { transform: translateY(-40%); }
  100% { transform: translateY(0); }
}
/* 세로 화면: 아래(1)에서 위(10)로 한 줄 — 원형·지그재그는 수직선 감각을 흐린다(Siegler) */
@media (orientation: portrait) {
  .board {
    --sq: min(calc((100svh - var(--safe-t) - var(--safe-b) - 300px) / 11 - 5px), 84px);
    display: flex;
    flex-direction: column-reverse;
    justify-content: center;
    gap: 5px;
    width: auto;
  }
  .sq { width: var(--sq); height: var(--sq); flex: none; }
  .sq-n { font-size: calc(var(--sq) * 0.5); }
  .sq-tokens { left: 115%; bottom: 50%; transform: translateY(50%); }
  .token { width: calc(var(--sq) * 1.15); height: calc(var(--sq) * 1.15); margin: 0 -12% 0 0; }
  .sq-flag { right: auto; left: -80%; top: -20%; width: 70%; }
}
.die {
  width: clamp(96px, 18vmin, 150px);
  height: clamp(96px, 18vmin, 150px);
  border-radius: 26%;
  background: #fff;
  box-shadow: 0 8px 0 var(--shadow), 0 14px 26px var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse 1.8s ease-in-out infinite;
  flex: none;
}
.die:disabled { animation: none; opacity: 0.6; }
.die.rolling { animation: roll 0.65s ease-out; opacity: 1; }
@keyframes roll {
  0% { transform: rotate(0) scale(1); }
  30% { transform: rotate(140deg) scale(0.85); }
  60% { transform: rotate(300deg) scale(1.1); }
  100% { transform: rotate(360deg) scale(1); }
}
.die-face { position: relative; width: 70%; height: 70%; display: block; }
.pip { position: absolute; width: 24%; height: 24%; border-radius: 50%; background: var(--ink); transform: translate(-50%, -50%); }
.d1 .pip:nth-child(1) { left: 50%; top: 50%; }
.d2 .pip:nth-child(1) { left: 25%; top: 25%; }
.d2 .pip:nth-child(2) { left: 75%; top: 75%; }
.d3 .pip:nth-child(1) { left: 22%; top: 22%; }
.d3 .pip:nth-child(2) { left: 50%; top: 50%; }
.d3 .pip:nth-child(3) { left: 78%; top: 78%; }
.mini-dice { display: flex; gap: 10px; height: clamp(120px, 20vmin, 190px); align-items: center; }
.die-face.small { width: 58px; height: 58px; background: #fff; border-radius: 26%; box-shadow: 0 4px 0 var(--shadow), inset 0 0 0 2px #f1e4d2; }
.count-bubble {
  position: absolute !important;
  left: 50%;
  top: 40%;
  z-index: 4 !important;
  transform: translate(-50%, -50%);
  font-size: clamp(90px, 22vmin, 200px);
  color: var(--orange-dark);
  text-shadow: 0 6px 0 #fff, 0 10px 24px var(--shadow);
  opacity: 0;
  pointer-events: none;
}
.count-bubble.on { animation: count-pop 0.5s ease-out; opacity: 0.9; }
@keyframes count-pop {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  40% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); }
}
.path-at { font-size: 26px; padding-left: 6px; color: var(--orange-dark); }
.result-flag { height: 90px; object-fit: contain; }

/* ── 패턴 ── */
.pattern { gap: clamp(14px, 3svh, 30px); }
.round-dots { display: flex; gap: 8px; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 2px #f0d9bd; }
.dot.done { background: var(--orange); box-shadow: none; }
.dot.now { transform: scale(1.3); box-shadow: inset 0 0 0 3px var(--orange); }
.pattern-line {
  --item: min(calc((100vw - 48px) / 6 - 8px), 130px);
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: nowrap;
}
.p-item {
  width: var(--item);
  height: var(--item);
  border-radius: 24%;
  background: #fffaf2;
  box-shadow: 0 5px 0 var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
}
.p-img { width: 82%; height: 82%; object-fit: contain; pointer-events: none; }
.p-item.blank {
  background: transparent;
  box-shadow: none;
  border: 4px dashed var(--orange);
  color: var(--orange);
  font-size: calc(var(--item) * 0.55);
  animation: pulse 1.4s ease-in-out infinite;
}
.p-item.blank.filled { border: 4px solid var(--ok-ring, #ffd23f); background: #fffaf2; animation: pop-in 0.4s ease-out; }
.pattern-choices { display: flex; gap: clamp(14px, 4vmin, 36px); justify-content: center; }
.p-choice {
  width: min(28vw, 170px);
  height: min(28vw, 170px);
  border-radius: 26%;
  background: #fff;
  box-shadow: 0 8px 0 var(--shadow), 0 12px 22px var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s, opacity 0.3s;
}
.p-choice:active { transform: translateY(6px); }
.p-choice.nope { animation: nope 0.45s; }
.p-choice.fade { opacity: 0.25; }
.p-choice.chosen { transform: scale(1.08); box-shadow: 0 0 0 5px #ffd23f, 0 8px 0 var(--shadow); }
@keyframes nope {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px) rotate(-4deg); }
  60% { transform: translateX(10px) rotate(4deg); }
}
.mini-line { display: flex; gap: 4px; align-items: center; height: clamp(120px, 20vmin, 190px); }
.mini-p { width: 34px; height: 34px; object-fit: contain; }
.mini-p.blank { border: 3px dashed var(--orange); border-radius: 8px; color: var(--orange); font-size: 22px; display: flex; align-items: center; justify-content: center; }

/* ── 신호등 ── */
.light { gap: 12px; }
.rule-slot { min-height: 64px; display: flex; align-items: center; }
.rule-card { display: flex; gap: 14px; padding: 8px 16px; border-radius: 999px; background: #fff; box-shadow: 0 5px 0 var(--shadow); }
.rule { display: inline-flex; align-items: center; gap: 6px; font-size: 30px; }
.rule.stop { opacity: 0.8; }
.lamp { width: 34px; height: 34px; border-radius: 50%; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.15); }
.lamp.green { background: #4cc57a; }
.lamp.red { background: #f0565a; }
.rule-card.big { padding: 18px 30px; gap: 34px; }
.rule-card.big .rule { font-size: 64px; gap: 12px; }
.rule-card.big .lamp { width: 84px; height: 84px; }
@media (max-width: 520px) {
  .rule-card.big { padding: 12px 20px; gap: 18px; }
  .rule-card.big .rule { font-size: 44px; gap: 6px; }
  .rule-card.big .lamp { width: 58px; height: 58px; }
}
.ready { position: absolute !important; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; pointer-events: none; z-index: 3 !important; }
.ready:empty { display: none; }
.ready > * { pointer-events: auto; }
.rule-hint { margin: 0; font-size: 22px; color: var(--ink-soft); }
.stage {
  flex: 1;
  width: min(86vw, 70svh, 560px);
  max-height: min(86vw, 70svh, 560px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fff7ea;
  box-shadow: 0 10px 0 var(--shadow), inset 0 0 0 14px #f4e6d3;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: box-shadow 0.15s;
  touch-action: manipulation;
}
.stage.on.green { box-shadow: 0 10px 0 var(--shadow), inset 0 0 0 22px #4cc57a; background: #f0fbf3; }
.stage.on.red { box-shadow: 0 10px 0 var(--shadow), inset 0 0 0 22px #f0565a; background: #fff1f1; }
.stage-img { width: 58%; height: 58%; object-fit: contain; animation: pop-in 0.3s ease-out; pointer-events: none; }
.stage.fb-hit .stage-img, .stage.fb-oops .stage-img { animation: none; }
.stage.fb-oops { animation: nope 0.45s; }
.stage.fb-miss { opacity: 0.6; }
.stage-star { position: absolute; width: 34%; animation: pop-in 0.4s ease-out; pointer-events: none; }
.stage-tag { position: absolute; bottom: 10%; font-size: clamp(26px, 5vmin, 44px); color: #3a9a5e; pointer-events: none; }
.speed-art { font-size: clamp(80px, 14vmin, 130px); height: clamp(120px, 20vmin, 190px); display: flex; align-items: center; }
.turn-banner.flip .banner-text { background: var(--orange); }

/* ── 컵 숨기기 ── */
.cups { gap: 14px; }
.cups-say { margin: 0; font-size: clamp(22px, 4vmin, 36px); min-height: 1.4em; text-align: center; }
.cup-table {
  position: relative;
  width: min(92vw, 760px);
  height: min(52vw, 46svh, 420px);
  margin-top: auto;
  margin-bottom: auto;
}
.cup-wrap {
  position: absolute;
  bottom: 0;
  width: calc(100% / 3);
  height: 100%;
  transition: left 0.6s cubic-bezier(0.45, 0, 0.3, 1);
}
.cup-img {
  position: absolute;
  left: 6%;
  bottom: 0;
  width: 88%;
  transition: transform 0.45s cubic-bezier(0.3, 1.4, 0.5, 1);
  filter: drop-shadow(0 8px 6px var(--shadow));
  z-index: 2;
}
.cup-prize { position: absolute; left: 30%; bottom: 4%; width: 40%; opacity: 0; z-index: 1; transition: opacity 0.2s; }
.cup-wrap.has-prize .cup-prize { opacity: 1; }
.cup-wrap.up .cup-img { transform: translateY(-62%) rotate(-6deg); }
.cup-wrap.arc-up { z-index: 3; animation: arc-up 0.6s ease-in-out; }
.cup-wrap.arc-down { animation: arc-down 0.6s ease-in-out; }
@keyframes arc-up { 50% { transform: translateY(-22%) scale(1.06); } }
@keyframes arc-down { 50% { transform: translateY(10%) scale(0.94); } }
.cup-table.pick .cup-img { animation: wobble 1.6s ease-in-out infinite; }
.cup-table.pick .cup-wrap:nth-child(2) .cup-img { animation-delay: 0.2s; }
.cup-table.pick .cup-wrap:nth-child(3) .cup-img { animation-delay: 0.4s; }
@keyframes wobble {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-3deg); }
  75% { transform: rotate(3deg); }
}
.mini-cups { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px; width: 100%; height: clamp(120px, 20vmin, 190px); align-content: center; }
.mini-cup { width: 30%; object-fit: contain; }
.mini-swaps { width: 100%; text-align: center; font-size: 26px; color: var(--orange-dark); letter-spacing: 2px; }

/* ── 퍼즐 ── */
.puzzle { gap: 14px; }
.pz-board {
  --cell: min(calc((100vw - 48px) / var(--cols)), calc((100svh - 330px) / var(--rows)), 240px);
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell));
  grid-template-rows: repeat(var(--rows), var(--cell));
  border-radius: 22px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 8px 0 var(--shadow), 0 14px 26px var(--shadow);
}
.pz-ghost { position: absolute; inset: 0; background-size: cover; opacity: 0.16; filter: grayscale(0.4); pointer-events: none; }
.pz-slot { position: relative; box-shadow: inset 0 0 0 2px rgba(138, 111, 92, 0.25); background-repeat: no-repeat; }
.pz-slot.target { box-shadow: inset 0 0 0 4px rgba(255, 154, 60, 0.6); animation: pulse 1.4s ease-in-out infinite; }
.pz-slot.filled { box-shadow: none; animation: none; }
.pz-slot.snap { animation: pop-in 0.35s ease-out; }
.pz-slot.nope { animation: nope 0.45s; }
.pz-board.complete { animation: pulse 0.9s ease-in-out 2; box-shadow: 0 0 0 8px #ffd23f, 0 8px 0 var(--shadow); }
.pz-tray {
  --piece: min(calc((100vw - 60px) / 3 - 10px), 150px, 18svh);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  min-height: var(--piece);
}
.pz-piece {
  width: var(--piece);
  height: var(--piece);
  border-radius: 16px;
  background-repeat: no-repeat;
  box-shadow: 0 6px 0 var(--shadow), 0 0 0 3px #fff;
  transition: transform 0.15s, box-shadow 0.15s;
}
.pz-piece.sel { transform: translateY(-8px) scale(1.06); box-shadow: 0 0 0 5px var(--orange), 0 12px 0 var(--shadow); }
.pz-piece.nope { animation: nope 0.45s; }
.pz-result { width: 96px; height: 96px; border-radius: 16px; background-size: cover; box-shadow: 0 0 0 3px #fff; }
.mini-pz {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-template-rows: repeat(var(--rows), 1fr);
  width: clamp(120px, 20vmin, 190px);
  height: clamp(120px, 20vmin, 190px);
  border-radius: 16px;
  background-size: cover;
  overflow: hidden;
}
.mini-pz-cell { box-shadow: inset 0 0 0 2px #fff; }

/* 알림이 끝나기 전 ▶ — 눌러도 안 되는 동안엔 뛰지 않고 흐리게 */
.ready-go:disabled { animation: none; opacity: 0.4; filter: grayscale(0.5); }

/* ── 누구랑? 다섯 자리(혼자·아빠 둘·친구 둘) ── */
.seats { max-width: 1000px; }
.seats .tile { width: clamp(150px, 22vmin, 210px); padding: 12px 10px 10px; }
.seats .tile.wide { width: clamp(170px, 27vmin, 260px); }
.seats .tile-img { height: clamp(90px, 15vmin, 160px); }
.seats .seat-friend .caption { color: #b4741a; }
@media (max-width: 520px) {
  .seats { gap: 10px; }
  .seats .tile, .seats .tile.wide { width: calc(50% - 6px); }
  .seats .tile-img { height: 78px; }
  .seats .caption { font-size: 18px; }
}
.sheet-art { height: 110px; object-fit: contain; align-self: center; }
.menu-btn.primary { background: var(--orange); color: #fff; }

