@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-stage.webp') center/cover no-repeat; }
@media (max-aspect-ratio: 4/5) { .bg { background-image: url('img/bg-stage-tall.webp'); } }
section { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 2.2vmin;
  padding: max(3vmin, env(safe-area-inset-top)) max(3vmin, env(safe-area-inset-right)) max(3vmin, env(safe-area-inset-bottom)) max(3vmin, env(safe-area-inset-left)); }
#app[data-scene=title] #title, #app[data-scene=howto] #howto, #app[data-scene=pick] #pick,
#app[data-scene=camset] #camset, #app[data-scene=match] #match, #app[data-scene=result] #result { display: flex; }

/* ---------- 광택 버튼 ---------- */
.gbtn { --c1: #ffe36e; --c2: #ffb51f; --edge: #8a4a00;
  position: relative; min-width: 14em; min-height: 48px; 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; 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(12.5px, 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(12px, 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; }
.medir { position: absolute; inset: 0; display: grid; place-items: center; font-size: 8vmin; color: #ffcf4a; text-shadow: 0 0 6px #000, 0 3px 0 var(--ink); }
#app[data-scene=camset] .mebox { display: block; right: 3vmin; bottom: 3vmin; width: 28vmin; height: 21vmin; }
#app[data-scene=match] .mebox { display: block; right: max(2vmin, env(safe-area-inset-right)); bottom: max(2vmin, env(safe-area-inset-bottom)); width: 24vmin; height: 18vmin; }
#app:not(.camon) .mebox, #app.nocam .mebox { display: none !important; }

/* ---------- 대결 ---------- */
.hud { position: absolute; top: max(2vmin, env(safe-area-inset-top)); left: max(2vmin, env(safe-area-inset-left)); right: max(2vmin, env(safe-area-inset-right)); display: flex; justify-content: space-between; align-items: flex-start; gap: 2vmin; z-index: 2; }
.sc { display: flex; flex-direction: column; align-items: center; padding: .4em 1em; background: var(--cream); border: .4vmin solid var(--ink); border-radius: 2vmin; box-shadow: 0 .5vmin 0 var(--ink); font-size: clamp(18px, 4.5vmin, 38px); color: #ffb51f; line-height: 1; }
.sc small { font-size: max(12px, .45em); color: var(--ink); margin-bottom: .2em; }
.role { align-self: center; padding: .3em 1em; border-radius: 999px; border: .4vmin solid var(--ink); background: #fff; font-size: clamp(14px, 3.4vmin, 28px); text-align: center; }
.role.att { background: #ff8fc0; color: #fff; text-shadow: 0 2px 0 var(--ink); }
.role.def { background: #8fe0ff; color: #fff; text-shadow: 0 2px 0 var(--ink); }
.role:empty { visibility: hidden; }
.stage { position: absolute; left: 0; right: 0; bottom: 0; height: 78%; display: flex; justify-content: center; align-items: flex-end; }
.op { height: 100%; max-width: 100%; object-fit: contain; filter: drop-shadow(0 1vmin 0 rgba(0,0,0,.3)); transform-origin: 50% 100%; }
.op.flip { transform: scaleX(-1); }
.op.pop { animation: pop .25s ease-out; }
.op.flip.pop { animation: popf .25s ease-out; }
@keyframes pop { 0% { transform: scale(.92, 1.06); } 100% { transform: none; } }
@keyframes popf { 0% { transform: scaleX(-1) scale(.92, 1.06); } 100% { transform: scaleX(-1); } }

.call, .verdict { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); pointer-events: none; z-index: 3; white-space: nowrap; opacity: 0;
  font-size: clamp(60px, 20vmin, 200px); color: #fff; -webkit-text-stroke: .05em var(--ink); paint-order: stroke fill; text-shadow: 0 .07em 0 var(--ink); }
.call.c0 { color: #ffe36e; } .call.c1 { color: #ffb51f; } .call.c2 { color: #ff3d8b; font-size: clamp(80px, 28vmin, 260px); }
.call.go { animation: shout .5s 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); } }
.verdict { font-size: clamp(44px, 13vmin, 130px); top: 30%; }
.verdict.good { color: #6dff9e; } .verdict.bad { color: #ff5d7a; } .verdict.meh { color: #c9c2ff; }
.verdict.go { animation: stamp .35s cubic-bezier(.2, 1.6, .4, 1) forwards; }
@keyframes stamp { 0% { opacity: 0; transform: translate(-50%, -50%) scale(2.5); } 100% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-3deg); } }

.pads { position: absolute; left: max(2vmin, env(safe-area-inset-left)); bottom: max(2vmin, env(safe-area-inset-bottom)); display: none; gap: 2vmin; z-index: 2; }
#app.nocam .pads { display: flex; }
@media (pointer: coarse) { #app.nocam .pads { left: 0; right: 0; justify-content: space-between; padding: 0 max(3vmin, env(safe-area-inset-right)) 0 max(3vmin, env(safe-area-inset-left)); } }
.pads button { width: 16vmin; height: 16vmin; border-radius: 50%; border: .5vmin solid var(--ink); background: linear-gradient(#fff, #ffd6ea); box-shadow: 0 .6vmin 0 var(--ink); font-size: 7vmin; color: #e0287a; touch-action: none; }
/* 세 번째 참 ~ 받는 시간 동안 버튼이 반짝: 지금 누르면 돼요 */
.pads.open button { background: linear-gradient(#fff6c2, #ffcf4a); animation: padglow .2s ease-in-out infinite alternate; }
@keyframes padglow { to { transform: scale(1.08); box-shadow: 0 0 0 1.4vmin rgba(255,207,74,.45), 0 .6vmin 0 var(--ink); } }
.pads button:active { transform: translateY(.4vmin); box-shadow: 0 .2vmin 0 var(--ink); }

/* ---------- 결과 ---------- */
.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 .prog { margin: -.6vmin 0 .4vmin; font-size: clamp(13px, 2.4vmin, 19px); color: #8a5a8a; }
.result-box p { margin: 0 0 1vmin; font-size: clamp(15px, 3vmin, 24px); }
