:root {
  --bg: #0f1117;
  --panel: #171a23;
  --panel-2: #1f2330;
  --line: #2a2f3d;
  --text: #eef0f6;
  --muted: #8b91a3;
  --accent: #7c6cff;
  --accent-2: #a597ff;
  --human: #2fc98f;
  --ai: #ff7a59;
  --bubble-me: #7c6cff;
  --bubble-them: #252a38;
  --radius: 18px;
  --app-h: 100dvh;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #07080c; color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", system-ui, sans-serif; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input { font: inherit; color: inherit; }

/* 데스크톱에서도 모바일 프레임으로 */
#app {
  position: relative; margin: 0 auto; width: 100%; max-width: 430px;
  height: var(--app-h); background: var(--bg); overflow: hidden;
  display: flex; flex-direction: column;
}
@media (min-width: 500px) {
  body { display: flex; align-items: center; justify-content: center; }
  #app { height: min(900px, 96dvh); border-radius: 28px; box-shadow: 0 30px 80px #0009, 0 0 0 1px #ffffff12; }
}
.screen { flex: 1; display: flex; flex-direction: column; min-height: 0;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }

.btn { border-radius: 14px; padding: 13px 18px; font-weight: 700; transition: transform .08s, opacity .2s; }
.btn:active { transform: scale(.97); }
.btn.big { padding: 17px; font-size: 17px; }
.btn.primary { background: linear-gradient(135deg, var(--accent), #5a8bff); color: #fff; }
.btn.ghost { background: var(--panel-2); color: var(--text); }
.btn:disabled { opacity: .45; }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; background: var(--panel-2); font-size: 17px; font-weight: 700; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }

/* 온보딩 */
#s-onboard { padding: 24px; justify-content: center; gap: 22px; }
.onboard-track { display: flex; overflow: hidden; }
.slide { flex: 0 0 100%; text-align: center; transition: transform .35s ease; }
.slide .emoji { font-size: 72px; margin-bottom: 18px; }
.slide h2 { margin: 0 0 10px; font-size: 22px; }
.slide p { margin: 0; color: var(--muted); }
.dots { display: flex; gap: 6px; justify-content: center; }
.dots i { width: 7px; height: 7px; border-radius: 9px; background: var(--line); transition: all .3s; }
.dots i.on { width: 22px; background: var(--accent); }

/* 홈 */
.home-head, .plain-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; }
.plain-head h1 { font-size: 18px; margin: 0; }
.plain-head span { width: 38px; }
.logo { font-size: 22px; font-weight: 800; letter-spacing: -.5px; }
.logo span { color: var(--accent-2); margin-left: 2px; }
.home-body { flex: 1; overflow-y: auto; padding: 4px 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.hero { text-align: center; padding: 26px 0 12px; }
.hero-emoji { font-size: 54px; letter-spacing: 6px; }
.hero-emoji span { font-size: 30px; vertical-align: middle; }
.hero p { color: var(--muted); margin: 10px 0 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 13px; color: var(--muted); padding-left: 4px; }
.field input { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; outline: none; }
.field input:focus { border-color: var(--accent); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; padding: 14px 8px; }
.stats b { display: block; font-size: 20px; }
.stats small { color: var(--muted); font-size: 12px; }

/* 대기 */
#s-queue { padding: 24px; }
.queue-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.queue-body h2 { margin: 28px 0 4px; }
.tip { color: var(--muted); font-size: 13px; max-width: 280px; margin-top: 26px; min-height: 40px; }
.radar { position: relative; width: 140px; height: 140px; display: grid; place-items: center; }
.radar b { width: 64px; height: 64px; border-radius: 50%; background: var(--panel-2); display: grid; place-items: center; font-size: 28px; z-index: 1; }
.radar i { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--accent); opacity: 0; animation: ping 2.4s infinite; }
.radar i:nth-child(2) { animation-delay: .8s; }
.radar i:nth-child(3) { animation-delay: 1.6s; }
@keyframes ping { 0% { transform: scale(.4); opacity: .9; } 100% { transform: scale(1.1); opacity: 0; } }

/* 채팅 */
.chat-head { position: relative; display: flex; align-items: center; gap: 10px; padding: 10px 14px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.who { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, #444a5e, #2a2f3d); display: grid; place-items: center; font-weight: 800; color: var(--muted); }
.name { font-weight: 700; }
.sub { font-size: 12px; color: var(--muted); }
.sub.typing { color: var(--accent-2); }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 18px; padding: 6px 10px; border-radius: 10px; background: var(--panel-2); }
.timer.warn { color: #ffb35c; }
.timer.danger { color: #ff5c7a; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .5; } }
.timebar { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: transparent; }
.timebar i { display: block; height: 100%; background: var(--accent); transition: width 1s linear; }

.banner { margin: 8px 12px 0; padding: 10px 12px; border-radius: 14px; background: #2a2450; border: 1px solid #4b3fa8; display: flex; align-items: center; gap: 8px; font-size: 14px; }
.banner .grow { flex: 1; }
.banner button { padding: 6px 12px; border-radius: 10px; font-weight: 700; font-size: 13px; }
.banner .yes { background: var(--accent); color: #fff; }
.banner .no { background: var(--panel-2); }

.msgs { flex: 1; overflow-y: auto; padding: 14px 12px 8px; display: flex; flex-direction: column; gap: 4px; overscroll-behavior: contain; }
.topic { align-self: center; text-align: center; background: var(--panel); border: 1px dashed var(--line); border-radius: 14px; padding: 10px 14px; margin: 4px 0 14px; font-size: 13px; color: var(--muted); max-width: 90%; }
.topic b { display: block; color: var(--text); font-size: 15px; margin-top: 2px; }
.sys { align-self: center; font-size: 12px; color: var(--muted); background: var(--panel); padding: 4px 10px; border-radius: 99px; margin: 8px 0; }
.bubble { max-width: 76%; padding: 9px 13px; border-radius: 18px; word-break: break-word; white-space: pre-wrap; animation: pop .18s ease-out; }
.bubble.me { align-self: flex-end; background: var(--bubble-me); color: #fff; border-bottom-right-radius: 6px; }
.bubble.them { align-self: flex-start; background: var(--bubble-them); border-bottom-left-radius: 6px; }
.bubble.me + .bubble.me { border-top-right-radius: 6px; }
.bubble.them + .bubble.them { border-top-left-radius: 6px; }
.bubble.me + .bubble.them, .bubble.them + .bubble.me { margin-top: 8px; }
@keyframes pop { from { transform: scale(.9) translateY(4px); opacity: 0; } }
.typing-dots { align-self: flex-start; background: var(--bubble-them); border-radius: 18px; padding: 12px 14px; display: flex; gap: 4px; margin-top: 4px; }
.typing-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

.guess-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); background: var(--panel); font-size: 13px; color: var(--muted); }
.seg { display: flex; background: var(--bg); border-radius: 11px; padding: 3px; gap: 3px; }
.seg button { padding: 6px 11px; border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--muted); }
.seg button.on[data-g="human"] { background: var(--human); color: #062a1c; }
.seg button.on[data-g="ai"] { background: var(--ai); color: #2e0d04; }
.chip { margin-left: auto; padding: 6px 12px; border-radius: 99px; background: #2a2450; border: 1px solid #4b3fa8; color: var(--accent-2); font-weight: 700; font-size: 13px; }
.composer { display: flex; gap: 8px; padding: 8px 12px 12px; background: var(--panel); }
.composer input { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 22px; padding: 11px 16px; outline: none; font-size: 16px; }
.composer input:focus { border-color: var(--accent); }
.send { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 20px; font-weight: 800; flex: none; }
.send:disabled { opacity: .4; }

.sheet-wrap { position: absolute; inset: 0; background: #000a; display: flex; align-items: flex-end; z-index: 10; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet { width: 100%; background: var(--panel); border-radius: 26px 26px 0 0; padding: 26px 20px calc(26px + env(safe-area-inset-bottom, 0px)); text-align: center; animation: up .25s ease-out; }
@keyframes up { from { transform: translateY(40px); } }
.verdict-title { font-size: 22px; font-weight: 800; }
.verdict-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0; }
.vbtn { padding: 20px 0; border-radius: 18px; background: var(--panel-2); border: 2px solid transparent; font-size: 40px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.vbtn span { font-size: 16px; font-weight: 800; }
.vbtn.on[data-g="human"] { border-color: var(--human); background: #133528; }
.vbtn.on[data-g="ai"] { border-color: var(--ai); background: #3a1d16; }
.vbtn:disabled { opacity: .7; }
.vtimer { height: 4px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.vtimer i { display: block; height: 100%; background: var(--accent); }

/* 결과 */
.result-body { flex: 1; overflow-y: auto; padding: 22px 18px 12px; display: flex; flex-direction: column; gap: 12px; }
.reveal { text-align: center; padding: 22px 16px; border-radius: 22px; }
.reveal.human { background: linear-gradient(160deg, #123a2b, #171a23); }
.reveal.ai { background: linear-gradient(160deg, #42221a, #171a23); }
.reveal .big { font-size: 64px; animation: flip .6s ease-out; }
@keyframes flip { from { transform: rotateY(90deg) scale(.6); opacity: 0; } }
.reveal h2 { margin: 6px 0 2px; font-size: 22px; }
.reveal .persona { font-size: 13px; color: var(--muted); margin-top: 4px; }
.versus { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.versus .card { text-align: center; padding: 14px 8px; }
.versus .label { font-size: 12px; color: var(--muted); }
.versus .val { font-size: 17px; font-weight: 800; margin-top: 4px; }
.ok { color: var(--human); }
.bad { color: var(--ai); }
.points { display: flex; flex-direction: column; gap: 6px; }
.points .row { display: flex; justify-content: space-between; font-size: 14px; }
.points .total { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 2px; font-weight: 800; font-size: 16px; }
.section-title { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { padding: 7px 11px; border-radius: 99px; background: var(--panel-2); font-size: 13px; border: 1px solid transparent; }
.tag.on { border-color: var(--accent); color: var(--accent-2); background: #2a2450; }
.tag.static { cursor: default; }
details.replay summary { cursor: pointer; font-weight: 700; list-style: none; }
details.replay summary::after { content: " ▾"; color: var(--muted); }
details.replay .msgs { padding: 10px 0 0; max-height: none; overflow: visible; }
.result-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; padding: 12px 18px 16px; border-top: 1px solid var(--line); }

/* 랭킹 */
.tabs { display: flex; gap: 6px; padding: 0 16px; }
.tabs button { flex: 1; padding: 10px; border-radius: 12px; background: var(--panel); font-weight: 700; font-size: 14px; color: var(--muted); }
.tabs button.on { background: var(--accent); color: #fff; }
.rank-desc { padding: 10px 18px 0; margin: 0; }
.rank-list { list-style: none; margin: 0; padding: 12px 16px 24px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.rank-list li { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.rank-list .no { width: 26px; font-weight: 800; text-align: center; color: var(--muted); }
.rank-list li:nth-child(1) .no { color: #ffd257; }
.rank-list li:nth-child(2) .no { color: #d0d6e2; }
.rank-list li:nth-child(3) .no { color: #e09a5f; }
.rank-list .nm { flex: 1; min-width: 0; }
.rank-list .nm b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-list .nm small { color: var(--muted); font-size: 12px; }
.rank-list .sc { font-weight: 800; font-size: 17px; }
.rank-list .empty { justify-content: center; color: var(--muted); }

.toast { position: absolute; left: 50%; top: calc(76px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); background: #2b3040; color: var(--text); padding: 10px 16px; border-radius: 99px; font-size: 14px; z-index: 20; box-shadow: 0 6px 20px #0008; animation: fade .2s; white-space: nowrap; }

.decide-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0; }
.decide-btns .btn.picked { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.decide-btns .btn.agree { background: linear-gradient(135deg, var(--human), #2fb4c9); color: #062a1c; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { transform: scale(1.03); } }
.chip.agree { background: var(--human); border-color: var(--human); color: #062a1c; animation: pulse 1.2s infinite; }
.composer input:disabled { opacity: .5; }
