/* ============================================================
   끝말잇기 — 모노톤 에디토리얼 디자인 시스템 (v2)
   헤어라인 구조 · 위계 있는 타이포 · 모노 숫자 · 잇는 글자 시그니처
   ============================================================ */

:root {
  --bg: #eeeeef;
  --surface: #ffffff;
  --raise: #fafafb;
  --field: #ffffff;
  --ink: #16161a;
  --ink-2: #56565e;
  --ink-3: #8b8b93;
  --ink-4: #b8b8bf;
  --hair: #e7e7ea;
  --hair-2: #d9d9de;
  --primary: #16161a;
  --primary-ink: #ffffff;
  --primary-hover: #2a2a30;
  --focus: rgba(22, 22, 26, 0.13);
  --p0-bg: #16161a;
  --p0-ink: #ffffff;
  --p1-bg: #ffffff;
  --p1-ink: #16161a;
  --p1-br: #cfcfd6;
  --good: #1c8a5a;
  --danger: #d4453e;
  --danger-soft: #fbeae9;
  --sh-card: 0 1px 2px rgba(17, 17, 19, 0.04), 0 8px 30px rgba(17, 17, 19, 0.05);
  --sh-pop: 0 16px 50px rgba(17, 17, 19, 0.2);
  --r1: 12px;
  --r2: 16px;
  --r3: 20px;
  --pill: 999px;
  --mono: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #0a0a0b;
    --surface: #161618;
    --raise: #1c1c1f;
    --field: #1c1c1f;
    --ink: #f3f3f5;
    --ink-2: #aeaeb6;
    --ink-3: #84848c;
    --ink-4: #55555c;
    --hair: #262629;
    --hair-2: #34343a;
    --primary: #f3f3f5;
    --primary-ink: #161618;
    --primary-hover: #e2e2e6;
    --focus: rgba(243, 243, 245, 0.14);
    --p0-bg: #f3f3f5;
    --p0-ink: #161618;
    --p1-bg: #222226;
    --p1-ink: #f3f3f5;
    --p1-br: #3a3a40;
    --good: #34c98a;
    --danger: #f06a63;
    --danger-soft: #2e1d1c;
    --sh-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 30px rgba(0, 0, 0, 0.4);
    --sh-pop: 0 16px 50px rgba(0, 0, 0, 0.6);
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0a0a0b;
  --surface: #161618;
  --raise: #1c1c1f;
  --field: #1c1c1f;
  --ink: #f3f3f5;
  --ink-2: #aeaeb6;
  --ink-3: #84848c;
  --ink-4: #55555c;
  --hair: #262629;
  --hair-2: #34343a;
  --primary: #f3f3f5;
  --primary-ink: #161618;
  --primary-hover: #e2e2e6;
  --focus: rgba(243, 243, 245, 0.14);
  --p0-bg: #f3f3f5;
  --p0-ink: #161618;
  --p1-bg: #222226;
  --p1-ink: #f3f3f5;
  --p1-br: #3a3a40;
  --good: #34c98a;
  --danger: #f06a63;
  --danger-soft: #2e1d1c;
  --sh-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 30px rgba(0, 0, 0, 0.4);
  --sh-pop: 0 16px 50px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}
body {
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.012em;
  transition: background-color 0.4s var(--ease), color 0.4s var(--ease);
}
[hidden] {
  display: none !important;
}
::selection {
  background: var(--ink);
  color: var(--surface);
}

/* 라벨 (에디토리얼 캡션) */
.lab {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  text-transform: uppercase;
}

/* ---------- 공통 컨트롤 ---------- */
.input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
  background: var(--field);
  border: 1.5px solid var(--hair-2);
  border-radius: var(--r1);
  outline: none;
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease),
    background 0.4s var(--ease), color 0.4s var(--ease);
}
.input::placeholder {
  color: var(--ink-4);
  font-weight: 500;
}
.input:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 4px var(--focus);
}
.input:disabled {
  background: var(--raise);
  color: var(--ink-4);
  border-color: var(--hair);
}

.btn {
  height: 52px;
  padding: 0 20px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  border: none;
  border-radius: var(--r1);
  cursor: pointer;
  color: var(--ink);
  background: var(--raise);
  transition: transform 0.1s var(--ease), background 0.18s var(--ease),
    opacity 0.18s, border-color 0.18s, color 0.4s var(--ease);
  letter-spacing: -0.01em;
}
.btn:active {
  transform: scale(0.975);
}
.btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--primary);
  color: var(--primary-ink);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}
.btn-line {
  background: var(--surface);
  border: 1.5px solid var(--hair-2);
}
.btn-line:hover:not(:disabled) {
  border-color: var(--ink-3);
}
.btn-ghost {
  height: 40px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 600;
  background: transparent;
  color: var(--ink-2);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--raise);
}
.btn-ghost.danger {
  color: var(--danger);
}
.btn-block {
  width: 100%;
}

/* ---------- 입장 화면 ---------- */
.entry {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 24px;
}
.entry-card {
  width: 100%;
  max-width: 396px;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r3);
  box-shadow: var(--sh-card);
  padding: 38px 30px 30px;
  animation: rise 0.5s var(--ease-out);
}
.brand {
  text-align: center;
  margin-bottom: 30px;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 19px;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 31px;
  font-weight: 800;
}
.brand-title {
  margin: 18px 0 7px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.04em;
}
.brand-sub {
  margin: 0;
  font-size: 14px;
  color: var(--ink-3);
  font-weight: 500;
}
.field {
  display: block;
  margin-bottom: 14px;
}
.field-label {
  display: block;
  margin: 0 0 8px 2px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.or {
  position: relative;
  text-align: center;
  margin: 20px 0;
}
.or::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--hair);
}
.or span {
  position: relative;
  background: var(--surface);
  padding: 0 12px;
  font-size: 13px;
  color: var(--ink-4);
  font-weight: 500;
}
.join-row {
  display: flex;
  gap: 8px;
}
.input-code {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-weight: 700;
  font-family: var(--mono);
}
.join-row .btn {
  flex: 0 0 92px;
}
.entry-error {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--danger);
  font-weight: 600;
  text-align: center;
}
.entry-foot {
  font-size: 12px;
  color: var(--ink-4);
  font-weight: 500;
}

/* ---------- 탑바 ---------- */
.room {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--hair);
}
.topbar-inner {
  max-width: 980px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
}
.brandbar {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}
.brandbar-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
}
.brandbar-name {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.03em;
}
.topbar-mid {
  flex: 1;
  display: flex;
  justify-content: center;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: var(--r1);
  font-size: 19px;
  color: var(--ink-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}
.icon-btn:hover {
  background: var(--raise);
  color: var(--ink);
}
.icon-btn svg {
  width: 19px;
  height: 19px;
}
.codechip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 38px;
  padding: 0 15px;
  border: 1.5px solid var(--hair-2);
  background: var(--surface);
  border-radius: var(--pill);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.16s var(--ease), transform 0.1s var(--ease);
}
.codechip:hover {
  border-color: var(--ink-3);
}
.codechip:active {
  transform: scale(0.97);
}
.codechip-label {
  font-size: 10px;
  color: var(--ink-4);
  font-weight: 700;
  letter-spacing: 0.06em;
}
.codechip-code {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--ink);
  font-family: var(--mono);
}
.codechip-copy {
  font-size: 12px;
  color: var(--ink-2);
  font-weight: 700;
}

/* ---------- 셸 / 레이아웃 ---------- */
.shell {
  flex: 1;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 18px 20px 28px;
}
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 322px;
  gap: 16px;
  align-items: start;
}
.board {
  min-width: 0;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r3);
  box-shadow: var(--sh-card);
  overflow: hidden;
  transition: background 0.4s var(--ease), border-color 0.4s var(--ease);
}

/* 플레이어 */
.panel-players {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  align-items: stretch;
}
.panel-divider {
  background: var(--hair);
}
.seat {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 18px;
  position: relative;
  min-width: 0;
  transition: background 0.25s var(--ease);
}
.seat--1 {
  flex-direction: row-reverse;
  text-align: right;
}
.seat-avatar {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
}
.seat--0 .seat-avatar {
  background: var(--p0-bg);
  color: var(--p0-ink);
}
.seat--1 .seat-avatar {
  background: var(--p1-bg);
  color: var(--p1-ink);
  border: 1.5px solid var(--p1-br);
}
.seat-info {
  min-width: 0;
  flex: 1;
}
.seat-nick {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seat-state {
  text-transform: none;
  letter-spacing: 0.01em;
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 600;
  margin-top: 2px;
}
.seat.is-turn {
  background: var(--raise);
}
.seat.is-turn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--ink);
  animation: fade 0.3s var(--ease-out);
}
.seat.is-turn .seat-state {
  color: var(--ink);
}
.seat.is-win::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--good);
}
.seat.is-win .seat-state {
  color: var(--good);
}
.seat.is-me .seat-nick::after {
  content: '나';
  margin-left: 6px;
  font-size: 10px;
  font-weight: 800;
  color: var(--ink-2);
  background: var(--raise);
  border: 1px solid var(--hair-2);
  padding: 1px 6px;
  border-radius: var(--pill);
  vertical-align: middle;
}
.seat--1.is-me .seat-nick::after {
  margin-left: 0;
  margin-right: 6px;
}
.seat.is-off {
  opacity: 0.5;
}

/* 다음 글자 히어로 + 매너 */
.panel-hero {
  border-top: 1px solid var(--hair);
  background: var(--raise);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.next {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}
.next-label {
  margin: 0;
}
.next-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}
.next-prev {
  font-size: 15px;
  color: var(--ink-4);
  font-weight: 600;
  max-width: 9em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.next-arrow {
  color: var(--ink-4);
  font-size: 15px;
}
.next-char {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 0.92;
  color: var(--ink);
}
.next-char.is-free {
  font-size: 30px;
}
.next-alt {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  border: 1px solid var(--hair-2);
  border-radius: var(--pill);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
  align-self: center;
}
.manner {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px 0 11px;
  border-radius: var(--pill);
  border: 1.5px solid var(--hair-2);
  background: var(--surface);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-3);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.16s var(--ease);
  white-space: nowrap;
}
.manner-track {
  width: 28px;
  height: 17px;
  border-radius: var(--pill);
  background: var(--hair-2);
  position: relative;
  transition: background 0.2s var(--ease);
  flex: 0 0 auto;
}
.manner-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s var(--ease-out);
}
.manner[aria-pressed='true'] {
  color: var(--ink);
  border-color: var(--ink);
}
.manner[aria-pressed='true'] .manner-track {
  background: var(--ink);
}
.manner[aria-pressed='true'] .manner-track::after {
  transform: translateX(11px);
}
.manner:disabled {
  cursor: default;
  opacity: 0.75;
}

/* 배너 */
.banner {
  margin: 14px 18px 0;
  background: var(--surface);
  border: 1px solid var(--ink);
  border-radius: var(--r1);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  animation: rise 0.3s var(--ease-out);
}
.banner .banner-msg {
  flex: 1;
}
.banner .btn {
  height: 38px;
  padding: 0 15px;
  font-size: 14px;
}
.status-banner {
  margin: 14px 18px 0;
  text-align: center;
  padding: 16px;
  border-radius: var(--r1);
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-2);
  background: var(--raise);
  border: 1px solid var(--hair);
  animation: rise 0.3s var(--ease-out);
}
.status-banner.win {
  background: var(--surface);
  border-color: var(--ink);
  color: var(--ink);
}
.status-banner .big {
  font-size: 22px;
  font-weight: 800;
  display: block;
  margin-bottom: 3px;
  letter-spacing: -0.03em;
}

/* ---------- 기보 ---------- */
.panel-kibo {
  border-top: 1px solid var(--hair);
  padding: 8px 18px 14px;
}
.chain-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 2px 10px;
}
.chain-title {
  margin: 0;
}
.chain-rule {
  flex: 1;
  height: 1px;
  background: var(--hair);
}
.chain-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-4);
  font-family: var(--mono);
  letter-spacing: 0.02em;
}
.chain-copy {
  height: 28px;
  padding: 0 12px;
  font-size: 11.5px;
  font-weight: 700;
  font-family: inherit;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--hair-2);
  border-radius: var(--pill);
  cursor: pointer;
  transition: border-color 0.16s var(--ease), color 0.16s;
}
.chain-copy:hover {
  border-color: var(--ink-3);
  color: var(--ink);
}
.chain {
  min-height: 280px;
  max-height: min(50vh, 480px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}
.chain-empty {
  margin: auto;
  text-align: center;
  color: var(--ink-4);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.7;
  padding: 30px 0;
}
.chain-empty .ce-mark {
  font-size: 38px;
  font-weight: 800;
  color: var(--hair-2);
  display: block;
  margin-bottom: 10px;
}

.ki-head {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  text-decoration-color: var(--ink-4);
  opacity: 0.92;
}
/* 넘기는 글자(연결 글자)는 또렷한 칩으로 — 긴 단어가 줄바꿈돼도 어디서 잇는지 명확 */
.ki-tail {
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 8px;
  margin: 0 1px;
  white-space: nowrap;
}
.ki--0 .ki-tail {
  background: var(--p0-ink);
  color: var(--p0-bg);
}
.ki--1 .ki-tail {
  background: var(--p1-ink);
  color: var(--p1-bg);
}
.ki-num {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}
.ki-clickable {
  cursor: pointer;
}

/* (A) 좌우 분리 */
.chain[data-mode='sides'] {
  gap: 3px;
}
.chain[data-mode='sides'] .ki-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  animation: rise 0.3s var(--ease-out);
}
.chain[data-mode='sides'] .ki--1 {
  flex-direction: row-reverse;
}
.chain[data-mode='sides'] .ki-num {
  flex: 0 0 22px;
  font-size: 12px;
  text-align: right;
}
.chain[data-mode='sides'] .ki--1 .ki-num {
  text-align: left;
}
.chain[data-mode='sides'] .ki-dot,
.chain[data-mode='sides'] .ki-arrow {
  display: none;
}
.chain[data-mode='sides'] .ki-bubble {
  display: inline-flex;
  align-items: baseline;
  padding: 9px 15px;
  border-radius: 14px;
  font-size: 20px;
  font-weight: 700;
  max-width: 70%;
  overflow-wrap: anywhere;
  border: 1.5px solid transparent;
  transition: transform 0.12s var(--ease), border-color 0.12s var(--ease);
}
.chain[data-mode='sides'] .ki--0 .ki-bubble {
  background: var(--p0-bg);
  color: var(--p0-ink);
}
.chain[data-mode='sides'] .ki--1 .ki-bubble {
  background: var(--p1-bg);
  color: var(--p1-ink);
  border-color: var(--p1-br);
}
.chain[data-mode='sides'] .ki--0 .ki-head {
  text-decoration-color: color-mix(in srgb, var(--p0-ink) 55%, transparent);
}
.ki-who {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-4);
  white-space: nowrap;
  max-width: 84px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chain[data-mode='sides'] .ki-clickable:hover {
  transform: translateY(-1px);
  border-color: var(--ink);
}

/* (B) 한 줄 흐름 */
.chain[data-mode='flow'] {
  flex-direction: row;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px 3px;
  padding-top: 4px;
}
.chain[data-mode='flow'] .ki-row {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  animation: fade 0.26s var(--ease-out);
}
.chain[data-mode='flow'] .ki-num,
.chain[data-mode='flow'] .ki-who,
.chain[data-mode='flow'] .ki-dot {
  display: none;
}
.chain[data-mode='flow'] .ki-bubble {
  display: inline-flex;
  align-items: baseline;
  padding: 6px 13px;
  border-radius: var(--pill);
  font-size: 16px;
  font-weight: 700;
  overflow-wrap: anywhere;
  border: 1.5px solid var(--hair-2);
  background: var(--surface);
  transition: transform 0.12s var(--ease), border-color 0.12s;
}
.chain[data-mode='flow'] .ki--0 .ki-bubble {
  background: var(--p0-bg);
  color: var(--p0-ink);
  border-color: transparent;
}
.chain[data-mode='flow'] .ki--1 .ki-bubble {
  background: var(--p1-bg);
  color: var(--p1-ink);
  border-color: var(--p1-br);
}
.chain[data-mode='flow'] .ki--0 .ki-head {
  text-decoration-color: color-mix(in srgb, var(--p0-ink) 55%, transparent);
}
.chain[data-mode='flow'] .ki-arrow {
  color: var(--ink-4);
  font-size: 13px;
  font-weight: 700;
  margin: 0 1px;
}
.chain[data-mode='flow'] .ki-row:last-child .ki-arrow {
  display: none;
}
.chain[data-mode='flow'] .ki-clickable:hover {
  transform: translateY(-1px);
  border-color: var(--ink);
}

/* (C) 컴팩트 */
.chain[data-mode='compact'] {
  gap: 0;
}
.chain[data-mode='compact'] .ki-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 9px;
  animation: fade 0.22s var(--ease-out);
}
.chain[data-mode='compact'] .ki-row:nth-child(odd) {
  background: var(--raise);
}
.chain[data-mode='compact'] .ki-num {
  flex: 0 0 24px;
  font-size: 12px;
  text-align: right;
}
.chain[data-mode='compact'] .ki-dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.chain[data-mode='compact'] .ki--0 .ki-dot {
  background: var(--ink);
}
.chain[data-mode='compact'] .ki--1 .ki-dot {
  background: var(--surface);
  border: 1.5px solid var(--ink-3);
}
.chain[data-mode='compact'] .ki-bubble {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.chain[data-mode='compact'] .ki-who {
  max-width: 100px;
}
.chain[data-mode='compact'] .ki-arrow {
  display: none;
}
.chain[data-mode='compact'] .ki-clickable:hover .ki-bubble {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- 입력 ---------- */
.panel-input {
  border-top: 1px solid var(--hair);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.inputbar {
  display: flex;
  gap: 8px;
}
.word-input {
  flex: 1;
  height: 54px;
  font-size: 18px;
  font-weight: 700;
}
.inputbar .btn {
  flex: 0 0 92px;
  height: 54px;
}
.play-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.play-actions .sit,
.play-actions #btn-start,
.play-actions #btn-restart {
  height: 44px;
  font-size: 15px;
}
.toast {
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
  font-weight: 700;
  padding: 11px 14px;
  border-radius: var(--r1);
  animation: shake 0.34s var(--ease);
}

/* ---------- 사이드: 관전 + 채팅 ---------- */
.side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: calc(100vh - 116px);
  max-height: 760px;
  position: sticky;
  top: 78px;
}
.side-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--hair);
}
.spec-title {
  font-size: 14px;
  font-weight: 700;
}
.spec-list {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 180px;
}
.msg {
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
  animation: fade 0.2s var(--ease-out);
}
.msg.pending {
  opacity: 0.5;
}
.msg-head {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-right: 6px;
}
.msg-tag {
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: var(--pill);
  background: var(--raise);
  border: 1px solid var(--hair-2);
  color: var(--ink-3);
}
.msg-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.msg-dot--0 {
  background: var(--ink);
}
.msg-dot--1 {
  background: var(--surface);
  border: 1.5px solid var(--ink-3);
}
.msg-nick {
  font-weight: 700;
  color: var(--ink-2);
  font-size: 13px;
}
.msg-text {
  color: var(--ink);
}
.msg-sys {
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-4);
  font-weight: 500;
  padding: 2px 0;
  animation: fade 0.2s var(--ease-out);
}
.chat-inputbar {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--hair);
}
.chat-input {
  flex: 1;
  height: 46px;
  font-size: 15px;
}
.chat-send {
  flex: 0 0 64px;
  height: 46px;
  padding: 0;
  font-size: 15px;
}

/* ---------- 설정 시트 ---------- */
.sheet-scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(8, 8, 10, 0.46);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade 0.18s var(--ease-out);
}
.sheet {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r3);
  box-shadow: var(--sh-pop);
  padding: 22px;
  animation: rise 0.26s var(--ease-out);
}
.sheet-head {
  display: flex;
  align-items: center;
  margin-bottom: 18px;
}
.sheet-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.sheet-close {
  margin-left: auto;
}
.set-group {
  margin-bottom: 20px;
}
.set-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
  margin: 0 2px 9px;
}
.set-hint {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-4);
  margin: 8px 2px 0;
  line-height: 1.5;
}
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  background: var(--raise);
  border: 1px solid var(--hair);
  border-radius: var(--r1);
  padding: 4px;
}
.seg {
  height: 38px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-3);
  cursor: pointer;
  transition: background 0.16s var(--ease), color 0.16s var(--ease);
}
.seg:hover {
  color: var(--ink);
}
.seg.is-on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--sh-card);
}
:root[data-theme='dark'] .seg.is-on {
  background: var(--p1-bg);
}

/* ---------- 애니메이션 ---------- */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(9px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

/* ---------- 반응형 ---------- */
@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .side {
    position: static;
    height: auto;
    max-height: none;
  }
  .chat {
    max-height: 300px;
  }
  .chain {
    max-height: 44vh;
  }
  .shell {
    padding: 14px 14px 24px;
  }
  .brandbar-name {
    display: none;
  }
}
@media (max-width: 440px) {
  .panel-hero {
    gap: 12px;
  }
  .manner {
    margin-left: 0;
  }
  .next-char {
    font-size: 38px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* 스크롤바 */
.chain::-webkit-scrollbar,
.chat::-webkit-scrollbar {
  width: 8px;
}
.chain::-webkit-scrollbar-thumb,
.chat::-webkit-scrollbar-thumb {
  background: var(--hair-2);
  border-radius: 8px;
}
.chain::-webkit-scrollbar-track,
.chat::-webkit-scrollbar-track {
  background: transparent;
}

/* ============================================================
   응원객 / 격리벽 / 응원 연출
   ============================================================ */

/* 좌석 응원 카운트 */
.seat-cheer {
  position: absolute;
  top: 9px;
  font-size: 11px;
  font-weight: 800;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--hair-2);
  border-radius: var(--pill);
  padding: 2px 8px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  animation: rise 0.25s var(--ease-out);
}
.seat--0 .seat-cheer {
  right: 14px;
}
.seat--1 .seat-cheer {
  left: 14px;
}
.sc-ico {
  color: var(--danger);
  font-size: 10px;
}
.seat-cheer.bump {
  animation: cheerBump 0.4s var(--ease-out);
}
@keyframes cheerBump {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* 응원 콘솔(관전자) */
.cheer-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--raise);
  border: 1px solid var(--hair);
  border-radius: var(--r1);
}
.cheer-pick {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cheer-pick .lab {
  flex: 0 0 auto;
  margin-right: 2px;
}
.cheer-target {
  flex: 1;
  height: 40px;
  border-radius: 10px;
  border: 1.5px solid var(--hair-2);
  background: var(--surface);
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink-3);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color 0.15s var(--ease), color 0.15s, background 0.15s;
}
.cheer-target:hover {
  border-color: var(--ink-3);
}
.cheer-target.on {
  border-color: var(--ink);
  color: var(--primary-ink);
  background: var(--ink);
}
.cheer-kinds {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.cheer-kind {
  height: 46px;
  border-radius: 11px;
  border: 1.5px solid var(--hair-2);
  background: var(--surface);
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.1s var(--ease), border-color 0.15s, opacity 0.15s;
}
.cheer-kind:hover:not(:disabled) {
  border-color: var(--ink-3);
}
.cheer-kind:active:not(:disabled) {
  transform: scale(0.95);
}
.cheer-kind:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

/* 응원 연출 레이어 */
.cheer-fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  overflow: hidden;
}
.cheer-emoji {
  position: fixed;
  bottom: 130px;
  animation: cheerFloat 1.5s var(--ease-out) forwards;
}
@keyframes cheerFloat {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0.5) rotate(-8deg);
  }
  15% {
    opacity: 1;
    transform: translateY(-14px) scale(1.15) rotate(4deg);
  }
  100% {
    opacity: 0;
    transform: translateY(-240px) scale(0.95) rotate(-4deg);
  }
}
.cheer-name {
  position: fixed;
  bottom: 96px;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hair-2);
  border-radius: var(--pill);
  padding: 3px 11px;
  box-shadow: var(--sh-card);
  animation: cheerName 1.5s var(--ease-out) forwards;
  max-width: 40vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@keyframes cheerName {
  0% { opacity: 0; transform: translateY(10px); }
  18% { opacity: 1; transform: translateY(0); }
  78% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-14px); }
}

/* 격리벽 토글 */
.wall-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 2px;
  border-top: 1px solid var(--hair);
}
.wall-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.wtoggle {
  width: 46px;
  height: 26px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
}
.wtoggle .manner-track {
  width: 44px;
  height: 26px;
}
.wtoggle .manner-track::after {
  width: 22px;
  height: 22px;
  top: 2px;
  left: 2px;
}
.wtoggle[aria-pressed='true'] .manner-track {
  background: var(--ink);
}
.wtoggle[aria-pressed='true'] .manner-track::after {
  transform: translateX(18px);
}

/* 격리벽: 관전 채팅 숨김 */
.chat.mute-spec .msg.is-spec {
  display: none;
}

/* ============================================================
   끝말/앞말 모드 토글 + 시작/끝 안내
   ============================================================ */
.hero-toggles {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.manner {
  margin-left: 0;
}
.modepill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 14px;
  border-radius: var(--pill);
  border: 1.5px solid var(--ink);
  background: var(--ink);
  color: var(--primary-ink);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: opacity 0.16s var(--ease), transform 0.1s var(--ease);
}
.modepill:active {
  transform: scale(0.97);
}
.modepill:disabled {
  cursor: default;
  opacity: 0.85;
}
.modepill-ico {
  font-size: 14px;
  opacity: 0.7;
}
.next-suffix {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-3);
  align-self: flex-end;
  margin-bottom: 4px;
}

/* ============================================================
   로비 (방 목록 + 만들기 + 비번방)
   ============================================================ */
.lobby {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 20px 36px;
  gap: 16px;
}
.lobby-wrap {
  width: 100%;
  max-width: 560px;
}
.lobby-head {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r3);
  box-shadow: var(--sh-card);
  padding: 22px;
  margin-bottom: 20px;
  animation: rise 0.45s var(--ease-out);
}
.brand-row {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 18px;
}
.brand-row .brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  font-size: 22px;
  flex: 0 0 auto;
}
.brand-text {
  flex: 1;
  min-width: 0;
}
.brand-row .brand-title {
  margin: 0;
  font-size: 21px;
  letter-spacing: -0.04em;
}
.brand-row .brand-sub {
  margin: 2px 0 0;
  font-size: 13px;
}
.brand-row .icon-btn {
  flex: 0 0 auto;
}
.nick-row {
  display: flex;
  gap: 8px;
  margin-bottom: 9px;
}
.nick-row .input {
  flex: 1;
}
.nick-row .btn {
  flex: 0 0 auto;
  padding: 0 18px;
}
.lobby .join-row .btn {
  flex: 0 0 auto;
  padding: 0 16px;
}
.lobby-list-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 4px 12px;
}
.lobby-rule {
  flex: 1;
  height: 1px;
  background: var(--hair);
}
#lobby-refresh {
  height: 26px;
}
.lobby-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.lobby-empty {
  text-align: center;
  color: var(--ink-4);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.7;
  padding: 40px 0;
  border: 1px dashed var(--hair-2);
  border-radius: var(--r2);
}
.room-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r2);
  padding: 14px 16px;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
  box-shadow: var(--sh-card);
  transition: transform 0.12s var(--ease), border-color 0.14s var(--ease);
  animation: rise 0.3s var(--ease-out);
}
.room-card:hover {
  transform: translateY(-1px);
  border-color: var(--ink);
}
.room-card:active {
  transform: scale(0.99);
}
.rc-no {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 800;
  color: var(--ink-2);
  background: var(--raise);
  border: 1px solid var(--hair-2);
  border-radius: 9px;
  padding: 7px 10px;
  min-width: 46px;
  text-align: center;
}
.rc-main {
  flex: 1;
  min-width: 0;
}
.rc-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rc-lock {
  display: inline-flex;
  color: var(--ink-3);
  flex: 0 0 auto;
}
.rc-lock svg {
  width: 13px;
  height: 13px;
}
.rc-meta {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 500;
}
.rc-right {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}
.rc-state {
  font-size: 11px;
  font-weight: 800;
  color: var(--ink-3);
  background: var(--raise);
  border: 1px solid var(--hair-2);
  border-radius: var(--pill);
  padding: 2px 9px;
}
.rc-state.on {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}
.rc-seats {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-4);
  font-family: var(--mono);
}
.set-opt {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-4);
  margin-left: 4px;
}
@media (max-width: 480px) {
  .nick-row {
    flex-wrap: wrap;
  }
  .nick-row .btn {
    flex: 1;
  }
}

/* ============================================================
   턴 타이머
   ============================================================ */
.seat-clock {
  margin-top: 5px;
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
  transition: color 0.2s var(--ease);
}
.seat--1 .seat-clock {
  text-align: right;
}
.seat-clock.active {
  color: var(--ink);
}
.seat-clock.low {
  color: var(--danger);
}
.seat-clock.crit {
  color: var(--danger);
  animation: clockPulse 1s ease-in-out infinite;
}
@keyframes clockPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* 단어 뺏기 버튼 */
.btn-steal {
  height: 44px;
  padding: 0 18px;
  font-size: 15px;
  font-weight: 800;
  background: var(--ink);
  color: var(--surface);
  border: 1.5px solid var(--ink);
  animation: stealPop 0.3s var(--ease-out);
}
.btn-steal:hover:not(:disabled) {
  background: var(--primary-hover);
}
@keyframes stealPop {
  0% { transform: scale(0.9); opacity: 0; }
  60% { transform: scale(1.04); }
  100% { transform: scale(1); opacity: 1; }
}

/* ============================================================
   훈수꾼: 단어폭 + 훈수 표시
   ============================================================ */
.bank {
  border: 1px solid var(--hair);
  border-radius: var(--r1);
  background: var(--raise);
  overflow: hidden;
}
.bank-head {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 11px 13px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
}
.bank-mark {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--ink);
  color: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  flex: 0 0 auto;
}
.bank-title {
  font-weight: 800;
  font-size: 14px;
  letter-spacing: -0.02em;
}
.bank-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-4);
}
.bank-chev {
  margin-left: auto;
  color: var(--ink-3);
  display: flex;
  transition: transform 0.2s var(--ease);
}
.bank-chev svg {
  width: 18px;
  height: 18px;
}
.bank.open .bank-chev {
  transform: rotate(180deg);
}
.bank-body {
  border-top: 1px solid var(--hair);
  padding: 11px 13px 13px;
}
.bank-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 11px;
}
.bank-sep {
  width: 1px;
  height: 16px;
  background: var(--hair-2);
  margin: 0 2px;
}
.bank-pill {
  height: 28px;
  padding: 0 11px;
  border-radius: var(--pill);
  border: 1px solid var(--hair-2);
  background: var(--surface);
  color: var(--ink-2);
  font-weight: 700;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.14s var(--ease);
}
.bank-pill.on {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}
.bk-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
}
.bank-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 6px;
  max-height: 234px;
  overflow-y: auto;
}
.bank-w {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 11px;
  border-radius: 9px;
  border: 1px solid var(--hair);
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
  transition: transform 0.1s var(--ease), border-color 0.12s var(--ease);
}
.bank-w:hover {
  transform: translateY(-1px);
  border-color: var(--ink);
}
.bw-t {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bw-n {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-4);
  flex: 0 0 auto;
}
.bank-w.kill {
  border-color: var(--danger);
}
.bw-kill {
  font-size: 9px;
  font-weight: 800;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--pill);
  padding: 0 5px;
  flex: 0 0 auto;
}
.bank-more {
  width: 100%;
  margin-top: 9px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--hair-2);
  background: var(--surface);
  color: var(--ink-2);
  font-weight: 700;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
}
.bank-more:hover {
  border-color: var(--ink-3);
  color: var(--ink);
}

/* 훈수 도착(모두에게) */
.tips-strip {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 12px;
  border: 1px solid var(--ink);
  border-radius: var(--r1);
  background: var(--surface);
  animation: rise 0.3s var(--ease-out);
}
.tips-label {
  flex: 0 0 auto;
  margin-top: 5px;
}
.tips-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  flex: 1;
  min-width: 0;
}
.tip-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: var(--pill);
  border: 1.5px solid var(--hair-2);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.1s var(--ease), border-color 0.12s var(--ease);
}
.tip-chip:hover {
  transform: translateY(-1px);
  border-color: var(--ink);
}
.tc-word {
  font-size: calc(14px + (var(--big) - 1) * 2px);
  font-weight: 800;
}
.tip-chip.multi {
  border-color: var(--ink-3);
}
.tip-chip.top {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
  animation: tipTop 0.4s var(--ease-out);
}
@keyframes tipTop {
  0% { transform: scale(0.94); }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); }
}
.tc-count {
  font-size: 11px;
  font-weight: 800;
  background: var(--danger);
  color: #fff;
  border-radius: var(--pill);
  padding: 1px 7px;
}
.tip-chip.top .tc-count {
  background: var(--surface);
  color: var(--ink);
}
.tc-who {
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-4);
}
.tip-chip.top .tc-who {
  color: var(--p1-br);
}

/* ============================================================
   레이아웃 폭 전환 (아담 ↔ 넓게) — data-layout="wide"
   ============================================================ */
[data-layout='wide'] .topbar-inner,
[data-layout='wide'] .shell {
  max-width: 1320px;
}
/* 넓게: 게임 영역은 더 넓게, 채팅 칼럼은 약간만 키움 */
@media (min-width: 980px) {
  [data-layout='wide'] .layout {
    grid-template-columns: minmax(0, 1fr) 360px;
  }
}
/* 로비도 넓게 */
[data-layout='wide'] .lobby-wrap {
  max-width: 1080px;
}
/* 넓은 화면에서 로비 방 목록을 2열로 */
@media (min-width: 720px) {
  [data-layout='wide'] .lobby-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    align-items: start;
  }
}
@media (min-width: 1180px) {
  [data-layout='wide'] .lobby-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ============================================================
   이용 가이드 시트 (게임 방법)
   ============================================================ */
.sheet-guide {
  max-width: 520px;
  max-height: 84vh;
  display: flex;
  flex-direction: column;
}
.guide-body {
  overflow-y: auto;
  margin: 2px -4px 0;
  padding: 4px 4px 2px;
}
.guide-intro {
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink-2);
  margin: 0 0 18px;
}
.guide-sect {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  text-transform: uppercase;
  margin: 20px 0 10px;
}
.guide-sect:first-of-type {
  margin-top: 4px;
}
.guide-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 0 0 13px;
}
.gi-ic {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--raise);
  border: 1px solid var(--hair-2);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 700;
  margin-top: 1px;
}
.gi-ic svg {
  width: 15px;
  height: 15px;
}
.guide-item > div {
  flex: 1;
  font-size: 13.5px;
  line-height: 1.62;
  color: var(--ink-2);
}
.guide-item b {
  color: var(--ink);
  font-weight: 700;
}
.guide-foot {
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-3);
  margin: 14px 0 2px;
  padding-top: 14px;
  border-top: 1px solid var(--hair);
}
.guide-foot b {
  color: var(--ink-2);
}

/* ============================================================
   모바일 최적화 (≤600px) — 상단바/히어로/기보/입력 재설계
   ============================================================ */
@media (max-width: 600px) {
  /* 상단바: 절대 줄바꿈 안 되게 + 코드칩 복사 텍스트 숨김 */
  .topbar-inner {
    gap: 4px;
    padding: 8px 10px;
    flex-wrap: nowrap;
  }
  .topbar-mid {
    min-width: 0;
  }
  .codechip {
    height: 34px;
    padding: 0 11px;
    gap: 6px;
    min-width: 0;
    max-width: 100%;
  }
  .codechip-copy {
    display: none; /* "초대 링크 복사" 텍스트 숨김 — 칩을 탭하면 복사돼요 */
  }
  .codechip-label {
    font-size: 9px;
  }
  .codechip-code {
    font-size: 13px;
    letter-spacing: 0.1em;
  }
  .icon-btn {
    width: 36px;
    height: 36px;
  }
  .icon-btn svg {
    width: 18px;
    height: 18px;
  }
  .topbar-right {
    gap: 2px;
  }
  .brandbar {
    gap: 7px;
  }

  /* 셸 여백 축소 + 하단 안전영역(아이폰 홈바) */
  .shell {
    padding: 12px 12px calc(22px + env(safe-area-inset-bottom));
  }

  /* 좌석 컴팩트 */
  .seat {
    padding: 9px 12px;
    gap: 9px;
  }
  .seat-avatar {
    flex-basis: 30px;
    width: 30px;
    height: 30px;
    font-size: 14px;
    border-radius: 9px;
  }
  .seat-nick {
    font-size: 13.5px;
  }
  .seat-state {
    font-size: 11px;
  }
  .seat-clock {
    font-size: 15px;
    margin-top: 3px;
  }

  /* 다음 글자 히어로: 글자/여백 더 축소, 토글은 아래 줄 전체로 */
  .panel-hero {
    padding: 10px 12px;
    gap: 8px 10px;
  }
  .next {
    gap: 5px;
  }
  .next-char {
    font-size: 27px;
  }
  .next-char.is-free {
    font-size: 19px;
  }
  .next-prev {
    max-width: 6.5em;
    font-size: 13px;
  }
  .next-alt {
    font-size: 12px;
    padding: 3px 9px;
  }
  .hero-toggles {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
    gap: 6px;
  }

  /* 기보 단어 버블: 폰트 축소 + 폭 확대 + 강제 줄바꿈(긴 단어 오버플로우 방지) */
  .chain[data-mode='sides'] .ki-bubble,
  .chain[data-mode='flow'] .ki-bubble,
  .chain[data-mode='compact'] .ki-bubble {
    font-size: 15px;
    padding: 6px 11px;
    max-width: 76vw;
    overflow-wrap: anywhere;
    word-break: break-all;
  }
  .chain {
    max-height: 40vh;
  }
  .chain-head {
    padding: 8px 2px 8px;
  }

  /* 입력/제출: 탭하기 편하게 + iOS 자동 확대 방지(16px) */
  .inputbar {
    gap: 7px;
  }
  .word-input {
    height: 46px;
    font-size: 16px;
  }
  .inputbar .btn-primary {
    height: 46px;
    padding: 0 18px;
  }

  /* 모드/매너 알약 더 축소 */
  .modepill,
  .manner {
    height: 30px;
    padding: 0 11px;
    font-size: 11px;
    gap: 6px;
  }

  /* 플레이 액션 버튼 줄 약간 축소 */
  .play-actions .sit,
  .play-actions #btn-start,
  .play-actions #btn-restart {
    height: 40px;
    font-size: 14px;
  }

  /* 단어폭/채팅 높이 모바일에 맞게 */
  .chat {
    max-height: 240px;
  }

  /* 가로 스크롤 방지 */
  .board,
  .panel {
    min-width: 0;
  }
}

/* 아주 좁은 기기(≤380px) 추가 보정 */
@media (max-width: 380px) {
  .next-char {
    font-size: 30px;
  }
  .codechip-label {
    display: none; /* 'CODE' 라벨도 숨겨 코드만 */
  }
  .chain[data-mode='sides'] .ki-bubble,
  .chain[data-mode='flow'] .ki-bubble,
  .chain[data-mode='compact'] .ki-bubble {
    font-size: 15px;
    max-width: 72vw;
  }
}

/* ============================================================
   입력 독 고정 — 보드 카드를 화면 높이에 맞추고 기보만 내부 스크롤
   (채팅 .side와 동일한 패턴으로 입력창이 항상 보이게)
   ============================================================ */
.board {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.board > .panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - 116px);
}
.board > .panel > * {
  flex: 0 0 auto;
}
.board > .panel > .panel-kibo {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.panel-kibo .chain {
  flex: 1 1 auto;
  min-height: 88px;
  max-height: none;
}
.panel-input {
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 12px;
}
.action-dock {
  background: var(--surface);
}

/* 고정된 입력창 옆 '현재 글자' 미니 표시 — 스크롤해도 무슨 글자인지 보임 */
.dock-next {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 54px;
  height: 54px;
  padding: 0 14px;
  border-radius: var(--r1);
  background: var(--ink);
  color: var(--surface);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* 모바일: dvh 기준 + 단어폭 그리드 더 낮게 + 미니 글자 축소 */
@media (max-width: 860px) {
  .board > .panel {
    max-height: calc(100dvh - 88px);
  }
}
@media (max-width: 600px) {
  .bank-grid {
    max-height: 150px;
  }
  .dock-next {
    min-width: 42px;
    height: 46px;
    font-size: 17px;
    padding: 0 10px;
  }
  .inputbar .btn {
    flex-basis: 72px;
  }
}

/* 방 나가기 버튼 — 게임 액션과 분리(오른쪽), 은은하게 */
.play-actions .exit {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-3);
}
.play-actions .exit svg {
  width: 16px;
  height: 16px;
}
.play-actions .exit:hover:not(:disabled) {
  color: var(--danger);
  background: var(--danger-soft);
}
@media (max-width: 600px) {
  .play-actions .exit {
    height: 38px;
    font-size: 13px;
  }
}

/* ============================================================
   계정 / 구글 로그인 (로비 헤더)
   ============================================================ */
.auth-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 12px;
  min-height: 40px;
}
.auth-row:empty {
  display: none;
}
/* 구글 로그인 버튼 */
.btn-google {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 42px;
  padding: 0 16px;
  border-radius: var(--r1);
  border: 1.5px solid var(--hair-2);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.16s var(--ease), background 0.16s var(--ease);
}
.btn-google:hover {
  border-color: var(--ink-3);
  background: var(--raise);
}
.btn-google .g-ico {
  width: 18px;
  height: 18px;
  flex: none;
}
.auth-hint {
  font-size: 12px;
  color: var(--ink-4);
  font-weight: 500;
}
/* 로그인된 계정 칩 */
.acct {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 5px 6px 5px 5px;
  border: 1.5px solid var(--hair-2);
  border-radius: var(--pill);
  background: var(--surface);
  min-width: 0;
}
.acct-av {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex: none;
  object-fit: cover;
  background: var(--raise);
}
.acct-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}
.acct-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 12em;
}
.acct-nick {
  font-size: 11px;
  color: var(--ink-3);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.acct-nick .vchk {
  color: var(--good);
  font-weight: 800;
}
.acct-logout {
  margin-left: 4px;
  height: 30px;
  padding: 0 11px;
  border-radius: var(--pill);
  border: none;
  background: transparent;
  color: var(--ink-3);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.acct-logout:hover {
  background: var(--raise);
  color: var(--ink);
}
/* 닉네임이 계정에 묶였을 때 입력칸 잠금 표시 */
.nick-row .input.is-locked {
  background: var(--raise);
  color: var(--ink-2);
}
@media (max-width: 600px) {
  .btn-google { height: 40px; font-size: 13px; }
  .acct-name { max-width: 8em; }
}
