/*
  공개 대기방 — 조각보 문법 위에 얹습니다(patch.css 토큰만 씁니다).
  방 하나가 천 조각 하나. 조각 사이 솔기는 2px, 게임마다 라운지와 같은 물감을 씁니다.
*/
.public-lobby {
  width: 100%; margin: 40px auto 0; padding: 0;
  color: var(--ink); font-family: var(--font); text-align: left;
}
.public-lobby[hidden], .room-management[hidden] { display: none !important; }
.halli-main > .public-lobby { width: min(1200px, 100% - 2 * var(--gutter, 24px)); margin-bottom: 40px; }
.hub-page .public-lobby { margin: 28px 0 12px; }

/* ---------- 머리 ---------- */
.lobby-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; margin-bottom: 14px; }
.lobby-title { min-width: 0; }
.lobby-head h2 { font-size: var(--text-xl); }
.public-lobby[data-scope="game"] .lobby-head h2 { font-size: var(--text-lg); }
.lobby-online {
  display: flex; align-items: center; gap: 8px; margin-top: 6px;
  color: var(--ink-soft); font-size: var(--text-sm); font-weight: 620; font-variant-numeric: tabular-nums;
}
.lobby-online.is-live::before, .presence-inline.is-live::before {
  content: ''; flex: none; width: 8px; height: 8px; border-radius: 1px; background: var(--mugwort);
}
.lobby-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- 게임별 보기 (라운지) ---------- */
.lobby-filter {
  display: flex; width: fit-content; max-width: 100%; margin-bottom: 14px;
  gap: var(--seam-width); border: var(--seam-width) solid var(--seam); border-radius: var(--radius);
  background: var(--seam); overflow: hidden;
}
.lobby-filter-option {
  min-height: 38px; padding: 0 14px; gap: 7px;
  border: 0; border-radius: 0; background: var(--sheet); font-weight: 650;
}
.lobby-filter-option:hover:not(:disabled) { background: var(--sheet-hover); }
.lobby-filter-option[aria-pressed="true"], .lobby-filter-option[aria-pressed="true"]:hover:not(:disabled) { background: var(--ink); color: var(--on-dye); }
.lobby-filter-option:focus-visible { outline-offset: -5px; }
.lobby-filter-option[aria-pressed="true"]:focus-visible { outline-color: var(--on-dye); }
.lobby-filter-count { min-width: 1ch; color: var(--ink-soft); font-weight: 760; font-variant-numeric: tabular-nums; }
.lobby-filter-option[aria-pressed="true"] .lobby-filter-count { color: var(--gardenia); }

/* ---------- 방 조각 ----------
   조각마다 2px 솔기를 바깥으로 둘러 격자 사이 솔기가 한 줄로 이어지게 합니다(흐림 없는 선). */
.public-room-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 264px), 1fr));
  gap: var(--seam-width); padding: var(--seam-width);
}
.public-room {
  --dye: var(--seam-strong); --dye-ink: var(--on-dye); --seat: var(--ink);
  display: flex; flex-direction: column; min-width: 0;
  background: var(--sheet); box-shadow: 0 0 0 var(--seam-width) var(--seam-strong);
}
.public-room[data-game="blokus"] { --dye: var(--indigo-tint); --dye-ink: var(--ink); --seat: var(--indigo); }
.public-room[data-game="president"] { --dye: var(--safflower); --dye-ink: var(--on-dye); --seat: var(--safflower); }
.public-room[data-game="davinci"] { --dye: var(--ink); --dye-ink: var(--on-dye); --seat: var(--ink); }
.public-room[data-game="halli"] { --dye: var(--gardenia); --dye-ink: var(--ink); --seat: var(--gardenia); }
.room-game {
  padding: 7px 14px; background: var(--dye); color: var(--dye-ink);
  font-size: var(--text-sm); font-weight: 720; letter-spacing: -.01em;
}
.public-lobby[data-scope="game"] .public-room { border-top: 4px solid var(--dye); }
.room-body { display: grid; gap: 8px; padding: 14px 14px 12px; min-width: 0; }
.room-name {
  font-size: var(--text-lg); line-height: 1.25; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
}
.room-host { display: flex; gap: 6px; min-width: 0; font-size: var(--text-sm); color: var(--ink-soft); }
.room-host-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-weight: 650; }
.room-seats { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: var(--text-sm); font-weight: 650; font-variant-numeric: tabular-nums; }
.room-limit { padding: 0 6px; border: var(--seam-width) solid var(--seam-strong); border-radius: var(--radius-small); color: var(--ink); font-size: var(--text-xs); font-weight: 750; white-space: nowrap; }
.seat-blocks { display: flex; gap: 3px; }
.seat-blocks i { width: 14px; height: 14px; border: 1.5px solid var(--seam); border-radius: 1px; background: var(--sheet); }
.seat-blocks i.taken { border-color: var(--seat); background: var(--seat); }
.room-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding: 0 14px 14px; }
.room-status {
  display: inline-flex; align-items: center; min-height: 26px; padding: 0 8px;
  border: 1.5px solid var(--seam-strong); border-radius: var(--radius-small);
  background: var(--cloth-deep); color: var(--ink); font-size: var(--text-xs); font-weight: 720;
}
.public-room[data-status="waiting"] .room-status { border-color: var(--mugwort); background: var(--mugwort-tint); }
.public-room[data-status="full"] .room-status { border-color: var(--safflower); background: var(--safflower-tint); }
.room-join { min-width: 96px; }
/* 들어갈 수 없는 방은 바탕 모시 색으로 한 톤 물립니다. */
.public-room:not([data-status="waiting"]) { background: var(--cloth); }
.public-room:not([data-status="waiting"]) .room-name { color: var(--ink-soft); }
.public-room:not([data-status="waiting"]) .room-foot { min-height: 54px; }

/* ---------- 비었음 · 불러오는 중 · 오류 ---------- */
.lobby-state {
  grid-column: 1 / -1; display: grid; justify-items: start; gap: 6px;
  padding: 22px 20px; background: var(--sheet); box-shadow: 0 0 0 var(--seam-width) var(--seam-strong);
}
.lobby-state h3 { font-size: var(--text-md); }
.lobby-state p { max-width: 54ch; color: var(--ink-soft); font-size: var(--text-sm); }
.lobby-state .btn { margin-top: 8px; }
.lobby-state[data-state="error"] { background: var(--safflower-tint); box-shadow: 0 0 0 var(--seam-width) var(--safflower); }
.lobby-state[data-state="error"] p { color: var(--ink); }
.lobby-state-blocks { margin-bottom: 4px; }
.lobby-state-blocks i { animation: seat-fill 1.6s var(--ease) infinite; }
.lobby-state-blocks i:nth-child(2) { animation-delay: .2s; }
.lobby-state-blocks i:nth-child(3) { animation-delay: .4s; }
.lobby-state-blocks i:nth-child(4) { animation-delay: .6s; }
@keyframes seat-fill { 0%, 100% { background: var(--sheet); border-color: var(--seam); } 40%, 60% { background: var(--indigo); border-color: var(--indigo); } }

.lobby-message { margin-top: 12px; color: var(--ink-soft); font-size: var(--text-sm); font-weight: 600; }
.lobby-message:empty { display: none; }
.lobby-message[data-tone="error"] {
  padding: 10px 14px; border: 1.5px solid var(--safflower); border-radius: var(--radius);
  background: var(--safflower-tint); color: var(--ink);
}

/* ---------- 방 만들기 입력 ---------- */
.lobby-create-fields { display: grid; gap: 6px; margin: 14px 0; text-align: left; }
.lobby-create-fields label:not(:first-child) { margin-top: 6px; }
.lobby-create-fields input, .lobby-create-fields select { width: 100%; min-width: 0; }

/* ---------- 접속 인원 ---------- */
.game-online { display: block; margin-top: 12px; font-size: var(--text-sm); font-weight: 720; font-variant-numeric: tabular-nums; }
.presence-inline {
  display: inline-flex; align-items: center; gap: 6px; align-self: center; margin-right: 8px;
  color: var(--ink-soft); font-size: var(--text-xs); font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums;
}

/* 할리갈리 머리줄은 솔기로 이은 칸이라, 배지도 한 칸으로 채웁니다. */
.header-tools > .presence-inline { align-self: stretch; margin: 0; padding: 0 16px; background: var(--sheet); }

/* ---------- 방 관리 (방장 강퇴) ---------- */
.room-management { width: 100%; margin-top: 16px; padding-top: 14px; border-top: var(--seam-width) solid var(--seam); color: var(--ink); }
/* 프레지던트·다빈치 대기실은 솔기로 이은 칸 묶음이라 한 조각으로 들어갑니다. */
.waiting-room > .room-management { margin: 0; padding: 18px 32px; border-top: 0; }
.room-management-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 10px; }
.room-management h3 { min-width: 0; font-size: var(--text-lg); overflow-wrap: anywhere; }
.room-visibility, .room-member-tag {
  display: inline-flex; align-items: center; min-height: 22px; padding: 0 7px;
  border: 1.5px solid var(--seam); border-radius: var(--radius-small);
  background: var(--sheet); color: var(--ink-soft); font-size: var(--text-xs); font-weight: 720;
}
.room-members { display: grid; gap: var(--seam-width); border: var(--seam-width) solid var(--seam); border-radius: var(--radius); background: var(--seam); overflow: hidden; }
.room-member { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 6px 8px 6px 12px; background: var(--sheet); font-size: var(--text-md); }
.room-member-name { display: flex; align-items: center; gap: 8px; min-width: 0; overflow-wrap: anywhere; font-weight: 620; }
.room-member-tag.host { border-color: var(--indigo); background: var(--indigo-tint); color: var(--ink); }
.room-member-tag.me { border-color: var(--mugwort); background: var(--mugwort-tint); color: var(--ink); }
.room-kick { flex: none; min-height: 36px; padding: 0 12px; border-color: var(--safflower); color: var(--safflower); }
.room-kick:hover:not(:disabled) { background: var(--safflower-tint); }

/* ---------- 강퇴 확인 ---------- */
.lobby-confirm { width: min(440px, calc(100vw - 32px)); padding: 24px; }
.lobby-confirm h2 { margin-bottom: 10px; font-size: var(--text-lg); }
.lobby-confirm p { color: var(--ink-soft); font-size: var(--text-md); line-height: 1.6; }
.lobby-confirm .lobby-confirm-error { margin-top: 10px; color: var(--safflower); font-size: var(--text-sm); font-weight: 650; }
.lobby-confirm-error:empty { display: none; }
.lobby-confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ---------- 블로커스: 판 아래 접이식 ---------- */
.blokus-page { grid-template-rows: var(--header-height) minmax(0,1fr) auto; }
.blokus-lobby { background: var(--sheet); border-top: var(--seam-width) solid var(--seam); }
.blokus-lobby summary { cursor: pointer; padding: 10px 20px; font-size: var(--text-sm); font-weight: 700; }
.blokus-lobby summary:hover { background: var(--sheet-hover); }
.blokus-lobby .public-lobby { margin: 0; padding: 4px 20px 18px; max-height: 44dvh; overflow-y: auto; }
.blokus-lobby .lobby-head h2 { display: none; }
.blokus-lobby .lobby-head { align-items: center; margin-bottom: 12px; }
.blokus-lobby .lobby-online { margin-top: 0; }
.blokus-lobby:has(.public-lobby[hidden]) { display: none; }

@media (max-width: 640px) {
  .public-lobby { margin-top: 24px; }
  .lobby-head { flex-direction: column; align-items: stretch; gap: 12px; }
  .lobby-head h2 { font-size: var(--text-lg); }
  .public-lobby[data-scope="game"] .lobby-actions > .btn { flex: 1 1 0; }
  /* 좁은 화면에서는 한 줄로 두고 옆으로 밀어 봅니다. */
  .lobby-filter { overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
  .lobby-filter::-webkit-scrollbar { display: none; }
  .lobby-filter-option { flex: none; padding: 0 12px; }
  .room-body { padding: 12px 12px 10px; gap: 6px; }
  .room-foot { padding: 0 12px 12px; }
  .presence-inline { margin-right: 4px; }
  .blokus-toolbar .presence-inline { display: none; }
  .blokus-lobby .public-lobby { padding: 4px 16px 16px; }
  .blokus-lobby .lobby-head { align-items: stretch; }
  .waiting-room > .room-management { padding: 16px 20px; }
}
