:root {
  /* ★ 테마 색: --accent 하나만 바꾸면 나머지는 자동으로 어울리게 계산돼요 (JS의 applyTheme) */
  --accent: #e7738d;
  --accent-ink: #ffffff;
  --bg: color-mix(in srgb, var(--accent) 8%, #fff);
  --panel: #ffffff;
  --panel-2: color-mix(in srgb, var(--accent) 5%, #fff);
  --line: color-mix(in srgb, var(--accent) 28%, #fff);
  --accent-soft: color-mix(in srgb, var(--accent) 22%, #fff);
  --accent-strong: color-mix(in srgb, var(--accent) 72%, #000);
  --ink: color-mix(in srgb, var(--accent) 18%, #3f3437);
  --muted: color-mix(in srgb, var(--accent) 22%, #948a8c);
  --dark: color-mix(in srgb, var(--accent) 12%, #1f1a1b);
  --danger: #d9534f;
  --shadow: 0 4px 18px color-mix(in srgb, var(--accent) 16%, transparent);
  --radius: 14px;
  --font: 'Gowun Dodum', 'Malgun Gothic', sans-serif;
  --font-title: 'Jua', 'Malgun Gothic', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.grow { flex: 1; }
.row { display: flex; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 6px; }

/* 버튼 / 입력 */
.btn {
  font: inherit;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--accent-soft); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.big { padding: 12px 24px; font-size: 16px; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #f1c4c3; }

input, select, textarea {
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 8px 10px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }

/* 로비 */
.lobby {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(circle at 30% 20%, var(--accent-soft), transparent 60%), var(--bg);
}
.lobby-card {
  background: var(--panel);
  padding: 32px;
  border-radius: 22px;
  box-shadow: var(--shadow);
  text-align: center;
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.lobby-card h1 { font-family: var(--font-title); font-weight: normal; color: var(--accent); margin: 0; font-size: 28px; }
.lobby-card .row input { flex: 1; min-width: 0; }
.or { color: var(--muted); font-size: 12px; }

/* 레이아웃 */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.topbar .title { font-family: var(--font-title); font-size: 20px; color: var(--accent); }
.room-info { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.room-info b { color: var(--ink); }
.top-actions { margin-left: auto; display: flex; gap: 6px; position: relative; }
.badge {
  font-size: 11.5px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}
.badge.local { background: #fff1d6; color: #b07a12; }
.badge.offline { background: #eee; color: #888; }
.badge.host { background: #fff4cc; color: #9a6b10; }
.menu {
  position: absolute;
  right: 0;
  top: 110%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  padding: 6px;
  z-index: 50;
  min-width: 170px;
}
.menu button {
  font: inherit;
  background: none;
  border: 0;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink);
}
.menu button:hover { background: var(--accent-soft); }

.main { flex: 1; display: flex; min-height: 0; }
.board-area { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.side {
  width: 360px;
  border-left: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* 보드 */
.board-scroll { flex: 1; overflow: auto; position: relative; padding: 12px; }
.board {
  position: relative;
  margin: 0 auto;
  user-select: none;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.board { container-type: inline-size; --bw: 2000; --dim: .25; }
/* 보드 단위(보드 가로 = --bw)를 화면 크기로 바꾸는 글자 크기 */
.board img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.board-dim { position: absolute; inset: 0; background: var(--bg); opacity: var(--dim); pointer-events: none; }
.board.no-image {
  background:
    radial-gradient(circle at 20% 15%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 55%),
    radial-gradient(circle at 85% 90%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 50%),
    var(--panel);
}
.board.no-image .board-dim { display: none; }
.cell-layer, .piece-layer, .link-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.piece-layer { pointer-events: none; }
.link-svg { pointer-events: none; overflow: visible; }
.link-svg .ln { stroke: color-mix(in srgb, var(--accent) 55%, #fff); stroke-width: 10; stroke-linecap: round; }
.link-svg .ln.br { stroke-dasharray: 2 18; stroke-width: 9; }
.link-svg .ln.zn { stroke: color-mix(in srgb, #9b6ee0 50%, #fff); }

/* 장식: 타이틀 · 해프닝 ZONE */
.title-box {
  position: absolute;
  display: flex; flex-direction: column; justify-content: center; gap: .4em;
  padding: 0 1.2em;
  font-size: calc(100cqw * 16 / var(--bw));
  pointer-events: none;
}
.tb-title {
  font-family: var(--font-title);
  font-size: calc(100cqw * 78 / var(--bw));
  line-height: 1.1;
  color: var(--accent-strong);
  text-shadow: 0 .05em 0 #fff, 0 0 .3em #fff;
  word-break: keep-all; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tb-desc {
  font-size: calc(100cqw * 26 / var(--bw));
  color: var(--ink);
  background: color-mix(in srgb, #fff 75%, transparent);
  border-radius: .6em; padding: .3em .7em; width: fit-content; max-width: 100%;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.zone-box {
  position: absolute;
  border: calc(100cqw * 5 / var(--bw)) dashed color-mix(in srgb, #9b6ee0 55%, #fff);
  border-radius: calc(100cqw * 30 / var(--bw));
  background: color-mix(in srgb, #9b6ee0 8%, transparent);
  pointer-events: none;
}
.zone-box span {
  position: absolute; left: 50%; top: 0; transform: translate(-50%, -55%);
  font-family: var(--font-title);
  font-size: calc(100cqw * 24 / var(--bw));
  color: #7a4bc4; background: #fff; padding: 0 .6em; border-radius: 999px; white-space: nowrap;
  box-shadow: 0 0 0 calc(100cqw * 3 / var(--bw)) color-mix(in srgb, #9b6ee0 55%, #fff);
}

/* 칸 */
.tile {
  position: absolute;
  box-sizing: border-box;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2em;
  padding: .45em .5em;
  font-size: calc(100cqw * 14.5 / var(--bw));
  line-height: 1.25;
  text-align: center;
  word-break: keep-all; overflow-wrap: anywhere;
  color: var(--ink);
  background: color-mix(in srgb, #fff 94%, transparent);
  border: calc(100cqw * 3 / var(--bw)) solid color-mix(in srgb, var(--accent) 40%, #fff);
  border-radius: calc(100cqw * 16 / var(--bw));
  box-shadow: 0 calc(100cqw * 3 / var(--bw)) 0 color-mix(in srgb, var(--accent) 22%, transparent);
  overflow: hidden;
  transition: transform .12s, box-shadow .12s, outline-color .12s;
}
.tile .tx { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; max-width: 100%; }
.tile .tt { font-family: var(--font-title); font-weight: normal; font-size: 1.9em; line-height: 1; letter-spacing: .02em; }
.tile .num {
  position: absolute; top: .3em; left: .35em;
  font-style: normal; font-family: var(--font-title); font-size: .95em;
  min-width: 1.4em; height: 1.4em; line-height: 1.4em; border-radius: 999px; text-align: center;
  background: #9b6ee0; color: #fff;
}
.tile.t-start, .tile.t-goal {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent-strong);
  box-shadow: 0 calc(100cqw * 4 / var(--bw)) 0 var(--accent-strong);
}
.tile.t-goal .tt { font-size: 2.3em; }
.tile.t-goal .tx { -webkit-line-clamp: 7; }
.tile.t-stop {
  background: var(--accent-strong); color: #fff; border-color: color-mix(in srgb, var(--accent-strong) 70%, #000);
  box-shadow: 0 calc(100cqw * 4 / var(--bw)) 0 color-mix(in srgb, var(--accent-strong) 60%, #000);
}
.tile.t-stop .tt { font-size: 2.2em; }
.tile.t-stop .tx { -webkit-line-clamp: 3; }
.tile.t-stop .rule {
  font-size: .92em; line-height: 1.3; margin-top: .15em;
  background: color-mix(in srgb, #fff 18%, transparent); border-radius: .5em; padding: .2em .5em;
}
.tile.t-label {
  background: var(--accent-soft); border-color: var(--accent);
  font-family: var(--font-title); font-size: calc(100cqw * 19 / var(--bw)); color: var(--accent-strong);
}
.tile.t-happening { background: #fff1d6; border-color: #e0a31a; box-shadow: 0 calc(100cqw * 3 / var(--bw)) 0 #f0cf86; }
.tile.t-happening .num { background: #e0a31a; }
.tile.t-zone { background: #f4edff; border-color: #b99ae9; box-shadow: 0 calc(100cqw * 3 / var(--bw)) 0 #ddcdf6; }
.tile.t-zone .tx, .tile.t-happening .tx { margin-top: .5em; -webkit-line-clamp: 3; }

/* 말 선택 중: 옮길 칸 고르기 */
.board.selecting { cursor: crosshair; }
.board.selecting .tile { cursor: pointer; }
.board.selecting .tile:hover { transform: scale(1.06); outline: calc(100cqw * 5 / var(--bw)) solid var(--accent); z-index: 1; }
/* 보드 편집 중 */
.board.editing .tile { cursor: pointer; }
.board.editing .tile:hover { outline: calc(100cqw * 4 / var(--bw)) dashed var(--accent); }
.board.editing .tile.focus { outline: calc(100cqw * 6 / var(--bw)) solid var(--accent); transform: scale(1.08); z-index: 2; }
.board.editing .piece-layer { opacity: .25; }
.board.editing .piece { pointer-events: none; }

/* 보드 편집 패널 */
.side { position: relative; }
.board-editor {
  position: absolute; inset: 0; z-index: 30;
  display: flex; flex-direction: column;
  background: var(--panel);
}
.be-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.be-head b { font-family: var(--font-title); font-weight: normal; font-size: 17px; color: var(--accent); }
.be-head .muted { font-size: 12px; flex: 1; }
.be-body { flex: 1; overflow: auto; padding: 4px 14px 16px; }
.be-sec { padding: 12px 0; border-bottom: 1px dashed var(--line); }
.be-sec:last-child { border-bottom: 0; }
.be-sec h3 { margin: 0 0 8px; font-size: 14px; color: var(--accent-strong); }
.be-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 13px; }
.be-field > span { color: var(--muted); }
.be-field input[type=range] { padding: 0; accent-color: var(--accent); }
.be-field textarea { resize: vertical; }
.be-hint { font-size: 12px; margin: 0 0 8px; }
.be-swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; position: relative;
  display: grid; place-items: center; font-size: 14px; background: #fff;
}
.swatch.on { box-shadow: 0 0 0 2px var(--ink); }
.swatch.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; padding: 0; border: 0; }
.be-bg { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.be-bg-prev {
  width: 120px; aspect-ratio: 2000 / 1040; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2) center/cover no-repeat; display: grid; place-items: center; color: var(--muted); font-size: 12px;
}
.be-group { margin-bottom: 14px; }
.be-group h4 { margin: 0 0 6px; font-size: 12.5px; color: var(--muted); font-weight: bold; }
.be-cell { display: flex; gap: 6px; align-items: flex-start; margin-bottom: 5px; }
.be-cell textarea { flex: 1; min-width: 0; resize: none; padding: 5px 8px; font-size: 13px; line-height: 1.35; overflow: hidden; }
.be-tag {
  flex: none; min-width: 40px; text-align: center; font-size: 11px; padding: 6px 4px; border-radius: 8px;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--line);
}
.be-tag.t-label { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent); }
.be-tag.t-stop, .be-tag.t-start, .be-tag.t-goal { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.be-tag.t-happening { background: #fff1d6; color: #9a6b10; border-color: #e0a31a; }
.be-tag.t-zone { background: #f4edff; color: #6b4a95; border-color: #b99ae9; }
.be-foot { display: flex; gap: 6px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); }

/* 말 */
.piece {
  position: absolute;
  width: 2.4%;
  aspect-ratio: 1;
  transform: translate(-50%, -60%);
  border-radius: 50%;
  border: 3px solid var(--c, var(--accent));
  background: var(--c, var(--accent)) center/cover no-repeat;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .25), 0 0 0 2px #fff;
  pointer-events: auto;
  cursor: pointer;
  transition: left .28s ease, top .28s ease, transform .15s;
  display: grid;
  place-items: center;
  color: #fff;
  font-family: var(--font-title);
  font-size: clamp(10px, 1.2vw, 18px);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .3);
  z-index: 2;
}
.piece.jump { transition: left .6s cubic-bezier(.3, -0.3, .4, 1.4), top .6s cubic-bezier(.3, -0.3, .4, 1.4); }
.piece:hover { transform: translate(-50%, -60%) scale(1.12); z-index: 5; }
.piece.sel { animation: bob .8s ease-in-out infinite; z-index: 6; box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--c); }
.piece .name {
  position: absolute;
  top: 100%;
  margin-top: 2px;
  font-family: var(--font);
  font-size: 11px;
  background: rgba(255, 255, 255, .92);
  color: var(--ink);
  padding: 0 6px;
  border-radius: 999px;
  white-space: nowrap;
  text-shadow: none;
  pointer-events: none;
}
@keyframes bob { 50% { transform: translate(-50%, -75%); } }

.hint {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: color-mix(in srgb, var(--ink) 88%, transparent);
  color: #fff;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 20;
  pointer-events: none;
}
.cell-tip {
  position: fixed;
  max-width: 260px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12.5px;
  pointer-events: none;
  z-index: 100;
}

/* 주사위 바 */
.dice-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.who { display: flex; align-items: center; gap: 6px; }
.who label { color: var(--muted); font-size: 12px; }
.dice-pick { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.presets { display: flex; gap: 4px; flex-wrap: wrap; }
.presets button {
  font: inherit;
  font-size: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
}
.presets button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
#diceInput { width: 90px; text-align: center; }
.dice-btns { display: flex; gap: 6px; }
.dice-result {
  min-width: 64px;
  height: 46px;
  padding: 0 12px;
  display: grid;
  place-items: center;
  font-family: var(--font-title);
  font-size: 26px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 12px;
  margin-left: auto;
}
.dice-result.rolling { animation: shake .12s linear infinite; }
@keyframes shake { 50% { transform: rotate(8deg) scale(1.05); } }

/* 사이드 */
.box-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.box-head h2 { font-family: var(--font-title); font-weight: normal; font-size: 17px; margin: 0; color: var(--accent); }
.players-box { flex: none; display: flex; flex-direction: column; min-height: 0; }
.player-list { list-style: none; margin: 0; padding: 6px; overflow: auto; }
.player-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 10px;
  cursor: pointer;
}
.player-list li:hover { background: var(--panel-2); }
.player-list li.active { background: var(--accent-soft); }
.player-list .pinfo { flex: 1; min-width: 0; }
.player-list .pname { font-weight: bold; display: flex; gap: 6px; align-items: center; }
.player-list .pcell { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-list .me-tag { font-size: 10.5px; background: var(--accent); color: var(--accent-ink); padding: 0 6px; border-radius: 999px; font-weight: normal; }
.player-list .host-tag { font-size: 12px; }
.player-list li.others { cursor: default; }
.player-list li.others .edit { opacity: .7; }
.player-list .edit { opacity: .5; }
.player-list li:hover .edit { opacity: 1; }
.empty { color: var(--muted); padding: 10px; text-align: center; font-size: 13px; }

.avatar {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  background: var(--c, var(--accent)) center/cover no-repeat;
  border: 2px solid var(--c, var(--accent));
  display: grid;
  place-items: center;
  color: #fff;
  font-family: var(--font-title);
  font-size: 15px;
}
.avatar.big { width: 84px; height: 84px; font-size: 32px; }
.avatar.has-img { color: transparent; }

.chat-box { flex: 1; display: flex; flex-direction: column; min-height: 0; border-top: 1px solid var(--line); }
.chat-tools { display: flex; gap: 4px; }
.chat-log { flex: 1; overflow: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; background: var(--panel-2); }

.msg { display: flex; gap: 8px; align-items: flex-start; }
.msg .body { min-width: 0; flex: 1; }
.msg .meta { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: baseline; }
.msg .meta b { color: var(--c, var(--ink)); font-size: 13px; }
.msg .bubble {
  display: inline-block;
  background: #fff;
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: 4px 12px 12px 12px;
  margin-top: 2px;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 100%;
}
.msg.dice .bubble { background: #fff6e6; border-color: #f5ddb0; }
.reply-quote {
  display: flex; gap: 6px; align-items: baseline;
  max-width: 100%; width: fit-content;
  margin-top: 3px; padding: 2px 8px;
  border-left: 3px solid var(--rc, var(--accent));
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  border-radius: 0 6px 6px 0;
  font-size: 12px; color: var(--muted);
  cursor: pointer; overflow: hidden;
}
.reply-quote b { color: var(--rc, var(--accent)); flex: none; }
.reply-quote span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.reply-quote:hover { background: color-mix(in srgb, var(--accent) 15%, transparent); }
.msg.flash { animation: msgFlash 1.6s ease-out; border-radius: 8px; }
@keyframes msgFlash { 0%, 30% { background: color-mix(in srgb, var(--accent) 25%, transparent); } 100% { background: transparent; } }
.ctx-menu {
  position: fixed; z-index: 1000;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--ink) 18%, transparent);
  padding: 4px; display: flex; flex-direction: column; min-width: 140px;
}
.ctx-menu.hidden { display: none; }
.ctx-menu button {
  font: inherit; text-align: left; border: 0; background: none;
  padding: 7px 10px; border-radius: 6px; cursor: pointer; color: var(--ink);
}
.ctx-menu button:hover { background: var(--accent-soft); }
.reply-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-top: 1px solid var(--line);
  background: var(--accent-soft); font-size: 12.5px;
}
.reply-bar.hidden { display: none; }
.reply-bar .rb-ico { color: var(--accent); font-weight: bold; }
.reply-bar .rb-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.reply-bar .rb-text span { margin-left: 4px; color: var(--ink); }
.reply-bar .rb-x { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 14px; padding: 2px 6px; border-radius: 6px; }
.reply-bar .rb-x:hover { background: #fff; color: var(--accent); }
.reply-bar + .input-resizer + .chat-form, .reply-bar + .chat-form { border-top: 0; }
.msg.dice .bubble .total { font-family: var(--font-title); font-size: 18px; color: #c47a12; }
.msg.system {
  justify-content: center;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}
.msg.cell { justify-content: center; }
.msg.cell .card {
  background: linear-gradient(135deg, var(--accent-soft), #fff);
  border: 1.5px solid color-mix(in srgb, var(--accent) 45%, #fff);
  border-radius: 12px;
  padding: 8px 12px;
  max-width: 92%;
  text-align: center;
  box-shadow: 0 2px 6px color-mix(in srgb, var(--accent) 12%, transparent);
}
.msg.cell .card .who { justify-content: center; font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
.msg.cell .card .q { font-weight: bold; color: var(--accent-strong); }
.msg.cell.zone .card { background: linear-gradient(135deg, #f1e6ff, #fff); border-color: #cfb2f2; }
.msg.cell.zone .card .q { color: #7a3bd0; }
.msg.cell.goal .card { background: linear-gradient(135deg, #fff4cc, #fff); border-color: #f0d27a; }
.msg.cell.goal .card .q { color: #a77a00; }

.chat-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
  align-items: flex-end;
}
.chat-form textarea { flex: 1; resize: none; min-width: 0; }
.speaker .avatar { width: 38px; height: 38px; }

/* 다이얼로그 */
.dialog {
  border: 0;
  border-radius: 18px;
  padding: 22px;
  width: min(400px, calc(100% - 32px));
  box-shadow: 0 20px 60px color-mix(in srgb, var(--ink) 30%, transparent);
  color: var(--ink);
}
.dialog.wide { width: min(720px, calc(100% - 32px)); height: min(80vh, 800px); display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.dialog.wide[open] { display: flex; }
.dialog::backdrop { background: color-mix(in srgb, var(--ink) 35%, transparent); }
.dialog h3 { font-family: var(--font-title); font-weight: normal; color: var(--accent); margin: 0 0 14px; font-size: 20px; }
.dialog form { display: flex; flex-direction: column; gap: 12px; }
.dialog label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.dialog label.check { flex-direction: row; align-items: center; color: var(--ink); }
.avatar-edit { display: flex; gap: 16px; align-items: center; }
.colors { display: flex; gap: 6px; flex-wrap: wrap; }
.colors button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
}
.colors button.on { box-shadow: 0 0 0 2px var(--ink); }
.colors input[type=color] { width: 28px; height: 28px; padding: 0; border: 0; border-radius: 50%; overflow: hidden; cursor: pointer; }
.dialog-actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.log-view-head { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.log-view-head h3 { margin: 0; }
.chat-log.viewer { flex: 1; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: color-mix(in srgb, var(--ink) 92%, transparent);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  z-index: 200;
  font-size: 13.5px;
}

/* 말 이미지 */
.piece.img {
  width: 4.6%;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
  background: none !important;
  box-shadow: none;
  transform: translate(-50%, -88%);
  display: block;
}
.piece.img img.pimg { display: block; width: 100%; height: auto; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .3)); pointer-events: none; }
.piece.img:hover { transform: translate(-50%, -88%) scale(1.1); }
.piece.img.sel { box-shadow: none; animation: bobImg .8s ease-in-out infinite; }
.piece.img.sel img.pimg { filter: drop-shadow(0 0 4px #fff) drop-shadow(0 0 6px var(--c)); }
.piece.img .name { left: 50%; transform: translateX(-50%); }
.piece .name { left: 50%; transform: translateX(-50%); }
@keyframes bobImg { 50% { transform: translate(-50%, -100%); } }
.piece-img-wrap { display: flex; flex-direction: column; gap: 8px; }
.piece-img-box { display: flex; gap: 14px; align-items: center; }
.piece-img-preview {
  width: 84px;
  height: 84px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: repeating-conic-gradient(var(--panel-2) 0 25%, #fff 0 50%) 0 0/16px 16px;
  font-size: 11px;
  overflow: hidden;
}
.piece-img-preview img { max-width: 100%; max-height: 100%; }
.small-note { font-size: 11.5px; }

/* 자르기 */
.dialog.crop { width: min(360px, calc(100% - 32px)); }
.crop-stage {
  width: 280px;
  height: 280px;
  margin: 0 auto;
  border-radius: 12px;
  overflow: hidden;
  background: #333;
  touch-action: none;
  cursor: grab;
}
.crop-stage:active { cursor: grabbing; }
.crop-stage canvas { width: 100%; height: 100%; display: block; }
.crop-zoom { display: flex; align-items: center; gap: 8px; margin: 12px auto 0; width: 280px; color: var(--muted); }
.crop-zoom input { flex: 1; padding: 0; accent-color: var(--accent); }
.crop-help { text-align: center; font-size: 12px; margin: 8px 0 4px; }

/* 채팅 탭 */
.tabs { display: flex; gap: 4px; }
.tab {
  font: inherit;
  font-family: var(--font-title);
  font-size: 15px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 4px 12px;
  border-radius: 999px;
  cursor: pointer;
  position: relative;
}
.tab.on { background: var(--accent-soft); color: var(--accent); }
.unread {
  font-family: var(--font);
  font-size: 10.5px;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 0 5px;
  margin-left: 2px;
  vertical-align: 2px;
}
.chat-log.show-chat .msg[data-ch="answer"],
.chat-log.show-answer .msg[data-ch="chat"] { display: none; }
.msg .ans-tag {
  font-size: 10.5px;
  background: #e9f6ee;
  color: #3c8c5a;
  padding: 0 6px;
  border-radius: 999px;
}
.msg.turn { color: var(--accent); font-weight: bold; }
.answer-hint {
  padding: 6px 12px;
  font-size: 12.5px;
  background: #fff8e6;
  color: #9a6b10;
  border-top: 1px solid #f5e2b5;
}
.answer-hint.mine { background: #e9f6ee; color: #2f7a4b; border-color: #c9e8d4; }

/* 순서 */
.turn-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #fff8e6;
  border-bottom: 1px solid #f5e2b5;
  font-size: 13px;
}
.turn-bar #turnText { flex: 1; }
.order-no {
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 12%, #f3f3f3);
  color: var(--muted);
  font-family: var(--font-title);
  font-size: 13px;
  display: grid;
  place-items: center;
}
.player-list li.turn-now { background: #fff3d6; box-shadow: inset 3px 0 0 #e0a31a; }
.player-list li.turn-now .order-no { background: #e0a31a; color: #fff; }
.roll-tag { font-size: 11.5px; color: #9a6b10; background: #fff1d0; padding: 0 6px; border-radius: 999px; font-weight: normal; }
.roll-tag.wait { color: var(--muted); background: color-mix(in srgb, var(--accent) 6%, #f3f3f3); }

/* BGM */
.bgm-btn { display: inline-flex; align-items: center; gap: 6px; max-width: 220px; }
.bgm-btn #bgmNow { overflow: hidden; text-overflow: ellipsis; }
.bgm-btn .eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.bgm-btn .eq i { width: 3px; height: 4px; background: var(--muted); border-radius: 1px; }
.bgm-btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.bgm-btn.on .eq i { background: var(--accent); animation: eq .9s ease-in-out infinite; }
.bgm-btn.on .eq i:nth-child(2) { animation-delay: -.3s; }
.bgm-btn.on .eq i:nth-child(3) { animation-delay: -.6s; }
@keyframes eq { 0%, 100% { height: 3px; } 50% { height: 12px; } }
.bgm-panel {
  position: absolute;
  right: 0;
  top: 110%;
  width: 330px;
  max-width: calc(100vw - 32px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* 닫혀 있어도 영상은 계속 재생되도록 화면 밖으로만 숨김 */
.bgm-panel.closed { position: fixed; left: -10000px; top: 0; right: auto; }
.bgm-head { display: flex; flex-direction: column; gap: 2px; }
.bgm-head b { font-family: var(--font-title); font-weight: normal; font-size: 16px; color: var(--accent); }
.bgm-head .muted { font-size: 12px; }
.bgm-panel form input { flex: 1; min-width: 0; }
.bgm-video { position: relative; width: 100%; aspect-ratio: 16 / 9; background: var(--dark); border-radius: 10px; overflow: hidden; }
.bgm-video iframe, .bgm-video #bgmPlayer { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.bgm-empty { position: absolute; inset: 0; display: grid; place-items: center; color: color-mix(in srgb, var(--accent) 35%, #ccc); font-size: 13px; background: var(--dark); }
.bgm-title { font-size: 13px; font-weight: bold; word-break: break-all; }
.bgm-ctrl { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.bgm-ctrl label.check { display: flex; align-items: center; gap: 4px; font-size: 13px; margin-left: auto; }
.bgm-local { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.bgm-local input[type=range] { flex: 1; padding: 0; accent-color: var(--accent); }
.bgm-note { font-size: 11.5px; margin: 0; }

/* 크기 조절 손잡이 */
.side-resizer {
  width: 7px;
  margin: 0 -3px;
  flex: none;
  cursor: col-resize;
  position: relative;
  z-index: 10;
  touch-action: none;
}
.side-resizer::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 3px;
  width: 1px;
  background: var(--line);
  transition: background .15s, width .15s, left .15s;
}
.side-resizer:hover::after, .side-resizer.dragging::after { left: 2px; width: 3px; background: var(--accent); }
.side { border-left: 0; flex: none; }
.input-resizer {
  height: 8px;
  margin-bottom: -4px;
  cursor: row-resize;
  position: relative;
  z-index: 2;
  touch-action: none;
  border-top: 1px solid var(--line);
}
.input-resizer::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 2px;
  width: 36px;
  height: 4px;
  margin-left: -18px;
  border-radius: 2px;
  background: var(--line);
  transition: background .15s;
}
.input-resizer:hover::before, .input-resizer.dragging::before { background: var(--accent); }
.input-resizer + .chat-form { border-top: 0; }
body.resizing-x, body.resizing-x * { cursor: col-resize !important; user-select: none !important; }
body.resizing-y, body.resizing-y * { cursor: row-resize !important; user-select: none !important; }
body.resizing-x iframe, body.resizing-y iframe { pointer-events: none; }

/* Netlify 무료 요금제의 "Powered by Netlify" 배지(오른쪽 아래 고정)가
   입력창을 가리지 않도록, Netlify 주소에서만 아래쪽에 자리를 비워 둠 */
.nf-badge .chat-box::after {
  content: '⏎ 전송 · ⇧⏎ 줄바꿈';
  flex: none;
  height: 64px;
  line-height: 60px;
  padding-left: 14px;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--panel);
  white-space: nowrap;
  overflow: hidden;
}
@media (max-width: 900px) {
  .nf-badge .main { padding-bottom: 58px; }
}

/* 닫힌 다이얼로그는 항상 숨김 (display:flex 덮어쓰기 방지) */
.dialog:not([open]) { display: none !important; }

/* 채팅 탭 버튼 / 로그 메뉴 */
.chat-box .box-head { flex-wrap: nowrap; }
.tabs { flex: none; gap: 4px; }
.tab {
  white-space: nowrap;
  min-width: 64px;
  padding: 6px 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  text-align: center;
}
.tab:hover { background: var(--accent-soft); color: var(--accent); }
.tab.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab.on .unread { background: #fff; color: var(--accent); }
.chat-tools { position: relative; flex: none; }
.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  transition: background .15s;
}
.chat-tools:hover .icon-btn, .chat-tools.open .icon-btn, .icon-btn:focus-visible { background: var(--accent-soft); }
.log-menu {
  position: absolute;
  right: 0;
  top: 100%;
  padding-top: 6px;
  z-index: 40;
  display: none;
  flex-direction: column;
  min-width: 230px;
}
.log-menu::before {
  content: '';
  position: absolute;
  inset: 6px 0 0 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: -1;
}
.chat-tools:hover .log-menu, .chat-tools.open .log-menu, .chat-tools:focus-within .log-menu { display: flex; }
.log-menu button {
  font: inherit;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: none;
  border: 0;
  margin: 3px 5px 0;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink);
}
.log-menu button:last-child { margin-bottom: 5px; }
.log-menu button:hover { background: var(--accent-soft); }
.head-tools { display: flex; gap: 6px; flex: none; }
#btnFxHelp { font: 17px var(--font-title); }
.fx-menu { min-width: 290px; }
.fx-menu-head {
  margin: 10px 14px 4px;
  font-family: var(--font-title);
  color: var(--accent);
  font-size: 15px;
}
.fx-menu-head small { display: block; font-family: var(--font); font-size: 11.5px; color: var(--muted); }
#fxList { display: flex; flex-direction: column; max-height: min(60vh, 460px); overflow: auto; padding-bottom: 5px; }
.fx-menu .fx-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: center; margin: 1px 5px 0; padding: 6px 10px; }
.fx-row code {
  font-family: Consolas, 'Courier New', monospace;
  font-size: 12.5px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 6px;
  justify-self: start;
  white-space: nowrap;
}
.fx-row .fx-prev { font-size: 13.5px; white-space: nowrap; }
.fx-row .fx-name { grid-column: 1 / -1; font-size: 11px; color: var(--muted); margin-top: -4px; }
.log-menu b { display: block; font-size: 13px; }
.log-menu small { display: block; font-size: 11.5px; color: var(--muted); }
.lm-ico { font-size: 17px; }

/* 좁은 화면 */
@media (max-width: 900px) {
  .side-resizer { display: none; }
  .side { width: 100% !important; }
  .main { flex-direction: column; overflow: auto; }
  .board-area { flex: none; }
  .board-scroll { max-height: 60vh; padding: 8px; }
  .side { width: 100%; border-left: 0; border-top: 1px solid var(--line); flex: none; }
  .chat-box { height: 70vh; }
  .topbar .title { font-size: 17px; }
  .top-actions { margin-left: 0; }
  .dice-result { margin-left: 0; }
}

/* 로비: 보드 링크 */
.lobby-board {
  display: flex; flex-direction: column; gap: 6px; align-items: center;
  padding: 14px; border-radius: 14px; background: var(--accent-soft); border: 1px solid var(--line);
}
.lobby-board b { font-family: var(--font-title); font-weight: normal; font-size: 22px; color: var(--accent-strong); }
.lobby-board .btn { margin-top: 6px; }
/* 보드 편집: 파일·공유 */
.be-share { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }

/* P2P 연결 안내 */
.net-banner {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 20;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  max-width: calc(100% - 24px);
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 10px 8px 16px; box-shadow: var(--shadow); font-size: 13px;
}
.badge.p2p-host { background: var(--accent-soft); color: var(--accent-strong); }

/* 이용 안내 */
.lobby-foot { margin-top: 2px; }
.link-btn { font: inherit; font-size: 12.5px; color: var(--muted); background: none; border: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--accent); }
.help-head { display: flex; align-items: center; gap: 8px; padding: 16px 20px 10px; border-bottom: 1px solid var(--line); }
.help-head h3 { margin: 0; }
.help-body { overflow: auto; padding: 6px 22px 22px; line-height: 1.65; font-size: 14px; }
.help-body h4 { margin: 18px 0 6px; color: var(--accent-strong); font-size: 15px; }
.help-body ol, .help-body ul { margin: 0; padding-left: 20px; }
.help-body li { margin-bottom: 4px; }

.board.small .piece .name { display: none; }

/* 알림 설정 패널 */
.pop-panel {
  position: absolute; right: 0; top: 110%; z-index: 40;
  width: 280px; display: flex; flex-direction: column; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  padding: 12px 14px; font-size: 13px;
}
.pop-panel b { color: var(--accent-strong); }
.nf-vol { display: flex; align-items: center; gap: 8px; }
.nf-vol span { white-space: nowrap; }
.nf-vol input[type=range] { flex: 1; padding: 0; accent-color: var(--accent); }
.nf-note { font-size: 11.5px; margin: 0; line-height: 1.5; }

/* 작성 중 표시 */
.typing-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 12px; font-size: 12px; color: var(--muted);
  border-top: 1px solid var(--line); background: var(--panel-2);
}
.typing-bar .dots { display: inline-flex; gap: 3px; }
.typing-bar .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); opacity: .35; animation: typingDot 1.2s infinite ease-in-out; }
.typing-bar .dots i:nth-child(2) { animation-delay: .15s; }
.typing-bar .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes typingDot { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.typing-bar + .reply-bar { border-top: 0; }

/* 플레이어 목록: 4명까지 + 스크롤, 접기 */
.fold-btn {
  display: flex; align-items: center; gap: 6px;
  font: inherit; background: none; border: 0; padding: 2px 4px; margin: -2px -4px;
  border-radius: 8px; cursor: pointer; color: inherit; min-width: 0;
}
.fold-btn:hover { background: var(--panel-2); }
.fold-ico { color: var(--accent); font-size: 12px; transition: transform .15s; display: inline-block; }
.pcount { font-size: 12px; color: var(--muted); white-space: nowrap; }
.players-box.folded .fold-ico { transform: rotate(-90deg); }
.players-box.folded .player-list { display: none; }
.player-list.scrolls {
  overscroll-behavior: contain;
  background:
    linear-gradient(var(--panel) 30%, transparent) center top / 100% 18px no-repeat local,
    linear-gradient(transparent, var(--panel) 70%) center bottom / 100% 18px no-repeat local,
    radial-gradient(farthest-side at 50% 0, color-mix(in srgb, var(--ink) 14%, transparent), transparent) center top / 100% 8px no-repeat scroll,
    radial-gradient(farthest-side at 50% 100%, color-mix(in srgb, var(--ink) 14%, transparent), transparent) center bottom / 100% 8px no-repeat scroll;
}

.player-list { position: relative; }

/* 내 캐릭터로 가져오기 버튼: 글자가 길어서 두 줄까지 */
.player-list .edit.take { white-space: normal; max-width: 84px; line-height: 1.25; text-align: center; font-size: 11.5px; padding: 4px 8px; }

/* 새 칸 종류 */
.tile.t-plaza {
  background: color-mix(in srgb, var(--accent) 12%, #fff); border-color: var(--accent);
  font-family: var(--font-title); font-size: calc(100cqw * 20 / var(--bw)); color: var(--accent-strong);
}
.tile.t-plaza .tt { font-size: 2.2em; }
.tile.t-event { background: #fff6dc; border-color: #e0a31a; box-shadow: 0 calc(100cqw * 3 / var(--bw)) 0 #f0cf86; }
.tile.t-event .num { background: #e0a31a; }
.tile.t-all { background: color-mix(in srgb, var(--accent) 16%, #fff); border-color: var(--accent); }
.tile.t-all .num { background: var(--accent); }
.tile.t-reroll { background: #e6f7f1; border-color: #3fae8f; box-shadow: 0 calc(100cqw * 3 / var(--bw)) 0 #b5e2d3; }
.tile.t-reroll .num { background: #3fae8f; }
.tile.t-rest { background: #eef2f8; border-color: #8b9bb4; box-shadow: 0 calc(100cqw * 3 / var(--bw)) 0 #d3dbe7; }
.tile.t-rest .num { background: #8b9bb4; }
.tile.t-back { background: #fdeee8; border-color: #e07a55; box-shadow: 0 calc(100cqw * 3 / var(--bw)) 0 #f3c7b6; }
.tile.t-back .num { background: #e07a55; }
.tile.t-event .tx, .tile.t-all .tx, .tile.t-reroll .tx, .tile.t-rest .tx, .tile.t-back .tx { margin-top: .5em; -webkit-line-clamp: 3; }

/* 이벤트 카드 더미 */
.deck-box {
  position: absolute; display: flex; align-items: center; gap: 1.2em;
  padding: 0 1.4em; font-size: calc(100cqw * 16 / var(--bw)); pointer-events: none;
  background: color-mix(in srgb, #fff 70%, transparent); border-radius: 1em;
  border: calc(100cqw * 3 / var(--bw)) dashed #e0a31a;
}
.deck-cards { position: relative; width: 5.5em; height: 7.5em; flex: none; }
.deck-cards i {
  position: absolute; inset: 0; border-radius: .6em; background: #fff6dc; border: calc(100cqw * 3 / var(--bw)) solid #e0a31a;
}
.deck-cards i:nth-child(1) { transform: rotate(-10deg) translate(-.4em, .2em); }
.deck-cards i:nth-child(2) { transform: rotate(4deg) translate(.3em, 0); }
.deck-cards i:nth-child(3) { display: grid; place-items: center; }
.deck-cards i:nth-child(3)::after { content: '🃏'; font-size: 2.6em; font-style: normal; }
.deck-info { display: flex; flex-direction: column; gap: .2em; }
.deck-info b { font-family: var(--font-title); font-weight: normal; font-size: 2em; color: #9a6b10; }
.deck-info span { font-size: 1.5em; color: var(--ink); }
.deck-info small { font-size: 1.05em; color: var(--muted); }

/* 채팅: 이벤트 카드 · 모두에게 질문 */
.msg.cell.event .card { background: linear-gradient(135deg, #fff4d6, #fff); border-color: #f0cf86; }
.msg.cell.event .card .q { color: #9a6b10; }
.msg.cell.all .card { background: linear-gradient(135deg, var(--accent-soft), #fff); border-color: var(--accent); }

/* 편집: 이벤트 카드 목록 */
.be-cards { width: 100%; resize: vertical; font-size: 13px; line-height: 1.5; }
.be-tag.t-event { background: #fff6dc; color: #9a6b10; border-color: #e0a31a; }
.be-tag.t-all { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent); }
.be-tag.t-reroll { background: #e6f7f1; color: #2a7d65; border-color: #3fae8f; }
.be-tag.t-rest { background: #eef2f8; color: #5a6a84; border-color: #8b9bb4; }
.be-tag.t-back { background: #fdeee8; color: #a8492a; border-color: #e07a55; }
.be-tag.t-plaza { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent); }

/* 채팅 이미지 저장 */
.icon-btn.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.capture-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 7px 12px; font-size: 12.5px; background: var(--accent-soft); border-bottom: 1px solid var(--line);
}
.capture-bar #capText { flex: 1; min-width: 160px; color: var(--ink); }
.capture-bar #capText b { color: var(--accent-strong); }
.cap-btns { display: flex; gap: 6px; }
.chat-log.capturing .msg[data-key] { cursor: pointer; border-radius: 10px; transition: background .1s; }
.chat-log.capturing .msg[data-key]:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.chat-log.capturing .msg.cap-sel { background: color-mix(in srgb, var(--accent) 20%, transparent); box-shadow: inset 3px 0 0 var(--accent); }
.capture-sheet { position: fixed; left: -10000px; top: 0; background: var(--panel-2); }
.capture-sheet .cap-log { overflow: visible; height: auto; flex: none; padding: 16px 18px; }

/* 대기 안내 화면 */
.main { position: relative; }
.wait-screen {
  position: absolute; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 20px; overflow: auto;
  background: radial-gradient(circle at 30% 20%, var(--accent-soft), transparent 60%), var(--bg);
}
.wait-card {
  width: min(560px, 100%); background: var(--panel); border-radius: 22px; box-shadow: var(--shadow);
  padding: 32px 30px 22px; text-align: center; display: flex; flex-direction: column; gap: 14px;
}
.wait-emoji { font-size: 54px; line-height: 1; animation: waitBob 2.4s ease-in-out infinite; }
@keyframes waitBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.wait-card h2 { margin: 0; font-family: var(--font-title); font-weight: normal; font-size: 28px; color: var(--accent-strong); }
.wait-sub { margin: 0; font-size: 15.5px; line-height: 1.6; color: var(--ink); }
.wait-steps { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.wait-step { display: flex; gap: 12px; align-items: flex-start; background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; font-size: 15px; line-height: 1.55; }
.wait-step > b { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 14px; }
.wait-alt { border-top: 1px dashed var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.wait-alt-title { font-weight: bold; font-size: 15.5px; color: var(--accent-strong); }
.wait-alt-text { margin: 0; font-size: 13.5px; line-height: 1.6; color: var(--muted); }
.wait-foot { display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; }
.wait-foot b { color: var(--ink); letter-spacing: .04em; }
@media (prefers-reduced-motion: reduce) { .wait-emoji { animation: none; } }

.app.waiting .top-actions { visibility: hidden; }

/* 편집: 커플 이름 */
.be-names { display: flex; align-items: center; gap: 8px; }
.be-names input { flex: 1; min-width: 0; text-align: center; font-weight: bold; }
.be-names b { color: var(--accent); font-size: 18px; }
.be-tip { font-size: 11.5px; line-height: 1.5; }

/* 확인 창 */
.ask-text { margin: 0 0 14px; white-space: pre-wrap; line-height: 1.6; font-size: 14.5px; }
.ask-input { width: 100%; margin-bottom: 12px; font-size: 13px; }
.btn.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }

/* 휴대폰: 보드 편집은 화면 전체로 */
@media (max-width: 900px) {
  .board-editor { position: fixed; inset: 0; z-index: 60; }
}
