/* 찬양 밴드 — 화면 모양. 그림이 오기 전 단색 도형 자리표시. 색은 base.css 토큰만 쓴다. */
.bd-body { background: var(--night); color: var(--cream); --focus: var(--gold); overscroll-behavior: none; }
.bd-body .topbar-title { color: var(--cream); }
.bd-page { max-width: 980px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.bd-start .play-title { color: var(--cream); }
.bd-start .say-row { width: 100%; max-width: 480px; text-align: left; }

/* 시작 화면 작은 무대 */
.bd-mini { display: flex; gap: 10px; align-items: flex-end; justify-content: center; padding: 18px 22px 0; border-radius: 24px 24px 12px 12px;
  background: linear-gradient(transparent 62%, var(--wood) 62%); }
.bd-mini-fig { animation: jw-hop 1s ease-in-out infinite; }
.bd-mini-fig:nth-child(2n) { animation-delay: .5s; }
/* 키 비율 (Daniel 10/15: 시우 80 · 다다 = 시우의 94% · 미미 76% · 봉봉 57%). 공통 img.fig 는 모두 같은 72×88 칸이라 미미·봉봉이 시우만큼 컸다 (10/17) */
img.bd-mini-fig { width: auto; max-width: 25%; height: 104px; }
img.bd-mini-fig:nth-child(1) { height: 79px; }  /* 미미 */
img.bd-mini-fig:nth-child(3) { height: 98px; }  /* 다다 */
img.bd-mini-fig:nth-child(4) { height: 59px; }  /* 봉봉 */

/* 소리 안내 */
.bd-tip { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 12px; font-weight: 800; font-size: 16px; }
.bd-tip-btn { min-height: 44px; padding: 0 16px; font-size: 16px; background: var(--lake); color: var(--cream); }

.bd { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }

/* ── 무대 ── */
.bd-hall {
  position: relative; isolation: isolate; overflow: hidden; border-radius: 28px;
  height: min(calc(100svh - 430px), 118vw, 520px); min-height: 250px; /* 430 = 위 막대 + 아래 줄·안내·서랍: 휴대폰 세로에서 서랍까지 한 화면에 */
  background: radial-gradient(circle at 20% 18%, rgba(255, 246, 227, .5) 0 1.5px, transparent 2.5px) 0 0 / 46px 38px,
    linear-gradient(var(--advent-dark), var(--night) 70%);
  user-select: none; -webkit-user-select: none;
}
.bd-sky, .bd-floor, .bd-crowd { position: absolute; left: 0; right: 0; pointer-events: none; }
.bd-sky { top: 0; height: 60%; }
.bd-sky::before, .bd-sky::after { /* 원작 무대 뒤 동그라미 장식 */
  content: ""; position: absolute; left: 50%; top: 12%; width: 70%; aspect-ratio: 1; transform: translateX(-50%); border-radius: 50%;
  border: 10px solid rgba(246, 183, 60, .18); }
.bd-sky::after { width: 46%; top: 22%; border-color: rgba(246, 183, 60, .12); }
.bd-floor { bottom: 0; height: 46%; background: var(--wood); border-top: 10px solid var(--wood-dark); border-radius: 50% 50% 0 0 / 14% 14% 0 0; }
.has-art { background: none; border: 0; }
.has-art img { width: 100%; height: 100%; object-fit: cover; }
.bd-sky.has-art::before, .bd-sky.has-art::after { display: none; } /* 그림이 오면 도형 장식은 끔 */
.bd-sky.has-art img { object-position: 50% 100%; }
.bd-floor.has-art { border-radius: 0; }
.bd-crowd.has-art { bottom: 0; height: 12%; opacity: 1; }
.bd-crowd.has-art img { object-position: 50% 100%; }
.bd-crowd { bottom: -4%; height: 13%; z-index: 3; /* 앞줄 구경꾼 머리 (뒷모습) */
  background: radial-gradient(circle at 50% 100%, var(--night-dark) 0 62%, transparent 64%) 0 100% / 44px 100% repeat-x; opacity: .9; }

/* 조명 (원작 lights.js: 천장 → 바닥 → 바닥 깜빡임 → 바닥 색 → 천장 색) */
.bd-beam { position: absolute; top: -6%; width: 34%; height: 92%; opacity: 0; pointer-events: none; z-index: 1;
  clip-path: polygon(42% 0, 58% 0, 100% 100%, 0 100%); transition: opacity .5s, background .5s;
  background: linear-gradient(rgba(255, 246, 227, .7), rgba(255, 246, 227, 0)); }
.bd-beam--0 { left: -4%; transform: rotate(-14deg); } .bd-beam--1 { left: 20%; transform: rotate(-5deg); }
.bd-beam--2 { left: 46%; transform: rotate(5deg); } .bd-beam--3 { left: 70%; transform: rotate(14deg); }
.l-ceil .bd-beam { opacity: .55; }
.l-ceilc .bd-beam--0 { background: linear-gradient(rgba(217, 56, 63, .8), transparent); }
.l-ceilc .bd-beam--1 { background: linear-gradient(rgba(246, 183, 60, .8), transparent); }
.l-ceilc .bd-beam--2 { background: linear-gradient(rgba(124, 199, 123, .8), transparent); }
.l-ceilc .bd-beam--3 { background: linear-gradient(rgba(143, 208, 245, .8), transparent); }
.bd-flood { position: absolute; bottom: 7%; width: 20%; height: 8%; border-radius: 50%; z-index: 2; pointer-events: none; opacity: 0;
  background: radial-gradient(rgba(255, 246, 227, .95), rgba(255, 246, 227, 0) 70%); transition: opacity .4s; }
.bd-flood--0 { left: 4%; } .bd-flood--1 { left: 28%; } .bd-flood--2 { left: 52%; } .bd-flood--3 { left: 76%; }
.l-floor .bd-flood { opacity: .8; }
.l-pulse .bd-flood { opacity: calc(.35 + var(--pulse, 0) * .65); transition: none; }
.l-floorc .bd-flood--0, .l-floorc .bd-flood--2 { background: radial-gradient(rgba(217, 56, 63, .95), transparent 70%); }
.l-floorc .bd-flood--1, .l-floorc .bd-flood--3 { background: radial-gradient(rgba(143, 208, 245, .95), transparent 70%); }

/* 무대 자리 6: 세로 화면 = 뒷줄 3 + 앞줄 3, 가로 화면 = 앞줄 5 + 가운데 위 특별 자리 */
.bd-spots { position: absolute; inset: 10% 2% 9%; z-index: 4; display: grid; gap: 2px 4px;
  grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr));
  grid-template-areas: "fl sp fr" "nl ce nr"; }
.bd-spot--farLeft { grid-area: fl; } .bd-spot--special { grid-area: sp; } .bd-spot--farRight { grid-area: fr; }
.bd-spot--nearLeft { grid-area: nl; } .bd-spot--center { grid-area: ce; } .bd-spot--nearRight { grid-area: nr; }
@media (orientation: landscape) {
  .bd-spots { inset: 4% 2% 8%; grid-template-columns: repeat(5, minmax(0, 1fr)); grid-template-areas: ". . sp . ." "fl nl ce nr fr"; }
}
.bd-spot { position: relative; display: flex; align-items: flex-end; justify-content: center; min-width: 0; min-height: 0; container-type: size; }
.bd-pad { position: absolute; left: 10%; right: 10%; bottom: 0; height: 20%; border-radius: 50%; pointer-events: none;
  background: rgba(255, 246, 227, .1); border: 3px dashed rgba(255, 246, 227, .45); transition: background .2s, border-color .2s, transform .2s; }
.bd-spot--special .bd-pad { background: rgba(217, 56, 63, .35); border-style: solid; border-color: var(--joy); height: 26%; } /* 특별 자리: 빨간 단 */
.bd-spot.filled .bd-pad { border-style: solid; border-color: transparent; }
.bd-spot--green.filled .bd-pad { background: radial-gradient(rgba(124, 199, 123, .95), rgba(124, 199, 123, .25)); }
.bd-spot--blue.filled .bd-pad { background: radial-gradient(rgba(143, 208, 245, .95), rgba(143, 208, 245, .25)); }
.bd-spot--red.filled .bd-pad { background: radial-gradient(rgba(255, 150, 140, .95), rgba(217, 56, 63, .5)); }
.dropping .bd-spot:not(.filled) .bd-pad { border-color: var(--gold); }
.bd-spot.over .bd-pad { background: rgba(246, 183, 60, .55); border-color: var(--gold); transform: scale(1.12); }
.bd-arrow { position: absolute; top: 18%; left: 50%; margin-left: -.5em; font-size: 26px; line-height: 1; color: var(--gold);
  display: none; animation: jw-hop .9s ease-in-out infinite; pointer-events: none; }
.is-empty .bd-arrow, .dropping .bd-spot:not(.filled) .bd-arrow { display: block; }

/* 무대가 처음 꽉 찼을 때 시편 150:6 */
/* 말씀 띠는 무대 아래쪽(구경꾼 머리 위)에: 위쪽 4% 자리는 무대가 꽉 차는 순간 뒷줄 세 친구 얼굴을 다 덮었다 (10/17) */
.bd-verse { position: absolute; left: 50%; bottom: 3%; transform: translateX(-50%); z-index: 6; width: max-content; max-width: 92%;
  display: grid; justify-items: center; padding: 8px 18px; border-radius: 18px; background: var(--gold); color: var(--ink);
  text-align: center; line-height: 1.35; box-shadow: 0 4px 0 var(--gold-dark); animation: bd-pop .5s cubic-bezier(.3, 1.6, .5, 1); pointer-events: none; }
.bd-verse b { font-size: clamp(15px, 4.2vw, 18px); font-weight: 900; }
.bd-verse small { font-size: 13px; font-weight: 700; }
.bd-verse.out { opacity: 0; transition: opacity 1s; }
@keyframes bd-pop { from { transform: translateX(-50%) scale(.4); opacity: 0; } }

/* ── 악기 친구 (그림 오기 전: 둥근 몸 + 악기 도형 + 이름) ── */
.bd-friend { position: relative; display: grid; justify-items: center; align-content: end; gap: 2px; width: 84px; height: 112px;
  padding: 0; border: 0; border-radius: 18px; background: none; color: var(--cream); cursor: grab;
  touch-action: pan-x; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
/* 무대 위: 발끝이 자리 동그라미 가운데에 (10/17 — 그림 높이가 정해지지 않아 가로세로 비율대로 늘고 이름표 위에 얹혀
   동그라미보다 30~40px 떠 있었고, 좁고 긴 그림은 크게·넓은 그림은 작게 나왔다). 뒷줄은 조금 작게 (멀리) */
.bd-friend.on-stage { touch-action: none; width: 100%; max-width: 112px; height: 86cqh; max-height: 150px; margin-bottom: 10cqh; z-index: 1;
  grid-template-rows: minmax(0, 1fr); }
.bd-spot--special .bd-friend.on-stage { margin-bottom: 13cqh; }
@media (orientation: portrait) { .bd-spot--farLeft .bd-friend.on-stage, .bd-spot--farRight .bd-friend.on-stage { height: 72cqh; max-height: 126px; } }
.bd-spot--special .bd-friend.on-stage { height: 70cqh; max-height: 124px; }
.bd-blob { position: relative; display: block; width: 64px; height: 70px; border-radius: 46% 46% 40% 40%; background: var(--c);
  box-shadow: inset -7px -8px 0 rgba(0, 0, 0, .16); transform-origin: 50% 100%; }
.on-stage .bd-blob { width: min(72%, 76px); height: auto; aspect-ratio: .92; }
.bd-blob::before { /* 흰자 있는 두 눈 */
  content: ""; position: absolute; left: 22%; right: 22%; top: 26%; height: 22%;
  background: radial-gradient(circle at 50% 60%, var(--ink) 0 26%, var(--white) 28% 64%, transparent 66%) 0 0 / 50% 100% repeat-x; }
.bd-blob::after { /* 발밑 그림자 */
  content: ""; position: absolute; left: 6%; right: 6%; bottom: -7px; height: 10px; border-radius: 50%; background: rgba(0, 0, 0, .28); z-index: -1; }
.bd-art { width: 76px; height: 86px; object-fit: contain; object-position: 50% 100%; transform-origin: 50% 100%; pointer-events: none; }
.on-stage .bd-art { width: 100%; height: 100%; min-height: 0; }
.on-stage[data-inst="bell"] .bd-art { height: 64%; align-self: end; }    /* 봉봉 = 시우의 57% (키 비율 10/15). 같은 칸에 꽉 채우면 아이들만큼 컸다 */
.on-stage[data-inst="timbrel"] .bd-art { height: 82%; align-self: end; } /* 미미 = 시우의 76% (그림에 소고·몽실이 포함) */
.bd-name { display: grid; line-height: 1.15; text-align: center; font-size: 14px; pointer-events: none; }
.bd-name b { font-weight: 900; }
.bd-name small { font-size: 12px; font-weight: 700; opacity: .85; }
.on-stage .bd-name { position: absolute; left: -10px; right: -10px; bottom: -10cqh; font-size: 12px; text-shadow: 0 1px 2px var(--night); }
.bd-spot--special .on-stage .bd-name { bottom: -13cqh; }
.on-stage .bd-name small { display: none; }

/* 악기 도형 (자리표시) */
.bd-inst { position: absolute; right: -14%; bottom: 4%; width: 46%; aspect-ratio: 1; background: var(--ic); border-radius: 50%;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
[data-inst="drum"] .bd-inst { width: 62%; right: -22%; border: 4px solid var(--wood); aspect-ratio: 1.2; border-radius: 40%; }
[data-inst="harp"] .bd-inst { border-radius: 0; clip-path: polygon(0 0, 30% 0, 100% 100%, 0 100%); width: 52%; }
[data-inst="trumpet"] .bd-inst { border-radius: 0; clip-path: polygon(0 40%, 60% 40%, 100% 0, 100% 100%, 60% 60%, 0 60%); width: 64%; right: -36%; top: 30%; }
[data-inst="flute"] .bd-inst { border-radius: 99px; width: 80%; aspect-ratio: 6; right: -40%; top: 52%; transform: rotate(-12deg); }
[data-inst="timbrel"] .bd-inst { background: none; border: 6px solid var(--ic); width: 54%; right: -26%; }
[data-inst="bell"] .bd-inst { width: 32%; border-radius: 50% 50% 40% 40%; }
[data-inst="cymbal"] .bd-inst { aspect-ratio: 3; width: 60%; right: -30%; bottom: 30%; box-shadow: 0 10px 0 var(--ic), 0 12px 0 rgba(0, 0, 0, .2); }
[data-inst="xylo"] .bd-inst { border-radius: 4px; aspect-ratio: 1.6; width: 62%; right: -30%; background: repeating-linear-gradient(90deg, var(--ic) 0 18%, var(--gold) 18% 24%); }
[data-inst="lute"] .bd-inst { border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; width: 44%; aspect-ratio: .8; }
[data-inst="clap"] .bd-inst { width: 30%; right: -6%; bottom: 30%; box-shadow: -40px 0 0 var(--ic); }

/* 상태: 기다림(다음 마디까지) / 연주 중(박자에 맞춰 통통) / 끌기 / 인사 */
.bd-friend.waiting .bd-blob, .bd-friend.waiting .bd-art { animation: bd-ready .45s ease-in-out infinite alternate; }
@keyframes bd-ready { from { transform: rotate(-5deg); } to { transform: rotate(5deg); } }
.bd-friend.playing .bd-blob, .bd-friend.playing .bd-art {
  transform: translateY(calc(var(--hop, 0) * -12px)) scale(calc(1 + var(--sq, 0) * .1), calc(1 - var(--sq, 0) * .1)); }
.bd-friend.playing .bd-inst { transform: rotate(calc(var(--sq, 0) * -18deg)); }
.bd-friend.dragging { position: fixed; z-index: 50; max-width: none; max-height: none; cursor: grabbing; pointer-events: none; }
.bd-friend.dragging .bd-blob, .bd-friend.dragging .bd-art { transform: scale(1.14) rotate(-6deg); }
.bd-friend.land .bd-blob, .bd-friend.land .bd-art { animation: bd-land .3s ease-out; }
@keyframes bd-land { 0% { transform: scale(1.2, .8); } 60% { transform: scale(.94, 1.08); } }
.bow .bd-friend .bd-blob, .bow .bd-friend .bd-art { transform: rotate(14deg) translateY(4px) scaleY(.9) !important; transition: transform .5s; }
.bd-friend:focus-visible { outline-offset: 0; }

/* 떠오르는 음표 */
.bd-note { position: absolute; left: 50%; bottom: 60%; z-index: 5; font-size: 22px; font-weight: 900; color: var(--gold); pointer-events: none;
  animation: bd-note 1.6s ease-out forwards; }
.bd-note img { width: 24px; height: 24px; }
@keyframes bd-note { from { transform: translate(-50%, 0) scale(.6); opacity: 1; } to { transform: translate(calc(-50% + var(--dx, 0px)), -60px) scale(1.1); opacity: 0; } }

/* ── 무대 아래 줄 ── */
.bd-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.bd-count { display: grid; line-height: 1.2; font-weight: 800; font-size: 15px; }
.bd-dots { color: var(--gold); letter-spacing: 2px; font-size: 14px; }
.bd-btns { display: flex; gap: 8px; }
.bd-mix { min-height: 52px; padding: 0 16px; }
.bd-end { min-height: 52px; padding: 0 20px; font-size: 18px; animation: bd-pop2 .4s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes bd-pop2 { from { transform: scale(.5); } }
.bd-how { text-align: center; font-weight: 800; font-size: 16px; color: var(--gold); }

/* ── 악기 서랍 ── */
.bd-drawer { display: flex; align-items: center; gap: 6px; padding: 8px 6px; border-radius: 24px; background: rgba(255, 246, 227, .1); }
.bd-tray { flex: 1; min-width: 0; display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; padding: 4px 2px; }
.bd-tray::-webkit-scrollbar { display: none; }
.bd-cell { flex: none; width: 84px; height: 116px; display: grid; place-items: end center; scroll-snap-align: start; }
.bd-cell.gone { display: none; } /* 원작: 무대로 간 친구 칸은 접힘 */
.bd-scroll { width: 48px; height: 48px; font-size: 30px; font-weight: 900; background: var(--cream); color: var(--ink); }
@media (pointer: coarse) { .bd-scroll { display: none; } } /* 휴대폰은 손가락으로 밀어서 */

/* 가로로 눕힌 휴대폰: 무대 왼쪽, 오른쪽 칸에 개수·단추 + 서랍(남은 높이 전부) */
@media (orientation: landscape) and (max-height: 540px) {
  .bd-body .topbar { padding-top: 4px; padding-bottom: 4px; }
  .bd-page { padding-bottom: 8px; }
  .bd { grid-template-columns: minmax(0, 1fr) 208px; grid-template-rows: auto auto minmax(0, 1fr); height: calc(100svh - 72px); min-height: 280px; }
  .bd-hall { grid-row: 1 / 4; height: auto; min-height: 0; }
  .bd-bar, .bd-tip, .bd-drawer { grid-column: 2; }
  .bd-bar { gap: 6px; } .bd-count { width: 100%; } .bd-dots { display: none; }
  .bd-mix, .bd-end { min-height: 48px; padding: 0 12px; font-size: 16px; }
  .bd-how { display: none; } /* 빈 무대의 화살표가 대신 알려 줌 */
  .bd-tip { font-size: 13px; gap: 4px 8px; } .bd-tip-btn { min-height: 40px; }
  .bd-drawer { min-height: 0; height: 100%; padding: 6px; }
  .bd-tray { flex-wrap: wrap; overflow-x: hidden; overflow-y: auto; align-content: flex-start; justify-content: center; height: 100%; scroll-snap-type: y proximity; }
  .bd-friend:not(.on-stage) { touch-action: pan-y; }
  .bd-scroll { display: none; }
  .bd-cell { width: 84px; height: 108px; }
}
@media (max-width: 360px) { .bd-mix { padding: 0 10px; font-size: 16px; } }

.bd-verse-card .pq-label { font-size: 15px; font-weight: 800; opacity: .8; }

@media (prefers-reduced-motion: reduce) {
  .bd-friend.waiting .bd-blob { outline: 3px dashed var(--gold); outline-offset: 4px; border-radius: 46%; }
  .bd-friend.playing .bd-blob { box-shadow: inset -7px -8px 0 rgba(0, 0, 0, .16), 0 0 0 4px var(--gold); }
}
