:root {
  color-scheme: light dark;
  --bg: #ffffff; --fg: #1b1b1f; --mut: #6b6b76; --line: #e0e0e8; --panel: #f4f4f8;
  --acc: #3b6df0; --acc-fg: #ffffff; --bub: #eef0f6; --mine: #3b6df0; --mine-fg: #fff;
  --ok: #1f9d55; --warn: #c2410c; --wis: #8e44ad; --danger: #d33;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16161a; --fg: #ececf1; --mut: #9a9aa6; --line: #2e2e38; --panel: #1f1f26;
    --acc: #6f93ff; --acc-fg: #0c0c10; --bub: #262630; --mine: #3d5fd0; --mine-fg: #fff;
    --ok: #4cc47f; --warn: #fb923c; --wis: #c58af0; --danger: #ff6b6b;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); overscroll-behavior: none; }
body { font: 15px/1.5 system-ui, -apple-system, "Malgun Gothic", "Apple SD Gothic Neo", sans-serif; }
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 8px 12px; cursor: pointer; }
button.primary { background: var(--acc); color: var(--acc-fg); border-color: transparent; font-weight: 600; }
input[type=text], input:not([type]), input[type=password] {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); outline: none;
}
input:focus { border-color: var(--acc); }
code { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; font-size: 13px; }
.hint { color: var(--mut); font-size: 13px; }

.screen { height: var(--vh, 100dvh); display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0); padding-bottom: env(safe-area-inset-bottom, 0); }

/* 로그인 */
#auth { align-items: center; justify-content: center; padding: 20px; }
.card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 10px; text-align: center; }
.card h1 { margin: 0 0 4px; font-size: 22px; }
.logo { align-self: center; border-radius: 18px; }
.tabs { display: flex; gap: 6px; }
.tabs button { flex: 1; }
.tabs button.on { background: var(--acc); color: var(--acc-fg); border-color: transparent; font-weight: 600; }
#err { color: var(--danger); min-height: 1.4em; font-size: 13px; }

/* 채팅 */
header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.title b { white-space: nowrap; }
.actions { display: flex; gap: 6px; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--mut); white-space: nowrap; }
.pill.up { color: var(--ok); border-color: var(--ok); }
#conn { background: var(--warn); color: #fff; text-align: center; font-size: 13px; padding: 3px; }
#notice { background: var(--panel); border-bottom: 1px solid var(--line); padding: 6px 12px; font-size: 13px; }
.body { flex: 1; min-height: 0; display: flex; position: relative; }
main { flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; }
#log { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; -webkit-overflow-scrolling: touch; }
#jump { position: absolute; right: 14px; bottom: 12px; background: var(--acc); color: var(--acc-fg); border: 0; border-radius: 999px; box-shadow: 0 2px 8px #0005; }

.row { display: flex; flex-direction: column; max-width: 86%; }
.row.mine { align-self: flex-end; align-items: flex-end; }
.row.other { align-self: flex-start; align-items: flex-start; }
.row .nick { background: none; border: 0; padding: 0 4px; font-size: 12px; color: var(--mut); }
.bubble { background: var(--bub); padding: 7px 11px; border-radius: 14px; word-break: break-word; white-space: pre-wrap; }
.row.mine .bubble { background: var(--mine); color: var(--mine-fg); }
.time { font-size: 11px; color: var(--mut); padding: 1px 4px; }
.row.whisper .bubble { border: 1px dashed var(--wis); background: transparent; color: var(--wis); }
.row.mine.whisper .bubble { color: var(--wis); }
.wlabel { font-size: 12px; color: var(--wis); padding: 0 4px; }
.sys { align-self: center; text-align: center; font-size: 12.5px; color: var(--mut); padding: 2px 8px; white-space: pre-wrap; }
.sys.err { color: var(--danger); }
.sys.ann { color: var(--acc); font-weight: 600; }

aside#users { width: 220px; border-left: 1px solid var(--line); overflow-y: auto; padding: 8px; background: var(--bg); }
.u { display: block; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: 6px 8px; }
.u:hover { background: var(--panel); }
.u small { display: block; font-size: 11.5px; color: var(--mut); }
.u small.on { color: var(--ok); }
.u .me { color: var(--mut); font-size: 11px; }

footer { border-top: 1px solid var(--line); padding: 8px 12px; background: var(--bg); }
#wchip { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 6px; padding: 2px 4px 2px 10px; border: 1px solid var(--wis); color: var(--wis); border-radius: 999px; font-size: 13px; }
#wchip button { border: 0; background: none; padding: 2px 8px; color: inherit; }
.composer { display: flex; gap: 8px; }
.composer input { flex: 1; min-width: 0; }

/* 메뉴 */
dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--bg); color: var(--fg); width: min(92vw, 420px); padding: 16px; }
dialog::backdrop { background: #0008; }
dialog h2 { margin: 0 0 8px; font-size: 18px; }
dialog section { border-top: 1px solid var(--line); padding: 10px 0; display: flex; flex-direction: column; gap: 8px; }
.row2 { display: flex; justify-content: space-between; gap: 10px; }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; min-width: 0; text-transform: uppercase; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.btns { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; }

/* 모바일: 접속자 목록을 오른쪽 서랍으로 */
@media (max-width: 799px) {
  aside#users { position: absolute; top: 0; right: 0; bottom: 0; z-index: 5; box-shadow: -4px 0 16px #0004;
    transform: translateX(105%); transition: transform .18s ease; }
  aside#users.open { transform: translateX(0); }
}
@media (min-width: 800px) {
  #btn-users { display: none; }
  #log { padding: 14px 18px; }
}

/* 게임 서버 공지 */
.sys.game { align-self: stretch; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; font-size: 13.5px; }
