:root {
  --bg: #fff4d6;
  --ink: #4a3b2f;
  --accent: #ffd166;
  --font: 'Jua', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
}

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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

button {
  font: inherit;
  color: inherit;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
}

#app {
  height: 100dvh;
}

/* ---------- 메인 메뉴 ---------- */

.menu {
  height: 100%;
  overflow-y: auto;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  background: #e4f5ff url('../images/playground.svg') center bottom / cover no-repeat;
}

/* 놀이터 잔디 위의 동물 친구들. 화면 아래에 고정되고 카드보다 뒤에 있다. */
.menu-friends {
  position: fixed;
  left: 0;
  right: 0;
  bottom: max(64px, calc(env(safe-area-inset-bottom) + 48px));
  z-index: 0;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: clamp(0px, 1.5vw, 20px);
  padding: 0 16px;
}

.menu-friend {
  padding: 0;
  background: none;
  line-height: 0;
  animation: friend-bob 2.4s ease-in-out infinite;
}

.menu-friend:nth-child(2n) { animation-delay: -0.8s; }
.menu-friend:nth-child(3n) { animation-delay: -1.6s; }

.menu-friend.jump {
  animation: friend-jump 0.5s ease-out;
}

.menu-friend-img {
  width: clamp(64px, 12vw, 120px);
  height: auto;
}

/* 좁은 화면에서는 다섯 친구만 */
@media (max-width: 520px) {
  .menu-friend:nth-child(n + 6) { display: none; }
}

@keyframes friend-bob {
  50% { transform: translateY(-6px); }
}

@keyframes friend-jump {
  40% { transform: translateY(-28px) scale(1.06); }
}

@media (prefers-reduced-motion: reduce) {
  .menu-friend { animation: none; }
}

.menu > :not(.menu-friends, .support-banner, .voice-note) {
  position: relative;
  z-index: 1;
}

.menu-title {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 4px 0 24px;
  font-size: clamp(56px, 16vw, 104px);
  font-weight: normal;
  line-height: 1.15;
  white-space: nowrap;
}

.menu-title-letter {
  display: inline-block;
  -webkit-text-stroke: 0.16em #fff;
  paint-order: stroke fill;
  text-shadow: 0 0.09em 0 rgba(74, 51, 40, 0.25);
}

.menu-title-gap {
  width: 0.35em;
}

.menu-title-letter:nth-child(1) { color: #ff7a6b; transform: rotate(-8deg); }
.menu-title-letter:nth-child(2) { color: #ffb020; transform: rotate(6deg) translateY(-0.08em); }
.menu-title-letter:nth-child(4) { color: #5bbf4a; transform: rotate(-5deg); }
.menu-title-letter:nth-child(5) { color: #4f9fe0; transform: rotate(7deg) translateY(-0.08em); }
.menu-title-letter:nth-child(6) { color: #a77be8; transform: rotate(-6deg); }

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(180px, calc(50% - 10px)), 1fr));
  gap: 20px;
  max-width: 960px;
  margin: 0 auto;
}

.game-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  aspect-ratio: 1;
  padding: 16px;
  border-radius: 32px;
  background: var(--card-color);
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.15);
  transition: transform 0.1s;
}

.game-card:active {
  transform: translateY(6px) scale(0.97);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.15);
}

.game-card-emoji {
  font-size: clamp(56px, 14vw, 88px);
  line-height: 1;
}

.game-card-title {
  font-size: clamp(20px, 4.5vw, 28px);
  color: #fff;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.2);
}

/* ---------- 아이디어·개발자 돕기 배너 (메인 왼쪽 아래) ---------- */

.menu {
  padding-bottom: max(88px, calc(env(safe-area-inset-bottom) + 72px));
}

.support-banner {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 999px;
  background: #fff;
  font-size: 18px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.12);
  opacity: 0.92;
}

.support-banner:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}

.support-banner-emoji {
  font-size: 22px;
  line-height: 1;
}

/* AI 음성 안내 문구는 배너 반대편 오른쪽 아래에 작게 둔다. */
.voice-note {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(20px, calc(env(safe-area-inset-bottom) + 4px));
  z-index: 1;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  font-size: 13px;
  color: #8a7560;
  pointer-events: none;
}

@media (max-width: 420px) {
  .voice-note {
    right: 10px;
    padding: 3px 8px;
    font-size: 11px;
  }
}

.support-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.35);
  animation: fade-in 0.2s;
}

.support-box {
  width: min(440px, 100%);
  padding: 28px 24px 20px;
  border-radius: 32px;
  background: #fff;
  text-align: center;
  animation: bounce-in 0.4s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.support-box-wide {
  width: min(640px, 100%);
}

.support-form {
  display: block;
  width: 100%;
  height: min(70dvh, 640px);
  margin-bottom: 8px;
  border: none;
  border-radius: 16px;
  background: #f6f1e7;
}

.support-title {
  margin: 0 0 12px;
  font-size: clamp(24px, 6vw, 30px);
  font-weight: normal;
  color: #ff7b54;
}

.support-text {
  margin: 0 0 20px;
  font-size: 18px;
  line-height: 1.5;
}

.support-question {
  margin: 0 0 20px;
  font-size: 40px;
}

.support-choices {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}

.support-choice {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: var(--accent);
  font-size: 30px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
}

.support-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.support-actions .big-button {
  font-size: 22px;
  padding: 14px 24px;
}

.support-actions a.big-button {
  display: block;
  text-decoration: none;
  color: var(--ink);
}

.support-actions .support-donate {
  background: #ff8fab;
  color: #fff;
}

.support-email {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: -4px;
  font-size: 16px;
  color: #8a7a6c;
}

.support-email-address {
  user-select: text;
  -webkit-user-select: text;
  -webkit-touch-callout: default;
}

.support-copy {
  padding: 4px 12px;
  border-radius: 999px;
  background: #f1e7d6;
  font-size: 15px;
}

.support-close {
  padding: 8px 20px;
  background: none;
  font-size: 18px;
  color: #8a7a6c;
}

/* ---------- 게임 화면 공통 ---------- */

.game-screen {
  position: relative;
  height: 100%;
  background: linear-gradient(#bde0fe, #e8f6ff);
}

.game-stage {
  position: absolute;
  inset: 0;
  display: flex;
  overflow: hidden;
  touch-action: none;
}

.home-button {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  z-index: 10;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #fff;
  font-size: 32px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
}

.home-button:active {
  transform: translateY(3px);
}

.big-button {
  padding: 18px 32px;
  border-radius: 999px;
  background: var(--accent);
  font-size: clamp(22px, 5vw, 32px);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.15);
}

.big-button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.15);
}

/* ---------- 축하 화면 ---------- */

.celebrate {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.35);
  animation: fade-in 0.3s;
}

.celebrate-box {
  width: min(480px, 100%);
  padding: 32px 24px;
  border-radius: 40px;
  background: #fff;
  text-align: center;
  animation: bounce-in 0.5s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.celebrate-stars {
  font-size: clamp(48px, 14vw, 80px);
  animation: wiggle 1s ease-in-out infinite;
}

.celebrate-message {
  margin: 12px 0 24px;
  font-size: clamp(28px, 7vw, 40px);
  font-weight: normal;
  color: #ff7b54;
}

.celebrate-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
}

.celebrate-actions .again {
  background: #8ac926;
  color: #fff;
}

.celebrate-actions .home {
  background: #4cc9f0;
  color: #fff;
}

/* ---------- 정답 칭찬 효과 ---------- */

.cheer {
  position: absolute;
  inset: 0;
  z-index: 18;
  overflow: hidden;
  pointer-events: none;
}

.cheer-text {
  position: absolute;
  top: 50%;
  left: 50%;
  padding: 12px 32px;
  border-radius: 40px;
  background: #fff;
  color: #ff7b54;
  z-index: 1;
  width: max-content;
  max-width: calc(100vw - 32px);
  font-size: clamp(26px, 8vmin, 72px);
  text-align: center;
  word-break: keep-all;
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.12);
  transform: translate(-50%, -50%);
  animation: cheer-pop 2.2s cubic-bezier(0.2, 1.6, 0.4, 1) forwards;
}

.cheer-piece {
  position: absolute;
  top: -60px;
  animation: cheer-fall 1.8s ease-in var(--delay) forwards;
}

@keyframes cheer-pop {
  0% { transform: translate(-50%, -50%) scale(0.2) rotate(-10deg); opacity: 0; }
  20% { transform: translate(-50%, -50%) scale(1.15) rotate(3deg); opacity: 1; }
  30%, 80% { transform: translate(-50%, -50%) scale(1) rotate(0); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
}

@keyframes cheer-fall {
  to { transform: translate(var(--drift), 110vh) rotate(var(--spin)); }
}

@keyframes fade-in {
  from { opacity: 0; }
}

@keyframes bounce-in {
  from { transform: scale(0.3); opacity: 0; }
}

@keyframes wiggle {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(6deg); }
}

@media (prefers-reduced-motion: reduce) {
  .celebrate-stars {
    animation: none;
  }
}

/* ---------- 게임: 국기 맞추기 ---------- */

.fq-progress {
  position: absolute;
  top: max(20px, env(safe-area-inset-top));
  left: 0;
  right: 0;
  padding: 0 88px;
  text-align: center;
  font-size: clamp(22px, 5vw, 36px);
  pointer-events: none;
}

.fq-star {
  color: rgba(255, 255, 255, 0.8);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.1);
}

.fq-star.on {
  color: #ffd23f;
}

.fq-board {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 2.5vh, 24px);
  width: 100%;
  max-width: 640px;
  margin: auto;
  padding: max(96px, calc(env(safe-area-inset-top) + 84px)) 20px max(20px, env(safe-area-inset-bottom));
}

.fq-question {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(8px, 2vh, 20px);
}

.fq-flag {
  width: min(78vw, 46vh, 420px);
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 6px solid #fff;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.12);
  animation: bounce-in 0.4s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.fq-flag.correct {
  animation: fq-jump 0.6s ease;
}

.fq-ask {
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  font-size: clamp(18px, 4vw, 24px);
}

.fq-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.fq-option {
  display: flex;
  gap: 10px;
}

.fq-pick,
.fq-listen {
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.12);
  transition: transform 0.1s, background 0.2s;
}

.fq-pick {
  flex: 1;
  min-height: 64px;
  padding: 12px 16px;
  font-size: clamp(22px, 5vw, 32px);
}

.fq-listen {
  flex: none;
  width: 64px;
  font-size: 26px;
}

.fq-pick:active,
.fq-listen:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.12);
}

.fq-option.correct .fq-pick {
  background: #8ac926;
  color: #fff;
  animation: fq-jump 0.6s ease;
}

.fq-option.wrong {
  opacity: 0.45;
  transition: opacity 0.4s;
}

.fq-option.wrong .fq-pick {
  animation: fq-wobble 0.5s ease;
}

/* 화면 아래 양쪽 구석의 동물 친구들(배경). 문제·버튼 뒤에 있고 터치를 막지 않는다. */
.fq-friends {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(4px, env(safe-area-inset-bottom));
  z-index: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 clamp(4px, 2vw, 24px);
  pointer-events: none;
}

.fq-friend {
  line-height: 0;
  animation: friend-bob 2.4s ease-in-out infinite;
}

.fq-friend:nth-child(2) { animation-delay: -1.2s; }

.fq-friend.jump {
  animation: friend-jump 0.5s ease-out;
}

.fq-friend-img {
  width: clamp(72px, min(18vw, 16vh), 150px);
  height: auto;
}

.fq-friend:nth-child(2) .fq-friend-img {
  transform: scaleX(-1);
}

@media (prefers-reduced-motion: reduce) {
  .fq-friend { animation: none; }
}

/* 틀렸을 때 잠깐 떠오르는 말풍선: 칭찬보다 작고 부드럽게 */
.fq-oops {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 17;
  padding: 10px 26px;
  border: 4px solid #ffd27a;
  border-radius: 32px;
  background: #fff8e6;
  color: #e08a00;
  font-size: clamp(22px, 6vw, 40px);
  font-weight: 800;
  width: max-content;
  max-width: calc(100vw - 32px);
  text-align: center;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.1);
  pointer-events: none;
  animation: fq-oops-pop 1.6s ease forwards;
}

@keyframes fq-oops-pop {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  15% { transform: translate(-50%, -50%) scale(1.08); opacity: 1; }
  25%, 75% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -60%) scale(0.95); opacity: 0; }
}

/* 시작 화면: 몇 문제 풀지 고르기 */
.fq-setup {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 4vh, 36px);
  width: 100%;
  margin: auto;
  padding: max(80px, calc(env(safe-area-inset-top) + 72px)) 16px max(16px, env(safe-area-inset-bottom));
}

.fq-setup-title {
  padding: 8px 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  font-size: clamp(26px, min(7vw, 7vh), 44px);
}

.fq-numbers {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: clamp(8px, min(2.5vw, 2.5vh), 18px);
}

.fq-number {
  width: clamp(52px, min(15vw, 15vh), 104px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fff;
  font-size: clamp(24px, min(7vw, 7vh), 48px);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.12);
  transition: transform 0.15s, background 0.15s;
}

.fq-number.selected {
  background: #ff9f1c;
  color: #fff;
  transform: scale(1.12);
  box-shadow: 0 6px 0 #d97f00;
}

.fq-go {
  background: #8ac926;
  color: #fff;
  padding: clamp(10px, 2.5vh, 18px) 48px;
  box-shadow: 0 6px 0 #5f9a12;
}

/* 가로 화면(태블릿·폰 가로 모드): 왼쪽 국기, 오른쪽 보기 */
@media (orientation: landscape) {
  /* 가로에서는 제목이 홈 버튼과 겹치지 않으므로 위 여백을 줄인다 */
  .fq-setup {
    padding-top: max(16px, env(safe-area-inset-top));
  }

  .fq-progress {
    top: max(12px, env(safe-area-inset-top));
  }

  .fq-board {
    flex-direction: row;
    gap: clamp(20px, 4vw, 56px);
    max-width: 1200px;
    padding: max(64px, calc(env(safe-area-inset-top) + 56px)) max(24px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  }

  .fq-flag {
    /* 국기 + 질문 버튼이 화면 높이 안에 들어오도록 높이 기준으로 크기를 정한다 */
    width: min(48vw, calc((100dvh - 150px) * 4 / 3), 560px);
  }

  .fq-options {
    flex: 1;
    max-width: 440px;
    gap: clamp(8px, 2.5vh, 18px);
  }

  .fq-pick {
    min-height: clamp(48px, 15vh, 88px);
    padding: 6px 12px;
    font-size: clamp(20px, 4.5vh, 34px);
  }

  .fq-listen {
    width: clamp(48px, 13vh, 76px);
    font-size: clamp(20px, 4vh, 30px);
  }

  .fq-ask {
    padding: 6px 16px;
    font-size: clamp(16px, 3.6vh, 24px);
  }
}

@keyframes fq-jump {
  30% { transform: translateY(-14px) scale(1.04); }
}

@keyframes fq-wobble {
  25% { transform: rotate(-2deg); }
  75% { transform: rotate(2deg); }
}

/* ---------- 게임: 눈싸움 대작전 (태블릿 가로, 2인용) ---------- */

.sb-scene {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: linear-gradient(#9ccfee, #dff3ff 70%);
  pointer-events: none;
}

.sb-ground {
  position: absolute;
  left: -10%;
  right: -10%;
  bottom: 0;
  height: 55%;
  border-radius: 50% 50% 0 0 / 60px 60px 0 0;
  background: linear-gradient(#ffffff, #eaf4fb);
  box-shadow: 0 -6px 0 rgba(255, 255, 255, 0.6);
}

/* 가운데 경계선: 왼쪽 반은 왼쪽 친구, 오른쪽 반은 오른쪽 친구 자리 */
.sb-divider {
  position: absolute;
  top: 12%;
  bottom: 0;
  left: 50%;
  border-left: 4px dashed rgba(90, 169, 230, 0.45);
}

.sb-deco {
  position: absolute;
  line-height: 1;
}

.sb-tree {
  left: 50%;
  bottom: 50%;
  font-size: 12vmin;
  transform: translateX(-50%);
}

.sb-flake {
  position: absolute;
  top: -20px;
  border-radius: 50%;
  background: #fff;
  opacity: 0.9;
  will-change: transform;
}

/* 눈송이 흔들림은 3가지 고정 애니메이션 중 하나를 쓴다.
   키프레임 안에서 CSS 변수를 쓰면 GPU로 넘기지 못해 매 프레임 스타일을 다시 계산하므로 고정값으로 둔다. */
.sb-flake.drift-a { animation: sb-fall-a 10s linear infinite; }
.sb-flake.drift-b { animation: sb-fall-b 10s linear infinite; }
.sb-flake.drift-c { animation: sb-fall-c 10s linear infinite; }

.sb-scene.no-tree .sb-tree,
.sb-scene.no-divider .sb-divider {
  display: none;
}

@keyframes sb-fall-a {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-40px, 110vh, 0); }
}

@keyframes sb-fall-b {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(0, 110vh, 0); }
}

@keyframes sb-fall-c {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(40px, 110vh, 0); }
}

/* 혼자 / 둘이 고르기 */
.sb-mode {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 5vh, 40px);
  padding: 72px 16px 16px;
}

.sb-mode-title {
  padding: 8px 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  font-size: clamp(22px, 4vw, 40px);
}

.sb-mode-row {
  display: flex;
  gap: clamp(16px, 4vw, 48px);
}

.sb-mode-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: clamp(150px, 26vw, 300px);
  aspect-ratio: 1.1;
  border-radius: 36px;
  color: #fff;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.15);
  transition: transform 0.1s;
}

.sb-mode-button:active {
  transform: translateY(5px) scale(0.97);
}

.sb-mode-button.solo { background: #4cc9f0; }
.sb-mode-button.duo { background: #ff8fab; }

.sb-mode-emoji {
  font-size: clamp(44px, 9vw, 96px);
  line-height: 1;
}

.sb-mode-text {
  font-size: clamp(22px, 3.6vw, 38px);
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15);
}

/* 혼자 하기 난이도 */
.sb-level-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: clamp(130px, 22vw, 240px);
  aspect-ratio: 1;
  border-radius: 36px;
  color: #fff;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.15);
  transition: transform 0.1s;
}

.sb-level-button:active {
  transform: translateY(5px) scale(0.97);
}

.sb-level-button.level-1 { background: #8ac926; }
.sb-level-button.level-2 { background: #ff9f1c; }
.sb-level-button.level-3 { background: #ff5a5f; }

.sb-level-stars {
  font-size: clamp(22px, 3.6vw, 40px);
  line-height: 1.2;
}

.sb-level-name {
  font-size: clamp(28px, 4.6vw, 52px);
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15);
}

.sb-level-desc {
  font-size: clamp(18px, 2.6vw, 28px);
  opacity: 0.95;
}

/* 캐릭터 고르기: 혼자면 가운데 하나, 둘이면 반쪽씩 */
.sb-select.solo {
  grid-template-columns: 1fr;
}

.sb-select {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.sb-pick-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 3vh, 28px);
  padding: 72px 12px 16px;
}

.sb-pick-title {
  padding: 8px 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  font-size: clamp(18px, 3.4vw, 34px);
}

.sb-pick-panel.ready .sb-pick-title {
  background: #8ac926;
  color: #fff;
}

.sb-select-row {
  display: flex;
  gap: clamp(10px, 2.5vw, 32px);
}

.sb-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: clamp(8px, 1.6vh, 16px) clamp(10px, 1.8vw, 20px);
  border-radius: 28px;
  background: #fff;
  border: 6px solid var(--card-border);
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.12);
  transition: transform 0.15s, opacity 0.15s;
}

.sb-card:active {
  transform: translateY(5px) scale(0.97);
}

.sb-pick-panel.ready .sb-card:not(.selected) {
  opacity: 0.4;
}

.sb-card.selected {
  transform: scale(1.06);
}

.sb-card-boy { --card-border: #4a90e2; }
.sb-card-girl { --card-border: #ff8fab; }

.sb-card-pic {
  width: clamp(70px, min(14vw, 30vh), 180px);
  aspect-ratio: 100 / 130;
}

.sb-card-pic svg,
.sb-player svg,
.sb-face svg {
  display: block;
  width: 100%;
  height: 100%;
}

.sb-card-name {
  font-size: clamp(16px, 2.6vw, 28px);
  color: var(--card-border);
}

/* 대결 */
.sb-player {
  position: absolute;
  left: 0;
  bottom: 12%;
  z-index: 2;
  width: min(22vmin, 18vw);
  aspect-ratio: 100 / 130;
  /* 위치는 JS에서 transform으로 옮긴다 (부드럽게 움직이도록 GPU 레이어로) */
  will-change: transform;
  pointer-events: none;
}

.sb-player svg {
  transform-origin: 50% 100%;
}

.sb-player.charging svg {
  animation: sb-charge 0.3s ease-in-out infinite alternate;
}

/* 걷는 중: 통통 */
.sb-player.walking svg {
  animation: sb-walk 0.35s ease-in-out infinite alternate;
}

@keyframes sb-walk {
  from { transform: translateY(0) rotate(-3deg); }
  to { transform: translateY(-5%) rotate(3deg); }
}

.sb-player.throw svg {
  animation: sb-throw 0.3s ease;
}

.sb-player.right.throw svg {
  animation-name: sb-throw-right;
}

@keyframes sb-charge {
  from { transform: scale(1, 1); }
  to { transform: scale(1.04, 0.96); }
}

@keyframes sb-throw {
  40% { transform: rotate(10deg) translateY(-6%); }
}

@keyframes sb-throw-right {
  40% { transform: rotate(-10deg) translateY(-6%); }
}

.sb-hint {
  position: absolute;
  bottom: 2.5%;
  z-index: 3;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  font-size: clamp(16px, 2.4vw, 26px);
  width: max-content;
  max-width: calc(100vw - 32px);
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
  transition: opacity 0.4s;
}

.sb-hint.left { left: 25%; }
.sb-hint.right { left: 75%; }
.sb-hint.hide { opacity: 0; }

.sb-fx {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.sb-ball {
  position: absolute;
  top: 0;
  left: 0;
  width: min(6vmin, 44px);
  height: min(6vmin, 44px);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff 0 35%, #dbe9f3 80%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.18);
  will-change: transform;
}

/* 최대로 커지면 반짝반짝 */
.sb-ball.max {
  box-shadow: 0 0 0 3px #ffd166, 0 0 14px #ffd166;
}

.sb-splat {
  position: absolute;
  width: min(10vmin, 70px);
  height: min(10vmin, 70px);
  margin: calc(min(10vmin, 70px) / -2) 0 0 calc(min(10vmin, 70px) / -2);
  border-radius: 50%;
  background:
    radial-gradient(circle at 20% 30%, #fff 0 18%, transparent 19%),
    radial-gradient(circle at 75% 25%, #fff 0 14%, transparent 15%),
    radial-gradient(circle at 70% 75%, #fff 0 16%, transparent 17%),
    radial-gradient(circle at 25% 75%, #fff 0 12%, transparent 13%),
    radial-gradient(circle, #fff 0 32%, transparent 33%);
  filter: drop-shadow(0 1px 1px rgba(90, 130, 160, 0.4));
  animation: sb-splat 0.6s ease-out forwards;
}

@keyframes sb-splat {
  from { transform: scale(0.4); opacity: 1; }
  to { transform: scale(1.4); opacity: 0; }
}

.sb-pop {
  position: absolute;
  width: max-content;
  max-width: calc(100vw - 32px);
  text-align: center;
  transform: translate(-50%, -50%);
  animation: sb-pop 1.2s ease-out forwards;
}

.sb-pop.score {
  color: #ff9f1c;
  font-size: clamp(26px, 6vmin, 48px);
  text-shadow: 2px 2px 0 #fff;
}

.sb-pop.bubble {
  padding: 6px 14px;
  border-radius: 20px;
  background: #fff;
  font-size: clamp(16px, 3.5vmin, 26px);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.1);
}

@keyframes sb-pop {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  20% { transform: translate(-50%, -70%) scale(1.1); opacity: 1; }
  100% { transform: translate(-50%, -140%) scale(1); opacity: 0; }
}

/* 점수판 */
.sb-score {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: clamp(6px, 1.5vw, 14px);
  padding: 6px clamp(10px, 2vw, 18px);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.1);
  transform: translateX(-50%);
  pointer-events: none;
}

.sb-side {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sb-side.theirs {
  flex-direction: row-reverse;
}

.sb-face {
  width: clamp(30px, 6vmin, 48px);
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 50%;
  background: #eaf4fb;
}

.sb-face svg {
  height: auto;
  margin-top: -10%;
}

.sb-pips {
  display: flex;
  gap: 3px;
}

.sb-pip {
  width: clamp(10px, 2.2vmin, 16px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #d6e6f2;
}

.sb-pip.on {
  background: #ff9f1c;
}

.sb-vs {
  font-size: clamp(14px, 3vmin, 22px);
  color: #8aa4b8;
}

.sb-banner {
  position: absolute;
  top: 45%;
  left: 50%;
  z-index: 4;
  padding: 10px 36px;
  border-radius: 999px;
  background: #fff;
  color: #3a86ff;
  font-size: clamp(32px, 9vmin, 72px);
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.1);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.sb-skip {
  position: absolute;
  top: calc(45% + clamp(40px, 8vmin, 70px));
  left: 50%;
  z-index: 4;
  padding: 8px 22px;
  border-radius: 999px;
  background: #ff9f1c;
  color: #fff;
  font-size: clamp(18px, 3vw, 30px);
  box-shadow: 0 5px 0 #d97f00;
  width: max-content;
  max-width: calc(100vw - 32px);
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
  animation: sb-skip-pulse 1s ease-in-out infinite alternate;
}

@keyframes sb-skip-pulse {
  to { transform: translateX(-50%) scale(1.06); }
}

.sb-banner.go {
  color: #ff7b54;
  animation: sb-go 0.9s ease forwards;
}

@keyframes sb-go {
  0% { transform: translate(-50%, -50%) scale(0.6); }
  25% { transform: translate(-50%, -50%) scale(1.15); }
  70% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.3); opacity: 0; }
}

/* 태블릿 가로 전용: 세로로 들면 돌려 달라고 안내 */
.sb-rotate {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: rgba(142, 202, 230, 0.97);
  color: #fff;
}

@media (orientation: portrait) {
  .sb-rotate {
    display: flex;
  }
}

.sb-rotate-icon {
  font-size: 96px;
  animation: sb-rotate 2s ease-in-out infinite;
}

.sb-rotate-text {
  font-size: clamp(24px, 6vw, 36px);
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15);
}

@keyframes sb-rotate {
  0%, 20% { transform: rotate(0); }
  50%, 80% { transform: rotate(-90deg); }
  100% { transform: rotate(0); }
}

/* ---------- 게임: 동물 마트 사장님 ---------- */

.am-root {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: clamp(8px, 2vmin, 16px);
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background:
    repeating-linear-gradient(90deg, #ffe5d9 0 40px, #fff1e6 40px 80px) top / 100% 64px no-repeat,
    linear-gradient(#fff1e6, #fde2c8);
}

.am-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding-left: 76px; /* 🏠 버튼 자리 */
}

.am-level {
  padding: 6px 16px;
  border-radius: 999px;
  background: #fff;
  font-size: clamp(18px, 3.5vmin, 26px);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.08);
}

.am-stars {
  display: flex;
  gap: 4px;
  font-size: clamp(28px, 6vmin, 44px);
}

.am-star {
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.12);
}

.am-star.on {
  color: #ffd23f;
}

.am-star.pop {
  animation: am-star-pop 0.6s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.am-listen {
  flex: none;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #fff;
  font-size: 30px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
}

.am-listen:active {
  transform: translateY(3px);
}

/* 손님 + 말풍선 */
.am-counter {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 3vmin, 24px);
  min-height: 0;
}

.am-customer {
  flex: none;
  font-size: clamp(72px, 18vmin, 170px);
  line-height: 1;
  filter: drop-shadow(0 6px 0 rgba(0, 0, 0, 0.1));
}

.am-customer.enter { animation: am-enter 0.7s cubic-bezier(0.2, 1.2, 0.4, 1); }
.am-customer.jump { animation: am-jump 0.7s ease; }
.am-customer.giggle { animation: am-giggle 0.6s ease; }
.am-customer.leave { animation: am-leave 0.7s ease-in forwards; }

.am-bubble {
  position: relative;
  order: 1; /* 세로: 손님 오른쪽 */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 120px;
  max-width: 100%;
  padding: 12px 20px;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.08);
}

.am-bubble:empty {
  visibility: hidden;
}

.am-bubble::before {
  content: '';
  position: absolute;
  top: 50%;
  left: -14px;
  border: 10px solid transparent;
  border-right: 14px solid #fff;
  border-left: 0;
  transform: translateY(-50%);
}

.am-order-line,
.am-bubble-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: clamp(26px, 6vmin, 44px);
}

.am-order-emoji {
  font-size: clamp(36px, 8vmin, 60px);
  line-height: 1;
}

.am-order-qty {
  min-width: 1.2em;
  color: #ff7b54;
  font-size: clamp(36px, 8vmin, 60px);
  text-align: center;
}

.am-order-pics {
  max-width: 260px;
  font-size: clamp(20px, 4.5vmin, 30px);
  line-height: 1.2;
  text-align: center;
  word-break: break-all;
}

/* 작업대: 진열대·지갑(왼쪽) + 바구니·쟁반(오른쪽) */
.am-work {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: clamp(10px, 2vmin, 16px);
  min-height: 0;
}

.am-shelf {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(8px, 2vmin, 14px);
  align-content: center;
  padding: clamp(8px, 2vmin, 14px);
  border-radius: 24px;
  background: #e9c46a;
  box-shadow: inset 0 -8px 0 #d4a64a;
}

.am-item {
  position: relative;
  min-width: 64px;
  min-height: max(64px, min(14vmin, 110px));
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.12);
  touch-action: none;
  transition: transform 0.1s;
}

.am-item.pressed,
.am-pile.pressed {
  transform: scale(0.94);
}

.am-item.dragging,
.am-pile.dragging {
  opacity: 0.5;
}

.am-item-emoji {
  font-size: clamp(36px, 8vmin, 60px);
  line-height: 1;
}

.am-item .am-coin.tag {
  position: absolute;
  right: 4px;
  bottom: 4px;
}

.am-side {
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 2vmin, 16px);
  min-height: 0;
}

.am-basket {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 110px;
  padding: 12px;
  border: 4px dashed #f4a261;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.75);
  transition: transform 0.15s, background 0.15s;
}

.am-basket.drop-ready,
.am-desk.drop-ready {
  border-style: solid;
  background: #fff8d6;
  transform: scale(1.03);
}

.am-basket.bump,
.am-desk.bump {
  animation: am-bump 0.3s ease;
}

.am-zone-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(56px, 14vmin, 110px);
  opacity: 0.22;
  pointer-events: none;
}

.am-chips {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.am-chip {
  position: relative;
  width: 76px;
  height: 76px;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.12);
  animation: bounce-in 0.3s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.am-chip:active {
  transform: scale(0.92);
}

.am-chip-emoji {
  font-size: 46px;
  line-height: 1;
}

.am-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  min-width: 36px;
  height: 36px;
  padding: 0 6px;
  border-radius: 18px;
  background: #ff7b54;
  color: #fff;
  font-size: 24px;
  line-height: 36px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.15);
}

.am-done {
  flex: none;
  min-height: 72px;
  padding: 10px 24px;
  border-radius: 999px;
  background: #8ac926;
  color: #fff;
  font-size: clamp(22px, 4.5vmin, 32px);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.15);
  box-shadow: 0 6px 0 #5f9a12;
}

.am-done:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #5f9a12;
}

/* 동전 */
.am-coin {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  font-size: 28px;
  color: #6b4a00;
  background: radial-gradient(circle at 35% 30%, #fff3b0, #ffd166 60%, #f2b632);
  box-shadow: inset 0 0 0 4px #e0a800, 0 3px 0 rgba(0, 0, 0, 0.15);
}

.am-coin.c5 {
  width: 64px;
  height: 64px;
  font-size: 32px;
  color: #34495e;
  background: radial-gradient(circle at 35% 30%, #ffffff, #d5e3ef 60%, #a9bfd2);
  box-shadow: inset 0 0 0 4px #8aa4b8, 0 3px 0 rgba(0, 0, 0, 0.15);
}

.am-coin.c10 {
  color: #fff;
  background: radial-gradient(circle at 35% 30%, #ffc38a, #ff9f1c 60%, #e07b00);
  box-shadow: inset 0 0 0 4px #c76a00, 0 3px 0 rgba(0, 0, 0, 0.15);
}

.am-coin.tag,
.am-coin.c5.tag {
  width: 32px;
  height: 32px;
  font-size: 18px;
  box-shadow: inset 0 0 0 3px #e0a800;
}

.am-coin.c5.tag {
  box-shadow: inset 0 0 0 3px #8aa4b8;
}

.am-coin.big {
  width: 60px;
  height: 60px;
  font-size: 28px;
}










.am-purse {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  min-height: 100px;
  padding: 12px;
  border-radius: 24px;
  background: #ffd6a5;
  box-shadow: inset 0 -6px 0 #f4b67a;
}

.am-pile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 88px;
  height: 88px;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.12);
  touch-action: none;
  transition: transform 0.1s, opacity 0.2s;
}

.am-pile .am-coin {
  width: 64px;
  height: 64px;
  font-size: 32px;
}

.am-pile .am-coin.c5 {
  width: 72px;
  height: 72px;
}

.am-pile.empty {
  opacity: 0.35;
}





/* 끌고 다니는 복사본 */
.am-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 50;
  margin: 0;
  pointer-events: none;
  opacity: 0.9;
}

/* 가로 화면: 왼쪽 손님, 오른쪽 작업대 */
@media (orientation: landscape) {
  .am-root {
    grid-template-columns: minmax(150px, 0.7fr) minmax(0, 2fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .am-top {
    grid-column: 1 / -1;
  }

  .am-counter {
    flex-direction: column;
  }

  .am-bubble {
    order: 0; /* 말풍선이 손님 위 */
  }

  .am-bubble::before {
    top: auto;
    bottom: -14px;
    left: 50%;
    border: 10px solid transparent;
    border-top: 14px solid #fff;
    border-bottom: 0;
    transform: translateX(-50%);
  }

  .am-work {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }

  .am-item {
    min-height: max(64px, min(18vh, 120px));
  }
}

/* 높이가 낮은 가로 화면(폰): 조금씩 줄인다 */
@media (orientation: landscape) and (max-height: 500px) {
  .am-customer { font-size: clamp(56px, 16vh, 96px); }
  .am-done { min-height: 64px; }
  .am-coin.c5 { width: 58px; height: 58px; }
  .am-pile { width: 76px; height: 76px; }
  .am-pile .am-coin, .am-pile .am-coin.c5 { width: 58px; height: 58px; }
}

@keyframes am-enter {
  from { transform: translateX(-60vw) rotate(-10deg); }
}

@keyframes am-leave {
  30% { transform: translateY(-20px); }
  to { transform: translateX(80vw); opacity: 0; }
}

@keyframes am-jump {
  25% { transform: translateY(-28px) scale(1.06); }
  50% { transform: translateY(0); }
  75% { transform: translateY(-14px); }
}

@keyframes am-giggle {
  20% { transform: rotate(-10deg); }
  40% { transform: rotate(8deg); }
  60% { transform: rotate(-6deg); }
  80% { transform: rotate(4deg); }
}

@keyframes am-bump {
  50% { transform: scale(1.05); }
}

@keyframes am-star-pop {
  from { transform: scale(2.2); }
}

/* 동물 마트: 시작 화면 (단계 고르기) */
.am-root[hidden] {
  display: none;
}

.am-setup {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 4vh, 32px);
  padding: max(84px, calc(env(safe-area-inset-top) + 76px)) 16px max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(#fff1e6, #fde2c8);
}

.am-setup-title {
  padding: 8px 24px;
  border-radius: 999px;
  background: #fff;
  font-size: clamp(22px, min(6vw, 6vh), 40px);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.08);
}

.am-levels {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(8px, 2vw, 20px);
  width: min(100%, 980px);
}

.am-level-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: clamp(120px, 34vh, 220px);
  padding: 10px 6px;
  border-radius: 28px;
  color: #fff;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.15);
  transition: transform 0.1s;
}

.am-level-card:active {
  transform: translateY(5px) scale(0.97);
}

.am-level-card.level-1 { background: #8ac926; }
.am-level-card.level-2 { background: #4cc9f0; }
.am-level-card.level-3 { background: #ffb703; }
.am-level-card.level-4 { background: #fb8500; }
.am-level-card.level-5 { background: #ff5a5f; }

.am-level-num {
  font-size: clamp(28px, min(6vw, 7vh), 52px);
  line-height: 1;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.15);
}

.am-level-icon {
  font-size: clamp(30px, min(6vw, 7vh), 56px);
  line-height: 1.2;
}

.am-level-name {
  font-size: clamp(16px, min(3vw, 4vh), 26px);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.15);
  word-break: keep-all;
}

.am-level-mark {
  position: absolute;
  top: -12px;
  right: -8px;
  font-size: 36px;
  animation: wiggle 1s ease-in-out infinite;
}

@media (orientation: portrait) {
  .am-levels {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 480px;
  }

  .am-level-card {
    min-height: clamp(100px, 18vh, 160px);
  }

  .am-level-card.level-5 {
    grid-column: 1 / -1;
  }
}

/* 동물 마트: 계산대 (동전은 크기와 상관없이 블록 하나) */
.am-desk {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 3vmin, 24px);
  min-height: 0;
  padding: clamp(10px, 2vmin, 18px);
  border: 4px dashed #f4a261;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.8);
  transition: transform 0.15s, background 0.15s;
}

.am-price-total {
  align-self: center;
  margin-left: 4px;
  font-size: clamp(26px, 6vmin, 44px);
}

.am-coins-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 80px;
  font-size: clamp(26px, 6vmin, 44px);
}

.am-coin-block {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  padding: 0;
  border-radius: 50%;
  background: none;
}

.am-coin-block .am-coin {
  width: 64px;
  height: 64px;
  font-size: 32px;
}

.am-coin-block .am-coin.c5 {
  width: 72px;
  height: 72px;
}

.am-coin-block.counted .am-coin {
  filter: brightness(0.92);
}

/* 이어 센 수 */
.am-count {
  position: absolute;
  top: -18px;
  right: -8px;
  min-width: 34px;
  height: 34px;
  padding: 0 6px;
  border-radius: 17px;
  background: #ff7b54;
  color: #fff;
  font-size: 22px;
  line-height: 34px;
  animation: bounce-in 0.25s cubic-bezier(0.2, 1.6, 0.4, 1);
}


.am-op {
  color: #b08968;
}




@media (orientation: landscape) and (max-height: 500px) {
  .am-coin-block { width: 60px; height: 60px; }
  .am-coin-block .am-coin { width: 50px; height: 50px; font-size: 24px; }
  .am-coin-block .am-coin.c5 { width: 58px; height: 58px; }
  .am-coins-row { min-height: 64px; gap: 6px; }
}

.am-equation {
  color: #ff7b54;
  font-size: clamp(26px, 6vmin, 44px);
  animation: bounce-in 0.4s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.am-equation:empty {
  display: none;
}

/* 처음 누를 동전을 손가락으로 가리킨다 */
.am-pile.point::after,
.am-coin-block.point::after {
  content: '👆';
  position: absolute;
  bottom: -34px;
  left: 50%;
  font-size: 36px;
  transform: translateX(-50%);
  animation: am-point 0.9s ease-in-out infinite;
  pointer-events: none;
}

@keyframes am-point {
  50% { transform: translate(-50%, -10px); }
}

/* 동물 마트: 손님이 낸 돈 판단하기 */
.am-answers {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(10px, 2.5vmin, 18px);
  min-height: 0;
}

.am-answer {
  min-height: 72px;
  padding: 10px 20px;
  border-radius: 999px;
  color: #fff;
  font-size: clamp(22px, 4.5vmin, 34px);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.15);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.1s;
}

.am-answer:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
}

.am-answer.ok { background: #8ac926; }
.am-answer.short { background: #4cc9f0; }
.am-answer.over { background: #b197fc; }

/* 손님이 동전을 하나씩 올려놓는다 */
.am-coin-block.drop-in {
  animation: am-coin-in 0.35s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}

@keyframes am-coin-in {
  from { transform: translateY(-40px) scale(0.4); opacity: 0; }
}

@media (orientation: portrait) {
  .am-answers {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-content: center;
  }

  .am-answer {
    flex: 1 1 140px;
  }
}

.am-prices {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.am-price {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.am-price-emoji {
  font-size: clamp(28px, 6vmin, 44px);
  line-height: 1;
}

/* 이름표: 🧾 물건값, 👛 손님이 낸 돈 */
.am-labeled {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.am-label {
  padding: 4px 14px;
  border-radius: 999px;
  background: #fff1e6;
  color: #8a5a3b;
  font-size: clamp(16px, 3.2vmin, 24px);
  text-align: center;
}

.am-label.done {
  background: #8ac926;
  color: #fff;
  font-size: clamp(20px, 4vmin, 30px);
  animation: bounce-in 0.4s cubic-bezier(0.2, 1.6, 0.4, 1);
}

.am-answers > .am-label {
  align-self: center;
  font-size: clamp(20px, 4vmin, 28px);
}

/* 손님이 낸 10원 = 1원 10개 */
.am-paid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: clamp(26px, 6vmin, 44px);
}

.am-paid .am-coins-row {
  --c: clamp(36px, 16cqi, 64px);
  display: grid;
  grid-template-columns: repeat(5, var(--c));
  gap: 6px;
  min-height: 0;
}

/* 1원 10개는 판 너비에 맞춰 작게 */
.am-paid .am-coin-block,
.am-slots .am-slot {
  width: var(--c);
  height: var(--c);
}

.am-paid .am-coin-block .am-coin,
.am-slot .am-coin {
  width: calc(var(--c) * 0.9);
  height: calc(var(--c) * 0.9);
  font-size: calc(var(--c) * 0.42);
}

/* 거스름돈이 된 동전 */
.am-coin-block.change .am-coin {
  box-shadow: inset 0 0 0 4px #e0a800, 0 0 0 4px #8ac926;
}

.am-coin-block.change .am-count {
  background: #8ac926;
}

/* 서랍: 물건값만큼 빈자리 */
.am-drawer {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 0;
  padding: 16px;
  border-radius: 24px;
  background: #ffd6a5;
  box-shadow: inset 0 -6px 0 #f4b67a;
  transition: transform 0.15s;
}

.am-drawer.drop-ready {
  transform: scale(1.03);
  background: #ffe2bd;
}

.am-drawer.bump {
  animation: am-bump 0.3s ease;
}

.am-slots {
  --c: clamp(36px, 16cqi, 68px);
  display: grid;
  grid-template-columns: repeat(5, var(--c));
  gap: 8px;
  justify-content: center;
}

.am-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 4px dashed #c98a4b;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
}

.am-slot.filled {
  border-style: solid;
  border-color: transparent;
  background: none;
  animation: bounce-in 0.25s cubic-bezier(0.2, 1.6, 0.4, 1);
}

@media (orientation: landscape) and (max-height: 500px) {
  .am-slots, .am-paid .am-coins-row { --c: clamp(32px, min(16cqi, 12vh), 54px); gap: 4px; }
  .am-labeled { gap: 2px; }
  .am-label { font-size: 15px; padding: 2px 10px; }
}

/* 단계 그림의 동전 */
.am-level-icon .am-coin.icon {
  width: 1.05em;
  height: 1.05em;
  margin: 0 2px;
  font-size: inherit;
  vertical-align: middle;
}

.am-level-icon .am-coin.icon .am-coin-value {
  font-size: 0.55em;
}

.am-level .am-level-icon {
  font-size: inherit;
}

/* 손님이 돈을 고치는 동안 버튼 잠금 */
.am-answers.waiting .am-answer {
  opacity: 0.4;
  pointer-events: none;
}
