@font-face { font-family: 'Jua'; src: url('font/jua.woff2') format('woff2'); font-display: swap; }
:root { --ink: #3a1430; --cream: #fff8ec; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #1b0f3a; overflow: hidden; }
body { font-family: 'Jua', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif; color: var(--ink); user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }

#app { position: relative; width: 100%; height: 100%; overflow: hidden; }
.bg { position: absolute; inset: 0; background: #2a1760 url('img/bg-table.webp') center/cover no-repeat; }
@media (max-aspect-ratio: 4/5) { .bg { background-image: url('img/bg-table-tall.webp'); } }
section { position: absolute; inset: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); display: none; flex-direction: column; align-items: center; justify-content: safe center; overflow-y: auto; gap: 2.2vmin; padding: 3vmin; }
#app[data-scene=title] #title, #app[data-scene=howto] #howto, #app[data-scene=pick] #pick,
#app[data-scene=camset] #camset, #app[data-scene=play] #play, #app[data-scene=result] #result { display: flex; }

/* ---------- 광택 버튼 ---------- */
.gbtn { --c1: #ffe36e; --c2: #ffb51f; --edge: #8a4a00;
  position: relative; min-width: 14em; padding: .55em 1.6em .65em; border: .22em solid var(--ink); border-radius: 999px;
  font-size: clamp(18px, 4vmin, 34px); color: #fff; letter-spacing: .02em;
  text-shadow: 0 .09em 0 var(--ink), .06em 0 0 var(--ink), -.06em 0 0 var(--ink), 0 -.06em 0 var(--ink);
  background: linear-gradient(var(--c1), var(--c2)); box-shadow: inset 0 -.28em 0 var(--edge), 0 .3em 0 var(--ink); transition: transform .08s; }
.gbtn::before { content: ''; position: absolute; left: 12%; right: 12%; top: .18em; height: .42em; border-radius: 999px; background: rgba(255,255,255,.55); }
.gbtn:active { transform: translateY(.2em); box-shadow: inset 0 -.18em 0 var(--edge), 0 .1em 0 var(--ink); }
.gbtn.small { min-width: 9em; min-height: 46px; font-size: clamp(15px, 3vmin, 24px); }
.gbtn.pink { --c1: #ff8fc0; --c2: #ff3d8b; --edge: #a3104d; }
.gbtn.blue { --c1: #8fe0ff; --c2: #3aa8ff; --edge: #135e9e; }
.gbtn.gray { --c1: #e6dcf2; --c2: #a99bc4; --edge: #5c4d7a; }
.gbtn[hidden] { display: none; }
.btns { display: flex; flex-wrap: wrap; gap: 2vmin; justify-content: center; align-items: center; }

/* ---------- 첫 화면 ---------- */
.logo { width: min(64vw, 70vmin); max-height: 34vh; object-fit: contain; filter: drop-shadow(0 1vmin 0 rgba(0,0,0,.25)); animation: bob 2.4s ease-in-out infinite; }
.lineup { display: flex; align-items: flex-end; justify-content: center; width: min(98vw, 1000px); height: 30vh; margin-top: -2vh; }
.lineup img { flex: 1 1 0; min-width: 0; height: 100%; object-fit: contain; object-position: 50% 100%; margin: 0 -1.5vmin; filter: drop-shadow(0 .8vmin 0 rgba(0,0,0,.25)); }
.lineup .l-muscle { flex-grow: 1.35; height: 118%; z-index: 1; }
.lineup .l-baby { height: 78%; }
.hint { margin: 0; color: #fff; font-size: clamp(12px, 2.3vmin, 18px); opacity: .85; text-shadow: 0 1px 2px #000; }
@keyframes bob { 50% { transform: translateY(-1.2vmin) rotate(-1deg); } }

/* ---------- 판 ---------- */
.panel { background: var(--cream); border: .5vmin solid var(--ink); border-radius: 3vmin; box-shadow: 0 1vmin 0 var(--ink); padding: 3vmin 4vmin; max-width: min(92vw, 720px); max-height: 92%; overflow: auto; display: flex; flex-direction: column; align-items: center; gap: 2vmin; }
.panel h2, .ttl { margin: 0; font-size: clamp(24px, 5.5vmin, 44px); font-weight: normal; }
.ttl { color: #fff; text-shadow: 0 .08em 0 var(--ink), .05em 0 0 var(--ink), -.05em 0 0 var(--ink), 0 -.05em 0 var(--ink); }
.panel ol { margin: 0; padding-left: 1.3em; font-size: clamp(15px, 3vmin, 22px); line-height: 1.55; }
.panel b { color: #e0287a; font-weight: normal; }

/* ---------- 상대 고르기 ---------- */
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2vmin; width: min(96vw, 1100px); }
@media (max-aspect-ratio: 4/5) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.card { position: relative; display: flex; flex-direction: column; align-items: center; gap: .3em; padding: 1.5vmin 1vmin 2vmin; border: .45vmin solid var(--ink); border-radius: 2.5vmin;
  background: linear-gradient(#fff, #ffe9f3); box-shadow: 0 .8vmin 0 var(--ink); color: var(--ink); transition: transform .1s; }
.card:hover { transform: translateY(-.6vmin) rotate(-1deg); }
.card img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.card b { font-weight: normal; font-size: clamp(16px, 3.6vmin, 30px); }
.card small { font-size: clamp(11px, 2vmin, 16px); opacity: .75; min-height: 2.6em; }
.card .tag { position: absolute; top: 1vmin; left: 1vmin; padding: .1em .6em; border-radius: 999px; background: #3aa8ff; color: #fff; font-size: clamp(11px, 2vmin, 16px); border: 2px solid var(--ink); }
.card.c-muscle { background: linear-gradient(#fff6c2, #ffcf4a); }
.card.c-muscle .tag { background: #ff3d8b; }
.card .won { position: absolute; top: 1vmin; right: 1vmin; font-style: normal; background: #2fc46b; color: #fff; padding: .1em .5em; border-radius: 999px; border: 2px solid var(--ink); font-size: clamp(11px, 2vmin, 16px); }

/* ---------- 카메라 준비 ---------- */
.panel.wide { width: min(92vw, 760px); }
.msg { margin: 0; text-align: center; font-size: clamp(14px, 2.8vmin, 20px); min-height: 1.4em; }
.steps { list-style: none; padding: 0 !important; display: grid; grid-template-columns: 1fr 1fr; gap: 1vmin 3vmin; }
.steps li { opacity: .35; }
.steps li.now { opacity: 1; color: #e0287a; animation: bob 1s infinite; }
.steps li.done { opacity: 1; }
.steps li.done::before { content: '✔ '; color: #2fc46b; }
.meter { position: relative; display: none; width: 80%; height: 3.4vmin; border: 3px solid var(--ink); border-radius: 999px; background: linear-gradient(90deg, #8fe0ff, #fff 45% 55%, #ff8fc0); justify-content: space-between; align-items: center; padding: 0 1em; font-size: clamp(11px, 2vmin, 15px); }
.meter i { position: absolute; left: calc(50% - 1.6vmin); top: -.6vmin; width: 3.2vmin; height: 3.2vmin; border-radius: 50%; background: #ffcf4a; border: 3px solid var(--ink); transition: transform .06s; }
#steps:not(:empty) + .meter { display: flex; }

/* ---------- 내 카메라 ---------- */
.mebox { position: absolute; display: none; overflow: hidden; border: .5vmin solid var(--ink); border-radius: 2vmin; background: #000; box-shadow: 0 .6vmin 0 var(--ink); }
.mebox video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
#app[data-scene=camset] .mebox { display: block; right: 3vmin; bottom: 3vmin; width: 28vmin; height: 21vmin; }
#app[data-scene=play] .mebox { display: block; right: 2vmin; bottom: 2vmin; width: 22vmin; height: 16.5vmin; }
#app:not(.camon) .mebox, #app.nocam .mebox { display: none !important; }

/* ---------- 결과 ---------- */
.result-box { display: flex; flex-direction: column; align-items: center; gap: 1vmin; background: var(--cream); border: .5vmin solid var(--ink); border-radius: 3vmin; box-shadow: 0 1vmin 0 var(--ink); padding: 2vmin 5vmin 3vmin; animation: stamp2 .4s cubic-bezier(.2, 1.5, .4, 1); }
@keyframes stamp2 { from { transform: scale(.6); opacity: 0; } }
.result-box img { height: 38vh; }
.result-box h2 { margin: 0; font-weight: normal; font-size: clamp(36px, 10vmin, 90px); -webkit-text-stroke: .04em var(--ink); paint-order: stroke fill; }
.result-box.won h2 { color: #ffcf4a; } .result-box.lost h2 { color: #8fa3ff; }
.result-box p { margin: 0 0 1vmin; font-size: clamp(15px, 3vmin, 24px); }

/* ---------- 판 고르기: 얼굴 여럿 ---------- */
.cards.three, .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-aspect-ratio: 4/5) { .cards { grid-template-columns: 1fr; width: min(92vw, 420px); } .card .faces img { width: 26%; } .card small { min-height: 0; } }
.card .faces { display: flex; justify-content: center; width: 100%; }
.card .faces img { width: 34%; margin: 0 -2%; aspect-ratio: 1; }
.card.t-boss { background: linear-gradient(#fff6c2, #ffcf4a); }
.card.t-boss .tag { background: #ff3d8b; }
.live { margin: 0; font-size: clamp(14px, 3vmin, 22px); color: #3aa8ff; min-height: 1.3em; }

/* ---------- 판 ---------- */
.seats { position: absolute; top: 2vmin; left: 2vmin; right: 2vmin; display: flex; justify-content: center; gap: 2vmin; }
.seat { position: relative; flex: 0 1 32vmin; display: flex; flex-direction: column; align-items: center; transition: opacity .3s, transform .2s; }
.seat .face { width: 100%; aspect-ratio: 1; object-fit: contain; filter: drop-shadow(0 .6vmin 0 rgba(0,0,0,.25)); }
.seat .friend { width: 70%; aspect-ratio: 1; margin: 15% 0; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(#8fe0ff, #3aa8ff); border: .5vmin solid var(--ink); color: #fff; font-size: 10vmin; text-shadow: 0 .5vmin 0 var(--ink); }
.seat .nm { font-weight: normal; margin-top: -1vmin; padding: .1em .8em; background: var(--cream); border: .35vmin solid var(--ink); border-radius: 999px; font-size: clamp(12px, 2.6vmin, 22px); }
.seat.turn .nm { background: #ffcf4a; }
.seat.turn { transform: translateY(1vmin) scale(1.06); }
.seat.gone { opacity: .55; }
.hands { display: flex; justify-content: center; gap: 0; margin-top: .5vmin; height: 15vmin; }
.hands .hd { height: 100%; aspect-ratio: 1; object-fit: contain; transition: transform .15s; }
.hands .hd.r { transform: scaleX(-1); }
.hands .hd.up { animation: thumb .25s ease-out; }
.hands .hd.r.up { animation: thumbr .25s ease-out; }
.hands .hd[hidden] { display: none; }
@keyframes thumb { 0% { transform: translateY(1.5vmin); } }
@keyframes thumbr { 0% { transform: scaleX(-1) translateY(1.5vmin); } }
.badge { position: absolute; top: 30%; padding: .1em .6em; border-radius: 999px; font-style: normal; font-size: clamp(14px, 3vmin, 26px); color: #fff; background: #2fc46b; border: .35vmin solid var(--ink); transform: rotate(-8deg); }
.badge:empty { display: none; }
.bubble { position: absolute; top: 4%; right: 0; z-index: 2; min-width: 2em; padding: .05em .4em; text-align: center; background: #fff; border: .4vmin solid var(--ink); border-radius: 1em; font-size: clamp(22px, 6vmin, 52px); color: #e0287a; opacity: 0; transform: scale(.4); transition: transform .2s cubic-bezier(.2, 1.6, .4, 1), opacity .15s; }
.bubble.on { opacity: 1; transform: scale(1); }
.left { position: absolute; left: 2vmin; top: 50%; padding: .2em .8em; background: rgba(255,248,236,.9); border: .35vmin solid var(--ink); border-radius: 999px; font-size: clamp(12px, 2.6vmin, 20px); }

.myrow { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; }
.myhands { display: flex; gap: 2vmin; }
.myhand { width: 24vmin; height: 24vmin; padding: 0; border: none; background: none; touch-action: none; }
.myhand img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 .8vmin 0 rgba(0,0,0,.3)); }
.myhand:last-child img { transform: scaleX(-1); }
.myhand.up img { animation: thumb .2s ease-out; }
.myhand:last-child.up img { animation: thumbr .2s ease-out; }
.myhand[hidden] { display: none; }
.myrow.turn .myhands { filter: drop-shadow(0 0 2vmin #ffe36e); }
.bubble.me { top: auto; bottom: 6vmin; right: auto; left: calc(50% + 27vmin); }
.badge.me { top: auto; bottom: 10vmin; }
.pad { position: absolute; bottom: 27vmin; display: none; gap: 1.2vmin; flex-wrap: wrap; justify-content: center; max-width: 92vw; }
#app.mycall .pad { display: flex; }
.pad button { width: 9vmin; height: 9vmin; min-width: 48px; min-height: 48px; border-radius: 50%; border: .45vmin solid var(--ink); background: linear-gradient(#fff, #ffd6ea); box-shadow: 0 .5vmin 0 var(--ink); font-size: clamp(18px, 4.5vmin, 36px); color: #e0287a; }
.pad button.sel { background: linear-gradient(#ffe36e, #ffb51f); color: #fff; text-shadow: 0 2px 0 var(--ink); transform: scale(1.12); }

.call, .total, .banner { position: absolute; left: 50%; transform: translate(-50%, -50%); pointer-events: none; z-index: 3; white-space: nowrap; color: #fff; -webkit-text-stroke: .05em var(--ink); paint-order: stroke fill; text-shadow: 0 .07em 0 var(--ink); }
.call { top: 48%; opacity: 0; font-size: clamp(56px, 18vmin, 180px); }
.call.c0 { color: #ffe36e; } .call.c1 { color: #ffb51f; } .call.c2 { color: #ff3d8b; font-size: clamp(80px, 26vmin, 240px); }
.call.go { animation: shout .6s ease-out forwards; }
@keyframes shout { 0% { opacity: 0; transform: translate(-50%, -50%) scale(2.2) rotate(-8deg); } 30% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-4deg); } 100% { opacity: 0; transform: translate(-50%, -60%) scale(.9) rotate(-4deg); } }
.total { top: 47%; opacity: 0; font-size: clamp(30px, 9vmin, 80px); color: #ffe36e; }
.total.on { opacity: 1; }
.banner { top: 57%; opacity: 0; font-size: clamp(18px, 5vmin, 44px); padding: .2em .8em; }
.banner.good { color: #6dff9e; } .banner.bad { color: #ff5d7a; }
.banner.go { animation: stamp .35s cubic-bezier(.2, 1.6, .4, 1) forwards; }
@keyframes stamp { 0% { opacity: 0; transform: translate(-50%, -50%) scale(2); } 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@media (max-aspect-ratio: 4/5) { .seat { flex-basis: 32vw; } .hands { height: 15vw; } .myhand { width: 34vw; height: 34vw; } .pad { bottom: 36vw; } .bubble.me { bottom: 3vw; left: auto; right: 2vw; } }

.ranks { list-style: none; margin: 0 0 1vmin; padding: 0; display: flex; flex-wrap: wrap; gap: .4em 1em; justify-content: center; font-size: clamp(14px, 2.8vmin, 22px); }
.ranks li.last { color: #e0287a; }

#play { overflow: hidden; }
/* 폰 세로: 카메라 미리보기는 왼쪽 가운데 (내 손·숫자 말풍선을 가리지 않게), 세로 영상이라 3:4 */
@media (max-aspect-ratio: 4/5) {
  #app[data-scene=play] .mebox { left: 2vw; right: auto; top: 28%; bottom: auto; width: 22vw; height: 29vw; }
  .left { top: 28%; transform: translateY(-120%); }
  .bubble.me { bottom: 30vw; right: 3vw; font-size: 10vw; }
}
@media (max-aspect-ratio: 4/5) and (max-height: 700px) { .card .faces img { width: 21%; } }

/* 손맛 */
#play.shake { animation: shake .35s; }
@keyframes shake { 20% { transform: translateX(-1.5vmin); } 40% { transform: translateX(1.5vmin); } 60% { transform: translateX(-1vmin); } 80% { transform: translateX(.6vmin); } }
.conf { position: absolute; top: -12vmin; width: 9vmin; z-index: 4; pointer-events: none; animation: fall 1.8s ease-in forwards; }
@keyframes fall { to { transform: translateY(120vh) rotate(var(--r)); } }
.taphint { position: absolute; bottom: calc(100% + 1vmin); padding: .2em .8em; border-radius: 999px; background: #ff3d8b; color: #fff; border: .35vmin solid var(--ink); font-size: clamp(14px, 3vmin, 22px); animation: bob 1s infinite; pointer-events: none; }
.taphint[hidden] { display: none; }
#app.mycall .taphint { display: none; }
/* 폰 세로 카메라 준비: 단계는 한 줄씩, 미리보기는 크게 가운데 아래 (영상 비율 그대로) — 두 손이 다 들어오는지 보이게 */
@media (max-aspect-ratio: 4/5) {
  #camset { justify-content: flex-start; padding-top: 7vh; }
  .steps { grid-template-columns: 1fr; }
  #app[data-scene=camset] .mebox { width: 34vw; height: auto; right: auto; left: 50%; bottom: 1.5vh; transform: translateX(-50%); }
}
