/* ── Canvas Empty State（初回ガイダンス） ────────────────── */
.canvas-empty-state {
  position: absolute;
  left: 50%; top: 40%;
  transform: translate(-50%, -50%);
  max-width: 420px;
  padding: 32px 28px;
  background: var(--surface);
  border: var(--rule-w-strong) solid var(--ink);
  text-align: left;
  z-index: 5;
}
.canvas-empty-state__eyebrow {
  font-family: var(--font-mono);
  font-size: var(--t-label);
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--accent-strong);
  font-weight: 700;
  margin-bottom: 10px;
}
.canvas-empty-state__title {
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: 28px;
  letter-spacing: -0.5px;
  color: var(--ink);
  margin: 0 0 6px;
  line-height: 1.15;
}
.canvas-empty-state__title .kuten { color: var(--accent); }
.canvas-empty-state__rule {
  width: 48px;
  border-top: var(--rule-w) solid var(--ink);
  margin: 14px 0 20px;
}
.canvas-empty-state__steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.canvas-empty-state__steps li {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 10px 0;
  border-top: var(--rule-w) solid var(--rule);
}
.canvas-empty-state__steps li:first-child { border-top: none; }
.canvas-empty-state__num {
  font-family: var(--font-mono);
  font-size: var(--t-label);
  letter-spacing: 2px;
  color: var(--muted);
  flex-shrink: 0;
  width: 24px;
}
.canvas-empty-state__step {
  font-family: var(--font-sans);
  font-size: var(--t-body);
  color: var(--ink);
  line-height: 1.7;
}
.canvas-empty-state__step strong {
  font-family: var(--font-serif);
  font-weight: 900;
  letter-spacing: 1px;
}

/* ── キャンバス ───────────────────────────────────────── */
/* overflow-x: auto により、1280px の PC でも絶対配置カードを水平スクロールで到達できる */
.canvas-wrap { flex: 1; overflow: auto; overflow-x: auto; position: relative; }

#canvas {
  /* min-width: 5列 × 280px (TABLE_CELL_WIDTH) + 初期オフセット40px + カード幅220px = 1640px。
     12卓イベントで右端カード(5列目)が切れないよう 1600px に引き上げ。 */
  position: relative; min-width: 1600px; min-height: 800px;
  background-color: var(--bg);
  background-image: radial-gradient(circle, var(--rule) 1px, transparent 1px);
  background-size: 28px 28px;
}
.zoom-controls {
  position: fixed; bottom: 100px; right: 16px; z-index: 20;
  display: flex; gap: 4px; align-items: center;
  background: var(--surface); border: var(--rule-w) solid var(--ink);
  border-radius: 0; padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: var(--t-label); color: var(--muted); user-select: none;
}
.zoom-controls button {
  width: 28px; height: 28px; border: none; border-radius: 0;
  background: transparent; color: var(--ink); font-size: 16px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.zoom-controls button:hover { background: var(--ink); color: var(--bg); }
@media (max-width: 768px) { .zoom-controls { display: none; } }

/* ── 卓カード（エディトリアル） ─────────────────────── */
.table-card {
  position: absolute; width: 220px;
  background: var(--surface);
  border: var(--rule-w) solid var(--rule);
  border-radius: 0;
  cursor: grab; user-select: none; overflow: hidden;
  transition: border-color 0.15s;
  z-index: 2;
}
.table-card:hover      { border-color: var(--ink); }
.table-card.dragging   { cursor: grabbing; box-shadow: 0 8px 24px var(--shadow-strong); z-index: 100; }
.table-card.selected   { border-color: var(--accent); border-width: var(--rule-w-strong); }
.table-card.status-playing {
  border-color: var(--positive);
  border-width: var(--rule-w-strong);
}
.table-card.status-playing.irregular {
  border-color: var(--cautionary);
  border-width: var(--rule-w-strong);
}
.irregular-badge {
  font-family: var(--font-mono);
  font-size: var(--t-micro); letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--cautionary);
  padding: 1px 0;
}
.table-card.pending {
  border-color: var(--accent);
  border-width: var(--rule-w-strong);
}

/* 席替えモード — 卓 ↔ 卓 の物理位置 swap 視覚補強 (2026-05-18) */
/* TEST-OUT-OF-SCOPE: visual CSS、挙動変更なし */
body.swap-mode .table-card {
  cursor: pointer;
}
body.swap-mode .table-card:hover {
  outline: 2px dashed var(--accent2);
  background: rgba(79,195,247,0.08);
}
body.swap-mode .table-card.swap-selected {
  outline: 3px solid var(--warning);
  background: rgba(249,168,37,0.18);
}
/* swap-mode 中は卓カード内ボタン群を無効化（誤発火防止） */
body.swap-mode .table-card .table-actions,
body.swap-mode .table-card .table-footer {
  pointer-events: none;
  opacity: 0.55;
}
.pending-badge {
  font-family: var(--font-mono);
  font-size: var(--t-micro); letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent-strong);  /* WCAG AA */
  font-weight: 700;
  padding: 2px 0;
}
.table-player.pending-player { color: var(--accent-strong); }


.table-header {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px;
  padding: 6px 12px 4px;
  border-bottom: var(--rule-w) solid var(--rule);
  position: relative;
}
/* 仕様準拠: ヘッダ直下に 2px × 30px の墨色区切り（エディトリアル感） */
.table-header::after {
  content: '';
  position: absolute;
  left: 12px; bottom: -2px;
  width: 30px; height: 2px;
  background: var(--ink);
}

/* 卓番号 (NO.01) — serif 卓名の前に mono micro で置く */
.table-no {
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  flex-shrink: 0;
}
.table-label {
  /* 2段ヘッダ: NO/size/actions は上段、label は次行の全幅で serif 表示 */
  flex: 1 0 100%;
  order: 2;
  font-family: var(--font-serif);
  font-weight: 900;
  font-size: 18px;
  line-height: 1.1;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; min-width: 0;
  color: var(--ink);
}
.table-size {
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.table-actions { display: flex; gap: 4px; margin-left: auto; order: 1; }
.table-actions button {
  width: 24px; height: 24px; border: none; background: transparent;
  color: var(--muted); cursor: pointer; border-radius: 0;
  font-size: 13px; display: flex; align-items: center; justify-content: center;
}
.table-actions button:hover { background: var(--weak); color: var(--ink); }

.table-players { padding: 8px 12px; }
.table-player {
  font-size: 14px; padding: 5px 0;
  font-weight: 500; word-break: break-word;
  display: flex; align-items: baseline; gap: 6px;
  border-bottom: var(--rule-w) solid var(--rule);
}
.table-player:last-child { border-bottom: none; }
/* T4 (2026-05-18): 切り詰め時に最低 4 文字相当（4em）を確保し、識別不能を防ぐ。 */
.table-player .tp-name { flex: 1; min-width: 4em; overflow: hidden; text-overflow: ellipsis; }
.table-player .tp-score {
  margin-left: auto; display: flex; align-items: center; gap: 2px;
  font-family: var(--font-mono);
  font-size: 12px; color: var(--accent-strong); font-weight: 700;
  white-space: nowrap; flex-shrink: 0;
}
.table-player.empty-slot {
  color: var(--muted); font-style: italic;
  font-weight: 400; font-size: 13px;
}

.report-badge {
  font-family: var(--font-mono);
  font-size: var(--t-micro); letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
}
/* 2026-05-19 A4: 部分報告 progress バッジ — 通常色で常時可視。
 * realtime / polling で 1/4, 2/4 が届くようになったため、admin が
 * 進捗を一目で把握できるよう全卓に常時表示する。alert より控えめ配色。 */
.report-badge.progress {
  color: var(--ink);
  border: var(--rule-w) solid var(--rule);
  background: transparent;
  padding: 2px 6px;
  border-radius: 0;
  font-weight: 700;
}
.report-badge.alert {
  font-weight: 700;
  color: var(--cautionary);
  border: var(--rule-w) solid var(--cautionary);
  background: transparent;
  padding: 2px 6px;
  border-radius: 0;
}
/* 2026-05-19 UX fix #3: 全員報告済バッジ — 塗りつぶし + pulse で admin の視線誘導 */
.report-badge.alert.all-reported {
  color: #fff;
  background: var(--cautionary);
  border-color: var(--cautionary);
  animation: pulse-all-reported 1.6s ease-in-out infinite;
}
@keyframes pulse-all-reported {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.7; }
}

.table-footer {
  padding: 8px 12px;
  border-top: var(--rule-w) solid var(--rule);
  min-height: 36px; display: flex; align-items: center;
  gap: 6px; flex-wrap: wrap;
}

.btn-finish {
  font-family: var(--font-serif);
  font-size: 12px; padding: 8px 14px; min-height: 36px;
  font-weight: 700; letter-spacing: 2px;
  border: none; background: var(--ink); color: var(--bg);
  border-radius: 0; cursor: pointer;
}
.btn-finish:hover { background: var(--accent-strong); }
/* 2026-05-19 UX fix #3: 全員報告済の時、終了ボタンを警戒色で目立たせる (admin への確定促し) */
.btn-finish.btn-finish-ready {
  background: var(--cautionary);
  color: #fff;
  box-shadow: 0 0 0 2px var(--cautionary);
}
.btn-finish.btn-finish-ready:hover { background: var(--cautionary); filter: brightness(1.1); }

.btn-disband {
  font-family: var(--font-mono);
  font-size: var(--t-label); padding: 6px 12px; min-height: 34px;
  letter-spacing: 2px; text-transform: uppercase;
  border: var(--rule-w) solid var(--muted);
  background: transparent;
  color: var(--muted); border-radius: 0; cursor: pointer;
}
.btn-disband:hover { border-color: var(--ink); color: var(--ink); }


.select-check {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-mono);
  font-size: var(--t-label); letter-spacing: 2px; text-transform: uppercase;
  color: var(--muted); cursor: pointer;
}
.select-check input { accent-color: var(--accent); cursor: pointer; }

/* ── マッチングバー ────────────────────────────── */
.matching-bar {
  height: auto; min-height: 56px; background: var(--surface);
  border-top: var(--rule-w) solid var(--rule); flex-shrink: 0; z-index: 10;
}
.matching-bar-inner {
  display: flex; align-items: center; gap: 10px;
  height: 100%; padding: 8px 16px; overflow-x: auto;
  flex-wrap: wrap;
}
#match-preview { display: flex; gap: 6px; white-space: nowrap; flex-shrink: 0; }
/* ─────── Timer Widget (canvas 上のドラッグ可能タイマー) ─────── */
.timer-widget {
  position: absolute;
  background: var(--surface);
  border: var(--rule-w-strong) solid var(--ink);
  border-radius: 0;
  cursor: grab;
  user-select: none;
  z-index: 3;
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  gap: 8px;
  box-shadow: 0 4px 12px var(--shadow);
  /* container queries: widget サイズを基準に子要素のフォントをスケール */
  container-type: size;
  container-name: timer;
}
.timer-widget.dragging { cursor: grabbing; box-shadow: 0 8px 24px var(--shadow-strong); }
.timer-widget-display {
  font-family: var(--font-mono);
  /* widget 幅 30% / 高さ 50% の小さい方を採用。controls 領域を圧迫しないよう 50cqh に抑える。
     widget を大きく resize すれば数字も比例して大きくなる */
  font-size: max(24px, min(30cqw, 50cqh));
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 3px;
  color: var(--ink);
  text-align: center;
  line-height: 1.1;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.timer-widget-ctrl {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}
.timer-widget-input {
  width: 56px;
  font-size: 14px;
  padding: 2px 4px;
  border: var(--rule-w) solid var(--rule);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-mono);
}
.timer-widget-unit { font-size: 11px; color: var(--muted); }
.timer-widget-resize {
  position: absolute;
  right: 0; bottom: 0;
  width: 24px; height: 24px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, var(--muted) 50%);
}
.timer-widget-header {
  position: absolute;
  top: 2px; right: 2px;
  display: flex; gap: 4px;
  z-index: 1;
}
.timer-widget-mini-btn {
  width: 22px; height: 22px;
  border: var(--rule-w) solid var(--rule);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 14px; line-height: 1;
  padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.timer-widget-mini-btn:hover { background: var(--weak); color: var(--ink); }

/* ─────── 最小化状態 (画面右下に固定) ─────── */
.timer-widget.maximized {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  z-index: 10;
}

.timer-widget.minimized {
  position: fixed;
  left: auto; top: auto;
  right: 16px; bottom: 16px;
  width: 160px; height: auto;
  padding: 6px 10px;
  gap: 4px;
  cursor: default;
  /* container queries を最小化時は無効化 (cqw/cqh 依存を切る) */
  container-type: normal;
  z-index: 50;
}
.timer-widget.minimized .timer-widget-display {
  font-size: 22px;
  letter-spacing: 1px;
}
.timer-widget.minimized .timer-widget-ctrl { justify-content: center; }

/* ─────── タイトル入力 ─────── */
.timer-widget-title {
  width: 100%;
  font-family: var(--font-sans);
  /* widget サイズ（container queries）に連動。タイマー数字と同じく cqw/cqh 基準でスケール。
     最小 11px、上限 8cqw / 12cqh の小さい方で controls 行と衝突しないよう抑える。 */
  font-size: max(11px, min(8cqw, 12cqh));
  font-weight: 600;
  padding: 4px 6px;
  border: var(--rule-w) solid var(--rule);
  background: var(--bg);
  color: var(--ink);
  margin-bottom: 4px;
  box-sizing: border-box;
}
.timer-widget.minimized .timer-widget-title { display: none; }
.timer-widget.maximized .timer-widget-title { font-size: 18px; }

/* ─────── 時間切れ (expired): 点滅で注意喚起 ─────── */
@keyframes timer-widget-flash {
  0%, 50%   { background: var(--negative); color: #fff; }
  51%, 100% { background: var(--surface);  color: var(--negative); }
}
.timer-widget.expired {
  animation: timer-widget-flash 1s steps(1, end) infinite;
  border-color: var(--negative);
}
.timer-widget.expired .timer-widget-display { font-weight: 900; }

.round-timer {
  display: none;
  font-family: var(--font-mono);
  font-size: 20px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent-strong);  /* WCAG AA */
  letter-spacing: 2px;
  cursor: pointer; white-space: nowrap;
}
/* タイマー状態色（src/timer.js calcTimerState の戻り値 color と対応） */
.round-timer.timer-normal   { color: var(--positive); }
.round-timer.timer-warn     { color: var(--cautionary); }
.round-timer.timer-danger   { color: var(--negative);  }
.round-timer.timer-expired  { color: var(--negative);  }

.auto-match-admin-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border: var(--rule-w) solid var(--rule);
  white-space: nowrap;
}
.auto-match-admin-status[hidden] { display: none; }
.auto-match-admin-label {
  font-family: var(--font-mono);
  font-size: var(--t-label);
  font-variant-numeric: tabular-nums;
  color: var(--accent-strong);
}

/* ラウンド番号表示（matching-bar、round-timer の隣） */
.round-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 10px;
  border: var(--rule-w) solid var(--rule);
  white-space: nowrap;
}
.round-badge__label {
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.round-badge__value {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 900;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* 参加コード常時表示（matching-bar 右側） */
.code-display {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 10px;
  border: var(--rule-w) solid var(--rule);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s;
}
.code-display:hover { border-color: var(--ink); }
.code-display__label {
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.code-display__value {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
}

.match-preview-item {
  background: var(--weak);
  border: var(--rule-w) solid var(--rule);
  border-radius: 0;
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: var(--t-small);
  letter-spacing: 1px;
  white-space: nowrap;
  color: var(--ink);
}
.match-preview-item strong {
  color: var(--accent-strong);
  font-family: var(--font-serif);
  font-weight: 900;
}

/* ── ボタン共通（エディトリアル） ───────────────── */
.btn {
  font-family: var(--font-mono);
  padding: 8px 14px; border: none; border-radius: 0;
  cursor: pointer; font-size: var(--t-label);
  letter-spacing: 2px; text-transform: uppercase;
  font-weight: 700;
  white-space: nowrap;
  transition: opacity 0.15s, transform 0.1s; flex-shrink: 0;
}
.btn:hover  { opacity: 0.85; }
.btn:active { transform: scale(0.97); }

.btn-danger   { background: var(--negative);  color: var(--bg); }
.btn-monitor  { background: transparent; color: var(--ink); border: var(--rule-w) solid var(--rule); }
.btn-monitor:hover { border-color: var(--ink); background: var(--weak); }
.btn-icon     { padding: 8px 10px; }
.btn-match    {
  background: var(--ink); color: var(--bg);
  font-family: var(--font-serif);
  font-size: 13px; padding: 10px 22px;
  font-weight: 700; letter-spacing: 3px;
  text-transform: none;
  border-radius: 0;
}
.btn-match:hover { background: var(--accent-strong); }
.btn-regen    { background: transparent; color: var(--ink); border: var(--rule-w) solid var(--ink); }
.btn-confirm  {
  background: var(--accent); color: var(--bg);
  font-family: var(--font-serif);
  font-size: 13px; padding: 10px 22px;
  font-weight: 700; letter-spacing: 3px;
  text-transform: none;
  border-radius: 0;
}
.btn-confirm:hover { background: var(--accent-strong); }
.btn-sm       { padding: 4px 10px; font-size: var(--t-micro); }
.btn-cancel-m { background: transparent; color: var(--ink); border: var(--rule-w) solid var(--rule); }
.btn-ok-add   { background: var(--ink); color: var(--bg); }
.btn-del      { background: var(--negative); color: var(--bg); }

/* ── 部屋オブジェクト ─────────────────────────────────── */
.room-obj {
  position: absolute;
  border: 2px dashed rgba(255,255,255,0.22);
  border-radius: 10px;
  cursor: grab;
  user-select: none;
  z-index: 1;
  min-width: 80px; min-height: 50px;
  display: flex; flex-direction: column;
  transition: border-color .15s;
  overflow: hidden;
}
.room-obj:hover { border-color: rgba(255,255,255,0.5); }
.room-obj.dragging { cursor: grabbing; z-index: 50; }

.room-obj-inner {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 8px;
}
.room-obj-label {
  font-size: 18px; font-weight: 700; text-align: center;
  opacity: 0.85; word-break: break-all; pointer-events: none;
}
.room-obj-bar {
  display: flex; justify-content: flex-end; gap: 2px;
  padding: 3px 4px 0;
  opacity: 0; transition: opacity .15s;
  flex-shrink: 0;
}
.room-obj:hover .room-obj-bar { opacity: 1; }
.room-obj-bar button {
  width: 20px; height: 20px; border: none; border-radius: 3px;
  background: rgba(0,0,0,0.4); color: rgba(255,255,255,0.7);
  font-size: 11px; cursor: pointer; display:flex; align-items:center; justify-content:center;
}
.room-obj-bar button:hover { background: rgba(0,0,0,0.7); color: white; }

.room-obj-resize {
  position: absolute; right: 0; bottom: 0; width: 16px; height: 16px;
  cursor: nwse-resize; z-index: 5;
  background: linear-gradient(135deg, transparent 50%, rgba(255,255,255,0.3) 50%);
  border-radius: 0 0 8px 0;
}
.room-obj:hover .room-obj-resize { background: linear-gradient(135deg, transparent 50%, rgba(255,255,255,0.55) 50%); }

.hidden  { display: none !important; }
.no-drag { cursor: default !important; }

/* ── 席替えモード固定操作バー (T5 / 2026-05-18) ───────────────
   swap mode ON 中に画面下部に表示し、キャンセル / 完了を明示する。
   z-index は matching-bar (1000 想定) より上 / dialog (5000) より下。 */
#swap-mode-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: var(--surface); border-top: 2px solid var(--accent-strong);
  box-shadow: 0 -4px 14px rgba(0,0,0,0.18);
  z-index: 4000;
  font-family: var(--font-serif); font-size: 14px; color: var(--ink);
}
#swap-mode-bar[hidden] { display: none; }
#swap-mode-bar .swap-mode-bar__label {
  font-size: 18px; line-height: 1;
}
#swap-mode-bar .swap-mode-bar__text {
  font-weight: 700; letter-spacing: 0.04em;
  flex: 0 0 auto;
}
/* C2 iter2 (2026-05-19): ヒント文を bar 内 1 行統合。
   半透明を解消し、ink 色で明示。長文 viewport では省略表示 (ellipsis) で 1 行死守。 */
.swap-mode-bar__hint {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  opacity: 1;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#swap-mode-bar .btn {
  min-height: 44px; min-width: 88px;
  padding: 10px 18px; font-size: 14px;
}
/* C2 (2026-05-19): 席替えモード中は footer matching-bar を非表示にして
   #swap-mode-bar との重なり / 誤クリックを防ぐ。swap-mode-bar 自身に
   キャンセル / 完了が含まれるため、footer 全体を hide しても操作不能には
   ならない。PC / モバイル両 viewport 共通の挙動。 */
body.swap-mode .matching-bar { display: none !important; }
