/* © 2026 JoY Studio (김준영, 김태형). All rights reserved. */
:root {
  --ink: #26215c;
  --paper: #fffaf3;
  --line: #3c3489;
  --muted: #7a70a8;
  --violet: #8a5ad0;
  --pink: #f07ab0;
  --yellow: #ffcf3f;
  --bg: #cbbcf6;
  --display: 'Jua', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --vtop: 0px; /* 화면 키보드 때문에 위로 밀려 안 보이는 높이 */
  --vbot: 0px; /* 화면 키보드가 아래에서 가리는 높이 */
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--display);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; overscroll-behavior: none;
}
#app { position: fixed; left: 0; top: 0; right: 0; height: var(--apph, 100%); overflow: hidden;
  background: repeating-linear-gradient(45deg, #cbbcf6 0 18px, #c3b2f2 18px 36px); }
.hidden { display: none !important; }
button { font-family: var(--display); color: var(--ink); cursor: pointer; }
input { font-family: var(--display); color: var(--ink); user-select: text; -webkit-user-select: text; }

/* ───── 화면 공통 ───── */
.screen {
  position: absolute; inset: 0; overflow-y: auto; display: flex; z-index: 10;
  padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  touch-action: pan-y;
}
.screen.dim { background: rgba(38, 33, 92, 0.45); z-index: 30; }
.inner { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; max-width: 560px; }
.inner.wide { max-width: 860px; }
h1 { margin: 0; font-weight: 400; font-size: 46px; line-height: 1; text-align: center; letter-spacing: 1px; }
h1 .t1 { color: var(--yellow); }
h1 .t2 { color: #fff; }
h1 span { text-shadow: 0 4px 0 var(--line), 3px 0 0 var(--line), -3px 0 0 var(--line), 0 -3px 0 var(--line), 3px 3px 0 var(--line), -3px 3px 0 var(--line); }
h2 { margin: 0; font-weight: 400; font-size: 28px; color: #fff; text-align: center; text-shadow: 0 3px 0 var(--line), 2px 0 0 var(--line), -2px 0 0 var(--line), 0 -2px 0 var(--line); }
.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; align-items: center; }
.col { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.card { background: var(--paper); border: 3px solid var(--line); border-radius: 12px; padding: 10px 14px; box-shadow: 0 4px 0 rgba(38, 33, 92, 0.25); display: flex; flex-direction: column; gap: 8px; width: 100%; }
.card.center { align-items: center; text-align: center; font-size: 19px; padding: 18px; }
.card small { color: var(--muted); font-size: 14px; }
.note { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.4; }
.btn {
  font-size: 21px; line-height: 1.15; background: #fff; border: 3px solid var(--line); border-radius: 12px;
  padding: 8px 20px; min-width: 200px; box-shadow: 0 4px 0 var(--line); transition: transform 0.08s;
}
.btn small { display: block; font-size: 12px; color: var(--muted); }
.btn.small { font-size: 16px; min-width: 96px; padding: 6px 12px; }
.btn.primary { background: var(--violet); color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); }
.btn.primary small { color: #efe6ff; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.btn:disabled { opacity: 0.45; }
.copyright { font-size: 12px; color: #fff; text-decoration: none; text-shadow: 0 1px 2px var(--ink); font-family: sans-serif; }
.copyright:hover { text-decoration: underline; }

/* 첫 화면 */
.title { gap: 14px; }
.titlerow { display: flex; gap: 22px; align-items: center; justify-content: center; flex-wrap: wrap; }
.me-card { background: var(--paper); border: 3px solid var(--line); border-radius: 14px; width: 170px; min-height: 196px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px; box-shadow: 0 4px 0 rgba(38, 33, 92, 0.25); }
.me-card b { font-size: 20px; }
.me-card small { font-size: 12px; color: var(--muted); }
.me-pic { width: 102px; height: 156px; image-rendering: pixelated; }
.me-empty { font-size: 60px; opacity: 0.4; }
.me-card > b:not(:first-child) { text-align: center; }
.me-empty + b { font-size: 15px; }

/* 꾸미기 */
.editor-card { padding: 8px 10px; }
#editor { display: flex; gap: 10px; min-height: 220px; }
.ed-left { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 0 0 auto; }
.ed-preview { width: 102px; height: 156px; image-rendering: pixelated; background: #efe8ff; border-radius: 10px; border: 2px solid #d6caf6; }
.ed-right { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.ed-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { font-size: 15px; padding: 4px 12px; border: 2px solid var(--line); border-radius: 999px; background: #fff; }
.tab.on { background: var(--violet); color: #fff; }
.ed-body { display: flex; flex-direction: column; gap: 5px; }
.ed-row { display: flex; gap: 8px; align-items: center; }
.ed-row > b { flex: 0 0 64px; font-weight: 400; font-size: 14px; color: var(--muted); }
.ed-opts { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { font-size: 14px; padding: 3px 9px; border: 2px solid #c9bdf0; border-radius: 8px; background: #fff; }
.chip.on { border-color: var(--line); background: #ffe9a8; }
.swatch { width: 24px; height: 24px; border: 2px solid #c9bdf0; border-radius: 6px; padding: 0; }
.swatch.on { border: 3px solid var(--line); transform: scale(1.12); }
.namerow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.namerow b { font-weight: 400; color: var(--muted); }
#name-in { font-size: 18px; width: 150px; padding: 4px 8px; border: 2px solid var(--line); border-radius: 8px; }
#name-msg { color: #c83a3a; font-size: 14px; flex: 1; }

/* 약속 */
.promise { gap: 6px; }
.pr { text-align: left; font-size: 17px; background: #fff; border: 2px solid #c9bdf0; border-radius: 10px; padding: 8px 10px; display: flex; gap: 8px; align-items: center; }
.pr i { font-style: normal; font-size: 22px; color: var(--muted); }
.pr.on { border-color: var(--line); background: #eaf8e4; }
.pr.on i { color: #3b8a3a; }

/* 방 만들기 */
.themes { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; width: 100%; }
.theme { border: 3px solid #fff; border-radius: 10px; padding: 0; background: #fff; overflow: hidden; display: flex; flex-direction: column; }
.theme canvas { width: 100%; aspect-ratio: 3/2; image-rendering: pixelated; display: block; }
.theme .rnd { aspect-ratio: 3/2; display: flex; align-items: center; justify-content: center; font-size: 34px; background: #ece6fb; }
.theme span { font-size: 15px; padding: 3px 0; }
.theme.on { border-color: var(--line); box-shadow: 0 0 0 3px var(--yellow); }
.seg { display: flex; border: 3px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { font-size: 17px; padding: 6px 16px; border: 0; background: #fff; }
.seg button.on { background: var(--yellow); }

/* 코드 입력 */
#code-show { display: flex; gap: 6px; }
#code-show span { width: 40px; height: 50px; border: 3px solid var(--line); border-radius: 8px; background: #fff; font-size: 30px; display: flex; align-items: center; justify-content: center; }
#keypad { display: grid; grid-template-columns: repeat(3, 70px); gap: 6px; }
.key { font-size: 22px; height: 42px; border: 3px solid var(--line); border-radius: 10px; background: #fff; box-shadow: 0 3px 0 var(--line); }
.key:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }

.spin { font-size: 40px; animation: bob 1s infinite; }
@keyframes bob { 50% { transform: translateY(-6px); } }

/* ───── 대화방 ───── */
#room { position: absolute; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr) clamp(220px, 32vw, 320px); }
#stage { position: relative; overflow: hidden; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#badge { position: absolute; left: max(8px, env(safe-area-inset-left)); top: 8px; background: rgba(38, 33, 92, 0.82); color: #fff; border-radius: 10px; padding: 4px 10px; display: flex; gap: 8px; font-size: 14px; align-items: center; pointer-events: none; }
#badge b { font-weight: 400; color: var(--yellow); }
#topbtns { position: absolute; right: 8px; top: 8px; display: flex; gap: 6px; }
.ibtn { width: 40px; height: 40px; border-radius: 12px; border: 3px solid var(--line); background: #fff; font-size: 20px; box-shadow: 0 3px 0 var(--line); padding: 0; }
#emotes { position: absolute; left: max(8px, env(safe-area-inset-left)); bottom: 8px; display: flex; gap: 6px; }
.ebtn { width: 42px; height: 42px; border-radius: 50%; border: 3px solid var(--line); background: #fff; font-size: 20px; padding: 0; box-shadow: 0 3px 0 var(--line); }
.ebtn:active, .ibtn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
#hint { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); background: rgba(255, 255, 255, 0.9); border-radius: 999px; padding: 3px 12px; font-size: 13px; pointer-events: none; transition: opacity 0.6s; white-space: nowrap; margin-left: 60px; }
#hint.gone { opacity: 0; }
#asks { position: absolute; left: 50%; top: 52px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; width: min(92%, 440px); z-index: 5; }
.ask { display: flex; gap: 8px; align-items: center; background: #fff; border: 3px solid var(--line); border-radius: 12px; padding: 6px 8px; box-shadow: 0 4px 0 rgba(38, 33, 92, 0.35); animation: pop 0.25s; }
.ask-t { flex: 1; font-size: 15px; }
.ask-t b { font-weight: 400; color: var(--violet); }
@keyframes pop { from { transform: scale(0.8); opacity: 0; } }
.thumb { image-rendering: pixelated; background: #efe8ff; border-radius: 8px; flex: 0 0 auto; }

#chat { background: #f6f3ff; border-left: 3px solid var(--line); display: flex; flex-direction: column; min-height: 0; padding-right: env(safe-area-inset-right); }
#chat-head { background: var(--violet); color: #fff; padding: 5px 10px; display: flex; flex-direction: column; }
#chat-head span { font-size: 16px; }
#chat-head small { font-size: 11px; opacity: 0.9; font-family: sans-serif; }
#log { flex: 1; overflow-y: auto; padding: 4px 8px; display: flex; flex-direction: column; gap: 2px; font-size: 15px; line-height: 1.35; user-select: text; -webkit-user-select: text; min-height: 0; }
.line { word-break: break-all; }
.line b { font-weight: 400; }
.line.me { background: #fff5c8; border-radius: 6px; padding: 0 4px; }
.line.sys { color: #8a84a8; font-size: 13px; text-align: center; }
.line.nope { color: #c83a3a; font-size: 13px; background: #ffe6e6; border-radius: 6px; padding: 1px 6px; }
#quickbar { display: flex; gap: 4px; padding: 5px 6px 2px; flex-wrap: wrap; border-top: 2px solid #ddd4fa; }
#quickgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; padding: 6px; background: #ece6fb; border-top: 2px solid #ddd4fa; max-height: 45%; overflow-y: auto; }
.qb { font-size: 14px; padding: 4px 8px; border: 2px solid #b8a8ee; border-radius: 8px; background: #fff; }
.qb.more { background: #ece6fb; }
.qb:active { background: #ffe9a8; }
#say { display: flex; gap: 4px; padding: 4px 6px 6px; }
#say-in { flex: 1; min-width: 0; font-size: 16px; padding: 6px 8px; border: 2px solid var(--line); border-radius: 8px; }
.sbtn { font-size: 14px; padding: 5px 10px; border: 2px solid var(--line); border-radius: 8px; background: var(--violet); color: #fff; white-space: nowrap; }
.sbtn.gray { background: #fff; color: var(--ink); }
.sbtn.red { background: #e05a5a; }
#quickonly { padding: 8px; font-size: 13px; color: var(--muted); text-align: center; }
/* 화면 키보드가 올라오면: 무대 크기는 그대로(캔버스가 내 캐릭터 쪽으로 올라감), 대화창만 보이는 곳에 맞춤 */
#chat { padding-top: var(--vtop); padding-bottom: var(--vbot); }
#badge, #topbtns { margin-top: var(--vtop); }
#asks { margin-top: var(--vtop); }
#toast { margin-top: var(--vtop); }
.screen { padding-bottom: calc(max(10px, env(safe-area-inset-bottom)) + var(--vbot)); }
#app.kb #chat-head, #app.kb #quickbar, #app.kb #quickgrid, #app.kb #emotes, #app.kb #hint { display: none; }

/* 사람 목록 */
.cardhead { display: flex; justify-content: space-between; align-items: center; font-size: 18px; }
.cardhead b { font-weight: 400; }
#people-list { display: flex; flex-direction: column; gap: 4px; max-height: 52vh; overflow-y: auto; }
.prow { display: flex; gap: 6px; align-items: center; padding: 3px 4px; border-bottom: 1px solid #ece6fb; }
.prow b { font-weight: 400; font-size: 17px; }
.prow.hid { opacity: 0.5; }
.prow .grow { flex: 1; }
.tag { font-size: 11px; background: #ece6fb; border-radius: 6px; padding: 1px 6px; color: var(--muted); }
.tag.me { background: #fff0b0; color: #8a6a10; }
.toggle { display: flex; gap: 6px; align-items: center; font-size: 15px; }

#toast { position: absolute; left: 50%; top: 14px; transform: translate(-50%, -80px); background: var(--ink); color: #fff; padding: 6px 16px; border-radius: 999px; font-size: 16px; z-index: 60; transition: transform 0.25s; pointer-events: none; }
#toast.show { transform: translate(-50%, 0); }
#rotate { display: none; position: absolute; inset: 0; z-index: 80; background: var(--bg); color: #fff; flex-direction: column; align-items: center; justify-content: center; font-size: 22px; text-shadow: 0 2px 0 var(--ink); }
#rotate div { font-size: 56px; }
@media (orientation: portrait) and (max-width: 700px) { #rotate { display: flex; } }
/* 낮은 가로 화면(폰) */
@media (max-height: 430px) {
  h1 { font-size: 36px; }
  .btn { font-size: 18px; padding: 6px 16px; }
  .me-card { min-height: 170px; width: 150px; }
  .me-pic { width: 85px; height: 130px; }
  #editor { min-height: 0; }
  .ed-preview { width: 119px; height: 182px; }
  .chip { font-size: 13px; padding: 2px 7px; }
  .swatch { width: 21px; height: 21px; }
  .themes canvas { aspect-ratio: 3/2; }
  #keypad { grid-template-columns: repeat(3, 62px); gap: 4px; }
  .key { height: 34px; font-size: 18px; }
  #code-show span { width: 34px; height: 40px; font-size: 24px; }
  h2 { font-size: 22px; }
}
