@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: #0d1030; 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: #141a44 url('img/bg-dojo.webp') center/cover no-repeat; }
@media (max-aspect-ratio: 4/5) { .bg { background-image: url('img/bg-dojo-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; min-height: 44px; 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; }

/* ---------- 첫 화면 ---------- */
.master-big { height: 34vh; object-fit: contain; filter: drop-shadow(0 1vmin 0 rgba(0,0,0,.35)); margin-top: -2vh; }
.ttl, .hint { text-shadow: 0 .08em 0 var(--ink), .05em 0 0 var(--ink), -.05em 0 0 var(--ink), 0 -.05em 0 var(--ink); }

/* ---------- 기술 카드 ---------- */
.jlist { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1vmin; width: 100%; }
.jt { display: flex; flex-direction: column; align-items: center; padding: .4em .5em .3em; border: .35vmin solid var(--ink); border-radius: 1.6vmin; background: #fff; box-shadow: 0 .4vmin 0 var(--ink); line-height: 1.1; }
.jt b { font-weight: normal; font-size: clamp(13px, 2.4vmin, 20px); color: var(--ink) !important; }
.jt span { display: flex; align-items: center; gap: .1em; }
.jt span i { font-style: normal; opacity: .4; }
.jt img { width: clamp(26px, 5.4vmin, 50px); aspect-ratio: 1; object-fit: contain; opacity: .55; transition: transform .15s, opacity .15s; }
.jt img.lit { opacity: 1; transform: scale(1.18); filter: drop-shadow(0 0 .6vmin #ffe36e); }
.jt small { font-size: clamp(10px, 1.7vmin, 14px); opacity: .7; }
.j-fire { background: linear-gradient(#fff, #ffd9c2); } .j-water { background: linear-gradient(#fff, #c9ecff); }
.j-thunder { background: linear-gradient(#fff, #fff1a8); } .j-wind { background: linear-gradient(#fff, #d2f7c9); } .j-clone { background: linear-gradient(#fff, #e6dcf2); }

/* ---------- 연습 ---------- */
.teach { display: flex; align-items: center; gap: 2vmin; width: 100%; }
.t-master { width: 30%; max-width: 220px; aspect-ratio: 1; object-fit: contain; }
.t-right { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1vmin; }
.say { margin: 0; padding: .4em .8em; background: #fff; border: .3vmin solid var(--ink); border-radius: 1.6vmin; font-size: clamp(14px, 2.8vmin, 22px); text-align: center; }
.t-sign { width: clamp(80px, 18vmin, 160px); aspect-ratio: 1; object-fit: contain; animation: bob 1.2s infinite; }
.steps { list-style: none; padding: 0 !important; margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: .6vmin 1.2vmin; font-size: clamp(11px, 2vmin, 16px) !important; line-height: 1.1 !important; }
.steps li { display: flex; flex-direction: column; align-items: center; opacity: .35; }
.steps li img { width: clamp(26px, 5vmin, 44px); aspect-ratio: 1; }
.steps li.now { opacity: 1; color: #e0287a; }
.steps li.done { opacity: 1; }
.steps li.done::after { content: '✔'; color: #2fc46b; }
.msg { margin: 0; text-align: center; font-size: clamp(14px, 2.8vmin, 20px); min-height: 1.4em; }
.panel.wide { width: min(94vw, 820px); }

/* ---------- 내 카메라 ---------- */
.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: 5; }
.mebox video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.mesign { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; font-weight: normal; color: #fff; background: rgba(0,0,0,.45); font-size: clamp(12px, 2.4vmin, 18px); }
#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: 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); max-width: 92vw; }
@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; }

/* ---------- 수련장 고르기 ---------- */
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2vmin; width: min(96vw, 1100px); }
.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, #e3e9ff); box-shadow: 0 .8vmin 0 var(--ink); color: var(--ink); transition: transform .1s; }
.pickcard:hover { transform: translateY(-.6vmin) rotate(-1deg); }
.pickcard b { font-weight: normal; font-size: clamp(16px, 3.6vmin, 30px); }
.pickcard small { font-size: clamp(11px, 2vmin, 16px); opacity: .75; }
.pickcard .tag { position: absolute; top: 1vmin; left: 1vmin; padding: .1em .6em; border-radius: 999px; background: #3aa8ff; color: #fff; font-style: normal; font-size: clamp(11px, 2vmin, 16px); border: 2px solid var(--ink); }
.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); }
.pickcard .faces { display: flex; justify-content: center; width: 100%; padding-top: 2.5vmin; }
.pickcard .faces img { flex: 0 1 34%; min-width: 0; margin: 0 -3%; aspect-ratio: 1; object-fit: contain; }
.pickcard.t-boss { background: linear-gradient(#fff6c2, #ffcf4a); }
.pickcard.t-boss .tag { background: #ff3d8b; }
@media (max-aspect-ratio: 4/5) { .cards { grid-template-columns: 1fr; width: min(92vw, 420px); } .pickcard .faces img { width: 24%; } }

/* ---------- 판 ---------- */
#play { padding: 0; justify-content: flex-start; }
.field, .fxlayer { position: absolute; inset: 0; pointer-events: none; }
.yokai { position: absolute; width: 22vmin; aspect-ratio: 1; object-fit: contain; transform-origin: 50% 100%; will-change: transform; filter: drop-shadow(0 1vmin .6vmin rgba(0,0,0,.45)); }
.yokai.pop { animation: poof .6s ease-out forwards; }
@keyframes poof { 0% { filter: brightness(2.2); } 100% { opacity: 0; } }
.yokai.shake { animation: shake .3s; }
@keyframes shake { 25% { margin-left: -1.5vmin; filter: brightness(1.8); } 75% { margin-left: 1.5vmin; } }
.hpbar { position: absolute; width: 14vmin; height: 1.4vmin; transform: translateX(-50%); border: .3vmin solid var(--ink); border-radius: 999px; background: linear-gradient(90deg, #ff3d8b calc(var(--hp) * 100%), rgba(255,255,255,.5) 0); }
.fx { position: absolute; left: 50%; top: 80%; width: min(80vw, 110vmin); transform: translate(-50%, -50%) scale(.3); opacity: 0; animation: fly .9s ease-out forwards; filter: drop-shadow(0 0 2vmin rgba(255,255,200,.6)); }
@keyframes fly { 15% { opacity: 1; } 60% { opacity: 1; transform: translate(calc(-50% + var(--tx, 0px)), calc(-50% + var(--ty, -30vh))) scale(1); } 100% { opacity: 0; transform: translate(calc(-50% + var(--tx, 0px)), calc(-50% + var(--ty, -30vh))) scale(1.2); } }
.fx-clone { animation-duration: .9s; top: 45%; }
#app.ouch #play { animation: ouch .35s; }
@keyframes ouch { 30% { transform: translateX(-1.5vmin); background: rgba(255,0,60,.25); } 60% { transform: translateX(1.5vmin); } }

.hud { position: absolute; top: 1.5vmin; left: 2vmin; right: 2vmin; display: flex; align-items: center; gap: 2vmin; z-index: 3; }
.hearts i { font-style: normal; font-size: clamp(22px, 5vmin, 44px); color: #ff3d8b; -webkit-text-stroke: .06em var(--ink); paint-order: stroke fill; }
.hearts i.off { color: #555a; }
.score { padding: .1em .8em; background: var(--cream); border: .35vmin solid var(--ink); border-radius: 999px; font-size: clamp(18px, 4vmin, 34px); }
.left { margin-left: auto; padding: .15em .8em; background: rgba(13,16,48,.7); color: #fff; border-radius: 999px; font-size: clamp(13px, 2.6vmin, 22px); }
.rival { position: absolute; top: 9vmin; left: 2vmin; z-index: 3; padding: .15em .8em; background: #3aa8ff; color: #fff; border: .3vmin solid var(--ink); border-radius: 999px; font-size: clamp(13px, 2.6vmin, 22px); }
.rival b { font-weight: normal; }
.coach { position: absolute; left: 1vmin; bottom: 25vmin; display: flex; align-items: flex-end; z-index: 3; pointer-events: none; }
.coach img { width: 17vmin; aspect-ratio: 1; object-fit: contain; }
.coach .say { max-width: 30vmin; margin-bottom: 8vmin; margin-left: -1vmin; font-size: clamp(12px, 2.3vmin, 18px); opacity: 0; }
.coach .say.show { animation: say 3s forwards; }
@keyframes say { 0%, 85% { opacity: 1; } 100% { opacity: 0; } }

.banner { position: absolute; left: 50%; top: 22%; transform: translate(-50%, -50%); pointer-events: none; z-index: 200; text-align: center; max-width: 92vw; width: max-content; opacity: 0; color: #fff; -webkit-text-stroke: .05em var(--ink); paint-order: stroke fill; text-shadow: 0 .07em 0 var(--ink); font-size: clamp(26px, 7vmin, 64px); }
.banner.good { color: #6dff9e; } .banner.bad { color: #ff5d7a; }
.banner.cast-fire { color: #ff9a3d; } .banner.cast-water { color: #6ad0ff; } .banner.cast-thunder { color: #ffe36e; } .banner.cast-wind { color: #7dff8a; } .banner.cast-clone { color: #d9c2ff; }
.banner.go { animation: stamp 1.4s cubic-bezier(.2, 1.6, .4, 1) forwards; }
@keyframes stamp { 0% { opacity: 0; transform: translate(-50%, -50%) scale(2); } 20%, 75% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1); } }

.dock { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; gap: .8vmin; padding: 1vmin 2vmin max(1.2vmin, env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(13,16,48,.75) 35%); z-index: 4; }
.buf { display: flex; align-items: center; justify-content: center; gap: .6vmin; height: clamp(34px, 7vmin, 64px); }
.buf img { height: 100%; aspect-ratio: 1; object-fit: contain; filter: drop-shadow(0 .4vmin 0 rgba(0,0,0,.4)); }
.buf em { color: #fff; opacity: .7; font-style: normal; font-size: clamp(13px, 2.6vmin, 20px); }
.buf .pop-in { animation: pin .25s; }
@keyframes pin { from { transform: scale(1.8); } }
.jutsu { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1vmin; width: min(100%, 980px); }
.pad { display: flex; justify-content: center; gap: .8vmin; }
.pad button { position: relative; width: clamp(44px, 8vmin, 70px); aspect-ratio: 1; padding: .3vmin; border: .3vmin solid var(--ink); border-radius: 1.4vmin; background: linear-gradient(#fff, #dfe6ff); box-shadow: 0 .4vmin 0 var(--ink); touch-action: manipulation; }
.pad button:active { transform: translateY(.3vmin); box-shadow: none; }
.pad img { width: 100%; height: 100%; object-fit: contain; }
.pad kbd { position: absolute; right: .2em; bottom: 0; font: inherit; font-size: clamp(9px, 1.6vmin, 13px); opacity: .6; }
#app.camon .pad { opacity: .75; }
@media (max-aspect-ratio: 4/5) {
  .jutsu { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .jt small { display: none; }
  .pad { flex-wrap: wrap; width: 100%; }
  .dock { padding-left: 4px; padding-right: 4px; }
  .pad { gap: 2px; }
  .pad button { width: clamp(42px, 11vw, 64px); }
  .yokai { width: 30vw; }
  .coach { bottom: auto; top: 10vh; left: auto; right: 0; flex-direction: row-reverse; }
  .coach img { width: 18vw; }
  .coach .say { max-width: 46vw; margin-left: 0; margin-right: -1vw; }
  #app[data-scene=play] .mebox { left: 2vmin; right: auto; top: 10vh; width: 26vw; height: 19.5vw; }
  .rival { top: 6.5vh; }
  .teach { flex-direction: column; }
  .t-master { width: 34%; }
}

.combo { padding: .1em .7em; border-radius: 999px; color: #fff; background: #ff3d8b; border: .3vmin solid var(--ink); font-size: clamp(14px, 3vmin, 26px); }
.combo:empty { display: none; }
.combo.bump { animation: bump .35s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes bump { from { transform: scale(1.7) rotate(-8deg); } }
.jt.hint { border-color: #ffcf4a; box-shadow: 0 0 0 .4vmin #ffcf4a, 0 0 2.4vmin #ffcf4a; animation: hintbob 1s ease-in-out infinite; }
@keyframes hintbob { 50% { transform: translateY(-.6vmin); } }
#play::after { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0; z-index: 150; background: var(--flash, #fff); }
#play.boom { animation: boom .3s; }
#play.boom::after { animation: flash .3s; }
#play[data-boom=fire] { --flash: #ff9a3d; } #play[data-boom=water] { --flash: #6ad0ff; } #play[data-boom=thunder] { --flash: #ffe36e; } #play[data-boom=wind] { --flash: #7dff8a; } #play[data-boom=clone] { --flash: #d9c2ff; }
@keyframes boom { 25% { transform: translate(-.8vmin, .6vmin); } 50% { transform: translate(.8vmin, -.4vmin); } 75% { transform: translate(-.4vmin, .3vmin); } }
@keyframes flash { 0% { opacity: .35; } 100% { opacity: 0; } }

/* 가로로 든 폰 (높이가 낮다): 손 단추를 오른쪽 4×2 로, 기술 카드는 납작하게 → 요괴 길이 덜 가려진다 */
@media (orientation: landscape) and (max-height: 500px) {
  .dock { flex-direction: row; align-items: flex-end; gap: 1.2vw; padding: 0 2vw max(6px, env(safe-area-inset-bottom)); }
  .buf { position: absolute; left: 0; right: 0; bottom: calc(100% + 4px); height: 34px; }
  .jutsu { flex: 1; gap: 6px; }
  .jt { padding: 2px 4px; }
  .jt b { font-size: 13px; }
  .jt img { width: 22px; }
  .jt small { display: none; }
  .pad { display: grid; grid-template-columns: repeat(4, 44px); gap: 4px; }
  .pad button { width: 44px; }
  .coach { bottom: auto; top: 14vh; }
  .coach img { width: 15vh; }
  .coach .say { margin-bottom: 4vh; max-width: 34vw; }
}
