/* ─────────────────────────────────────────────
 * 속여라! 마피아 (2026-11-13 누구나 게임 개편) — 한봇 게임즈 화면 틀(공용 public/css/boardgame/room.css) 위에 게임 토큰과 마을 판만
 * 소재: 등불이 켜진 밤 마을
 *   밤하늘 #1b2033(바탕) · 판자 #262c44(상자) · 등불 #f2c46b(강조·내 차례) · 핏빛 #e0453e(마피아·경고) · 새벽빛 #9db4ff(밤) · 노을 #ff9a76(투표)
 *   낮은 등불빛, 밤은 새벽빛, 투표는 노을빛 — 예전 진행 화면 색을 그대로 이어 쓴다
 * 시그니처(하나): 단계 띠(.mf-phase) — 밤·낮·투표가 바뀔 때 띠의 하늘색이 한 번 천천히 바뀐다
 * ───────────────────────────────────────────── */
.mf-root, .chat-fab, .chat-panel {
    --mf-night: #1b2033;
    --mf-board: #262c44;
    --mf-lamp: #f2c46b;
    --mf-blood: #e0453e;
    --mf-dawn: #9db4ff;
    --mf-dusk: #ff9a76;
    --bg-bg: var(--mf-night);
    --bg-panel: var(--mf-board);
    --bg-line: color-mix(in srgb, var(--mf-dawn) 18%, var(--mf-board));
    --bg-ink: #eef0f8;
    --bg-dim: color-mix(in srgb, #eef0f8 60%, var(--mf-night));
    --bg-accent: var(--mf-lamp);
    --bg-accent-ink: #2a1f08;
    --bg-warn: var(--mf-blood);
    --chat-accent: var(--mf-lamp);
    --chat-accent-ink: #2a1f08;
}

/* 대기실 */
.mf-root .mf-stack { display: grid; gap: 14px; }
.mf-root .mf-form { display: grid; gap: 10px; }
.mf-root .mf-form .bgs-row input[type="number"], .mf-root .mf-form .bgs-row select { width: 100%; max-width: 12em; }
.mf-root .mf-pool { display: grid; gap: 8px; }
.mf-root .mf-pool-team { border: 1px solid var(--bg-line); border-radius: 10px; padding: 8px 10px; }
.mf-root .mf-pool-team > legend { font-size: 0.8rem; font-weight: 700; color: var(--bg-ink); padding: 0 4px; }
.mf-root .mf-pool-team.mafia { border-left: 3px solid var(--mf-blood); }
.mf-root .mf-pool-team.citizen { border-left: 3px solid var(--mf-dawn); }
.mf-root .mf-pool-team.neutral { border-left: 3px solid var(--mf-lamp); }
.mf-root .mf-pool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(8.5em, 100%), 1fr)); gap: 4px 8px; margin-top: 4px; }
.mf-root .mf-pool-grid label { display: flex; align-items: center; gap: 5px; font-size: 0.8rem; color: var(--bg-ink); cursor: pointer; }
.mf-root .mf-pool-grid input { width: 16px; height: 16px; accent-color: var(--bg-accent); flex-shrink: 0; }
.mf-root .mf-pool-grid input:disabled + span { opacity: 0.7; }
.mf-root .mf-pool-act { display: flex; gap: 6px; flex-wrap: wrap; }
.mf-root .mf-gap { margin-top: 10px; }
.mf-root .mf-roomtags { display: inline-flex; gap: 4px; flex-wrap: wrap; margin-left: 4px; vertical-align: middle; }

/* 방 — 왼쪽 마을 판, 오른쪽 기록·대화·설정 */
.mf-root .mf-room { display: grid; grid-template-columns: minmax(0, 1fr) clamp(290px, 28vw, 460px); gap: 14px; align-items: start; }
.mf-root .mf-main, .mf-root .mf-side { display: grid; gap: 12px; min-width: 0; }

/* 시그니처 — 단계 띠 */
.mf-phase {
    --sky: var(--mf-board);
    display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap;
    border-radius: 14px; padding: clamp(12px, 1.4vw, 20px);
    background: linear-gradient(120deg, color-mix(in srgb, var(--sky) 30%, var(--mf-board)), var(--mf-board) 70%);
    border: 1px solid color-mix(in srgb, var(--sky) 45%, var(--bg-line));
    transition: background 1.2s ease, border-color 1.2s ease;
}
/* 단계 바탕 그림 (2026-11-14) — 흐리게 깔아 위 색 그라데이션(하늘색 변화)을 그대로 살린다. 그림이 없으면 아무것도 안 깔림 */
.mf-phase { position: relative; isolation: isolate; overflow: hidden; }
.mf-phase::before {
    content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: 0.35;
    background: center / cover no-repeat;
    -webkit-mask-image: linear-gradient(90deg, #000 40%, transparent); mask-image: linear-gradient(90deg, #000 40%, transparent);
}
.mf-phase.ph-waiting::before { background-image: url(/img/mafia/art/phase-waiting.webp); }
.mf-phase.ph-night::before { background-image: url(/img/mafia/art/phase-night.webp); }
.mf-phase.ph-day::before { background-image: url(/img/mafia/art/phase-day.webp); }
.mf-phase.ph-vote::before { background-image: url(/img/mafia/art/phase-vote.webp); }
.mf-phase.night { --sky: var(--mf-dawn); }
.mf-phase.day { --sky: var(--mf-lamp); }
.mf-phase.vote { --sky: var(--mf-dusk); }
.mf-phase.finished { --sky: var(--mf-lamp); }
.mf-phase .mf-big { font-family: "hb-games-display", var(--font-sans); font-size: clamp(1.25rem, 1rem + 1vw, 2rem); color: var(--sky); }
.mf-phase.waiting .mf-big { color: var(--bg-ink); }
.mf-phase .mf-sub { font-size: 0.82rem; color: var(--bg-dim); }
.mf-phase .mf-clock { margin-left: auto; font-size: clamp(1.25rem, 1rem + 1vw, 2rem); font-weight: 800; font-variant-numeric: tabular-nums; color: var(--bg-ink); }
.mf-phase .mf-clock.warn { color: var(--mf-blood); }

.mf-banner { text-align: center; padding: 14px; border-radius: 12px; font-size: clamp(1rem, 0.9rem + 0.6vw, 1.4rem); font-weight: 800; border: 1px solid var(--bg-line); }
.mf-banner.mafia { background: color-mix(in srgb, var(--mf-blood) 18%, var(--mf-board)); color: #ffb0ab; }
.mf-banner.citizen { background: color-mix(in srgb, var(--mf-dawn) 16%, var(--mf-board)); color: var(--mf-dawn); }
.mf-banner.jester { background: color-mix(in srgb, var(--mf-lamp) 16%, var(--mf-board)); color: var(--mf-lamp); }
.mf-banner.none { background: var(--bg-soft); color: var(--bg-dim); }
.mf-banner { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
/* 직업·결과 그림 — 크기는 width/height 속성 */
.mf-art { display: inline-block; vertical-align: middle; object-fit: contain; flex: none; }
.mf-banner .mf-art { width: clamp(64px, 16vw, 96px); height: auto; aspect-ratio: 1; }
.mf-mine .mf-role .mf-art { width: clamp(64px, 18vw, 96px); height: auto; aspect-ratio: 1; }

/* 내 직업 */
.mf-mine { display: grid; gap: 6px; background: var(--bg-soft); border: 1px solid var(--bg-line); border-radius: 12px; padding: 10px 14px; }
.mf-mine .mf-role { font-size: 1rem; font-weight: 800; color: var(--bg-ink); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mf-mine .mf-d { font-size: 0.8rem; color: var(--bg-dim); line-height: 1.55; }
.mf-mine .mf-d b { color: var(--bg-ink); }
.mf-mine .mf-do { font-size: 0.84rem; color: var(--bg-accent); font-weight: 700; }
.mf-mine .mf-warn { color: var(--mf-lamp); }
.mf-mine .mf-dead { color: #ffb0ab; }
.mf-mine .mf-found.yes { color: #ffb0ab; }
.mf-mine .mf-found.no { color: #9fe3c0; }
.mf-team { font-size: 0.7rem; font-weight: 700; border: 1px solid var(--bg-line-2); border-radius: 999px; padding: 1px 8px; color: var(--bg-dim); }
.mf-news { background: color-mix(in srgb, var(--mf-dawn) 12%, var(--mf-board)); border-radius: 10px; padding: 8px 12px; font-size: 0.82rem; line-height: 1.7; color: var(--mf-dawn); }

/* 마을 사람들 */
.mf-seats { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 46%), 1fr)); gap: 10px; }
.mf-seat {
    position: relative; display: block; width: 100%; text-align: center; font: inherit; color: inherit;
    background: var(--bg-soft); border: 2px solid var(--bg-line); border-radius: 12px; padding: 10px 8px;
}
button.mf-seat { cursor: pointer; }
button.mf-seat:hover { border-color: var(--bg-ink); }
.mf-seat.dead { opacity: 0.45; }
.mf-seat.me { border-color: var(--bg-accent); }
.mf-seat.picked { box-shadow: 0 0 0 2px var(--bg-accent) inset; }
.mf-seat.mk-mafia { border-color: var(--mf-blood); }
.mf-seat.mk-sus { border-color: #f0a040; }
.mf-seat.mk-clear { border-color: #33c98a; }
.mf-seat.mk-police { border-color: #3d7bf5; }
.mf-seat.mk-doctor { border-color: #b48cff; }
.mf-seat.mk-watch { border-color: #dddddd; }
.mf-seat .mf-nm { display: block; font-weight: 700; font-size: 0.88rem; color: var(--bg-ink); overflow-wrap: anywhere; }
.mf-seat .mf-ch { display: block; font-size: 0.7rem; color: var(--bg-dim); margin-top: 2px; }
.mf-seat .mf-rl { display: block; font-size: 0.76rem; margin-top: 4px; color: var(--bg-ink); }
.mf-seat .mf-tag { display: inline-block; font-size: 0.66rem; font-weight: 700; color: var(--bg-dim); border: 1px solid var(--bg-line-2); border-radius: 6px; padding: 0 5px; }
.mf-seat .mf-vt { position: absolute; top: -10px; right: -4px; font-size: 0.72rem; color: var(--mf-dusk); font-weight: 800; background: var(--bg-panel); border: 1px solid var(--bg-line-2); border-radius: 999px; padding: 0 7px; line-height: 1.4; }
.mf-seat .mf-memo { display: block; font-size: 0.7rem; color: var(--bg-accent); margin-top: 4px; overflow-wrap: anywhere; }
.mf-seat .mf-pick { display: block; font-size: 0.72rem; font-weight: 800; color: var(--bg-accent); margin-top: 3px; }

/* 기록·대화 */
.mf-log, .mf-chat { height: clamp(180px, 28vh, 420px); overflow-y: auto; font-size: 0.82rem; line-height: 1.7; color: var(--bg-ink); }
.mf-log p, .mf-chat p { margin: 0; padding: 2px 0; border-bottom: 1px solid color-mix(in srgb, var(--bg-line) 60%, transparent); overflow-wrap: anywhere; }
.mf-log .death { color: #ffb0ab; } .mf-log .save { color: #9fe3c0; } .mf-log .night { color: var(--mf-dawn); }
.mf-log .day { color: var(--mf-lamp); } .mf-log .vote { color: var(--mf-dusk); } .mf-log .end, .mf-log .reveal { color: var(--bg-accent); font-weight: 700; }
.mf-chat .mafia { color: #ffb0ab; }
.mf-chat b { color: var(--bg-accent); margin-right: 4px; }
.mf-chatrow { display: flex; gap: 6px; margin-top: 8px; }
.mf-chatrow .input { flex: 1; min-width: 0; }
.mf-chatrow .input:disabled { opacity: 0.6; cursor: not-allowed; }

/* 개인 메모장 */
.mf-noterow { display: grid; grid-template-columns: minmax(90px, 1fr) auto minmax(120px, 1.6fr); gap: 8px; align-items: center; padding: 5px 0; border-bottom: 1px solid color-mix(in srgb, var(--bg-line) 60%, transparent); }
.mf-noterow:last-child { border-bottom: none; }
.mf-noterow .mf-who { font-size: 0.84rem; font-weight: 700; color: var(--bg-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mf-noterow .mf-who.dead { color: var(--bg-dim); text-decoration: line-through; }
.mf-noterow .input { width: 100%; font-size: 0.8rem; }
.mf-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.mf-tagbtn { border: 1px solid var(--bg-line-2); background: transparent; color: var(--bg-dim); border-radius: 7px; padding: 3px 8px; font-size: 0.74rem; cursor: pointer; font-family: inherit; white-space: nowrap; }
.mf-tagbtn[aria-pressed="true"] { color: #10131c; font-weight: 800; border-color: transparent; }
.mf-tagbtn[aria-pressed="true"][data-tag="mafia"] { background: var(--mf-blood); color: #fff; }
.mf-tagbtn[aria-pressed="true"][data-tag="sus"] { background: #f0a040; }
.mf-tagbtn[aria-pressed="true"][data-tag="clear"] { background: #33c98a; }
.mf-tagbtn[aria-pressed="true"][data-tag="police"] { background: #3d7bf5; color: #fff; }
.mf-tagbtn[aria-pressed="true"][data-tag="doctor"] { background: #b48cff; }
.mf-tagbtn[aria-pressed="true"][data-tag="watch"] { background: #dddddd; }
.mf-notefree { width: 100%; min-height: 84px; margin-top: 10px; line-height: 1.7; resize: vertical; }

/* 직업 안내 */
.mf-rolegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(215px, 100%), 1fr)); gap: 8px; }
.mf-rolecard { background: var(--bg-soft); border: 1px solid var(--bg-line); border-radius: 10px; padding: 8px 12px; }
.mf-rolecard.mafia { border-left: 3px solid var(--mf-blood); }
.mf-rolecard.citizen { border-left: 3px solid var(--mf-dawn); }
.mf-rolecard.neutral { border-left: 3px solid var(--mf-lamp); }
.mf-rolecard .mf-rt { font-weight: 700; font-size: 0.86rem; color: var(--bg-ink); }
.mf-rolecard .mf-rd { font-size: 0.76rem; color: var(--bg-dim); line-height: 1.55; margin-top: 3px; }
.mf-teamhead { font-size: 0.84rem; font-weight: 700; color: var(--bg-ink); margin: 12px 0 6px; }
.mf-roles > summary { cursor: pointer; font-size: 0.86rem; color: var(--bg-ink); font-weight: 700; }

/* 태블릿 — 한 줄로 쌓기(대화를 기록보다 먼저) */
@media (max-width: 1100px) {
    /* 한 줄로 쌓을 때는 방장 단추(시작·NPC 채우기)와 대화를 판 바로 아래로 — 메모장 밑까지 내려가 찾기 어렵지 않게 */
    .mf-root .mf-room { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
    .mf-root .mf-main, .mf-root .mf-side { display: contents; }
    .mf-root #mf-banner { order: 1; }
    .mf-root #mf-phase { order: 2; }
    .mf-root .mf-side > .bg-panel:first-child { order: 3; }
    .mf-root #mf-mine { order: 4; }
    .mf-root .mf-main > section:nth-of-type(1) { order: 5; }
    .mf-root .mf-side > section:nth-of-type(1) { order: 6; }
    .mf-root .mf-side > section:nth-of-type(2) { order: 7; }
    .mf-root .mf-main > section:nth-of-type(2) { order: 8; }
    .mf-root #mf-settings { order: 9; }
}
@media (max-width: 900px) {
    .mf-root .bg-lobby { grid-template-columns: 1fr; }
}
/* 휴대폰 */
@media (max-width: 640px) {
    .mf-seats { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px 6px; }
    .mf-seat { padding: 9px 5px 8px; }
    .mf-noterow { grid-template-columns: 1fr; gap: 5px; }
    .mf-log { height: 170px; }
    .mf-chat { height: 210px; }
    .mf-root .bg-roomrow { grid-template-columns: 1fr; }
    .mf-root .bg-roomrow .bg-ract { justify-content: flex-start; }
}
/* 터치 화면 — 누르는 영역 넓히기, 입력 글자 16px(아이폰 확대 방지) */
@media (pointer: coarse) {
    .mf-tagbtn { min-height: 34px; padding: 4px 9px; }
    .mf-root .input { font-size: 16px; }
    .mf-root .bg-mini { min-height: 36px; }
}
/* 4K — 글자와 판을 조금 키운다 */
@media (min-width: 2400px) {
    .mf-root { font-size: 1.25rem; }
    .mf-seats { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
}
.mf-root :focus-visible { outline: 2px solid var(--bg-accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
    .mf-phase { transition: none; }
}
.mf-root #mf-banner:empty { display: none; }
