/* ── 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;
}

/* ── キャンバス ───────────────────────────────────────── */
.canvas-wrap { flex: 1; overflow: auto; position: relative; }

#canvas {
  position: relative; min-width: 1200px; 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);
}
.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: 6px 8px;
  padding: 10px 12px 8px;
  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;
  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: 28px; height: 28px; border: none; background: transparent;
  color: var(--muted); cursor: pointer; border-radius: 0;
  font-size: 14px; 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-all;
  display: flex; align-items: baseline; gap: 6px;
  border-bottom: var(--rule-w) solid var(--rule);
}
.table-player:last-child { border-bottom: none; }
.table-player .tp-name { flex: 1; 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;
}
.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);
}
.report-badge.alert {
  font-weight: 700;
  color: var(--cautionary);
  border: var(--rule-w) solid var(--cautionary);
  background: transparent;
  padding: 2px 6px;
  border-radius: 0;
}

.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); }

.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 幅と高さの両方に連動。幅 25% と高さ 50% の小さい方を採用して溢れ防止 */
  font-size: clamp(24px, min(25cqw, 50cqh), 160px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 3px;
  color: var(--ink);
  text-align: center;
  line-height: 1.1;
  flex: 1;
  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: 14px; height: 14px;
  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.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; }

/* ─────── 時間切れ (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);  }

/* ラウンド番号表示（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; }
