/* 모두의 퍼즐 — 한봇 게임즈 화면 (2026-11-18). 배치 바탕은 public/css/boardgame/room.css 공용 틀, 여기는 색 토큰과 퍼즐 고유 요소만.
 * 토큰: 퍼즐 매트 펠트(청록 결) 바탕 + 퍼즐 상자 판지색 강조. 서체는 게임즈 공용 제목체(hb-games-display)·본문체 + 숫자는 고정폭 숫자.
 * 시그니처 = 다 맞추면 조각 사이 이음매가 대각선으로 한 번에 녹아 한 장의 그림이 되는 순간(render.js uSweep). 나머지는 조용하게. */
.jg-root, .jg-overlay {
    --bg-bg: #142827;          /* 매트 바깥 */
    --bg-panel: #1b3533;       /* 매트 */
    --bg-line: #2d4c49;
    --bg-ink: #eaf0e6;
    --bg-dim: #93aba5;
    --bg-accent: #d6b183;      /* 퍼즐 상자 판지 */
    --bg-accent-ink: #2b1f0f;
    --bg-warn: #ff9a85;
    --bg-line-2: color-mix(in srgb, var(--bg-ink) 22%, var(--bg-panel));
    --bg-soft: color-mix(in srgb, var(--bg-panel) 70%, var(--bg-bg));
    --jg-felt: #23403f;        /* 판 바탕 — render.js R.felt와 같은 색 */
}
.jg-root :focus-visible, .jg-overlay :focus-visible { outline: 2px solid var(--bg-accent); outline-offset: 2px; }

/* 대기실 */
.jg-lobby { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 14px; align-items: start; }
.jg-lobby > * { min-width: 0; }
.jg-lead { margin: 0 0 10px; font-size: 0.86rem; line-height: 1.7; color: var(--bg-ink); }
.jg-dev { margin: 12px 0 0; font-size: 0.8rem; color: var(--bg-dim); }
.jg-dev b { color: var(--bg-ink); }
.jg-how { list-style: none; margin: 12px 0 0; padding: 12px 0 0; border-top: 1px solid var(--bg-line); display: grid; gap: 6px; font-size: 0.8rem; line-height: 1.6; color: var(--bg-dim); }
.jg-how b { color: var(--bg-ink); margin-right: 4px; }
.jg-code { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--bg-line); display: grid; gap: 6px; }
.jg-code label { font-size: 0.82rem; color: var(--bg-ink); font-weight: 700; }
.jg-rooms { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 10px; }
.jg-room-card { display: grid; grid-template-columns: 96px 1fr; grid-template-rows: 1fr auto; gap: 8px 12px; background: var(--bg-soft); border: 1px solid var(--bg-line); border-radius: 12px; padding: 10px; }
.jg-room-card .jg-thumb { grid-row: 1 / 3; }
.jg-thumb { position: relative; aspect-ratio: 3 / 2; border-radius: 8px; overflow: hidden; background: var(--jg-felt); }
.jg-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.jg-prog { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: rgba(0, 0, 0, 0.45); }
.jg-prog i { display: block; height: 100%; width: var(--p, 0%); background: var(--bg-accent); }
.jg-rmain { min-width: 0; }
.jg-rtitle { color: var(--bg-ink); font-weight: 700; font-size: 0.92rem; overflow-wrap: anywhere; }
.jg-rsub { font-size: 0.76rem; color: var(--bg-dim); margin-top: 4px; }
.jg-rsub b { color: var(--bg-ink); }
.jg-rwarn { font-size: 0.74rem; color: var(--bg-warn); margin-top: 4px; }
.jg-ract { display: flex; justify-content: flex-end; align-items: end; }
.jg-mine { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--bg-line); }
.jg-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; }

/* 방 — 판이 화면 높이를 꽉 채우게 */
.jg-room { display: grid; grid-template-columns: minmax(0, 1fr) clamp(260px, 22vw, 380px); gap: 12px; height: calc(100dvh - var(--topbar-h, 0px) - 16px); min-height: 380px; scroll-margin-top: calc(var(--topbar-h, 0px) + 8px); position: relative; }
.jg-stage { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.jg-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.jg-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; flex: 1 1 200px; }
.jg-title b { font-family: "hb-games-display", var(--font-sans); font-weight: 400; color: var(--bg-ink); font-size: clamp(1.05rem, 0.95rem + 0.4vw, 1.4rem); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jg-title span { font-size: 0.76rem; color: var(--bg-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jg-progress { position: relative; flex: 0 1 260px; min-width: 150px; height: 24px; border-radius: 999px; background: var(--bg-soft); border: 1px solid var(--bg-line); overflow: hidden; }
.jg-progress i { position: absolute; inset: 0 auto 0 0; width: var(--p, 0%); background: color-mix(in srgb, var(--bg-accent) 55%, var(--bg-panel)); transition: width 0.4s ease; }
.jg-progress span { position: relative; display: block; text-align: center; font-size: 0.74rem; line-height: 22px; color: var(--bg-ink); font-variant-numeric: tabular-nums; }
.jg-time { font-size: 0.9rem; color: var(--bg-ink); min-width: 4.5em; text-align: right; }
.jg-conn { font-size: 0.76rem; color: var(--bg-warn); }
.jg-side-btn { display: none; }
.jg-board { position: relative; flex: 1; min-height: 0; border-radius: 14px; overflow: hidden; background: var(--jg-felt); border: 1px solid var(--bg-line); }
.jg-board canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#jg-canvas { touch-action: none; outline: none; }
#jg-canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--bg-accent); }
.jg-arrow { pointer-events: none; }
.jg-ov { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.jg-tag { position: absolute; left: 0; top: 0; translate: -50% -100%; padding: 2px 8px; border-radius: 999px; background: var(--c); color: #10201f; font-size: 0.72rem; font-weight: 700; white-space: nowrap; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35); }
.jg-cur { position: absolute; left: 0; top: 0; display: flex; align-items: flex-start; gap: 2px; color: var(--c); }
.jg-cur svg { fill: var(--c); stroke: #10201f; stroke-width: 1; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.4)); }
.jg-cur span { margin-top: 12px; padding: 1px 6px; border-radius: 6px; background: rgba(16, 32, 31, 0.8); font-size: 0.68rem; white-space: nowrap; }
.jg-preview { position: absolute; right: 10px; top: 10px; margin: 0; width: clamp(140px, 22%, 320px); padding: 6px; border-radius: 10px; background: rgba(16, 32, 31, 0.88); border: 1px solid var(--bg-line); }
.jg-preview img { width: 100%; display: block; border-radius: 6px; }
.jg-preview .jg-zoom-btn { width: 100%; }
.jg-preview figcaption { font-size: 0.7rem; color: var(--bg-dim); text-align: center; margin-top: 4px; }
.jg-msg { position: absolute; left: 50%; top: 50%; translate: -50% -50%; max-width: min(90%, 420px); padding: 14px 18px; border-radius: 12px; background: var(--bg-panel); color: var(--bg-ink); border: 1px solid var(--bg-line); text-align: center; font-size: 0.9rem; line-height: 1.6; }
.jg-tools { position: absolute; left: 50%; bottom: 12px; translate: -50% 0; display: flex; gap: 6px; padding: 6px; border-radius: 14px; background: rgba(16, 32, 31, 0.86); border: 1px solid var(--bg-line); backdrop-filter: blur(4px); max-width: calc(100% - 20px); overflow-x: auto; }
.jg-tool { font: inherit; font-size: 0.8rem; color: var(--bg-ink); background: transparent; border: 1px solid transparent; border-radius: 9px; padding: 7px 12px; cursor: pointer; white-space: nowrap; min-height: 36px; }
.jg-tool:hover { border-color: var(--bg-line-2); }
.jg-tool[aria-pressed="true"] { background: var(--bg-accent); color: var(--bg-accent-ink); font-weight: 700; }
.jg-tool[aria-expanded="true"] { border-color: var(--bg-accent); }
/* 판 배경 색 고르기 — 도구 줄 바로 위 (내 화면에만 적용) */
.jg-bgpick { position: absolute; left: 50%; bottom: 64px; translate: -50% 0; display: grid; gap: 8px; padding: 10px 12px; border-radius: 14px; background: rgba(16, 32, 31, 0.92); border: 1px solid var(--bg-line); backdrop-filter: blur(4px); width: max-content; max-width: calc(100% - 20px); }
.jg-bgpick-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.jg-bgpick-note { flex: 1; white-space: nowrap; font-size: 0.74rem; color: var(--bg-ink-3, var(--bg-ink)); opacity: 0.8; }
.jg-sw { width: 32px; height: 32px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.35); background: var(--sw); cursor: pointer; padding: 0; position: relative; overflow: hidden; }
.jg-sw[aria-pressed="true"] { border-color: var(--bg-accent); box-shadow: 0 0 0 2px var(--bg-accent); }
.jg-sw:focus-visible, .jg-sw-pick:focus-within { outline: 2px solid var(--bg-accent); outline-offset: 2px; }
.jg-sw-pick { background: conic-gradient(#e55, #ec5, #5c7, #5ae, #a6e, #e55); }
.jg-sw-pick input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.jg-tool:disabled { opacity: 0.5; cursor: default; }

/* 옆 칸: 사람·채팅 */
/* 아래 칸은 공용 '전체 채팅'·'게임 설명' 단추(오른쪽 아래 고정)가 덮는 자리 — 방 채팅 입력칸이 가려지지 않게 비움 */
.jg-side { display: flex; flex-direction: column; gap: 10px; min-height: 0; padding-bottom: 116px; }
.jg-people-panel { flex: 0 1 auto; display: flex; flex-direction: column; min-height: 0; max-height: 55%; }
.jg-ph { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.jg-ph h2 { margin: 0 0 8px; font-size: 1rem; color: var(--bg-ink); font-weight: 800; }
.jg-ph h2 small { font-weight: 400; color: var(--bg-dim); font-size: 0.78rem; margin-left: 4px; }
.jg-code-show { font-size: 0.78rem; color: var(--bg-dim); }
.jg-code-show b { color: var(--bg-accent); }
.jg-people { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; overflow-y: auto; min-height: 0; }
.jg-person { display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; align-items: center; padding: 5px 6px; border-radius: 8px; font-size: 0.84rem; }
.jg-person.me { background: var(--bg-soft); }
.jg-person.off { opacity: 0.5; }
.jg-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.jg-pnick { color: var(--bg-ink); min-width: 0; overflow-wrap: anywhere; }
.jg-pn { color: var(--bg-ink); font-weight: 700; font-size: 0.82rem; }
.jg-pmenu { font: inherit; background: transparent; border: 1px solid var(--bg-line-2); color: var(--bg-ink); border-radius: 8px; min-width: 32px; min-height: 28px; cursor: pointer; }
.jg-host { margin-top: 8px; }
.jg-leave-row { margin-top: 8px; justify-content: flex-end; }
.jg-chat-panel { flex: 1; display: flex; flex-direction: column; min-height: 160px; }
.jg-chat-panel h2 { margin: 0 0 8px; font-size: 1rem; color: var(--bg-ink); }
.jg-chat { flex: 1; max-height: none; min-height: 60px; align-content: start; }

/* 기록 창 — 판 위 왼쪽에 떠 있는 창(판을 가리지 않게 좁게) */
.jg-log { position: absolute; left: 10px; top: 46px; bottom: 70px; width: min(360px, calc(100% - 20px)); z-index: 5; display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--bg-panel) 96%, transparent); border: 1px solid var(--bg-line); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); }
.jg-log-head { display: flex; align-items: center; justify-content: space-between; }
.jg-log-head h2 { margin: 0; font-size: 1rem; color: var(--bg-ink); }
.jg-log-filter { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.jg-log-filter select { flex: 1; min-width: 0; }
.jg-check { font-size: 0.8rem; color: var(--bg-ink); display: inline-flex; gap: 6px; align-items: center; }
.jg-log-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; display: grid; gap: 2px; align-content: start; }
.jg-log-row { width: 100%; display: grid; grid-template-columns: auto auto 1fr; gap: 2px 8px; align-items: baseline; text-align: left; font: inherit; font-size: 0.78rem; color: var(--bg-ink); background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 5px 6px; cursor: pointer; }
.jg-log-row:hover, .jg-log-row.on { border-color: var(--bg-accent); }
.jg-log-row.flag { background: color-mix(in srgb, var(--bg-warn) 12%, transparent); }
.jg-log-row:disabled { cursor: default; }
.jg-lt { color: var(--bg-dim); }
.jg-ln { font-weight: 700; }
.jg-flag { grid-column: 1 / -1; justify-self: start; border-color: var(--bg-warn); color: var(--bg-warn); }
.jg-x { font: inherit; background: transparent; border: 0; color: var(--bg-dim); font-size: 1.4rem; min-width: 40px; min-height: 40px; border-radius: 8px; cursor: pointer; }
.jg-x:hover { color: var(--bg-ink); background: rgba(255, 255, 255, 0.06); }

/* 창 */
.jg-overlay .jg-modal { text-align: left; padding: 0; width: min(440px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; background: var(--bg-panel); border-color: var(--bg-line); color: var(--bg-ink); }
.jg-overlay .jg-modal.wide { width: min(620px, calc(100vw - 24px)); }
.jg-mhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 10px 10px 20px; border-bottom: 1px solid var(--bg-line); }
.jg-mhead h2 { margin: 0; font-size: 1.08rem; font-weight: 800; color: var(--bg-ink); }
.jg-mbody { padding: 16px 20px; overflow-y: auto; }
.jg-mbody p { margin: 0 0 10px; font-size: 0.88rem; color: var(--bg-ink); }
.jg-mact { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding: 12px 20px 16px; border-top: 1px solid var(--bg-line); }
.jg-form { display: grid; gap: 12px; }
.jg-field { border: 1px solid var(--bg-line); border-radius: 10px; padding: 10px 12px; margin: 0; display: grid; gap: 8px; }
.jg-field legend { padding: 0 6px; font-size: 0.82rem; font-weight: 700; color: var(--bg-ink); }
.jg-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.jg-chips .bg-chip { font-variant-numeric: tabular-nums; }
.jg-mbody .jg-hint, .jg-hint { margin: 0; font-size: 0.76rem; color: var(--bg-dim); line-height: 1.6; }
.jg-pick { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.jg-pick-img { display: flex; gap: 10px; align-items: center; flex: 1; min-width: 200px; }
.jg-pick-img img { width: 120px; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 8px; background: var(--jg-felt); }
.jg-pick-img div { display: grid; gap: 2px; }
.jg-pick-img small { color: var(--bg-dim); font-size: 0.76rem; }
.jg-zoom-btn { display: block; padding: 0; margin: 0; border: 0; background: none; border-radius: 8px; cursor: zoom-in; line-height: 0; }
.jg-zoom-btn:focus-visible { outline: 2px solid var(--bg-accent); outline-offset: 2px; }
.jg-overlay .input { background: var(--bg-soft); color: var(--bg-ink); border: 1px solid var(--bg-line-2); border-radius: 8px; padding: 7px 10px; font: inherit; font-size: 0.88rem; margin: 0; width: auto; }
.jg-menu { display: grid; gap: 8px; justify-items: start; }
.jg-danger { border-top: 1px dashed var(--bg-line); padding-top: 10px; display: grid; gap: 6px; justify-items: start; }
.jg-radio { display: flex; gap: 8px; align-items: center; font-size: 0.86rem; color: var(--bg-ink); padding: 3px 0; }
.jg-done-time { font-size: 1rem !important; }
.jg-done-time b { color: var(--bg-accent); font-variant-numeric: tabular-nums; }
.jg-contrib { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.jg-contrib li { display: grid; grid-template-columns: minmax(70px, 30%) 1fr auto; gap: 10px; align-items: center; font-size: 0.84rem; }
.jg-cn { color: var(--bg-ink); font-weight: 700; overflow-wrap: anywhere; }
.jg-cbar { height: 10px; border-radius: 999px; background: var(--bg-soft); overflow: hidden; }
.jg-cbar i { display: block; height: 100%; background: var(--bg-accent); border-radius: 999px; }
.jg-cv { color: var(--bg-dim); font-size: 0.78rem; white-space: nowrap; }

/* 앨범 */
.jg-album { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 12px; }
.jg-album-card { display: grid; gap: 8px; background: var(--bg-soft); border: 1px solid var(--bg-line); border-radius: 12px; padding: 10px; }
.jg-album-card b { color: var(--bg-ink); font-size: 0.9rem; }
.jg-album-card small { display: block; color: var(--bg-dim); font-size: 0.76rem; margin-top: 2px; }
.jg-album-card small b { font-size: inherit; }

/* 태블릿·휴대폰: 옆 칸은 판 위에 여닫는 판으로 */
@media (max-width: 1024px) {
    .jg-lobby { grid-template-columns: 1fr; }
    .jg-room { grid-template-columns: 1fr; }
    .jg-side-btn { display: inline-flex; }
    .jg-side { position: absolute; right: 8px; top: 48px; bottom: 112px; width: min(360px, calc(100% - 16px)); z-index: 6; display: none; padding: 8px; border-radius: 14px; background: var(--bg-bg); border: 1px solid var(--bg-line); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }
    .jg-side.open { display: flex; }
}
@media (max-width: 640px) {
    .jg-room { height: calc(100dvh - var(--topbar-h, 0px) - 8px); gap: 6px; }
    .jg-progress { order: 3; flex: 1 1 100%; }
    .jg-title span { display: none; }
    .jg-room-card { grid-template-columns: 80px 1fr; }
    /* 휴대폰: 아래쪽은 공용 채팅·설명 단추 자리라 도구 줄은 판 위쪽, 미리보기는 왼쪽 아래 */
    .jg-tools { left: 8px; right: 8px; translate: none; top: 8px; bottom: auto; }
    .jg-preview { top: auto; right: auto; bottom: 8px; left: 8px; width: 46%; }
    .jg-tool { padding: 7px 9px; font-size: 0.76rem; }
    .jg-log { top: 60px; bottom: 8px; left: 8px; width: calc(100% - 16px); }
    .jg-contrib li { grid-template-columns: 1fr auto; }
    .jg-cbar { grid-column: 1 / -1; grid-row: 2; }
}
@media (min-width: 2400px) {
    .jg-room { grid-template-columns: minmax(0, 1fr) 460px; }
}
/* 몰입(전체화면) 모드 — 위 칸이 사라진 만큼 판을 키움 */
body.hb-immersive .jg-room { height: calc(100dvh - 16px); }
@media (prefers-reduced-motion: reduce) {
    .jg-progress i { transition: none; }
}
