@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 { -webkit-touch-callout: none; touch-action: manipulation; 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: #1a1030 url('img/bg-ring.webp') center/cover no-repeat; }
@media (max-aspect-ratio: 4/5) { .bg { background-image: url('img/bg-ring-tall.webp'); } }
section { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; 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; 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)); } .pickcard small { min-height: 0 !important; } }
.pickcard { 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; }
.pickcard:hover { transform: translateY(-.6vmin) rotate(-1deg); }
.pickcard img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.pickcard b { font-weight: normal; font-size: clamp(16px, 3.6vmin, 30px); }
.pickcard small { font-size: clamp(11px, 2vmin, 16px); opacity: .75; min-height: 2.6em; }
.pickcard .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); }
.pickcard.c-muscle { background: linear-gradient(#fff6c2, #ffcf4a); }
.pickcard.c-muscle .tag { background: #ff3d8b; }
.pickcard .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: flex; flex-direction: column; gap: .4vmin; }
.steps:empty { display: none; }
.steps li { opacity: .35; }
.steps li.now { opacity: 1; color: #e0287a; }
.steps li.done { opacity: 1; }
.steps li.done::before { content: '✔ '; color: #2fc46b; }
.live { margin: 0; font-size: clamp(14px, 3vmin, 22px); color: #3aa8ff; min-height: 1.3em; }

/* ---------- 내 카메라 ---------- */
.mebox { position: absolute; display: none; overflow: hidden; border: .5vmin solid var(--ink); border-radius: 2vmin; background: #000; box-shadow: 0 .6vmin 0 var(--ink); z-index: 6; }
.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; top: 12vmin; width: 20vmin; height: 15vmin; }
#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; max-width: 94vw; animation: stamp2 .4s cubic-bezier(.2, 1.5, .4, 1); }
@keyframes stamp2 { from { transform: scale(.6); opacity: 0; } }
.result-box img { height: 36vh; }
.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); text-align: center; }
.gbtn[hidden], #nextBtn[hidden] { display: none; }

/* ---------- 시합 ---------- */
#play { padding: 0; justify-content: flex-start; }
.hud { position: absolute; top: 2vmin; left: 2vmin; right: 2vmin; display: flex; align-items: flex-start; gap: 2vmin; z-index: 5; }
.hp { flex: 1; display: flex; flex-direction: column; gap: .6vmin; }
.hp b { font-weight: normal; color: #fff; font-size: clamp(14px, 3vmin, 26px); text-shadow: 0 .08em 0 var(--ink), .05em 0 0 var(--ink), -.05em 0 0 var(--ink), 0 -.05em 0 var(--ink); }
.hp.foe { align-items: flex-end; }
.bar { width: 100%; height: clamp(14px, 3.4vmin, 30px); border: .4vmin solid var(--ink); border-radius: 999px; background: #3a1430; overflow: hidden; box-shadow: 0 .4vmin 0 var(--ink); }
.bar i { display: block; height: 100%; width: 100%; background: linear-gradient(#9dff7a, #2fc46b); border-radius: 999px; transition: width .25s; box-shadow: inset 0 .5vmin 0 rgba(255,255,255,.4); }
.hp.foe .bar { transform: scaleX(-1); }
.bar i.low { background: linear-gradient(#ff9a7a, #ff3d5a); }
.hp em { font-style: normal; font-size: clamp(11px, 2.2vmin, 18px); padding: .05em .7em; border-radius: 999px; background: #3aa8ff; color: #fff; border: 2px solid var(--ink); visibility: hidden; }
.hp em.on { visibility: visible; }
.hp em.o { background: #ffcf4a; color: var(--ink); }
.time { flex: 0 0 auto; padding: .1em .7em; background: var(--cream); border: .4vmin solid var(--ink); border-radius: 2vmin; font-size: clamp(20px, 5vmin, 44px); box-shadow: 0 .5vmin 0 var(--ink); }

.arena { position: absolute; left: 50%; bottom: 14vh; width: min(78vh, 92vw); aspect-ratio: 1; transform: translateX(-50%); }
.foe { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 1.4vmin 0 rgba(0,0,0,.35)); transform-origin: 50% 90%; animation: sway 1.6s ease-in-out infinite; }
@keyframes sway { 50% { transform: translateY(1.2%) rotate(-.8deg); } }
.foe.p-windup { animation: wind .5s ease-in-out infinite alternate; }
@keyframes wind { to { transform: translateX(-3%) rotate(3deg) scale(1.02); } }
.foe.p-punch { animation: lunge .3s ease-out; transform: scale(1.18); }
@keyframes lunge { from { transform: scale(1); } }
.foe.p-hit { animation: knock .35s ease-out; }
@keyframes knock { 30% { transform: translateX(5%) rotate(6deg); } }
.foe.p-open { animation: sway 1.2s ease-in-out infinite; filter: drop-shadow(0 1.4vmin 0 rgba(0,0,0,.35)) brightness(1.05); }
.foe.p-ko { animation: fall 1s ease-out forwards; }
@keyframes fall { to { transform: rotate(-10deg) translateY(6%); } }
.fx { position: absolute; left: 50%; top: 32%; width: 46%; transform: translate(-50%, -50%) scale(0); pointer-events: none; }
.fx.show { animation: pop .35s ease-out forwards; }
@keyframes pop { 0% { transform: translate(-50%, -50%) scale(.3); opacity: 1; } 60% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1.2); opacity: 0; } }
.warn { position: absolute; left: 50%; top: 4%; transform: translateX(-50%); width: 1.3em; height: 1.3em; display: grid; place-items: center; border-radius: 50%; background: #ff3d5a; color: #fff; border: .1em solid var(--ink); font-size: clamp(36px, 10vmin, 90px); line-height: 1; opacity: 0; box-shadow: 0 .08em 0 var(--ink); }
.warn.on { opacity: 1; animation: blink .25s steps(2) infinite; }
@keyframes blink { 50% { transform: translateX(-50%) scale(1.15); } }

.glove { position: absolute; bottom: -4vh; width: min(42vh, 40vw); pointer-events: none; z-index: 3; transition: transform .12s ease-out, opacity .1s; filter: drop-shadow(0 1vmin 0 rgba(0,0,0,.3)); }
.glove.l { left: 6vw; transform: rotate(8deg); }
.glove.r { right: 6vw; transform: rotate(-8deg); }
.glove.g { left: 50%; width: min(56vh, 60vw); bottom: -12vh; transform: translateX(-50%); opacity: 0; }
#app.guarding .glove.l, #app.guarding .glove.r { opacity: 0; }
#app.guarding .glove.g { opacity: 1; }
.glove.l.jab { transform: translate(28vw, -30vh) scale(.6); }
.glove.r.jab { transform: translate(-28vw, -30vh) scale(.6); }
.glove.l.hook { transform: translate(34vw, -36vh) rotate(-60deg) scale(.65); }
.glove.r.hook { transform: translate(-34vw, -36vh) rotate(60deg) scale(.65); }
.glove.l.upper { transform: translate(24vw, -48vh) rotate(-20deg) scale(.6); }
.glove.r.upper { transform: translate(-24vw, -48vh) rotate(20deg) scale(.6); }
.myfx { position: absolute; left: 50%; bottom: 8vh; width: min(50vh, 60vw); transform: translateX(-50%) scale(0); pointer-events: none; z-index: 4; }
.myfx.show { animation: pop2 .4s ease-out forwards; }
@keyframes pop2 { 0% { transform: translateX(-50%) scale(.4); opacity: 1; } 100% { transform: translateX(-50%) scale(1.15); opacity: 0; } }
.ouch { position: absolute; inset: 0; pointer-events: none; z-index: 4; box-shadow: inset 0 0 18vmin 6vmin rgba(255,30,60,.85); opacity: 0; }
.ouch.on { animation: ouch .45s ease-out; }
@keyframes ouch { 0% { opacity: 1; } 100% { opacity: 0; } }
#app.shake #play { animation: shake .3s; }
@keyframes shake { 20% { transform: translate(-1.5vmin, 1vmin); } 40% { transform: translate(1.5vmin, -1vmin); } 60% { transform: translate(-1vmin, 0); } }

.banner { position: absolute; left: 50%; top: 22%; transform: translate(-50%, -50%); pointer-events: none; z-index: 5; text-align: center; max-width: 92vw; width: max-content; padding: .15em .9em; border-radius: 999px; background: rgba(58,20,48,.55); opacity: 0; color: #fff; -webkit-text-stroke: .05em var(--ink); paint-order: stroke fill; text-shadow: 0 .07em 0 var(--ink); font-size: clamp(18px, 5vmin, 46px); }
.banner.good { color: #ffe36e; } .banner.bad { color: #ff7a8f; } .banner.blue { color: #8fe0ff; }
.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); } }
.ko { position: absolute; left: 50%; top: 45%; width: min(80vh, 80vw); transform: translate(-50%, -50%) scale(0); z-index: 7; pointer-events: none; }
.ko.on { animation: koin .5s cubic-bezier(.2, 1.6, .4, 1) forwards; }
@keyframes koin { to { transform: translate(-50%, -50%) scale(1) rotate(-6deg); } }

.pad { position: absolute; left: 0; right: 0; bottom: 2vmin; display: none; justify-content: center; gap: 2vmin; z-index: 6; padding: 0 2vmin; }
#app.nocam .pad { display: flex; }
.pad button { flex: 0 1 18vmin; min-height: 11vmin; border: .45vmin solid var(--ink); border-radius: 3vmin; font-size: clamp(16px, 4vmin, 30px); color: #fff; text-shadow: 0 .08em 0 var(--ink);
  background: linear-gradient(#ff8fc0, #ff3d8b); box-shadow: inset 0 -.8vmin 0 #a3104d, 0 .6vmin 0 var(--ink); touch-action: none; }
.pad button.pg { background: linear-gradient(#8fe0ff, #3aa8ff); box-shadow: inset 0 -.8vmin 0 #135e9e, 0 .6vmin 0 var(--ink); }
.pad button:active, .pad button.down { transform: translateY(.4vmin); box-shadow: inset 0 -.4vmin 0 rgba(0,0,0,.3), 0 .2vmin 0 var(--ink); }
#app.nocam .glove { bottom: 6vh; }

@media (max-aspect-ratio: 4/5) {
  .arena { bottom: 26vh; width: 96vw; }
  .glove { width: 44vw; } .glove.l { left: -2vw; } .glove.r { right: -2vw; } .glove.g { width: 80vw; }
  #app.nocam .glove { bottom: 10vh; }
  #app[data-scene=play] .mebox { top: auto; bottom: 26vh; width: 24vw; height: 18vw; }
  .pad button { min-height: 16vw; }
}

/* ---------- 힘·데미지 숫자·멈칫 ---------- */
.sta { width: 70%; height: clamp(7px, 1.6vmin, 14px); border: .3vmin solid var(--ink); border-radius: 999px; background: #3a1430; overflow: hidden; }
.sta i { display: block; height: 100%; width: 100%; background: linear-gradient(#fff3a0, #ffc21f); transition: width .15s; }
.sta i.low { background: #ff8a3d; animation: blink2 .4s steps(2) infinite; }
@keyframes blink2 { 50% { opacity: .4; } }
.dmg { position: absolute; top: 30%; font-style: normal; color: #fff; font-size: clamp(26px, 7vmin, 60px); -webkit-text-stroke: .06em var(--ink); paint-order: stroke fill; pointer-events: none; z-index: 4; animation: dmgup .8s ease-out forwards; }
.dmg.big { color: #ffe36e; font-size: clamp(36px, 10vmin, 84px); }
@keyframes dmgup { 0% { transform: translate(-50%, 0) scale(.5); opacity: 0; } 20% { transform: translate(-50%, -20%) scale(1.15); opacity: 1; } 100% { transform: translate(-50%, -140%) scale(1); opacity: 0; } }
#app.stop .arena { animation: zap .2s steps(2); }
@keyframes zap { 0% { filter: brightness(2.2) contrast(1.2); transform: translateX(-50%) scale(1.03); } }

/* ---------- 폰: 손가락 크기 버튼, 안전 영역 ---------- */
.pad { bottom: max(2vmin, env(safe-area-inset-bottom)); }
.pad button { min-height: max(56px, 11vmin); min-width: 64px; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.hud { top: max(2vmin, env(safe-area-inset-top)); }
.gbtn { min-height: 48px; }
/* 폰 세로: 연습 화면 내 모습은 크게 가운데 (몸이 다 들어오는지 보면서 물러나게), 영상 비율 그대로 */
@media (max-aspect-ratio: 4/5) {
  #app[data-scene=camset] .mebox { left: 50%; right: auto; bottom: max(3vh, env(safe-area-inset-bottom)); transform: translateX(-50%); width: 52vw; height: auto; max-height: 30vh; }
  #app[data-scene=play] .mebox { height: auto; }
  #app.camon #camset { justify-content: flex-start; padding-top: max(2vh, env(safe-area-inset-top)); }
  #app .mebox video { height: auto; max-height: 30vh; }
}
