@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-party.webp') center/cover no-repeat; }
@media (max-aspect-ratio: 4/5) { .bg { background-image: url('img/bg-party-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=lobby] #lobby,
#app[data-scene=game] #game { 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; }

.gbtn:disabled { filter: grayscale(.7); opacity: .7; cursor: default; }
@keyframes bob { 50% { transform: translateY(-1.2vmin) rotate(-1deg); } }

/* ---------- 공통 ---------- */
section { overflow-y: auto; justify-content: flex-start; padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); }
.logo { width: min(86vw, 520px); max-height: 26vh; object-fit: contain; filter: drop-shadow(0 6px 0 rgba(0,0,0,.25)); animation: bob 2.4s ease-in-out infinite; flex: none; }
.panel { width: 100%; max-width: 520px; flex: none; background: var(--cream); border: 4px solid var(--ink); border-radius: 22px; box-shadow: 0 7px 0 var(--ink); padding: 16px 18px 18px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.panel h2 { margin: 0; font-weight: normal; font-size: 30px; }
.panel h3 { align-self: flex-start; margin: 6px 0 0; font-weight: normal; font-size: 19px; }
.panel h3 i { font-style: normal; color: #e0287a; }
.panel ol { margin: 0; padding-left: 1.3em; font-size: 16px; line-height: 1.55; align-self: stretch; }
.panel b, .sub b { color: #e0287a; font-weight: normal; }
.sub { margin: 0; text-align: center; font-size: 16px; }
.lbl { align-self: flex-start; margin: 0; font-size: 16px; opacity: .8; }
.msg { margin: 0; min-height: 1.3em; text-align: center; font-size: 15px; color: #a3104d; }
.gbtn { min-width: 0; width: 100%; font-size: 24px; }
.gbtn.small { width: auto; font-size: 18px; }
.btns .gbtn { flex: 1 1 auto; }

/* ---------- 첫 화면 ---------- */
/* 가운데 두되 화면보다 길면 위가 잘리지 않고 스크롤되게 (justify-content: center 는 위를 잘라 먹음) */
#title, #lobby { justify-content: flex-start; }
#title > :first-child, #lobby > :first-child { margin-top: auto; }
#title > :last-child, #lobby > :last-child { margin-bottom: auto; }
#title { gap: 12px; }
.inp { width: 100%; font: inherit; font-size: 22px; padding: 10px 14px; border: 3px solid var(--ink); border-radius: 14px; background: #fff; color: var(--ink); outline: none; }
.inp:focus { box-shadow: 0 0 0 4px #ffcf4a; }
.inp.code { text-align: center; letter-spacing: .3em; text-transform: uppercase; flex: 1 1 130px; min-width: 0; }
.inp.code::placeholder { letter-spacing: 0; }
.joinrow .gbtn { flex: 1 0 auto; padding-left: 1em; padding-right: 1em; }
.avatars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px 10px; width: 100%; max-width: 300px; }
.avbtn { padding: 0; border: 3px solid transparent; border-radius: 50%; background: #fff3dc; aspect-ratio: 1; overflow: hidden; transition: transform .1s; }
.avbtn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avbtn.on { border-color: #ff3d8b; transform: scale(1.12); box-shadow: 0 3px 0 var(--ink); }
.or { width: 100%; display: flex; align-items: center; gap: 8px; font-size: 14px; opacity: .7; }
.or::before, .or::after { content: ''; flex: 1; height: 2px; background: var(--ink); opacity: .3; }
.joinrow { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; align-items: center; }

/* ---------- 방 ---------- */
.codebox { display: flex; flex-direction: column; align-items: center; border: 4px dashed var(--ink); border-radius: 18px; background: #fff; padding: 4px 26px 6px; color: var(--ink); }
.codebox b { font-weight: normal; font-size: 48px; letter-spacing: .25em; margin-right: -.25em; color: #3aa8ff; -webkit-text-stroke: 1.5px var(--ink); }
.codebox small { font-size: 12px; opacity: .6; }
.members { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; width: 100%; }
.members li { position: relative; display: flex; flex-direction: column; align-items: center; animation: pop .3s cubic-bezier(.2, 1.6, .4, 1); }
.members img { width: 64px; height: 64px; border-radius: 50%; background: #ffe9c7; border: 3px solid var(--ink); object-fit: cover; }
.members b { font-weight: normal; font-size: 14px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.members i { font-style: normal; font-size: 12px; color: #2fa35c; }
.members li.me img { border-color: #ff3d8b; }
.members li.host::before { content: ''; position: absolute; top: -10px; width: 30px; height: 24px; background: url('img/crown.webp') center/contain no-repeat; z-index: 1; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.chip { font: inherit; font-size: 16px; min-height: 44px; padding: 6px 14px; border: 3px solid var(--ink); border-radius: 999px; background: #fff; color: var(--ink); box-shadow: 0 3px 0 var(--ink); }
.chip.big { font-size: 18px; padding: 8px 8px; flex: 1; word-break: keep-all; line-height: 1.15; }
.chip.on { background: linear-gradient(#ffe36e, #ffb51f); }
.chip:disabled { opacity: .55; box-shadow: none; cursor: default; }
.chip.on:disabled { opacity: 1; }
.chip:not(:disabled):active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.chip.ok { background: linear-gradient(#9effc0, #2fc46b); color: #fff; text-shadow: 0 1px 0 var(--ink); font-size: 15px; padding: 4px 10px; width: 100%; }

/* ---------- 게임 ---------- */
#game { gap: 10px; justify-content: flex-start; }
#game > * { width: 100%; max-width: 560px; }
/* 차례·시간과 아래 버튼은 길어져 스크롤돼도 늘 보이게 */
.ghead { display: flex; justify-content: space-between; align-items: center; flex: none; position: sticky; top: 0; z-index: 3; }
.tag { padding: 4px 12px; border-radius: 999px; background: rgba(58,20,48,.75); color: #fff; font-size: 15px; }
.timer { min-width: 54px; text-align: center; font-weight: normal; font-size: 26px; padding: 0 10px; border-radius: 999px; background: var(--cream); border: 3px solid var(--ink); color: var(--ink); }
.timer:empty { visibility: hidden; }
.timer.hurry { background: #ff5d7a; color: #fff; animation: bob .5s infinite; }
.gbody { flex: 1 0 auto; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.gfoot { flex: none; padding-bottom: 4px; position: sticky; bottom: 0; z-index: 3; }
.gfoot:empty { display: none; }
.center { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; margin: auto 0; }
.center.top { margin: 0; }
.center p, .speaker p, .fhtop p { margin: 0; color: #fff; font-size: 17px; text-shadow: 0 2px 0 var(--ink), 0 0 6px rgba(0,0,0,.5); }
.center p b, .speaker p b { color: #ffcf4a; font-weight: normal; }
.center .big { font-size: 26px; }
.ttl { margin: 0; font-weight: normal; font-size: 30px; color: #fff; text-align: center; text-shadow: 0 3px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 -2px 0 var(--ink); }
.hint2 { margin: 0; width: 100%; text-align: center; color: #fff; font-size: 15px; text-shadow: 0 1px 2px #000; }
.scene-img { width: min(56vw, 230px); filter: drop-shadow(0 5px 0 rgba(0,0,0,.3)); animation: pop .4s cubic-bezier(.2, 1.6, .4, 1); }
.scene-img.sm { width: min(34vw, 140px); }

/* 내 카드 */
.mycard { position: relative; padding: 0; border: 0; background: none; width: min(62vw, 260px); aspect-ratio: 3 / 4; color: var(--ink); filter: drop-shadow(0 6px 0 rgba(0,0,0,.3)); animation: pop .35s cubic-bezier(.2, 1.6, .4, 1); }
.mycard img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.mycard span { position: absolute; inset: 18% 10% 12%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; }
.mycard b { font-weight: normal; font-size: 40px; line-height: 1.1; word-break: keep-all; }
.mycard small { font-size: 15px; opacity: .85; }
.mycard.closed span { background: rgba(255,248,236,.92); border-radius: 16px; font-size: 22px; }
.mycard.liar span { inset: 58% 8% 6%; color: #fff; text-shadow: 0 2px 0 #000; }
.mycard.liar b { color: #ffcf4a; font-size: 32px; }
.mycard.wait { display: grid; place-items: center; background: var(--cream); border: 4px dashed var(--ink); border-radius: 20px; font-size: 20px; }
.peekrow .mycard { width: min(34vw, 130px); }
.peekrow .mycard b { font-size: 22px; } .peekrow .mycard small { font-size: 11px; }
.peekrow .mycard.closed span { font-size: 13px; }
.peekrow .mycard.liar b { font-size: 16px; }

/* 말하는 차례 */
.strip { list-style: none; margin: 0; padding: 4px 2px; display: flex; gap: 6px; overflow-x: auto; width: 100%; flex: none; }
.strip li { flex: none; display: flex; flex-direction: column; align-items: center; width: 54px; opacity: .55; transition: opacity .2s, transform .2s; }
.strip img { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--ink); background: #ffe9c7; object-fit: cover; }
.strip b { font-weight: normal; font-size: 12px; color: #fff; text-shadow: 0 1px 2px #000; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.strip li.now { opacity: 1; transform: scale(1.12); }
.strip li.now img { border-color: #ffcf4a; box-shadow: 0 0 0 3px #ff3d8b; }
.speaker { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.speaker img { width: min(46vw, 190px); border-radius: 50%; border: 5px solid var(--ink); background: radial-gradient(#fff6c2, #ffcf4a); animation: pop .35s cubic-bezier(.2, 1.6, .4, 1); }
.speaker.mine img { box-shadow: 0 0 0 6px #ff3d8b, 0 0 30px #ff3d8b; animation: pop .35s, bob 1.2s infinite .35s; }
.lap { color: #fff; opacity: .8; }

/* 투표 */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; }
.grid.words { grid-template-columns: repeat(2, 1fr); }
.pcard { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border: 3px solid var(--ink); border-radius: 16px; background: var(--cream); color: var(--ink); box-shadow: 0 4px 0 var(--ink); font: inherit; }
.pcard img { width: 70%; aspect-ratio: 1; border-radius: 50%; object-fit: cover; }
.pcard b { font-weight: normal; font-size: 16px; }
.pcard i { position: absolute; top: 4px; right: 4px; font-style: normal; font-size: 11px; background: #2fc46b; color: #fff; padding: 1px 6px; border-radius: 999px; }
.pcard.on { background: linear-gradient(#ff8fc0, #ff3d8b); color: #fff; transform: translateY(-3px) rotate(-2deg); }
.pcard.on::after { content: ''; position: absolute; left: -8px; top: -14px; width: 38px; height: 38px; background: url('img/vote.webp') center/contain no-repeat; }

/* 결과 */
.reveal { font-size: 20px !important; }
.ranks { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 6px; }
.ranks li { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 3px solid var(--ink); border-radius: 14px; background: var(--cream); font-size: 17px; }
.ranks li.me { background: #fff1b8; }
.ranks img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.ranks b { font-weight: normal; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranks span { color: #a3104d; font-size: 15px; }
.ranks em { font-style: normal; color: #e0287a; min-width: 3.2em; }
.ranks i { font-style: normal; } .ranks u { text-decoration: none; color: #2fa35c; }

/* 이마 단어 */
.fhtop { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; }
.grid.fh { grid-template-columns: repeat(2, 1fr); }
.fhcard { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px 10px; border: 3px solid var(--ink); border-radius: 18px; background: var(--cream); box-shadow: 0 4px 0 var(--ink); transition: transform .2s; }
.fhcard .av { order: 2; width: 34px; height: 34px; border-radius: 50%; object-fit: cover; border: 2px solid var(--ink); background: #ffe9c7; margin-top: 2px; }
.fhcard .nm { font-weight: normal; font-size: 14px; order: 3; }
.fhword { position: relative; order: 1; height: min(21vh, 190px); aspect-ratio: 3 / 4; }
.fhword img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.fhword span { position: absolute; inset: 38% 12% 10%; display: grid; place-items: center; text-align: center; font-size: 24px; line-height: 1.1; word-break: keep-all; color: var(--ink); }
.grid.fh.many { grid-template-columns: repeat(3, 1fr); }
.grid.fh.many .fhword span { font-size: 17px; }
.fhcard.me .fhword span { font-size: 40px; color: #e0287a; }
.fhcard.now { transform: scale(1.04); box-shadow: 0 0 0 4px #ff3d8b, 0 4px 0 var(--ink); }
.fhcard.solved { background: linear-gradient(#fff6c2, #ffcf4a); }
.fhcard .chip { order: 4; margin-top: 4px; }
.rank { order: 4; font-style: normal; display: flex; align-items: center; gap: 4px; font-size: 16px; color: #a3104d; }
.rank img { width: 26px; }

.toast { position: absolute; left: 50%; bottom: 24px; transform: translate(-50%, 20px); max-width: 90vw; padding: 10px 18px; border-radius: 999px; background: rgba(58,20,48,.92); color: #fff; font-size: 16px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 9; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-aspect-ratio: 1/1) {
  #game > .gbody { max-width: 900px; }
  .grid.fh, .grid.fh.many { grid-template-columns: repeat(auto-fit, minmax(120px, 160px)); justify-content: center; }
  .grid.fh .fhword span { font-size: 19px; }
  .speaker img { width: min(30vh, 190px); }
}

/* 방: 방장 '시작!' 은 스크롤 안 해도 보이게 */
#lobby .panel > .btns { position: sticky; bottom: -18px; padding: 8px 0 18px; margin-bottom: -18px; background: var(--cream); width: 100%; z-index: 2; }
@media (max-height: 700px) { .members img { width: 52px; height: 52px; } .codebox b { font-size: 38px; } }
