/* 방 화면 공용 부품(room-kit.js)의 스타일. 위 제시/상태 줄, 좌우 플레이어, 가운데 stage, 아래 채팅. */
.rk {
  display: grid;
  grid-template-columns: 156px minmax(0, 1fr) 156px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "top top top" "left center right" "chat chat chat";
  gap: 10px;
  width: calc(100% - 40px); /* 상단 바와 같은 너비·같은 좌우 선 */
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 0 14px;
  height: 100%;
}
.rk-top { grid-area: top; display: flex; align-items: center; gap: 12px; padding: 6px 14px; min-width: 0; }
.rk-left { grid-area: left; }
.rk-right { grid-area: right; }
.rk-center { grid-area: center; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.rk-chat { grid-area: chat; display: flex; flex-direction: column; height: 118px; padding: 8px 10px; }

.rk-stage {
  flex: 1; min-height: 0; position: relative; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 18px; text-align: center;
  background: #fff; border: 3px solid var(--blue); border-radius: var(--radius);
}
.rk-stage h3 { margin: 0; font-size: 24px; }
.rk-stage p { margin: 0; }
.rk-stage .big { font-size: 26px; font-weight: 700; }
.rk-stage .sub { color: var(--muted); }

/* ---- 플레이어 카드 ---- */
.rk-side { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; align-content: flex-start; overflow-y: auto; min-height: 0; }
.rk-side li {
  position: relative; flex: none; display: grid; grid-template-columns: 44px minmax(0, 1fr); grid-template-areas: "av name" "av score";
  column-gap: 8px; align-items: center; padding: 6px 8px;
  background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius);
}
.rk-side li .avatar { grid-area: av; width: 44px; height: 44px; }
.rk-side li .name { grid-area: name; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 17px; }
.rk-side li .score { grid-area: score; color: var(--score); font-weight: 700; font-variant-numeric: tabular-nums; font-size: 17px; }
.rk-side li .mark { grid-area: score; justify-self: end; display: flex; gap: 2px; font-size: 16px; }
.rk-side li.is-active { border-color: var(--orange); background: #fff7e8; }
.rk-side li.win { animation: rk-win 1.6s ease-out both; }
@keyframes rk-win { 0%, 35% { background: #c9f0d8; border-color: var(--green); } 100% { background: var(--panel); border-color: var(--line); } }
.rk-side .score.pop { animation: rk-pop .5s ease-out; }
@keyframes rk-pop { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
.rk-side li.pickable { cursor: pointer; }
.rk-side li.pickable:hover { border-color: var(--blue); }
.rk-side li.pickable:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }

/* ---- 채팅 ---- */
.rk-log { flex: 1; min-height: 0; overflow-y: auto; font-size: 17px; display: flex; flex-direction: column; gap: 2px; padding-bottom: 6px; }
.rk-log > div { word-break: break-all; }
.rk-log b { font-weight: 700; color: var(--blue-dark); margin-right: 6px; }
.rk-log .mine b { color: var(--score); }
.rk-log .sys { color: var(--muted); font-size: 16px; }
.rk-log .ok { color: #166a39; font-weight: 700; }
.rk-chat form { display: flex; gap: 6px; }
.rk-chat input { flex: 1; min-width: 0; }

/* ---- 말풍선 (채팅 친 사람의 카드 옆, body에 붙는다) ---- */
.rk-bubble {
  position: fixed; z-index: 40; pointer-events: none;
  max-width: min(220px, 60vw); padding: 6px 12px;
  background: #fff; color: var(--ink); border: 2px solid var(--blue); border-radius: 12px;
  font-size: 17px; line-height: 1.3; word-break: break-all;
  animation: pop-in .15s ease-out;
}
.rk-bubble .t { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.rk-bubble::before, .rk-bubble::after { content: ''; position: absolute; width: 0; height: 0; border: 7px solid transparent; }
.rk-bubble.to-right::before { left: -16px; top: 10px; border-right-color: var(--blue); }
.rk-bubble.to-right::after { left: -13px; top: 10px; border-right-color: #fff; }
.rk-bubble.to-left::before { right: -16px; top: 10px; border-left-color: var(--blue); }
.rk-bubble.to-left::after { right: -13px; top: 10px; border-left-color: #fff; }
.rk-bubble.below::before { left: 18px; top: -16px; border-bottom-color: var(--blue); }
.rk-bubble.below::after { left: 18px; top: -13px; border-bottom-color: #fff; }

/* ---- 방장 메뉴 ---- */
.rk-menu {
  position: fixed; z-index: 45; min-width: 170px; padding: 8px; display: grid; gap: 6px;
  background: #fff; border: 2px solid var(--blue); border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(20, 50, 90, .25);
}
.rk-menu .who { margin: 0 4px; color: var(--muted); font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.rk-menu button { justify-content: flex-start; text-align: left; min-height: 44px; }
.rk-menu .danger { color: #fff; background: var(--danger); border-color: #8f2323; }
.rk-menu .danger:hover:not(:disabled) { background: #a62828; border-color: #8f2323; }

/* ---- 방 설정 창 ---- */
.rk-modal { position: fixed; inset: 0; z-index: 30; background: rgba(20, 50, 90, .45); display: grid; place-items: center; }
.rk-modal[hidden] { display: none; }
.rk-modal .box { padding: 22px; width: min(420px, 92vw); max-height: 92vh; overflow-y: auto; display: grid; gap: 14px; }
.rk-modal h3 { margin: 0; font-size: 20px; }
.rk-modal label:not(.chk) { display: grid; gap: 4px; font-weight: 600; color: var(--muted); }
.rk-modal .error { margin: 0; }
.rk-modal .actions { display: flex; justify-content: flex-end; gap: 8px; position: sticky; bottom: -22px; margin-bottom: -22px; padding: 10px 0 22px; background: var(--panel); }

/* 방 화면 가운데 버튼 줄 */
.rk-hostbtns { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; }

/* ---- 좁은 화면: 위에서 아래로 쌓는다 ---- */
@media (max-width: 860px) {
  .rk { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-template-areas: "top" "left" "right" "center" "chat"; height: auto; width: auto; margin: 0 10px; padding: 10px 0; }
  .rk-side { flex-direction: row; flex-wrap: wrap; overflow: visible; }
  .rk-side li { flex: 1 1 140px; }
  .rk-stage { min-height: 320px; }
  .rk-chat { height: 200px; }
  .rk-top { flex-wrap: wrap; }
}
