:root {
  --bg: #0a0a0f;
  --bg2: #12121c;
  --card: #17151f;
  --line: #2c2836;
  --text: #ece6dd;
  --muted: #9a8f9f;
  --gold: #d8b25a;
  --gold-soft: #3a3220;
  --crimson: #c0392b;
  --crimson-soft: #3a1a18;
  --green: #4caf72;
  --blue: #5b8cff;
  --radius: 15px;
  --shadow: 0 14px 44px rgba(0,0,0,.55);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  min-height: 100%;
  background:
    radial-gradient(900px 500px at 50% -8%, #241a2e 0%, var(--bg) 58%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
    "Malgun Gothic", "Noto Sans KR", serif;
  -webkit-user-select: none; user-select: none;
}
.app { max-width: 540px; margin: 0 auto; padding: 20px 16px 48px; }
.screen { display: flex; flex-direction: column; gap: 16px; }
.hidden { display: none !important; }

/* 진입 */
.brand { text-align: center; margin-top: 18px; }
.crest { font-size: 34px; letter-spacing: 4px; }
.brand h1 { font-size: 30px; letter-spacing: 6px; margin-top: 8px; font-weight: 800;
  background: linear-gradient(180deg, #f0d590, var(--gold)); -webkit-background-clip: text;
  background-clip: text; -webkit-text-fill-color: transparent; }
.sub { color: var(--muted); margin-top: 8px; font-size: 13px; letter-spacing: 1px; }
.rules-hint { text-align: center; color: var(--muted); font-size: 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 13px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 12px; color: var(--muted); font-weight: 700; letter-spacing: .5px; }
input, textarea {
  width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 11px;
  padding: 13px 14px; color: var(--text); font-size: 16px; outline: none; font-family: inherit;
}
input:focus, textarea:focus { border-color: var(--gold); }
#codeInput { text-transform: uppercase; letter-spacing: 4px; font-weight: 800; }

.btn { width: 100%; border: 1px solid var(--line); background: var(--bg2); color: var(--text);
  font-size: 16px; font-weight: 700; padding: 13px; border-radius: 11px; cursor: pointer;
  font-family: inherit; transition: transform .06s, filter .15s; }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-gold { background: linear-gradient(180deg, #e6c674, var(--gold)); border-color: transparent;
  color: #2a2008; box-shadow: 0 8px 20px rgba(216,178,90,.28); }
.btn-crimson { background: linear-gradient(180deg, #d0483a, var(--crimson)); border-color: transparent;
  color: #fff; }
.btn-ghost { background: transparent; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.room-list { display: flex; flex-direction: column; gap: 7px; }
.room-item { display: flex; justify-content: space-between; align-items: center; cursor: pointer;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; }
.room-item:hover { border-color: var(--gold); }
.room-item .rc { font-weight: 800; letter-spacing: 2px; }
.room-item .rm { font-size: 12px; color: var(--muted); }
.error { color: var(--crimson); font-size: 13px; text-align: center; min-height: 17px; }

/* 방 헤더 */
.rhead { display: flex; align-items: center; gap: 9px; }
.rcode { font-size: 13px; color: var(--muted); }
.rcode b { color: var(--text); letter-spacing: 2px; font-size: 15px; }
.phase-tag { font-weight: 800; font-size: 14px; padding: 5px 13px; border-radius: 999px;
  background: var(--bg2); border: 1px solid var(--line); }
.phase-tag.night { color: #9fb6ff; border-color: #2b3a66; }
.phase-tag.dawn { color: var(--gold); border-color: var(--gold-soft); }
.phase-tag.day { color: #ffd98a; }
.phase-tag.vote { color: #e79; }
.phase-tag.over { color: var(--gold); }
.timer { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 800; color: var(--muted); font-size: 14px; }
.btn-mini { background: transparent; border: 1px solid var(--line); color: var(--muted);
  padding: 6px 11px; border-radius: 999px; font-size: 12px; cursor: pointer; font-family: inherit; }

.banner { border-radius: var(--radius); padding: 16px; text-align: center; font-weight: 700;
  border: 1px solid var(--line); background: var(--card); }
.banner.guard { border-color: var(--gold-soft); background: linear-gradient(160deg, #2a2312, #17130a); color: var(--gold); }
.banner.spy { border-color: var(--crimson-soft); background: linear-gradient(160deg, #2e1614, #180b0a); color: #e78; }
.banner .big { font-size: 22px; display: block; margin-bottom: 4px; letter-spacing: 2px; }

/* 패널 */
.panel { display: flex; flex-direction: column; gap: 12px; }
.pcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 17px; box-shadow: var(--shadow); }
.pcard h3 { font-size: 15px; margin-bottom: 10px; letter-spacing: .5px; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; }

/* 역할 카드 */
.role-card { text-align: center; padding: 22px 18px; border-radius: var(--radius); border: 1px solid var(--line); }
.role-card.guard { background: linear-gradient(165deg, #2a2312, #14100a); border-color: var(--gold-soft); }
.role-card.spy { background: linear-gradient(165deg, #2e1513, #160a09); border-color: var(--crimson-soft); }
.role-emoji { font-size: 44px; }
.role-name { font-size: 24px; font-weight: 800; margin-top: 6px; letter-spacing: 2px; }
.role-card.guard .role-name { color: var(--gold); }
.role-card.spy .role-name { color: #e88; }
.role-fac { font-size: 13px; color: var(--muted); margin-top: 3px; }
.role-desc { font-size: 13px; color: var(--text); margin-top: 12px; line-height: 1.55; opacity: .92; }
.role-intel { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); font-size: 13px; }
.role-intel b { color: var(--gold); }
.role-card.spy .role-intel b { color: #e88; }

/* 행동 버튼 */
.actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.act { padding: 13px; border-radius: 11px; border: 1px solid var(--line); background: var(--bg2);
  color: var(--text); font-weight: 700; cursor: pointer; font-family: inherit; font-size: 15px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; }
.act small { font-weight: 500; color: var(--muted); font-size: 11px; }
.act:disabled { opacity: .4; cursor: not-allowed; }
.act.sel { border-color: var(--gold); background: var(--gold-soft); color: var(--gold); }
.act.wide { grid-column: 1 / -1; }

.targets { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 4px; }
.tgt { padding: 9px 13px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg2);
  color: var(--text); cursor: pointer; font-family: inherit; font-size: 14px; font-weight: 700; }
.tgt.sel { border-color: var(--crimson); background: var(--crimson-soft); color: #f9b; }
.tgt:disabled { opacity: .35; }

.waiting { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; justify-content: center; }
.dotpulse { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); animation: pulse 1.1s infinite; }
@keyframes pulse { 0%,100%{opacity:.3} 50%{opacity:1} }

/* 좌석 */
.seats-wrap { }
.seats-title { font-size: 12px; color: var(--muted); font-weight: 700; letter-spacing: 1px; margin-bottom: 8px; }
.seats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.seat { display: flex; align-items: center; gap: 9px; padding: 10px 11px; border-radius: 11px;
  background: var(--card); border: 1px solid var(--line); }
.seat.dead { opacity: .5; }
.seat.me { border-color: var(--gold); }
.seat .av { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: var(--bg2); font-size: 13px; font-weight: 800; flex: none; }
.seat .info { flex: 1; min-width: 0; }
.seat .nm { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat .meta { font-size: 11px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.seat .host { color: var(--gold); }
.seat .rv { font-size: 11px; padding: 1px 6px; border-radius: 5px; font-weight: 700; }
.seat .rv.guard { color: var(--gold); background: var(--gold-soft); }
.seat .rv.spy { color: #e88; background: var(--crimson-soft); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.dot.off { background: #566; }
.chk { color: var(--green); }
.dead-x { color: var(--crimson); font-weight: 800; }

/* 채팅 */
.chatbox { display: flex; flex-direction: column; gap: 8px; }
.chatlog { height: 168px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 11px; padding: 10px; }
.cmsg { font-size: 13px; line-height: 1.4; }
.cmsg b { color: var(--gold); }
.cmsg.sys { color: var(--muted); font-style: italic; }
.chatrow { display: flex; gap: 7px; }
.chatrow input { flex: 1; }
.chatrow .btn { width: auto; padding: 12px 16px; }

/* 로그 */
.logwrap { }
.log { display: flex; flex-direction: column; gap: 6px; }
.lentry { font-size: 13px; padding: 9px 12px; border-radius: 9px; background: var(--card);
  border: 1px solid var(--line); border-left: 3px solid var(--muted); line-height: 1.45; }
.lentry.TRIANGLE { border-left-color: #b06; }
.lentry.DUEL { border-left-color: var(--blue); }
.lentry.BLOCK { border-left-color: var(--green); }
.lentry.FOCUS { border-left-color: var(--crimson); }
.lentry.KILL { border-left-color: var(--crimson); }
.lentry.EXECUTE { border-left-color: var(--gold); }
.lentry.INFO { border-left-color: var(--line); color: var(--muted); }
.lentry .cyc { color: var(--muted); font-size: 11px; margin-right: 6px; }

/* 설정 토글 */
.toggles { display: flex; flex-direction: column; gap: 4px; }
.tog { display: flex; align-items: center; justify-content: space-between; padding: 9px 2px; font-size: 14px; }
.tog small { color: var(--muted); font-size: 11px; display: block; }
.switch { width: 44px; height: 26px; border-radius: 999px; background: var(--line); position: relative;
  cursor: pointer; flex: none; transition: background .15s; }
.switch.on { background: var(--gold); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; transition: left .15s; }
.switch.on::after { left: 21px; }
.scout-note { background: var(--bg2); border: 1px solid var(--blue); border-radius: 10px; padding: 11px;
  font-size: 13px; line-height: 1.5; margin-top: 8px; }
.scout-note b { color: var(--blue); }
