/* 명화 탐정 — 화면 스타일 (가로형 우선) */
:root {
  --paper: #fbf5e9;
  --paper2: #f3e9d4;
  --ink: #2a2440;
  --ink2: #5a5270;
  --red: #e5262f;
  --red2: #ff5a5f;
  --gold: #d9a441;
  --gold2: #f4cf72;
  --navy: #26305c;
  --teal: #2fa39a;
  --pink: #ff8fb1;
  --sky: #7cc4f2;
  --card: #fffdf7;
  --line: #e6d9bd;
  --shadow: 0 .35em 0 rgba(42, 36, 64, .12), 0 .6em 1.4em rgba(42, 36, 64, .12);
  --u: min(1.9vh, 1.05vw);            /* 기준 단위: 가로형 휴대폰에서는 높이가 좁다 */
  --r: calc(var(--u) * 1.6);
  font-size: clamp(11px, calc(var(--u) * 1.15 + 4px), 22px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--paper); color: var(--ink); }
body {
  font-family: 'Gowun Dodum', system-ui, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none; touch-action: manipulation;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 143, 177, .14), transparent 32%),
    radial-gradient(circle at 88% 82%, rgba(124, 196, 242, .16), transparent 34%),
    repeating-linear-gradient(45deg, rgba(0,0,0,.012) 0 2px, transparent 2px 6px),
    var(--paper);
}
button, input, select { font: inherit; color: inherit; }
.h, h1, h2, h3, .btn, .tab, .pill, .num { font-family: 'Jua', 'Gowun Dodum', system-ui, sans-serif; font-weight: 400; }
h1, h2, h3 { margin: 0; }
img { -webkit-user-drag: none; user-drag: none; }

#app { position: fixed; inset: 0; }
.screen { position: absolute; inset: 0; display: none; padding: env(safe-area-inset-top) max(env(safe-area-inset-right), 1.2em) env(safe-area-inset-bottom) max(env(safe-area-inset-left), 1.2em); }
.screen.on { display: flex; animation: fadein .28s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.version { position: fixed; right: .7em; bottom: .35em; font-size: .72rem; color: rgba(42, 36, 64, .45); z-index: 60; pointer-events: none; font-family: 'Jua', sans-serif; letter-spacing: .04em; }

/* ---------- 버튼 ---------- */
.btn {
  --bg: var(--card); --fg: var(--ink); --edge: #d8c8a6;
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  border: 0; border-radius: 999px; padding: .62em 1.25em; background: var(--bg); color: var(--fg);
  box-shadow: 0 .28em 0 var(--edge), 0 .5em 1em rgba(42,36,64,.12); cursor: pointer; position: relative;
  transition: transform .08s ease, box-shadow .08s ease, filter .15s; font-size: 1.05rem; white-space: nowrap;
}
.btn:active, .btn.press { transform: translateY(.22em) scale(.98); box-shadow: 0 .06em 0 var(--edge), 0 .2em .5em rgba(42,36,64,.1); }
.btn.red { --bg: linear-gradient(#ff5a5f, #e5262f); --fg: #fff; --edge: #a8141b; }
.btn.gold { --bg: linear-gradient(#ffd97f, #e6ad3c); --fg: #4a3200; --edge: #b07a18; }
.btn.navy { --bg: linear-gradient(#3c4a86, #26305c); --fg: #fff; --edge: #141a38; }
.btn.teal { --bg: linear-gradient(#45c2b8, #23877f); --fg: #fff; --edge: #145752; }
.btn.ghost { --bg: rgba(255,255,255,.65); box-shadow: 0 .2em 0 rgba(0,0,0,.08); }
.btn.small { font-size: .88rem; padding: .45em .9em; }
.btn.icon { width: 2.6em; height: 2.6em; padding: 0; border-radius: 50%; font-size: 1rem; }
.btn[disabled] { filter: grayscale(.8) opacity(.55); pointer-events: none; }
.btn svg { width: 1.25em; height: 1.25em; flex: none; }

.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); border: 2px solid #fff; }
.pill { display: inline-flex; align-items: center; gap: .3em; padding: .15em .7em; border-radius: 999px; background: var(--paper2); font-size: .85rem; }
.muted { color: var(--ink2); }
.row { display: flex; align-items: center; gap: .6em; }
.col { display: flex; flex-direction: column; gap: .6em; }
.grow { flex: 1; min-width: 0; min-height: 0; }
.scroll { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; scrollbar-width: thin; }
.scroll::-webkit-scrollbar { width: 6px; } .scroll::-webkit-scrollbar-thumb { background: #d8c8a6; border-radius: 6px; }

/* 상단 바 (목록 화면 공통) */
.topbar { display: flex; align-items: center; gap: .7em; padding: .7em 0 .5em; }
.topbar h2 { font-size: 1.55rem; }
.topbar .sp { flex: 1; }

/* ---------- 로고 ---------- */
.logo { font-family: 'Jua', sans-serif; line-height: 1; color: var(--ink); text-shadow: 0 .06em 0 #fff, 0 .12em 0 rgba(0,0,0,.08); }
.logo b { color: var(--red); }
.logo small { display: block; font-size: .32em; color: var(--ink2); margin-top: .5em; letter-spacing: .02em; text-shadow: none; font-family: 'Gowun Dodum', sans-serif; }

/* ---------- 로그인 ---------- */
#auth { align-items: stretch; gap: 2em; padding-top: 1.2em; padding-bottom: 1.2em; }
#auth .hero { flex: 1.25; border-radius: calc(var(--r) * 1.4); overflow: hidden; position: relative; background: #e9dcc0 center/cover no-repeat; box-shadow: var(--shadow); }
#auth .hero::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 45%, rgba(20, 16, 40, .55)); }
#auth .hero .logo { position: absolute; left: 1em; bottom: .8em; z-index: 2; font-size: 3.4rem; color: #fff; text-shadow: 0 .06em .25em rgba(0,0,0,.35); }
#auth .hero .logo b { color: #ffd0d2; }
#auth .hero .logo small { color: #fff3e0; }
#auth .panel { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: .8em; max-width: 30em; }
.tabs { display: flex; gap: .4em; background: var(--paper2); padding: .3em; border-radius: 999px; }
.tab { flex: 1; text-align: center; padding: .5em .8em; border-radius: 999px; border: 0; background: transparent; cursor: pointer; font-size: 1rem; color: var(--ink2); transition: background .2s, color .2s; }
.tab.on { background: #fff; color: var(--ink); box-shadow: 0 .15em .4em rgba(0,0,0,.08); }
.field { display: flex; flex-direction: column; gap: .25em; }
.field label { font-size: .85rem; color: var(--ink2); padding-left: .4em; }
.field input, .field select { border: 2px solid var(--line); background: #fff; border-radius: .9em; padding: .65em .9em; font-size: 1.05rem; outline: none; user-select: text; -webkit-user-select: text; transition: border-color .15s, box-shadow .15s; }
.field input:focus, .field select:focus { border-color: var(--gold); box-shadow: 0 0 0 .25em rgba(217,164,65,.2); }
.msg { min-height: 1.3em; color: var(--red); font-size: .9rem; }
.check { display: flex; align-items: center; gap: .5em; font-size: .9rem; color: var(--ink2); cursor: pointer; }
.check input { width: 1.2em; height: 1.2em; accent-color: var(--red); }

/* 캐릭터 고르기 */
.charpick { display: grid; grid-template-columns: repeat(6, 1fr); gap: .5em; }
.charpick button { aspect-ratio: 1; border: 3px solid transparent; border-radius: 1em; background: #fff; padding: .15em; cursor: pointer; transition: transform .15s, border-color .15s; box-shadow: 0 .2em 0 rgba(0,0,0,.06); }
.charpick button img { width: 100%; height: 100%; object-fit: contain; display: block; }
.charpick button.on { border-color: var(--red); transform: translateY(-.15em) scale(1.04); }
.charpick button:active { transform: scale(.94); }

/* ---------- 아바타 (겹쳐 그리기) ---------- */
.avatar { position: relative; aspect-ratio: 1; flex: none; }
.avatar > * { position: absolute; inset: 0; width: 100%; height: 100%; }
.avatar .bg { border-radius: 16%; object-fit: cover; }
.avatar .bgfill { border-radius: 16%; background: radial-gradient(circle at 50% 40%, #fff, var(--paper2)); }
.avatar .ch { object-fit: contain; animation: squish 3.2s ease-in-out infinite; transform-origin: 50% 85%; }
.avatar .lay { object-fit: contain; pointer-events: none; }
.avatar.still .ch { animation: none; }
.avatar .fr { border-radius: 16%; pointer-events: none; }
@keyframes squish { 0%, 100% { transform: scale(1, 1); } 45% { transform: scale(1.035, .965); } 55% { transform: scale(.98, 1.025); } }
.avatar.bounce .ch { animation: bounce .6s cubic-bezier(.3,1.6,.5,1) 2; }
@keyframes bounce { 0% { transform: translateY(0) scale(1); } 40% { transform: translateY(-14%) scale(.95, 1.06); } 70% { transform: translateY(0) scale(1.08, .92); } 100% { transform: none; } }
.fr-wood { box-shadow: inset 0 0 0 .5em #a0703c, inset 0 0 0 .62em #6d4520, inset 0 0 0 .75em #c99a5f; }
.fr-gold { box-shadow: inset 0 0 0 .45em #f4cf72, inset 0 0 0 .62em #b07a18, inset 0 0 0 .78em #ffe7a6, 0 0 1.2em rgba(244,207,114,.6); }
.fr-hanji { box-shadow: inset 0 0 0 .5em #f6ecd6, inset 0 0 0 .62em #2a2440, inset 0 0 0 .75em #c3332c; }
.fr-rainbow { box-shadow: inset 0 0 0 .3em #ff8fb1, inset 0 0 0 .5em #ffd97f, inset 0 0 0 .7em #7ee0b5, inset 0 0 0 .9em #7cc4f2, inset 0 0 0 1.05em #b79cf2; }
.fr-starry { box-shadow: inset 0 0 0 .55em #26305c, inset 0 0 0 .7em #f4cf72, 0 0 1em rgba(124,196,242,.7); background: radial-gradient(circle at 12% 12%, #fff 0 .12em, transparent .15em), radial-gradient(circle at 88% 14%, #fff 0 .1em, transparent .13em), radial-gradient(circle at 85% 88%, #fff 0 .12em, transparent .15em), radial-gradient(circle at 14% 86%, #fff 0 .1em, transparent .13em); }

/* ---------- 홈 ---------- */
#home { align-items: stretch; gap: 1.6em; padding-top: 1em; padding-bottom: 1.4em; }
#home .bgart { position: absolute; inset: 0; background: center/cover no-repeat; opacity: .16; filter: saturate(1.1); pointer-events: none; }
#home .me { width: 34%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5em; position: relative; z-index: 1; }
#home .me .avatar { width: min(100%, 52vh); }
#home .me .name { font-family: 'Jua'; font-size: 1.6rem; display: flex; align-items: center; gap: .4em; }
.lvl { display: inline-grid; place-items: center; min-width: 2.2em; height: 2.2em; border-radius: 50%; background: linear-gradient(#ffd97f, #e6ad3c); color: #4a3200; font-family: 'Jua'; font-size: .8em; box-shadow: 0 .15em 0 #b07a18; }
.xpbar { width: 100%; max-width: 18em; height: .9em; border-radius: 999px; background: var(--paper2); overflow: hidden; box-shadow: inset 0 .1em .2em rgba(0,0,0,.08); }
.xpbar i { display: block; height: 100%; background: linear-gradient(90deg, #ffb3c6, var(--red2)); border-radius: 999px; transition: width .8s cubic-bezier(.2,.9,.3,1); }
#home .menu { flex: 1; display: grid; grid-template-columns: 1fr 1fr 1fr; grid-template-rows: 1.35fr 1fr; gap: 1em; position: relative; z-index: 1; padding-top: 2.6em; }
.tile { border: 0; border-radius: calc(var(--r) * 1.2); cursor: pointer; position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end; padding: 1em 1.1em; text-align: left; color: var(--ink); box-shadow: 0 .4em 0 var(--edge, #d8c8a6), 0 .8em 1.6em rgba(42,36,64,.14); transition: transform .1s, box-shadow .1s; background: var(--bg, #fff); }
.tile:active { transform: translateY(.3em); box-shadow: 0 .1em 0 var(--edge, #d8c8a6), 0 .3em .8em rgba(42,36,64,.12); }
.tile .h { font-size: 1.55rem; position: relative; z-index: 1; }
.tile .s { font-size: .85rem; opacity: .85; position: relative; z-index: 1; margin-top: .15em; }
.tile .art { position: absolute; right: -.4em; top: -.2em; width: 58%; height: 78%; object-fit: contain; opacity: .95; pointer-events: none; }
.tile.big { grid-row: span 1; }
.tile.solo { --bg: linear-gradient(135deg, #ff7a7f, #e5262f); --edge: #a8141b; color: #fff; grid-column: span 2; }
.tile.vs { --bg: linear-gradient(135deg, #5a6bb3, #26305c); --edge: #141a38; color: #fff; }
.tile.gal { --bg: linear-gradient(135deg, #ffe39c, #f0b54a); --edge: #b07a18; }
.tile.stp { --bg: linear-gradient(135deg, #b8eadf, #57c0b2); --edge: #2c8a7f; }
.tile.drs { --bg: linear-gradient(135deg, #ffd1e0, #ff94b4); --edge: #d0607f; }
.tile svg.deco { position: absolute; right: .6em; top: .6em; width: 3.2em; height: 3.2em; opacity: .9; }
.tile .badge { position: absolute; left: .8em; top: .7em; background: rgba(255,255,255,.9); color: var(--red); border-radius: 999px; padding: .05em .6em; font-family: 'Jua'; font-size: .85rem; }
#home .tools { position: absolute; top: .9em; right: max(env(safe-area-inset-right), 1.2em); display: flex; gap: .5em; z-index: 5; }

/* ---------- 고르기 화면 ---------- */
#pick { flex-direction: column; }
#pick .body { flex: 1; display: flex; gap: 1em; min-height: 0; padding-bottom: 1em; }
.eralist { width: 25%; display: flex; flex-direction: column; gap: .5em; padding: .2em .3em 1em .1em; }
.era { border: 0; background: #fff; border-radius: 1em; padding: .6em .8em; text-align: left; cursor: pointer; box-shadow: 0 .2em 0 var(--line); transition: transform .12s, background .15s; display: flex; align-items: center; gap: .6em; }
.era .t { font-family: 'Jua'; font-size: 1.05rem; flex: 1; }
.era .c { font-size: .8rem; color: var(--ink2); }
.era.on { background: var(--ink); color: #fff; box-shadow: 0 .2em 0 #000; }
.era.on .c { color: #d6d0ef; }
.era:active { transform: scale(.97); }
.era .dot { width: .7em; height: .7em; border-radius: 50%; flex: none; }
.grid { flex: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(11em, 1fr)); gap: 1em; padding: .3em .5em 1.5em .3em; align-content: start; }
.eradesc { grid-column: 1 / -1; font-size: .92rem; color: var(--ink2); padding: .2em .2em 0; }
.pz { border: 0; padding: 0; background: #fff; border-radius: 1em; overflow: hidden; cursor: pointer; text-align: left; box-shadow: var(--shadow); position: relative; transition: transform .12s; display: flex; flex-direction: column; }
.pz:active { transform: scale(.96); }
.pz .im { aspect-ratio: 4 / 3; background: #eee5d2 center/cover no-repeat; position: relative; }
.pz .tt { padding: .45em .7em .55em; }
.pz .tt b { display: block; font-family: 'Jua'; font-weight: 400; font-size: .98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pz .tt span { font-size: .78rem; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.lvdots { position: absolute; left: .5em; top: .5em; display: flex; gap: .2em; background: rgba(255,255,255,.88); padding: .25em .45em; border-radius: 999px; }
.lvdots i { width: .5em; height: .5em; border-radius: 50%; background: #e4d6b8; }
.lvdots i.on { background: var(--red); }
.pz .stampmini { position: absolute; right: .3em; bottom: .3em; width: 3.4em; height: 3.4em; transform: rotate(-12deg); filter: drop-shadow(0 .1em .1em rgba(0,0,0,.2)); }
.pz .stars { position: absolute; left: .5em; bottom: .4em; display: flex; gap: .1em; }
.pz .stars svg { width: 1.05em; height: 1.05em; }
.special { display: flex; gap: .8em; grid-column: 1 / -1; }
.special .btn { flex: 1; }

/* ---------- 게임판 ---------- */
#play { flex-direction: column; padding-left: max(env(safe-area-inset-left), .5em); padding-right: max(env(safe-area-inset-right), .5em); background: #1f1b31; color: #fff; }
#play .hud { display: flex; align-items: center; gap: .6em; height: calc(var(--u) * 6.4); min-height: 2.6em; padding: .25em 0; }
#play .hud .btn.icon { width: 2.4em; height: 2.4em; --bg: rgba(255,255,255,.12); --fg: #fff; --edge: rgba(0,0,0,.4); }
#play .hud .title { font-family: 'Jua'; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 22%; color: #f3ecff; }
.timer { flex: 1; height: .9em; background: rgba(255,255,255,.12); border-radius: 999px; overflow: hidden; position: relative; min-width: 4em; }
.timer i { position: absolute; inset: 0; transform-origin: left; background: linear-gradient(90deg, #7ee0b5, #ffd97f); border-radius: 999px; transition: background .4s; }
.timer.warn i { background: linear-gradient(90deg, #ffb36b, #ff5a5f); }
.timer.danger { animation: pulse .5s ease-in-out infinite alternate; }
.timer.danger i { background: #ff3b44; }
@keyframes pulse { to { box-shadow: 0 0 0 .3em rgba(255,59,68,.35); } }
.tleft { font-family: 'Jua'; font-size: 1.1rem; min-width: 2.2em; text-align: right; color: #ffe7a6; }
.dots { display: flex; gap: .3em; }
.dots i { width: 1.05em; height: 1.05em; border-radius: 50%; border: 2px solid rgba(255,255,255,.45); transition: background .3s, transform .3s, border-color .3s; }
.dots i.on { background: var(--red2); border-color: #fff; transform: scale(1.15); box-shadow: 0 0 .6em rgba(255,90,95,.8); }
.score { font-family: 'Jua'; font-size: 1.2rem; min-width: 3.2em; text-align: right; color: #fff; }
.hintbtn { position: relative; }
.hintbtn .n { position: absolute; right: -.25em; top: -.25em; background: var(--gold2); color: #4a3200; font-family: 'Jua'; font-size: .7rem; min-width: 1.4em; height: 1.4em; border-radius: 999px; display: grid; place-items: center; }

.board { flex: 1; display: flex; gap: .5em; min-height: 0; padding-bottom: .4em; position: relative; }
.pane { flex: 1; position: relative; border-radius: .9em; overflow: hidden; background: #15121f; touch-action: none; cursor: crosshair; }
.pane .lbl { position: absolute; left: .6em; top: .5em; z-index: 3; font-family: 'Jua'; font-size: .8rem; background: rgba(0,0,0,.45); padding: .12em .6em; border-radius: 999px; pointer-events: none; color: #fff; opacity: .9; }
.stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.stage img { display: block; width: 100%; height: 100%; pointer-events: none; }
.stage svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.mark path { fill: none; stroke: #ee1c25; stroke-linecap: round; stroke-linejoin: round; opacity: .92; filter: drop-shadow(0 0 1.5px rgba(255,255,255,.9)); }
.mark.reveal path { stroke: #ffd400; stroke-dasharray: 3 2.2; animation: blink .55s steps(2) 6; }
@keyframes blink { 50% { opacity: .25; } }
.hintring { fill: rgba(255, 217, 127, .18); stroke: #ffd97f; stroke-width: 3; animation: hintp 1s ease-in-out 3; }
@keyframes hintp { 50% { fill: rgba(255, 217, 127, .38); } }
.fx { position: fixed; pointer-events: none; z-index: 80; }
.ripple { width: 3.2em; height: 3.2em; margin: -1.6em 0 0 -1.6em; border-radius: 50%; border: 3px solid rgba(255,255,255,.9); animation: rip .45s ease-out forwards; }
@keyframes rip { from { transform: scale(.2); opacity: 1; } to { transform: scale(1.3); opacity: 0; } }
.xmark { width: 2.4em; height: 2.4em; margin: -1.2em 0 0 -1.2em; animation: xm .55s ease-out forwards; }
@keyframes xm { 0% { transform: scale(.3) rotate(-20deg); opacity: 0; } 25% { transform: scale(1.15) rotate(6deg); opacity: 1; } 45% { transform: translateX(-.25em); } 60% { transform: translateX(.25em); } 100% { transform: scale(.9); opacity: 0; } }
.pop { font-family: 'Jua'; font-size: 1.6rem; color: #fff; text-shadow: 0 .08em 0 #c4161e, 0 0 .5em rgba(229,38,47,.8); transform: translate(-50%, -50%); animation: popup .9s ease-out forwards; white-space: nowrap; }
.pop.combo { color: #ffe27a; text-shadow: 0 .08em 0 #9b6a00, 0 0 .6em rgba(255,200,60,.9); font-size: 1.3rem; }
@keyframes popup { 0% { opacity: 0; transform: translate(-50%, -20%) scale(.6); } 20% { opacity: 1; transform: translate(-50%, -80%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -230%) scale(1); } }
.spark { width: .55em; height: .55em; margin: -.275em; border-radius: 50%; }
.lockveil { position: absolute; inset: 0; z-index: 20; display: none; place-items: center; background: rgba(20, 16, 40, .35); font-family: 'Jua'; font-size: 1.3rem; pointer-events: none; }
.lockveil.on { display: grid; animation: fadein .2s; }
.countdown { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; font-family: 'Jua'; font-size: 7rem; color: #fff; text-shadow: 0 .06em 0 #c4161e; pointer-events: none; }
.countdown span { animation: cd .9s ease-out forwards; }
@keyframes cd { 0% { transform: scale(2); opacity: 0; } 30% { transform: scale(1); opacity: 1; } 100% { transform: scale(.8); opacity: 0; } }
.banner { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); z-index: 40; font-family: 'Jua'; font-size: 4.4rem; color: #fff; pointer-events: none; white-space: nowrap; text-shadow: 0 .07em 0 #c4161e, 0 0 .4em rgba(0,0,0,.4); animation: banner 1.6s cubic-bezier(.2,1.4,.4,1) forwards; }
.banner.blue { text-shadow: 0 .07em 0 #26305c, 0 0 .4em rgba(0,0,0,.4); }
@keyframes banner { 0% { transform: translate(-50%, -50%) scale(.2) rotate(-8deg); opacity: 0; } 25% { transform: translate(-50%, -50%) scale(1.1) rotate(2deg); opacity: 1; } 80% { transform: translate(-50%, -50%) scale(1) rotate(0); opacity: 1; } 100% { transform: translate(-50%, -60%) scale(.95); opacity: 0; } }
.zoomhint { position: absolute; right: .6em; bottom: .5em; z-index: 3; font-size: .75rem; background: rgba(0,0,0,.45); padding: .15em .6em; border-radius: 999px; pointer-events: none; opacity: .8; }

/* 대전 상대 표시줄 */
.opps { display: flex; gap: .5em; align-items: center; }
.opp { display: flex; align-items: center; gap: .35em; background: rgba(255,255,255,.1); border-radius: 999px; padding: .15em .6em .15em .15em; position: relative; }
.opp.me { background: rgba(255,90,95,.28); }
.opp .avatar { width: 2.3em; }
.opp .nm { font-size: .78rem; line-height: 1.1; max-width: 5.5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opp .sc { font-family: 'Jua'; font-size: .95rem; color: #ffe7a6; }
.opp .pg { height: .3em; width: 3.6em; background: rgba(255,255,255,.18); border-radius: 999px; overflow: hidden; }
.opp .pg i { display: block; height: 100%; background: var(--red2); transition: width .3s; }
.opp.flash { animation: oppf .6s; }
@keyframes oppf { 30% { transform: scale(1.12); background: rgba(255,217,127,.45); } }
.bubble { position: absolute; left: 50%; top: 110%; transform: translateX(-50%); background: #fff; color: var(--ink); font-family: 'Jua'; padding: .2em .7em; border-radius: 1em; white-space: nowrap; font-size: .85rem; z-index: 50; animation: bub 2.2s ease forwards; box-shadow: 0 .2em .5em rgba(0,0,0,.25); }
@keyframes bub { 0% { opacity: 0; transform: translate(-50%, -.5em) scale(.7); } 12% { opacity: 1; transform: translate(-50%, 0) scale(1.05); } 80% { opacity: 1; } 100% { opacity: 0; } }
.emotes { display: flex; gap: .3em; }
.emotes .btn { font-size: .78rem; padding: .35em .65em; --bg: rgba(255,255,255,.14); --fg: #fff; --edge: rgba(0,0,0,.4); }

/* ---------- 덮개 창 ---------- */
.veil { position: fixed; inset: 0; z-index: 70; background: rgba(28, 22, 48, .62); display: none; align-items: center; justify-content: center; padding: 1em; backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.veil.on { display: flex; animation: fadein .2s; }
.sheet { background: var(--paper); color: var(--ink); border-radius: calc(var(--r) * 1.4); box-shadow: 0 1em 3em rgba(0,0,0,.35); max-width: 94vw; max-height: 94vh; display: flex; overflow: hidden; position: relative; animation: sheetin .35s cubic-bezier(.2,1.3,.4,1); }
@keyframes sheetin { from { transform: translateY(1.5em) scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet .x { position: absolute; right: .6em; top: .6em; z-index: 5; }
.dialog { padding: 1.4em 1.6em; flex-direction: column; gap: .9em; min-width: min(26em, 90vw); }
.dialog h3 { font-size: 1.4rem; }
.dialog .row.end { justify-content: flex-end; }

/* 결과 */
.result { width: min(62em, 94vw); height: min(30em, 90vh); }
.result .art { flex: 1.1; background: #2a2440; display: grid; place-items: center; position: relative; padding: 1em; }
.result .art .frame { max-width: 100%; max-height: 100%; position: relative; padding: .55em; background: linear-gradient(135deg, #f4cf72, #b07a18 40%, #ffe7a6 60%, #b07a18); border-radius: .3em; box-shadow: 0 .6em 1.6em rgba(0,0,0,.5); animation: tilt 3s ease-in-out infinite; }
.result .art img { display: block; max-width: 100%; max-height: calc(min(30em, 90vh) - 3.6em); border: .25em solid #3b2a10; }
@keyframes tilt { 50% { transform: rotate(-1deg) translateY(-.15em); } }
.result .art .saved { position: absolute; right: .8em; top: .8em; width: 5.8em; height: 5.8em; animation: stampin .5s cubic-bezier(.3,1.6,.5,1) .5s both; }
@keyframes stampin { 0% { transform: scale(3) rotate(-30deg); opacity: 0; } 60% { transform: scale(.9) rotate(-12deg); opacity: 1; } 100% { transform: scale(1) rotate(-14deg); } }
.result .info { flex: 1; padding: 1.2em 1.4em; display: flex; flex-direction: column; gap: .55em; overflow-y: auto; }
.result h3 { font-size: 1.6rem; }
.result .meta { font-size: .9rem; color: var(--ink2); }
.result .desc { font-size: .98rem; line-height: 1.5; background: #fff; border-radius: .8em; padding: .6em .8em; }
.bigstars { display: flex; gap: .3em; }
.bigstars svg { width: 2.4em; height: 2.4em; }
.bigstars svg.on { animation: starin .45s cubic-bezier(.3,1.7,.5,1) both; }
@keyframes starin { from { transform: scale(0) rotate(-90deg); } to { transform: none; } }
.scoreline { display: flex; gap: 1em; align-items: baseline; flex-wrap: wrap; }
.scoreline .num { font-size: 2.2rem; color: var(--red); }
.result .acts { margin-top: auto; display: flex; gap: .6em; flex-wrap: wrap; }
.credit { font-size: .72rem; color: var(--ink2); }
.credit a { color: inherit; }
.unlock { display: flex; gap: .5em; flex-wrap: wrap; }
.unlock .pill { background: #fff3c4; }

/* ---------- 도감 ---------- */
#gallery, #stamps, #dress, #rank, #lobby, #room { flex-direction: column; }
.galgrid { grid-template-columns: repeat(auto-fill, minmax(9.5em, 1fr)); }
.gal { border: 0; padding: .45em .45em .5em; background: linear-gradient(135deg, #e9c36d, #a87a26); border-radius: .4em; cursor: pointer; box-shadow: var(--shadow); transition: transform .12s; }
.gal:active { transform: scale(.95); }
.gal .im { aspect-ratio: 1; background: #2a2440 center/cover no-repeat; border: .2em solid #3b2a10; }
.gal .nm { font-family: 'Jua'; font-size: .82rem; color: #3b2a10; margin-top: .3em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.gal.empty { background: #e9e0cc; box-shadow: inset 0 0 0 2px #d8c8a6; cursor: default; }
.gal.empty .im { background: repeating-linear-gradient(45deg, #ddd2b8 0 6px, #e4dac3 6px 12px); border-color: #d1c4a5; display: grid; place-items: center; font-family: 'Jua'; font-size: 2rem; color: #c3b38e; }
.gal.empty .nm { color: #b3a37f; }
.artview { width: min(70em, 96vw); height: min(34em, 92vh); }
.artview .art { flex: 1.5; background: #1f1b31; display: grid; place-items: center; padding: .8em; }
.artview .art img { max-width: 100%; max-height: calc(min(34em, 92vh) - 1.6em); box-shadow: 0 .5em 1.4em rgba(0,0,0,.5); }

/* ---------- 업적판 ---------- */
.stampboard { display: grid; grid-template-columns: repeat(auto-fill, minmax(17em, 1fr)); gap: 1em; padding: .3em .4em 1.4em; align-content: start; }
.eracard { background: #fffdf7; border-radius: 1em; padding: .8em .9em; box-shadow: var(--shadow); background-image: repeating-linear-gradient(0deg, transparent 0 1.6em, rgba(217,164,65,.12) 1.6em calc(1.6em + 1px)); }
.eracard h4 { margin: 0 0 .5em; font-family: 'Jua'; font-weight: 400; font-size: 1.1rem; display: flex; justify-content: space-between; align-items: center; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.6em, 1fr)); gap: .35em; }
.slot { aspect-ratio: 1; border-radius: 50%; border: 2px dashed #d8c8a6; display: grid; place-items: center; position: relative; }
.slot svg { width: 115%; height: 115%; position: absolute; animation: none; }
.slot.got { border-color: transparent; }
.achgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(12em, 1fr)); gap: .8em; }
.ach { background: #fff; border-radius: 1em; padding: .7em .8em; display: flex; gap: .6em; align-items: center; box-shadow: 0 .2em 0 var(--line); }
.ach .st { width: 3.4em; height: 3.4em; flex: none; display: grid; place-items: center; border-radius: 50%; border: 2px dashed #d8c8a6; }
.ach .st svg { width: 110%; height: 110%; }
.ach.got .st { border-color: transparent; }
.ach b { font-family: 'Jua'; font-weight: 400; display: block; }
.ach span { font-size: .8rem; color: var(--ink2); }
.ach:not(.got) { opacity: .7; }
.section-h { font-family: 'Jua'; font-size: 1.25rem; margin: .4em .2em .6em; display: flex; align-items: center; gap: .5em; }

/* ---------- 꾸미기 ---------- */
#dress .body { flex: 1; display: flex; gap: 1.4em; min-height: 0; padding-bottom: 1em; }
#dress .preview { width: 36%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6em; }
#dress .preview .avatar { width: min(100%, 62vh); }
.items { flex: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(6.4em, 1fr)); gap: .7em; align-content: start; padding: .3em .3em 1em; }
.item { border: 3px solid transparent; background: #fff; border-radius: 1em; aspect-ratio: 1; padding: .3em; cursor: pointer; position: relative; box-shadow: 0 .2em 0 var(--line); transition: transform .12s, border-color .12s; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.item img { width: 100%; height: 72%; object-fit: contain; }
.item .nm { font-size: .72rem; text-align: center; line-height: 1.15; }
.item.on { border-color: var(--red); }
.item:active { transform: scale(.94); }
.item.locked { background: #efe7d6; cursor: default; }
.item.locked img { filter: grayscale(1) brightness(.6) opacity(.5); }
.item .lk { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: .7rem; color: var(--ink2); text-align: center; padding: .3em; gap: .2em; background: rgba(239,231,214,.55); border-radius: .8em; }
.item .lk svg { width: 1.6em; height: 1.6em; }
.item .none { font-family: 'Jua'; color: var(--ink2); }

/* ---------- 순위 ---------- */
.ranklist { display: flex; flex-direction: column; gap: .6em; padding: .3em .4em 1.4em; }
.rk { display: flex; align-items: center; gap: .9em; background: #fff; border-radius: 1em; padding: .5em 1em .5em .6em; box-shadow: 0 .2em 0 var(--line); }
.rk .no { font-family: 'Jua'; font-size: 1.5rem; width: 1.6em; text-align: center; color: var(--ink2); }
.rk.top1 .no { color: #d9a441; } .rk.top2 .no { color: #9aa3b5; } .rk.top3 .no { color: #c47a45; }
.rk .avatar { width: 3.6em; }
.rk .nm { font-family: 'Jua'; font-size: 1.15rem; flex: 1; }
.rk .st { display: flex; gap: .5em; flex-wrap: wrap; }
.rk.me { outline: 3px solid var(--red2); }

/* ---------- 대전 로비·방 ---------- */
#lobby .body, #room .body { flex: 1; display: flex; gap: 1.2em; min-height: 0; padding-bottom: 1em; }
.mk { width: 36%; padding: 1em 1.1em; display: flex; flex-direction: column; gap: .55em; }
.seg { display: flex; gap: .3em; background: var(--paper2); padding: .25em; border-radius: 999px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 999px; padding: .4em .2em; cursor: pointer; font-family: 'Jua'; font-size: .9rem; color: var(--ink2); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 .1em .3em rgba(0,0,0,.08); }
.roomlist { flex: 1; display: flex; flex-direction: column; gap: .6em; padding: .2em .3em 1em; }
.rm { display: flex; align-items: center; gap: .8em; background: #fff; border-radius: 1em; padding: .7em 1em; box-shadow: 0 .2em 0 var(--line); cursor: pointer; border: 0; text-align: left; transition: transform .12s; }
.rm:active { transform: scale(.98); }
.rm .lock { width: 2.4em; height: 2.4em; border-radius: 50%; background: var(--paper2); display: grid; place-items: center; flex: none; }
.rm .lock svg { width: 1.3em; }
.rm .t { flex: 1; min-width: 0; }
.rm .t b { font-family: 'Jua'; font-weight: 400; font-size: 1.1rem; display: block; }
.rm .t span { font-size: .8rem; color: var(--ink2); }
.empty-note { text-align: center; color: var(--ink2); padding: 2em 1em; font-size: .95rem; }
.players { flex: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(10em, 1fr)); gap: 1em; align-content: start; padding: .3em; }
.pl { background: #fff; border-radius: 1.2em; padding: .8em; display: flex; flex-direction: column; align-items: center; gap: .35em; box-shadow: var(--shadow); position: relative; }
.pl .avatar { width: 70%; }
.pl b { font-family: 'Jua'; font-weight: 400; font-size: 1.05rem; }
.pl .tag { position: absolute; top: .5em; right: .5em; font-size: .72rem; }
.pl.ready { box-shadow: 0 0 0 3px var(--teal), var(--shadow); }
.pl.host::before { content: '방장'; position: absolute; top: .5em; left: .5em; font-family: 'Jua'; font-size: .72rem; background: var(--gold2); color: #4a3200; padding: .05em .5em; border-radius: 999px; }
.standings { width: min(42em, 92vw); padding: 1.3em 1.5em; flex-direction: column; gap: .7em; }
.standings h3 { font-size: 1.6rem; text-align: center; }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: .8em; }
.podium .pd { display: flex; flex-direction: column; align-items: center; gap: .2em; }
.podium .pd .avatar { width: 5.2em; }
.podium .pd .blk { width: 6.2em; border-radius: .6em .6em 0 0; background: linear-gradient(#ffd97f, #e6ad3c); display: grid; place-items: center; font-family: 'Jua'; font-size: 1.4rem; color: #4a3200; }
.podium .pd.p1 .avatar { width: 6.6em; }
.podium .pd.p1 .blk { height: 4.2em; } .podium .pd.p2 .blk { height: 3em; background: linear-gradient(#e3e7ef, #aab3c4); } .podium .pd.p3 .blk { height: 2.2em; background: linear-gradient(#f0c39d, #c47a45); }
.crown { width: 2.6em; margin-bottom: -.6em; animation: bounce .8s ease infinite alternate; }

/* 세로 화면 안내 */
#rotate { position: fixed; inset: 0; z-index: 200; background: var(--ink); color: #fff; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 1.2em; text-align: center; padding: 2em; font-family: 'Jua'; font-size: 1.3rem; }
#rotate svg { width: 6em; height: 6em; animation: rot 2s ease-in-out infinite; }
@keyframes rot { 0%, 20% { transform: rotate(0); } 50%, 80% { transform: rotate(-90deg); } 100% { transform: rotate(-90deg); } }
@media (orientation: portrait) and (max-width: 1024px) { #rotate { display: flex; } }

/* 토스트 */
#toast { position: fixed; left: 50%; top: 1em; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: .4em; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: .55em 1.1em; border-radius: 999px; font-family: 'Jua'; box-shadow: 0 .4em 1.2em rgba(0,0,0,.25); animation: toast 2.6s ease forwards; display: flex; align-items: center; gap: .5em; }
.toast.gold { background: linear-gradient(#ffd97f, #e6ad3c); color: #4a3200; }
@keyframes toast { 0% { opacity: 0; transform: translateY(-1em) scale(.9); } 10% { opacity: 1; transform: none; } 85% { opacity: 1; } 100% { opacity: 0; transform: translateY(-.5em); } }

/* 불러오기 */
#boot { align-items: center; justify-content: center; flex-direction: column; gap: 1em; }
.loader { width: 3em; height: 3em; border-radius: 50%; border: .35em solid var(--paper2); border-top-color: var(--red); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { position: absolute; inset: 0; display: grid; place-items: center; z-index: 25; background: rgba(31,27,49,.75); font-family: 'Jua'; gap: .6em; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; }

@media (max-height: 430px) {
  #home .menu { gap: .7em; padding-top: 2.4em; }
  .tile { padding: .7em .8em; }
  .tile .h { font-size: 1.3rem; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; } }

#auth .pickhero { background: linear-gradient(135deg, #fff3f6, #eef7ff); display: flex; flex-direction: column; gap: .7em; padding: 1em 1.2em; justify-content: center; }
#auth .pickhero::after { display: none; }
#auth .pickhero .charpick button { display: flex; flex-direction: column; align-items: center; padding: .2em .1em .25em; aspect-ratio: auto; }
#auth .pickhero .charpick .avatar { width: 82%; }
#auth .pickhero .charpick span { font-family: 'Jua'; font-size: .78rem; color: var(--ink2); }
#auth .panel { overflow-y: auto; padding: .3em .2em; }
.result .acts { gap: .45em; }
#toast { top: 3.6em; }
.seg button { white-space: nowrap; padding-left: .55em; padding-right: .55em; }
#room .topbar { flex-wrap: wrap; row-gap: .4em; }
.grid { grid-auto-rows: max-content; } .pz, .gal { min-height: max-content; }
