/* ===== 폰트 (Mona12 기반, SIL OFL — assets/font/LICENSE 참고) ===== */
@font-face { font-family: "PNC Pixel"; src: url("../assets/font/pnc-pixel-core.woff") format("woff"); font-weight: 400; font-display: swap; }
@font-face { font-family: "PNC Pixel"; src: url("../assets/font/pnc-pixel-cjk.woff") format("woff"); font-weight: 400; font-display: swap;
  unicode-range: U+3400-4DBF, U+4E00-9FFF, U+F900-FAFF; }
@font-face { font-family: "PNC Pixel"; src: url("../assets/font/pnc-pixel-bold-core.woff") format("woff"); font-weight: 700; font-display: swap; }
@font-face { font-family: "PNC Pixel"; src: url("../assets/font/pnc-pixel-bold-cjk.woff") format("woff"); font-weight: 700; font-display: swap;
  unicode-range: U+3400-4DBF, U+4E00-9FFF, U+F900-FAFF; }
@font-face { font-family: "PNC Pixel Emoji"; src: url("../assets/font/pnc-pixel-emoji.woff") format("woff"); font-display: swap; }

/* ===== 테마 ===== */
:root {
  --font: "PNC Pixel", "PNC Pixel Emoji", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans CJK KR", sans-serif;
  --accent: #f08a24;
}
body[data-theme="black"] {
  --bg: #121316; --panel: #1b1d22; --line: #2e3138; --text: #e9e7e3; --sub: #9b9ea6; --hover: #262930;
  --empty: #3b1e1f; --emptyText: #a8595a; color-scheme: dark;
}
body[data-theme="gray"] {
  --bg: #393c43; --panel: #43464e; --line: #575b64; --text: #f0efed; --sub: #bcbfc6; --hover: #4d5059;
  --empty: #5a2b2c; --emptyText: #d08585; color-scheme: dark;
}
body[data-theme="white"] {
  --bg: #e7e8ea; --panel: #f5f5f6; --line: #c9ccd1; --text: #22252a; --sub: #5f636b; --hover: #e1e2e5;
  --empty: #dcc6c6; --emptyText: #985657; color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 16px; line-height: 1.5;
  padding-inline: 16px; padding-block: 0 24px;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ===== 상단 ===== */
.top {
  max-width: 1200px; margin: 0 auto; padding-block: 20px 8px;
  display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: end; justify-content: space-between;
}
.brand .game { margin: 0; color: var(--sub); font-size: 12px; letter-spacing: .08em; }
.brand h1 { margin: 0; font-size: 24px; font-weight: 700; }
.settings { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--sub); min-width: 0; }
.field.col { max-width: 1200px; margin: 0 auto 8px; }
.field.grow { flex: 1; }
.field input, .field select, .field textarea, #searchInput {
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
  padding: 6px 10px; font-size: 16px; color: var(--text); min-width: 0; width: 100%;
}
.field textarea { resize: vertical; }
.toggle { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--sub); padding-bottom: 8px; cursor: pointer; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }

.notice {
  margin: 0 16px 16px; padding: 10px 14px; line-height: 1.7;
  background: var(--panel); border-left: 3px solid var(--accent); font-size: 12px; color: var(--sub);
}
.notice p { margin: 0; }
.notice-sheet { width: min(560px, 100%); }
.notice-sheet .langs { margin: 4px 16px 12px; flex-wrap: wrap; }
.notice-sheet .sheet-foot { justify-content: space-between; }
.notice-sheet .sheet-foot .toggle { padding: 0; }
.btn.small { padding: 5px 12px; font-size: 14px; margin-bottom: 4px; }

/* ===== 탭 ===== */
.tabs { max-width: 1200px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button {
  background: none; border: 0; border-bottom: 3px solid transparent; padding: 8px 14px; cursor: pointer;
  color: var(--sub); font-size: 16px;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 700; }
.tabs button:hover { color: var(--text); }
.tabs .room-tab { margin-left: auto; }

main { max-width: 1200px; margin: 0 auto; padding-top: 16px; }
.row { display: flex; gap: 12px; margin-bottom: 12px; }

.stage { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.stage canvas { display: block; width: 100%; height: auto; cursor: pointer; touch-action: manipulation; }
#roomCanvas { cursor: default; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-block: 16px; }
.actions.left { justify-content: flex-start; margin-block: 0 8px; }
.btn {
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 8px 16px;
  cursor: pointer; font-size: 16px;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1b1408; font-weight: 700; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--sub); }

.codebox { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 12px; }
.codebox p { margin: 0 0 8px; font-size: 12px; color: var(--sub); }
.codeline { display: flex; gap: 8px; }
.codeline textarea {
  flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 4px;
  padding: 6px 8px; font-size: 12px; word-break: break-all; resize: none;
}

.msg { min-height: 1.5em; margin: 4px 0; font-size: 12px; color: var(--emptyText); }
.combo { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; margin: 0 0 12px; }
.seg { background: var(--panel); border: 0; padding: 7px 14px; cursor: pointer; font-size: 14px; color: var(--sub); }
.seg + .seg { border-left: 1px solid var(--line); }
.seg[aria-pressed="true"] { background: var(--accent); color: #1b1408; font-weight: 700; }
.members { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.members li {
  display: flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 2px 4px 2px 12px; font-size: 12px;
}
.members button { background: none; border: 0; cursor: pointer; color: var(--sub); padding: 2px 6px; }
.members button:hover { color: var(--accent); }

/* ===== 하단 PNC ===== */
.bottom { max-width: 1200px; margin: 24px auto 0; }
.pnc { margin: 0; font-size: 12px; letter-spacing: .25em; color: var(--sub); user-select: none; }
.pnc .o { color: var(--accent); }
.egg {
  background: none; border: 0; padding: 0; margin: 0; cursor: default; color: var(--accent);
  font: inherit; letter-spacing: inherit;
}

/* ===== 고르기 창 ===== */
.modal {
  position: fixed; inset: 0; z-index: 10; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.sheet {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  width: min(760px, 100%); max-height: min(86vh, 900px); display: flex; flex-direction: column;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 8px; }
.sheet-head h2 { margin: 0; font-size: 16px; }
.icon { background: none; border: 0; font-size: 16px; cursor: pointer; color: var(--sub); padding: 4px 8px; }
#searchInput { margin: 0 16px 8px; width: auto; }
.grid { overflow-y: auto; padding: 4px 16px 12px; flex: 1; min-height: 120px; }
.grid h3 { font-size: 12px; color: var(--sub); margin: 12px 0 6px; font-weight: 400; display: flex; align-items: center; gap: 6px; }
.grid h3 img { width: 18px; height: 18px; object-fit: contain; }
body[data-theme="white"] .grid h3 img { filter: brightness(.25); }
.grid .note { font-size: 12px; color: var(--accent); margin: 0 0 6px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px 8px; }
.card {
  background: none; border: 0; padding: 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 12px; color: var(--text); text-align: center; min-width: 0;
}
.card .hex {
  width: 84px; aspect-ratio: 1.1547; max-width: 100%; background: var(--panel);
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  display: grid; place-items: center; overflow: hidden;
}
.card .hex img { width: 100%; height: 100%; object-fit: cover; }
.card:hover .hex, .card.sel .hex { outline: none; filter: brightness(1.12); box-shadow: inset 0 0 0 3px var(--accent); }
.card.sel span { color: var(--accent); }
.card.hidden-char .hex { box-shadow: inset 0 0 0 3px #d61d62; }
.card.hidden-char span { color: #d61d62; }
.card span { line-height: 1.3; word-break: keep-all; overflow-wrap: anywhere; }
.hearts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.heart {
  width: 52px; aspect-ratio: 1.1547; border: 0; cursor: pointer; font-family: "PNC Pixel Emoji", var(--font); font-size: 24px;
  background: var(--hc); clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
}
/* 고르면 바로 닫히니까 '선택됨' 표시는 없음. 마우스 올리면 살짝 밝아지기만 */
.heart:hover { filter: brightness(1.15); }
.empty-msg { color: var(--sub); font-size: 12px; padding: 24px 0; text-align: center; }

.sheet-foot { border-top: 1px solid var(--line); padding: 10px 16px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sheet-foot p { margin: 0; font-size: 12px; color: var(--sub); width: 100%; }
.sheet-foot .chips { width: 100%; flex: none; }
.sheet-foot.plain { justify-content: flex-start; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.chip {
  display: flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 10px 3px 3px; cursor: pointer; font-size: 12px;
}
.chip img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.chip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.chip.hidden-chip { border-color: #d61d62; }
.chip.hidden-chip[aria-pressed="true"] { color: #d61d62; background: rgba(214,29,98,.12); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--panel); border: 1px solid var(--accent); color: var(--text); border-radius: 6px;
  padding: 10px 16px; font-size: 12px; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 20;
  max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== 해금 연출 (데이터 복호화) — 테마별 창 ===== */
body[data-theme="black"] { --dBack: rgba(4,5,7,.86); --dBox: #0d0e11; --dText: #e9e7e3; --dDim: #5f646e; }
body[data-theme="gray"]  { --dBack: rgba(30,32,36,.82); --dBox: #2c2e34; --dText: #f0efed; --dDim: #8a8e97; }
body[data-theme="white"] { --dBack: rgba(220,221,224,.86); --dBox: #f7f7f8; --dText: #22252a; --dDim: #a3a7af; }
.decode {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
  background: var(--dBack); padding: 16px;
}
.decode-box {
  width: min(680px, 100%); border: 1px solid var(--accent); background: var(--dBox); color: var(--dText);
  padding: 20px 22px; box-shadow: 0 0 0 4px rgba(240,138,36,.12);
}
.decode-log { font-size: 12px; line-height: 1.7; color: var(--accent); letter-spacing: .06em; margin-bottom: 14px; min-height: 5.1em; }
.decode-log p { margin: 0; white-space: pre-wrap; word-break: break-all; }
.decode-msg { margin: 0; font-size: 24px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; min-height: 1.5em; }
.decode .sc { color: var(--dDim); }

@media (max-width: 560px) {
  .tabs .room-tab { margin-left: 0; }
  .tabs button { padding: 8px 10px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
  .card .hex { width: 72px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
