:root {
  --page-bg: #f4f4f4;
  --page-fg: #222222;
  --header-bg: #222222;
  --header-fg: #ffffff;
  --panel-fg: #222222;
  --panel-border: #d2d2d2;
  --field-bg: #ffffff;
  --muted-fg: #666666;
  --hover-bg: #eeeeee;
  --action-bg: #2f4f66;
  --action-fg: #ffffff;
  --action-hover-bg: #42677d;
  --card-bg: #ffffff;
  --card-fg: #222222;
  --card-border: #222222;
  --header-height: 96px;
  --correct-color: #e85c5c;
  --wrong-color: #4455e7;
  --reach-win-color: #e85c5c;
  --reach-lose-color: #4455e7;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--page-fg);
  background: var(--page-bg);
  font-family: system-ui, sans-serif;
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

body.is-dark {
  --page-bg: #181818;
  --page-fg: #eeeeee;
  --header-bg: #111111;
  --header-fg: #f5f5f5;
  --panel-fg: #eeeeee;
  --panel-border: #555555;
  --field-bg: #181818;
  --muted-fg: #bbbbbb;
  --hover-bg: #333333;
  --action-bg: #8aa4b5;
  --action-fg: #101418;
  --action-hover-bg: #a6bdc9;
}

button,
input,
textarea,
select {
  font: inherit;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button,
.button-like {
  min-height: 34px;
  padding: 7px 10px;
  color: var(--panel-fg);
  background: var(--field-bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

button:hover,
.button-like:hover {
  background: var(--hover-bg);
}

.room-lobby {
  width: 100vw;
  height: 100vh;
  height: 100svh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.room-form {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  padding: 24px;
  color: var(--panel-fg);
  background: var(--page-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
}

.room-form h1 {
  margin: 3px 0 0;
  font-size: 24px;
  line-height: 1.2;
}

.room-form label {
  display: grid;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
}

.room-form input[type="text"],
.room-form input[type="password"] {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  color: var(--panel-fg);
  background: var(--field-bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  outline: none;
}

.role-choice {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.role-choice label {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  cursor: pointer;
}

.room-passwords {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.room-passwords.is-single-password {
  grid-template-columns: 1fr;
}

.app-shell {
  width: 100vw;
  height: 100vh;
  height: 100svh;
  display: grid;
  grid-template-columns: 1fr;
  min-width: 0;
}

body.is-viewer .app-shell {
  grid-template-columns: 1fr;
}

.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.score-header {
  position: relative;
  width: 100%;
  height: var(--header-height);
  min-height: 76px;
  padding: 10px 24px;
  box-sizing: border-box;
  flex: 0 0 auto;
  color: var(--header-fg);
  background: var(--header-bg);
  overflow: hidden;
  text-align: left;
  user-select: none;
}

.score-header-box {
  position: absolute;
  min-width: 44px;
  min-height: 18px;
  padding: 2px 4px;
  box-sizing: border-box;
  display: flex;
  align-items: flex-start;
  overflow: hidden;
  color: inherit;
}

.score-header-box span {
  display: block;
  width: 100%;
  max-height: 100%;
  overflow: hidden;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 表示編集の見本（template.css の .header-box / .header-count / .header-rule / .header-answer）と同じ。 */
.score-header-box { border: 1px solid transparent; }
.score-header-box-count { align-items: center; justify-content: center; text-align: center; }
.score-header-box-rule, .score-header-box-answer { opacity: 0.86; }

.score-header-box img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.score-header-box.is-logo {
  align-items: stretch;
  padding: 4px;
}

.score-board {
  flex: 1;
  min-height: 0;
  padding: 12px 20px 28px; /* 上12px・下28pxは表示編集の見本と同じ */
  display: grid;
  grid-template-columns: repeat(var(--player-board-columns, 1), var(--player-card-column-width, 220px));
  align-items: start;
  justify-content: center;
  justify-items: center;
  gap: var(--player-board-gap, 16px);
  overflow-x: hidden;
  overflow-y: auto;
}

body.is-host .score-board {
  padding-bottom: 92px;
}

body.is-host.is-host-preview .score-board {
  padding-bottom: 28px;
}

.score-board.is-empty {
  display: grid;
  place-items: center;
  grid-template-columns: 1fr;
}

.score-board.is-flow-roster {
  grid-template-columns: repeat(var(--roster-board-columns, 1), var(--roster-card-width, 240px));
  grid-template-rows: repeat(var(--roster-board-rows, 1), calc(var(--roster-card-height, 104px) + var(--roster-extra-height, 0px)));
  align-content: center;
  justify-content: center;
  gap: var(--roster-board-gap, 10px);
  overflow: hidden;
}


.free-screen {
  position: absolute;
  inset: 0;
  z-index: 50; /* 待機画面などの自由画面はタイマー（45）も含めてすべてを覆う */
  overflow: hidden;
  color: #ffffff;
  background: #050505;
  opacity: 1;
  transition: opacity var(--free-screen-fade-ms, 450ms) ease;
}

.free-screen.is-fade {
  opacity: 0;
}

.free-screen.is-fade.is-visible {
  opacity: 1;
}

.free-screen-item {
  position: absolute;
  max-width: 92%;
  transform: translate(-50%, -50%);
  color: #ffffff;
  font-weight: 800;
  line-height: 1.12;
  text-align: center;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}

.free-screen-item.is-image {
  display: grid;
  place-items: center;
}

.free-screen-item.is-image img {
  display: block;
  width: 100%;
  max-height: 88vh;
  object-fit: contain;
}

.player-cell {
  position: relative;
  width: var(--player-card-column-width, 220px);
  display: grid;
  justify-items: center;
  gap: 8px;
}

.score-board.is-flow-roster .player-cell {
  width: var(--roster-card-width, 240px);
  height: calc(var(--roster-card-height, 104px) + var(--roster-extra-height, 0px));
  gap: 0;
}

.player-cell.is-empty-slot {
  visibility: hidden;
  pointer-events: none;
}

.score-board.is-scaled .player-cell {
  min-height: var(--player-card-scaled-height, 260px);
}

.flow-roster-card {
  width: 100%;
  height: 100%;
  min-width: 0;
  padding: var(--roster-padding-y, 8px) var(--roster-padding-x, 12px) calc(var(--roster-padding-y, 8px) + 2px);
  display: grid;
  grid-template-rows: auto var(--roster-divider-size, 1px) minmax(0, 1fr);
  gap: var(--roster-gap, 7px);
  box-sizing: border-box;
  color: var(--card-fg);
  background: var(--card-bg);
  border: 2px solid var(--card-border);
  border-radius: var(--roster-card-radius, 8px);
  overflow: hidden;
}

.flow-roster-card.is-selected {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.flow-roster-card.is-name-hidden .flow-roster-name-area {
  opacity: 0.35;
}

.flow-roster-card.is-divider-hidden {
  grid-template-rows: auto minmax(0, 1fr);
}

.flow-roster-card.is-rank-hidden {
  grid-template-rows: minmax(0, 1fr);
}

.flow-roster-rank {
  min-width: 0;
  overflow: hidden;
  color: currentColor;
  font-size: var(--roster-rank-size, 14px);
  font-weight: var(--roster-rank-weight, 800);
  line-height: 1.05;
  text-align: var(--roster-rank-align, center);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flow-roster-divider {
  width: 100%;
  height: var(--roster-divider-size, 1px);
  background: var(--roster-divider-color, currentColor);
  opacity: var(--roster-divider-opacity, 0.72);
}

.flow-roster-name-area {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  align-items: center;
  justify-items: var(--roster-name-justify, center);
  overflow: hidden;
}

.flow-roster-name {
  position:absolute;
  top:50%;
  left:50%;
  width:max-content;
  max-width:none;
  font-size: var(--roster-name-size, 30px);
  font-weight: var(--roster-name-weight, 900);
  letter-spacing: 0;
  line-height: 1;
  text-align: var(--roster-name-align, center);
  white-space: nowrap;
  transform-origin: center center;
}

.player-card {
  position: relative;
  width: var(--player-card-base-width, 200px);
  min-height: 260px;
  padding: 12px clamp(4px, 9%, 18px) 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  box-sizing: border-box;
  color: var(--card-fg);
  background: var(--card-bg);
  border: 2px solid var(--card-border);
  border-radius: 8px;
  overflow: hidden;
}

.player-card.is-win {
  border-color: var(--correct-color);
}

.player-card.is-lose {
  border-color: var(--wrong-color);
}

.player-card.is-locked:not(.is-win):not(.is-lose)::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background: var(--page-bg);
  opacity: 0.48;
  pointer-events: none;
}

.score-board.is-scaled .player-card {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%) scaleX(var(--player-card-scale, 1));
  transform-origin: top center;
}

.card-top {
  width: 100%;
  display: grid;
  gap: 2px;
  justify-items: center;
}

.rank {
  font-size: 18px;
  font-weight: 700;
}

.top-text {
  width: 100%;
  min-height: 18px;
  display: grid;
  place-items: center;
  overflow: hidden;
  font-size: 18px;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
}

.rank[hidden],
.top-text[hidden] {
  display: none !important;
}

.name-area {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 12px 0;
  overflow: hidden;
}

/* 名前は横幅いっぱいの文字サイズで出し、縦に入りきらない分は JS が scale() でつぶす。
   枠より大きい文字でもずれないよう、名前欄の中央に絶対配置してから縮める。 */
.name-text {
  position: absolute;
  left: 50%;
  top: 50%;
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  transform: translate(-50%, -50%);
  transform-origin: center center;
}

.player-card.is-name-hidden .name-area {
  opacity: 0.35;
}

.score-area {
  width: 100%;
  height: var(--score-area-height, 128px);
  min-height: 64px;
  padding: 8px 0 10px;
  position: relative;
  z-index: 3;
  border-top: 1px solid currentColor;
  box-sizing: border-box;
}

.player-card.is-locked:not(.is-win):not(.is-lose) .score-area {
  background: var(--effective-card-bg, var(--card-bg));
}

/* 勝ち抜け・失格の色は状態の文字だけに付ける（区切り線や得点は通常の色のまま）。表示編集の見本と同じ。 */
.player-card.is-win .score-status-label {
  color: var(--correct-color);
}

.player-card.is-lose .score-status-label {
  color: var(--wrong-color);
}

.score-area.is-status {
  min-height: 96px;
  padding: 0;
  display: grid;
  place-items: center;
}

.score-status-label {
  display: grid;
  gap: 0; /* 行間・間隔は表示編集の見本（.editor-status-label）と同じ */
  font-size: var(--score-status-font-size, 36px);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.15;
  text-align: center;
  white-space: normal;
  font-variant-numeric: tabular-nums;
}

.score-status-label span {
  display: block;
}

/* 「文字はメインの数字の場所に出し、ほかの変数は残す」：メインの数字を隠して同じ枠に文字を置く（共通部分は shared/scores.css）。 */
.score-layer > .score-status-label.is-in-layer { justify-self: center; align-self: center; white-space: nowrap; }
.score-layer > .score-status-label.is-in-layer span { white-space: nowrap; }

.score-layer {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(13, minmax(0, 1fr));
  grid-template-rows: repeat(25, minmax(0, 1fr));
  user-select: none;
  z-index: 3;
}

.score-number {
  display: grid;
  place-items: center;
  justify-self: center;
  align-self: center;
  width: max-content;
  min-width: 0;
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  text-align: center;
}

.score-number.is-clickable-stat {
  cursor: pointer;
  border-radius: 4px;
}

.score-number.is-clickable-stat:hover {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.judge-row {
  display: none;
  width: 100%;
  max-width: 260px;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

body.is-host .judge-row {
  display: grid;
}

.icon-action-button {
  min-width: 34px;
  width: 100%;
  min-height: 34px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  color: var(--panel-fg);
  background: var(--field-bg);
  border-color: var(--panel-border);
  line-height: 1;
}

.icon-action-button:hover,
.icon-action-button:focus-visible {
  background: var(--hover-bg);
}

.icon-action-button.is-correct,
.judge-row button[data-action="correct"] {
  color: #ffffff;
  background: var(--correct-color);
  border-color: var(--correct-color);
}

.icon-action-button.is-wrong,
.judge-row button[data-action="wrong"] {
  color: #ffffff;
  background: var(--wrong-color);
  border-color: var(--wrong-color);
}

.icon-action-button.is-correct:hover,
.icon-action-button.is-correct:focus-visible {
  background: var(--correct-color);
}

.icon-action-button.is-wrong:hover,
.icon-action-button.is-wrong:focus-visible {
  background: var(--wrong-color);
}

.host-panel {
  min-width: 0;
  min-height: 0;
  padding: 16px 18px 22px;
  color: var(--panel-fg);
  background: var(--page-bg);
  overflow-x: hidden;
  overflow-y: auto;
}

body.is-viewer .modal-backdrop[hidden] .host-panel {
  display: none;
}

.panel-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--panel-border);
}

.eyebrow,
.connection-status,
.status-text {
  margin: 0;
  color: var(--muted-fg);
  font-size: 12px;
  line-height: 1.4;
}

.panel-top h1 {
  margin: 2px 0 0;
  font-size: 18px;
  line-height: 1.2;
}

.two-col,
.add-player-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.host-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
}

.host-tabs button {
  padding: 8px 10px;
  color: var(--muted-fg);
  background: transparent;
  border-color: transparent;
}

.host-tabs button.is-active {
  color: var(--action-fg);
  background: var(--action-bg);
  border-color: var(--action-bg);
}

.ops-strip {
  padding-top: 4px;
}

.ops-summary {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 8px;
}

.ops-summary .status-text {
  padding: 9px 10px;
  background: var(--field-bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
}

.control-section {
  display: grid;
  gap: 10px;
  padding: 0 0 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--panel-border);
}

.control-section h2 {
  margin: 0;
  color: var(--muted-fg);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

.control-section label {
  display: grid;
  gap: 5px;
  min-width: 0;
  font-size: 12px;
  font-weight: 700;
}

.control-section input,
.control-section textarea,
.control-section select {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  color: var(--panel-fg);
  background: var(--field-bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  outline: none;
}

.control-section textarea {
  min-height: 180px;
  resize: vertical;
  font-family: "Courier New", monospace;
  font-size: 12px;
  line-height: 1.45;
}

.add-player-form {
  grid-template-columns: 1fr auto;
}

.player-list {
  display: grid;
  gap: 8px;
}

.player-list-row {
  display: grid;
  gap: 6px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--panel-border);
}

.player-list-fields {
  display: grid;
  grid-template-columns: 1.2fr 0.7fr 1fr;
  gap: 6px;
}

.player-list-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.player-list-row input,
.player-list-row button {
  min-width: 0;
  padding: 7px 8px;
}

.participant-toolbar {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr 0.8fr 0.8fr 0.8fr;
  gap: 8px;
}

.participant-table-wrap {
  max-height: 430px;
  overflow: auto;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
}

.participant-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.participant-table th,
.participant-table td {
  padding: 6px;
  border-bottom: 1px solid var(--panel-border);
  text-align: left;
  vertical-align: middle;
}

.participant-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted-fg);
  background: var(--panel-bg);
  font-size: 11px;
  font-weight: 800;
}

.participant-table input {
  width: 86px;
  min-width: 72px;
  padding: 6px 7px;
}

.participant-table td:nth-child(2) input,
.participant-table td:nth-child(4) input {
  width: 130px;
}

.participant-actions {
  display: flex;
  gap: 4px;
}

.participant-actions button,
.assignment-row button {
  padding: 6px 8px;
  white-space: nowrap;
}

.assignment-list {
  display: grid;
  gap: 8px;
}

/* ノードのボタン列（ドロップダウンの代わり）。種類ごとに左の線の色を変える。今のノードは塗り、「次へ」の行き先は点線。 */
#flowNodePicker { display: none !important; }
.flow-node-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px; }
.flow-node-tabs[hidden] { display: none; }
#flowNodeTabs .flow-node-tab { display: grid; gap: 1px; justify-items: start; min-height: 44px; max-width: 220px; padding: 4px 10px 4px 9px; border: 1px solid var(--panel-border); border-left: 4px solid var(--node-color, var(--panel-border)); border-radius: 8px; background: var(--field-bg); color: inherit; text-align: left; cursor: pointer; transition: none; }
#flowNodeTabs .flow-node-tab-type { font-size: .68rem; opacity: .7; line-height: 1.1; }
#flowNodeTabs .flow-node-tab-name { font-size: .86rem; font-weight: 700; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
#flowNodeTabs .flow-node-tab[data-node-type="round"] { --node-color: #3b82f6; }
#flowNodeTabs .flow-node-tab[data-node-type="group"] { --node-color: #a855f7; }
#flowNodeTabs .flow-node-tab[data-node-type="written"] { --node-color: #f59e0b; }
#flowNodeTabs .flow-node-tab[data-node-type="screen"], #flowNodeTabs .flow-node-tab[data-node-type="display"] { --node-color: #10b981; }
#flowNodeTabs .flow-node-tab[data-node-type="end"] { --node-color: #6b7280; }
#flowNodeTabs .flow-node-tab.is-next { border-style: dashed; border-left-style: solid; border-color: var(--action-bg); }
#flowNodeTabs .flow-node-tab[aria-selected="true"] { background: var(--action-bg); color: var(--action-fg); border-color: var(--action-bg); }
#flowNodeTabs .flow-node-tab:hover:not([aria-selected="true"]) { background: var(--md-primary-container, var(--field-bg)); }

/* 手動組み分け：一番上で振り分け先を選び、各人の「入れる」でそこへ入れる。 */
.assignment-target-bar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 2px solid var(--action-bg);
  border-radius: 6px;
  background: var(--panel-bg, var(--field-bg));
  font-weight: 700;
  flex-wrap: wrap;
}
#groupAssignmentList .assignment-target-tile { flex: 1 1 120px; display: grid; gap: 2px; justify-items: center; min-height: 56px; padding: 6px 10px; border: 1px solid var(--panel-border); border-radius: 8px; background: var(--field-bg); color: inherit; cursor: pointer; transition: none; }
#groupAssignmentList .assignment-target-tile:hover:not([aria-checked="true"]) { border-color: var(--action-bg); background: var(--md-primary-container, var(--field-bg)); }
#groupAssignmentList .assignment-target-tile .assignment-target-name { font-size: 1rem; font-weight: 800; line-height: 1.2; text-align: center; }
#groupAssignmentList .assignment-target-tile .assignment-target-count { font-size: .8rem; opacity: .75; }
#groupAssignmentList .assignment-target-tile[aria-checked="true"] { background: var(--action-bg); color: var(--action-fg); border-color: var(--action-bg); }
#groupAssignmentList .assignment-target-tile[aria-checked="true"] .assignment-target-name::before { content: "✓ "; }

.assignment-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
}

.assignment-targets { display:flex; flex-wrap:wrap; gap:8px; min-width:0; margin:0; padding:0; border:0; }
.assignment-targets input, .assignment-legend { position:absolute; clip-path:inset(50%); overflow:hidden; width:1px; height:1px; margin:-1px; padding:0; border:0; white-space:nowrap; }
.assignment-row .assignment-targets label { display:inline-flex; grid-column:auto; align-items:center; justify-content:center; gap:6px; min-height:48px; padding:8px 12px; box-sizing:border-box; border:1px solid var(--panel-border); border-radius:8px; cursor:pointer; font-size:1rem; background:var(--field-bg); }
.assignment-targets input:checked + label { background:var(--action-bg); color:var(--action-fg); border-color:var(--action-bg); font-weight:700; }
.assignment-targets input:checked + label::before { content:"✓"; }
.assignment-targets input:focus-visible + label { outline:3px solid var(--action-bg); outline-offset:3px; }
@media (max-width:720px) { .assignment-row { grid-template-columns:minmax(0,1fr) auto auto; } .assignment-row > span { grid-column:1 / -1; } }

.assignment-row label {
  display: flex;
  grid-column: 1 / 3;
  align-items: center;
  gap: 8px;
}

.round-participant-list {
  max-height: min(54vh, 560px);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}

.round-participant-row {
  min-width: 0;
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  background: var(--field-bg);
}

.round-participant-row.is-assigned {
  border-color: var(--action-bg);
  box-shadow: inset 3px 0 0 var(--action-bg);
}

.round-participant-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.round-participant-main label {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 900;
}

.round-participant-main label span,
.round-participant-main > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.round-participant-main > span {
  color: var(--muted-fg);
  font-size: 12px;
  font-weight: 700;
}

.round-participant-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px;
  align-items: center;
}

.round-participant-actions select,
.round-participant-actions button {
  min-width: 0;
  padding: 6px 8px;
  white-space: nowrap;
}

.round-control-list {
  display: grid;
  gap: 8px;
}

.round-control-row {
  display: grid;
  grid-template-columns: minmax(140px, .6fr) minmax(520px, 1.8fr) minmax(310px, 1fr);
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--panel-border);
}

.round-control-row.is-terminal {
  opacity: 0.72;
}

.round-control-row.is-locked {
  opacity: 0.72;
}

.round-control-row.is-selected {
  outline: 2px solid var(--action-bg);
  outline-offset: -2px;
}

.round-control-player {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.round-control-player strong,
.round-control-player span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.round-control-player span {
  color: var(--muted-fg);
  font-size: 12px;
  font-weight: 700;
}

.round-control-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(74px, 1fr));
  gap: 6px;
}

.round-stat-control {
  min-width: 0;
  display: grid;
  grid-template-columns: auto 24px minmax(38px, 1fr) 24px;
  gap: 3px;
  align-items: center;
}

.round-stat-control span {
  font-size: 12px;
  font-weight: 900;
}

.round-stat-control input,
.round-stat-control button {
  min-width: 0;
  padding: 5px 4px;
  text-align: center;
}

.round-control-actions {
  display: grid;
  grid-template-columns: repeat(6, minmax(44px, 1fr));
  gap: 5px;
}

.round-control-actions button {
  min-height: 32px;
  padding: 0 8px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.empty-message {
  margin: 0;
  color: var(--muted-fg);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

.danger-button {
  color: #ffffff;
  background: #7f1d1d;
  border-color: #7f1d1d;
}

.manage-modal-button {
  display: none;
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 80;
}

body.is-host .manage-modal-button {
  display: block;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.64);
}

.manage-modal {
  width: min(1180px, calc(100vw - 32px));
  height: min(840px, calc(100vh - 32px));
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 18px;
  color: var(--panel-fg);
  background: var(--page-bg);
  border: 1px solid var(--panel-border);
  border-radius: 0;
  overflow-y: auto;
  z-index: 1001;
}

.modal-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--panel-border);
}

.modal-top h2 {
  margin: 2px 0 0;
  font-size: 18px;
  line-height: 1.2;
}

.modal-grid {
  display: grid;
  gap: 14px;
}

body.is-host {
  overflow: auto;
}

body.is-host:not(.is-host-preview).host-theme-light {
  --page-bg: #f6f7f9;
  --page-fg: #1f2933;
  --panel-fg: #1f2933;
  --panel-border: #cfd7e2;
  --field-bg: #ffffff;
  --muted-fg: #5f6b7a;
  --hover-bg: #edf1f6;
  --action-bg: #28557a;
  --action-fg: #ffffff;
  --action-hover-bg: #37698f;
}

body.is-host:not(.is-host-preview).host-theme-cool {
  --page-bg: #eef5f6;
  --page-fg: #17313a;
  --panel-fg: #17313a;
  --panel-border: #b8ccd1;
  --field-bg: #ffffff;
  --muted-fg: #526b73;
  --hover-bg: #dfecee;
  --action-bg: #286b73;
  --action-fg: #ffffff;
  --action-hover-bg: #34808a;
}

body.is-host:not(.is-host-preview).host-theme-mono {
  --page-bg: #f1f1f1;
  --page-fg: #222222;
  --panel-fg: #222222;
  --panel-border: #bdbdbd;
  --field-bg: #fbfbfb;
  --muted-fg: #666666;
  --hover-bg: #e6e6e6;
  --action-bg: #2f2f2f;
  --action-fg: #ffffff;
  --action-hover-bg: #4a4a4a;
}

body.is-host:not(.is-host-preview).host-theme-dark {
  --page-bg: #15191d;
  --page-fg: #edf2f5;
  --panel-fg: #edf2f5;
  --panel-border: #3b4852;
  --field-bg: #20262b;
  --muted-fg: #a8b5bd;
  --hover-bg: #2b343b;
  --action-bg: #8db7d2;
  --action-fg: #10161a;
  --action-hover-bg: #a7c8dc;
}

body.is-host .app-shell {
  display: none;
}

body.is-host.is-host-preview {
  overflow: hidden;
}

body.is-host.is-host-preview .app-shell {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  width: 100vw;
  height: 100vh;
  height: 100svh;
  background: var(--page-bg);
}

body.is-host.is-host-preview .modal-backdrop {
  display: none;
}

body.is-host.is-host-preview .stage {
  pointer-events: auto;
}

body.is-host.is-host-preview .judge-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 120px;
}

body.is-host.is-host-preview .judge-row .is-name-toggle {
  display: none;
}

body.is-host.is-host-preview .judge-row .icon-action-button {
  min-width: 0;
}

.viewer-preview-close {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 90;
  min-width: 116px;
  border-radius: 0;
}

body.is-host .modal-backdrop {
  position: static;
  inset: auto;
  z-index: auto;
  min-height: 100vh;
  display: block;
  padding: 0;
  background: var(--page-bg);
}

body.is-host .manage-modal {
  width: 100%;
  min-height: 100vh;
  height: auto;
  display: grid;
  align-content: stretch;
  grid-template-rows: auto auto auto 1fr;
  gap: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  overflow: visible;
}

body.is-host button,
body.is-host .button-like,
body.is-host input,
body.is-host textarea,
body.is-host select {
  border-radius: 0;
}

body.is-host .manage-modal-button,
body.is-host .floating-host-button,
body.is-host .host-footer {
  display: none;
}

.host-dashboard-head {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 18px 24px;
  color: var(--panel-fg);
  background: var(--page-bg);
  border-bottom: 1px solid var(--panel-border);
}

.host-dashboard-head h1 {
  margin: 2px 0 0;
  font-size: 22px;
  line-height: 1.15;
}

.host-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.host-theme-picker {
  min-width: 128px;
  display: grid;
  gap: 3px;
  color: var(--muted-fg);
  font-size: 11px;
  font-weight: 800;
}

.host-theme-picker select {
  min-height: 34px;
}

#manageModalCloseButton {
  color: var(--action-fg);
  background: var(--action-bg);
  border-color: var(--action-bg);
}

#manageModalCloseButton:hover,
#manageModalCloseButton:focus-visible {
  color: var(--action-fg);
  background: var(--action-hover-bg);
  border-color: var(--action-hover-bg);
}

.host-overview {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(180px, 0.8fr) minmax(180px, 0.7fr);
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--panel-border);
}

.host-status-card {
  min-width: 0;
  display: grid;
  gap: 6px;
  padding: 12px;
  background: var(--field-bg);
  border: 1px solid var(--panel-border);
}

.host-status-card span {
  color: var(--muted-fg);
  font-size: 11px;
  font-weight: 800;
}

.host-status-card strong {
  min-width: 0;
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.host-inline-actions,
.host-action-row,
.host-flow-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
}

.host-flow-actions {
  grid-template-columns: minmax(80px, 0.7fr) minmax(96px, 0.9fr) minmax(88px, 0.8fr) minmax(150px, 1.5fr) minmax(104px, 0.9fr);
  align-items: center;
}

.flow-next-target {
  min-width: 0;
  color: var(--muted-fg);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.host-tabs {
  position: sticky;
  top: 69px;
  z-index: 19;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: 0;
  padding: 0 24px;
  background: var(--page-bg);
  border: 0;
  border-bottom: 1px solid var(--panel-border);
  border-radius: 0;
}

.host-tabs button {
  min-height: 44px;
  border-width: 0 0 3px;
}

.host-tabs button.is-active {
  color: var(--page-fg);
  background: transparent;
  border-color: var(--page-fg);
}

.host-main {
  min-width: 0;
  padding: 18px 24px 28px;
}

.host-panel-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1.45fr) minmax(320px, 0.9fr);
  gap: 14px;
  align-items: start;
}

.host-card {
  min-width: 0;
  margin: 0;
  padding: 14px;
  background: var(--field-bg);
  border: 1px solid var(--panel-border);
  border-radius: 0;
}

.host-card-primary,
.host-card-wide {
  grid-column: span 1;
}

.host-card-wide {
  grid-column: 1 / -1;
}

#roundParticipantSection {
  grid-column: span 1;
  width: min(100%, 980px);
}

.host-note {
  padding: 10px;
  background: var(--page-bg);
  border: 1px solid var(--panel-border);
}

.primary-button {
  color: var(--action-fg);
  background: var(--action-bg);
  border-color: var(--action-bg);
}

.primary-button:hover {
  color: var(--action-fg);
  background: var(--action-hover-bg);
  border-color: var(--action-hover-bg);
}

body.is-host .participant-table-wrap {
  max-height: min(62vh, 680px);
}

body.is-host .player-list {
  display: none;
}

.host-footer {
  display: none;
  position: fixed;
  left: auto;
  right: 14px;
  bottom: 14px;
  z-index: 80;
  width: auto;
  grid-template-columns: repeat(6, max-content);
  justify-content: end;
  justify-items: end;
  gap: 10px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}

body.is-host.is-host-preview .host-footer {
  display: grid;
  z-index: 92;
}

.host-footer button {
  min-width: 0;
  min-height: 0;
  width: auto;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--page-fg);
  background: transparent;
  border: 0;
  border-radius: 0;
  font-weight: 400;
}

.host-footer .footer-icon-label {
  font-size: 14px;
  line-height: 1;
  white-space: nowrap;
}

.host-footer button:hover,
.host-footer button:focus-visible {
  background: transparent;
  color: var(--muted-fg);
}

.host-footer button.is-correct {
  color: var(--correct-color);
}

.host-footer button.is-wrong {
  color: var(--wrong-color);
}

.floating-host-button {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 10;
  min-width: 72px;
}

body.is-host .floating-host-button {
  display: none;
}

body.is-lobby .floating-host-button {
  display: none;
}

body.is-viewer:not(.is-host-capable) .floating-host-button {
  display: none;
}

body.is-lobby .manage-modal-button,
body.is-lobby .host-footer,
body.is-viewer .manage-modal-button,
body.is-viewer .host-footer {
  display: none;
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .app-shell {
    min-height: 100vh;
    height: auto;
    grid-template-columns: 1fr;
  }

  .stage {
    min-height: 70vh;
  }

  /* 閲覧者・表示プレビューは狭い画面でも表示領域の高さを固定して計算する。 */
  body.is-viewer .app-shell { min-height: 0; height: 100svh; }
  body.is-viewer .stage, body.is-host.is-host-preview .stage { min-height: 0; }

  .host-panel {
    border-left: 0;
    border-top: 1px solid var(--panel-border);
  }

  .host-tabs,
  .ops-summary,
  .participant-toolbar {
    grid-template-columns: 1fr;
  }

  .host-flow-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .flow-next-target {
    grid-column: 1 / -1;
  }

  .round-participant-actions {
    grid-template-columns: 1fr;
  }

  .host-dashboard-head,
  .host-overview,
  .host-panel-grid {
    grid-template-columns: 1fr;
  }

  .host-dashboard-head {
    position: static;
    padding: 14px;
  }

  .host-head-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .host-tabs {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 0 14px;
  }

  .host-main,
  .host-overview {
    padding-left: 14px;
    padding-right: 14px;
  }

  .round-control-row {
    grid-template-columns: 1fr;
  }

  .round-control-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .round-control-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .manage-modal {
    width: min(100%, calc(100vw - 20px));
    height: calc(100vh - 20px);
    padding: 12px;
  }

  .manage-modal-button {
    right: 14px;
  }

  .host-footer {
    left: auto;
    right: 12px;
    bottom: 12px;
    grid-template-columns: repeat(4, max-content);
  }

  .room-passwords,
  .player-list-fields {
    grid-template-columns: 1fr;
  }
}


/* ════════════════════════════════════════════════════════════════
   表示画面：画面・ヘッダーの色
   ════════════════════════════════════════════════════════════════ */
.stage {
  background: var(--stage-bg, transparent);
}

.app-shell.has-header-divider .score-header {
  border-bottom: 2px solid currentColor;
}

.score-header-box-custom span {
  white-space: pre-wrap;
}

/* ════════════════════════════════════════════════════════════════
   表示画面：プレイヤーカード（web得点表示相当の表現）
   ════════════════════════════════════════════════════════════════ */
.score-board .player-card {
  border-radius: var(--card-radius, 8px);
  border-width: var(--card-border-width, 2px);
  box-shadow: var(--card-shadow, none);
}

.name-area {
  position: relative;
  z-index: 1;
}

.card-top {
  position: relative;
  z-index: 1;
}

.name-text {
  color: var(--name-color, inherit);
}

.score-layer {
  color: var(--score-color, inherit);
}

.player-card.is-score-high .score-number {
  color: var(--score-high-color, #ffb300) !important;
}

.score-board[data-divider="0"] .score-area {
  border-top-color: transparent;
}

.score-board[data-divider="1"] .score-area {
  border-top-color: color-mix(in srgb, currentColor var(--divider-opacity, 100%), transparent);
}

/* 配置：得点が上・名前が下 */
.score-board[data-layout="score"] .player-card .card-top { order: 0; }
.score-board[data-layout="score"] .player-card .score-area {
  order: 1;
  border-top: 0;
  border-bottom: 1px solid color-mix(in srgb, currentColor var(--divider-opacity, 100%), transparent);
}
.score-board[data-layout="score"][data-divider="0"] .player-card .score-area { border-bottom-color: transparent; }
.score-board[data-layout="score"] .player-card .name-area { order: 2; }
.score-board[data-layout="score"] .player-card .wrong-marks { order: 3; }

/* 順位：背景色（丸い札） */
.rank.has-bg {
  padding: 1px 10px;
  border-radius: 999px;
  color: var(--rank-fg, inherit);
}

.rank:not(.has-bg) {
  color: var(--rank-fg, inherit);
}

/* 順位：上部の帯 */
.player-card.has-rank-band {
  padding-top: calc(var(--rank-band-height, 34px) + 8px);
}

/* 帯はカード全幅に敷くので、基準をカード本体にする */
.player-card.has-rank-band .card-top {
  position: static;
}

.player-card.has-rank-band .rank.is-band {
  position: absolute;
  inset: 0 0 auto 0;
  height: var(--rank-band-height, 34px);
  display: grid;
  place-items: center;
  padding: 0 6px;
  border-radius: 0;
  background: var(--rank-bg, rgba(127, 127, 127, 0.18));
  color: var(--rank-fg, inherit);
  z-index: 2;
}

.player-card.has-rank-band .rank.is-band.has-bg {
  /* プレイヤー個別の色・設定の色はインラインで入る */
  border-radius: 0;
}

.flow-roster-rank.has-bg {
  border-radius: 4px;
  color: var(--rank-fg, inherit);
}

/* 状態ラベル（WIN / LOSE / LOCK）の色 */
.player-card.is-win .score-status-label {
  color: var(--win-color, var(--correct-color));
}

.player-card.is-lose .score-status-label {
  color: var(--lose-color, var(--wrong-color));
}

/* 質感 */
.card-fx {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  border-radius: inherit;
}

/* ロック中の暗幕は質感より優先 */
.score-board .player-card.is-locked:not(.is-win):not(.is-lose)::before {
  background: var(--page-bg);
  opacity: 0.48;
  box-shadow: none;
  z-index: 2;
}

/* リーチの光 */
.score-board[data-reach-glow="1"] .player-card.is-win-reach {
  box-shadow: 0 0 var(--reach-glow-blur, 18px) var(--reach-win-color, #e85c5c), var(--card-shadow, 0 0 0 transparent);
}

.score-board[data-reach-glow="1"] .player-card.is-lose-reach {
  box-shadow: 0 0 var(--reach-glow-blur, 18px) var(--reach-lose-color, #4455e7), var(--card-shadow, 0 0 0 transparent);
}

/* 勝ち抜けの見せ方 */
.score-board[data-adv-style="highlight"] .player-card.is-advanced .card-fx {
  background: var(--adv-tint, rgba(255, 215, 0, 0.22));
}

.score-board[data-adv-style="glow"] .player-card.is-advanced {
  border-color: var(--adv-color, #ffd700) !important;
  box-shadow: 0 0 28px var(--adv-color, #ffd700), var(--card-shadow, 0 0 0 transparent);
}

.score-board[data-adv-style="badge"] .player-card.is-advanced .card-fx::after {
  content: "★";
  position: absolute;
  top: calc(var(--rank-band-height, 0px) * 0 + 8px);
  right: 8px;
  width: 1.6em;
  height: 1.6em;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #111111;
  background: var(--adv-color, #ffd700);
  box-shadow: 0 0 12px var(--adv-color, #ffd700);
  font-size: clamp(12px, calc(var(--player-card-base-width, 200px) * 0.1), 24px);
}

.score-board[data-rank-band="1"][data-adv-style="badge"] .player-card.is-advanced .card-fx::after {
  top: calc(var(--rank-band-height, 34px) + 6px);
}

/* 失格の見せ方 */
/* カードを暗くする：前面に置いた得点・名前・失格の文字・枠も含めてカード全体を暗くする（幕を敷くと前面の得点が明るいまま残る）。 */
.score-board[data-elim-style="dim"] .player-card.is-lose {
  filter: brightness(var(--elim-brightness, 0.45));
}

.score-board[data-elim-style="cross"] .player-card.is-lose .card-fx {
  background:
    linear-gradient(to top right, transparent calc(50% - 3px), var(--elim-color, #ff4444) calc(50% - 3px), var(--elim-color, #ff4444) calc(50% + 3px), transparent calc(50% + 3px)),
    linear-gradient(to bottom right, transparent calc(50% - 3px), var(--elim-color, #ff4444) calc(50% - 3px), var(--elim-color, #ff4444) calc(50% + 3px), transparent calc(50% + 3px)),
    rgba(0, 0, 0, 0.42);
}

/* ════════════════════════════════════════════════════════════════
   表示画面：タイマー
   ════════════════════════════════════════════════════════════════ */
/* ════════════════════════════════════════════════════════════════
   表示画面の小窓（PiP）
   ════════════════════════════════════════════════════════════════ */
.pip-window {
  position: fixed;
  z-index: 3000;
  display: grid;
  overflow: hidden;
  color: #e8eaed;
  background: #1f1f1f;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.25);
  user-select: none;
}

.pip-window.is-dragging {
  opacity: 0.92;
}

.pip-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 6px 14px;
  cursor: move;
  touch-action: none;
  font-size: 13px;
  font-weight: 700;
}

.pip-title {
  flex: 1 1 auto;
}

body .pip-head button,
body .pip-head select {
  min-height: 28px;
  padding: 2px 10px;
  color: #e8eaed;
  background: rgba(255, 255, 255, 0.08);
  border: 0;
  border-radius: 14px;
  font-size: 12px;
  cursor: pointer;
}

body .pip-head button:hover,
body .pip-head select:hover {
  background: rgba(255, 255, 255, 0.16);
}

.pip-body {
  position: relative;
}

.pip-viewport {
  position: relative;
  overflow: hidden;
  background: #000000;
}

.pip-canvas {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left;
  pointer-events: none;
  /* 閲覧者と同じ配色（司会画面のテーマ色を持ち込まない） */
  --page-bg: #f4f4f4;
  --page-fg: #222222;
  --panel-fg: #222222;
  --panel-border: #d2d2d2;
  --field-bg: #ffffff;
  --muted-fg: #666666;
  --hover-bg: #eeeeee;
  --action-bg: #2f4f66;
  --action-fg: #ffffff;
  --action-hover-bg: #42677d;
  color: var(--page-fg);
  background: var(--page-bg);
  font-family: system-ui, sans-serif;
}

body.is-dark .pip-canvas {
  --page-bg: #181818;
  --page-fg: #eeeeee;
  --panel-fg: #eeeeee;
  --panel-border: #555555;
  --field-bg: #181818;
  --muted-fg: #bbbbbb;
  --hover-bg: #333333;
}

body.is-host .pip-canvas > .app-shell {
  display: grid;
  position: static;
  width: 100%;
  height: 100%;
  background: var(--page-bg);
}

body.is-host .pip-canvas .judge-row {
  display: none;
}

body.is-host .pip-canvas .score-board {
  padding-bottom: 28px;
}

.pip-canvas .free-screen-item.is-image img {
  max-height: calc(var(--pip-h, 1080px) * 0.88);
}

.pip-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 22px;
  height: 22px;
  cursor: nwse-resize;
  touch-action: none;
  background: linear-gradient(135deg, transparent 50%, rgba(255, 255, 255, 0.55) 50%, rgba(255, 255, 255, 0.55) 60%, transparent 60%, transparent 70%, rgba(255, 255, 255, 0.55) 70%, rgba(255, 255, 255, 0.55) 80%, transparent 80%);
}

/* ════════════════════════════════════════════════════════════════
   管理画面：マテリアルデザイン
   既存テーマ（ライト/クール/モノ/ダーク）の色変数をそのまま使い、形・余白・影・動きを Material 3 風にする。
   ════════════════════════════════════════════════════════════════ */
body.is-host:not(.is-host-preview) {
  --md-radius-s: 8px;
  --md-radius-m: 12px;
  --md-radius-l: 16px;
  --md-radius-full: 999px;
  --md-elev-1: 0 1px 2px rgba(0, 0, 0, 0.12), 0 1px 3px 1px rgba(0, 0, 0, 0.06);
  --md-elev-2: 0 1px 2px rgba(0, 0, 0, 0.14), 0 2px 6px 2px rgba(0, 0, 0, 0.08);
  --md-primary: var(--action-bg);
  --md-on-primary: var(--action-fg);
  --md-primary-container: color-mix(in srgb, var(--action-bg) 14%, var(--field-bg));
  --md-surface: var(--field-bg);
  --md-surface-dim: color-mix(in srgb, var(--page-fg) 4%, var(--page-bg));
  --md-outline: color-mix(in srgb, var(--page-fg) 22%, transparent);
  font-family: "Noto Sans JP", system-ui, sans-serif;
  background: var(--md-surface-dim);
}

body.is-host:not(.is-host-preview) .modal-backdrop,
body.is-host:not(.is-host-preview) .manage-modal {
  background: var(--md-surface-dim);
}

/* トップアプリバー */
body.is-host:not(.is-host-preview) .host-dashboard-head {
  padding: 12px 24px;
  background: var(--md-surface);
  border-bottom: 0;
  box-shadow: var(--md-elev-1);
}

body.is-host:not(.is-host-preview) .host-dashboard-head h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0;
}

/* ボタン */
body.is-host:not(.is-host-preview) .manage-modal button,
body.is-host:not(.is-host-preview) .manage-modal .button-like {
  min-height: 36px;
  padding: 6px 16px;
  color: var(--md-primary);
  background: transparent;
  border: 1px solid var(--md-outline);
  border-radius: var(--md-radius-full);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.01em;
  transition: background-color 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

body.is-host:not(.is-host-preview) .manage-modal button:hover,
body.is-host:not(.is-host-preview) .manage-modal .button-like:hover {
  background: color-mix(in srgb, var(--md-primary) 8%, transparent);
}

body.is-host:not(.is-host-preview) .manage-modal button:focus-visible {
  outline: 2px solid var(--md-primary);
  outline-offset: 2px;
}

body.is-host:not(.is-host-preview) .manage-modal button:disabled {
  color: color-mix(in srgb, var(--page-fg) 38%, transparent);
  border-color: color-mix(in srgb, var(--page-fg) 12%, transparent);
  background: transparent;
  box-shadow: none;
  cursor: default;
}

body.is-host:not(.is-host-preview) .manage-modal .primary-button,
body.is-host:not(.is-host-preview) #manageModalCloseButton,
body.is-host:not(.is-host-preview) #applyRuleButton {
  color: var(--md-on-primary);
  background: var(--md-primary);
  border-color: transparent;
}

body.is-host:not(.is-host-preview) .manage-modal .primary-button:hover,
body.is-host:not(.is-host-preview) #manageModalCloseButton:hover,
body.is-host:not(.is-host-preview) #applyRuleButton:hover {
  background: var(--action-hover-bg);
  box-shadow: var(--md-elev-1);
}

body.is-host:not(.is-host-preview) .manage-modal .danger-button {
  color: #b3261e;
  border-color: color-mix(in srgb, #b3261e 40%, transparent);
}

body.is-host.host-theme-dark:not(.is-host-preview) .manage-modal .danger-button {
  color: #f2b8b5;
  border-color: color-mix(in srgb, #f2b8b5 40%, transparent);
}

body.is-host:not(.is-host-preview) .manage-modal .icon-action-button {
  min-width: 36px;
  padding: 4px 8px;
  border-radius: var(--md-radius-s);
}

body.is-host:not(.is-host-preview) .manage-modal .icon-action-button.is-correct {
  color: #ffffff;
  background: var(--correct-color);
  border-color: transparent;
}

body.is-host:not(.is-host-preview) .manage-modal .icon-action-button.is-wrong {
  color: #ffffff;
  background: var(--wrong-color);
  border-color: transparent;
}

/* 入力欄 */
body.is-host:not(.is-host-preview) .manage-modal input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),
body.is-host:not(.is-host-preview) .manage-modal select,
body.is-host:not(.is-host-preview) .manage-modal textarea {
  min-height: 36px;
  padding: 6px 10px;
  color: var(--page-fg);
  background: var(--md-surface);
  border: 1px solid var(--md-outline);
  border-radius: var(--md-radius-s);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

body.is-host:not(.is-host-preview) .manage-modal input:not([type="checkbox"]):not([type="radio"]):focus,
body.is-host:not(.is-host-preview) .manage-modal select:focus,
body.is-host:not(.is-host-preview) .manage-modal textarea:focus {
  border-color: var(--md-primary);
  box-shadow: 0 0 0 1px var(--md-primary);
  outline: none;
}

body.is-host:not(.is-host-preview) .manage-modal input[type="color"] {
  width: 44px;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--md-outline);
  border-radius: var(--md-radius-s);
  background: var(--md-surface);
}

body.is-host:not(.is-host-preview) .manage-modal input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--md-primary);
}

/* 概要カード */
body.is-host:not(.is-host-preview) .host-overview {
  padding: 16px 24px 4px;
  border-bottom: 0;
}

body.is-host:not(.is-host-preview) .host-status-card {
  padding: 14px 16px;
  background: var(--md-surface);
  border: 0;
  border-radius: var(--md-radius-m);
  box-shadow: var(--md-elev-1);
}

/* タブ（下線インジケーター付き） */
body.is-host:not(.is-host-preview) .host-tabs {
  display: flex;
  gap: 4px;
  top: 61px;
  padding: 8px 24px 0;
  background: var(--md-surface-dim);
  border-bottom: 1px solid var(--md-outline);
  overflow-x: auto;
  scrollbar-width: thin;
}

body.is-host:not(.is-host-preview) .host-tabs button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 8px 18px;
  color: var(--muted-fg);
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: var(--md-radius-s) var(--md-radius-s) 0 0;
  font-size: 14px;
  font-weight: 600;
}

body.is-host:not(.is-host-preview) .host-tabs button:hover {
  color: var(--page-fg);
  background: color-mix(in srgb, var(--md-primary) 6%, transparent);
}

body.is-host:not(.is-host-preview) .host-tabs button.is-active {
  color: var(--md-primary);
  border-bottom-color: var(--md-primary);
  background: transparent;
}

/* カード */
body.is-host:not(.is-host-preview) .host-main {
  padding: 20px 24px 40px;
}

body.is-host:not(.is-host-preview) .host-panel-grid {
  gap: 16px;
  margin-bottom: 16px;
}

body.is-host:not(.is-host-preview) .host-card {
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 18px 20px;
  background: var(--md-surface);
  border: 0;
  border-radius: var(--md-radius-l);
  box-shadow: var(--md-elev-1);
}

body.is-host:not(.is-host-preview) .host-card h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

body.is-host:not(.is-host-preview) .host-note {
  background: var(--md-surface-dim);
  border: 0;
  border-radius: var(--md-radius-s);
}

body.is-host:not(.is-host-preview) .participant-table th {
  background: var(--md-surface-dim);
}

body.is-host:not(.is-host-preview) .round-control-row,
body.is-host:not(.is-host-preview) .round-participant-row,
body.is-host:not(.is-host-preview) .assignment-row {
  border-radius: var(--md-radius-m);
}

/* 共通部品 */
.host-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.host-card-head .host-action-row {
  display: flex;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 10px;
  border-radius: 999px;
  color: var(--action-fg);
  background: var(--action-bg);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.chip.is-off {
  color: var(--muted-fg);
  background: color-mix(in srgb, var(--page-fg) 8%, transparent);
}

.chip.is-live {
  color: #ffffff;
  background: #188038;
}

.segmented {
  display: inline-flex;
}

body.is-host:not(.is-host-preview) .manage-modal .segmented button {
  border-radius: 0;
  margin-left: -1px;
}

body.is-host:not(.is-host-preview) .manage-modal .segmented button:first-child {
  border-radius: 999px 0 0 999px;
  margin-left: 0;
}

body.is-host:not(.is-host-preview) .manage-modal .segmented button:last-child {
  border-radius: 0 999px 999px 0;
}

body.is-host:not(.is-host-preview) .manage-modal .segmented button.is-active {
  color: var(--md-on-primary);
  background: var(--md-primary);
  border-color: var(--md-primary);
}

.host-card .host-action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

.inline-field input {
  width: 84px;
}

.check-field {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.host-details {
  border-top: 1px solid color-mix(in srgb, var(--page-fg) 12%, transparent);
  padding-top: 8px;
}

.host-details summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted-fg);
  padding: 4px 0;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px 14px;
  margin-top: 10px;
}

.settings-grid > label:not(.check-field) {
  display: grid;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted-fg);
}

/* 問題・解答 */
.qa-status {
  margin: 0;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
}

.qa-status.is-off { color: var(--muted-fg); background: color-mix(in srgb, var(--page-fg) 6%, transparent); }
.qa-status.is-wait { color: #7a5900; background: #fff4d6; }
.qa-status.is-live { color: #0b5c27; background: #dcf5e3; }
.qa-status.is-hidden { color: #8c1d18; background: #fde7e6; }

.qa-card {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--action-bg) 8%, var(--field-bg));
}

.qa-card-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted-fg);
}

.qa-question {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.qa-answer {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: #b3261e;
}

body.host-theme-dark .qa-answer { color: #f2b8b5; }

/* タイマー（司会画面の表示） */
.timer-readout {
  margin: 0;
  font-size: 56px;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.timer-readout.is-warn {
  color: #d93025;
}

/* カード・画面の見た目フォーム */
.display-style-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.style-group {
  display: grid;
  gap: 10px;
  align-content: start;
  margin: 0;
  padding: 12px 14px 14px;
  border: 1px solid color-mix(in srgb, var(--page-fg) 12%, transparent);
  border-radius: 12px;
}

.style-group legend {
  padding: 0 6px;
  font-size: 13px;
  font-weight: 800;
}

.style-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.style-field select,
.style-field input[type="number"] {
  width: 150px;
}

.color-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ヘッダーの要素エディタ */
.header-editor {
  display: grid;
  gap: 8px;
}

.header-item-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--page-fg) 4%, transparent);
}

.header-item-name {
  min-width: 64px;
  font-size: 13px;
}

.header-item-text {
  flex: 1 1 200px;
}

.mini-field {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted-fg);
}

.mini-field input[type="number"] {
  width: 68px;
}

/* フェーズ */
.phase-list {
  display: grid;
  gap: 10px;
}

.phase-row {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--page-fg) 12%, transparent);
}

.phase-row.is-active {
  border-color: var(--action-bg);
  box-shadow: inset 4px 0 0 var(--action-bg);
  background: color-mix(in srgb, var(--action-bg) 6%, transparent);
}

.phase-row-main,
.phase-row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.phase-index {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: var(--action-fg);
  background: var(--action-bg);
  font-size: 13px;
  font-weight: 800;
}

.phase-name-input {
  flex: 1 1 200px;
  font-weight: 700;
}

.phase-player-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px 12px;
  margin-top: 8px;
}

@media (max-width: 900px) {
  body.is-host:not(.is-host-preview) .host-panel-grid {
    grid-template-columns: 1fr;
  }

  .pip-head .pip-resolution {
    display: none;
  }
}

.participant-color-cell {
  white-space: nowrap;
}

.participant-color-cell input.is-unset {
  opacity: 0.45;
}

.participant-color-cell button {
  margin-left: 4px;
}

.rank-color-group {
  grid-column: 1 / -1;
}

.rank-color-rules {
  display: grid;
  gap: 6px;
}

.rank-rule-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.rank-rule-row input[type="number"] {
  width: 64px;
}

.host-footer button.is-active .footer-icon-label {
  text-decoration: underline;
  text-underline-offset: 4px;
  font-weight: 700;
}

body.is-host.is-host-preview .host-footer { bottom: 4px; right: 10px; gap: 8px; }
body.is-host.is-host-preview .host-footer button { min-height: 44px; padding: 0 4px; }
body.is-host.is-host-preview .score-board { padding-bottom: 0; }
@media (max-width: 480px) {
  body.is-host.is-host-preview .host-footer { gap: 4px; }
  .host-footer .footer-icon-label { font-size: 12px; }
}

.player-card.is-locked.is-lock-undimmed::before { display: none; }
/* フッターは一列の専用領域へ。判定ボタンと重ならず、カードを二重に縮めない。 */
body.is-host.is-host-preview .app-shell { height: calc(100svh - 36px); bottom: 36px; }
body.is-host.is-host-preview .host-footer { bottom: 0; right: 10px; gap: 8px; height: 36px; }
body.is-host.is-host-preview .host-footer button { min-height: 36px; height: 36px; }

.app-shell.has-stage-margin { background: var(--stage-margin-color, #000); }
/* 画面周囲の余白は表示編集の見本と同じ縮み方にする：ヘッダーと盤面がそれぞれ自分の中心を基準に縮む
   （ヘッダーは上端に残る）。タイマーは見本と同じく、ヘッダー配置ならヘッダーの中心、それ以外は画面中央が基準。
   余白部分は見本と同じく余白の色、盤面は画面の背景色。 */
.app-shell > .stage { background: var(--stage-bg, #000000); }
.app-shell.has-stage-margin > .stage { background: transparent; }
.app-shell.has-stage-margin #scoreBoard { background: var(--stage-bg, #000000); }
.app-shell #scoreHeader, .app-shell #scoreBoard, .app-shell #stageTimerLayer { scale: var(--stage-scale, 1); transform-origin: center; }
/* 待機画面などの自由画面は余白で縮めず、画面全体を覆う（縮めると周りから下のヘッダー・盤面がのぞく）。 */
.app-shell #freeScreen { scale: none; }
.stage-timer-layer { position: absolute; inset: 0; z-index: 45; pointer-events: none; }
.stage-timer-layer > .stage-timer { pointer-events: auto; }
.stage-timer-layer.is-header-position { transform-origin: 50% calc(var(--header-height) / 2); }

.bulk-rank-color-row { display:flex; align-items:end; flex-wrap:wrap; gap:8px; padding:8px 0; }
.bulk-rank-color-row label { display:grid; gap:4px; margin:0; }
.bulk-rank-color-row input[type="number"] { width:100px; min-width:0; }
.bulk-rank-color-row input[type="color"] { width:60px; min-height:40px; padding:3px; }
.bulk-rank-color-row > span { padding-bottom:10px; }

/* 得点編集はラベルと数値操作を分離し、ボタン同士を重ねない。 */
body.is-blank-flow #scoreHeader, body.is-blank-flow #scoreBoard, body.is-blank-flow #stageTimer, body.is-blank-flow #freeScreen { display:none !important; }
#roundControlList .round-control-stats { grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; }
#roundControlList .round-stat-control { display:grid; grid-template-columns:minmax(0,1fr); gap:6px; }
#roundControlList .round-stat-control > label { display:block; margin:0; padding:0; font-weight:700; font-size:13px; }
#roundControlList .round-stat-stepper { display:grid; grid-template-columns:36px minmax(42px,1fr) 36px; gap:4px; align-items:center; }
#roundControlList .round-stat-stepper button, #roundControlList .round-stat-stepper input { width:100%; min-width:0; height:40px; min-height:40px; margin:0; padding:4px; box-sizing:border-box; border-radius:8px; text-align:center; }
#roundControlList .round-control-actions { align-self:end; gap:8px; }
#roundControlList .round-control-actions button { min-height:40px; }
@media(max-width:1100px) { #roundControlList .round-control-row { grid-template-columns:minmax(0,1fr); gap:14px; } }
@media(max-width:560px) { #roundControlList .round-control-stats { grid-template-columns:repeat(2,minmax(0,1fr)); } #roundControlList .round-control-actions { grid-template-columns:repeat(3,minmax(0,1fr)); } }
@media(pointer:coarse) { #roundControlList .round-stat-stepper { grid-template-columns:48px minmax(42px,1fr) 48px; } #roundControlList .round-stat-stepper button, #roundControlList .round-stat-stepper input, #roundControlList .round-control-actions button { min-height:48px; height:48px; } }

/* 待機画面はいつでも出せる。非表示ノード（筆記中など）でも待機画面だけは表示する。 */
body.is-blank-flow #freeScreen.is-waiting-screen:not([hidden]) { display:block !important; }
.waiting-toggle-button[aria-pressed="true"] { color:#ffffff; background:#b45309; border-color:#b45309; }

/* タイムレース：司会が表示するまで、閲覧者画面（と小窓）では変数（得点の数字・記号、スコアバー、誤答マーク）だけを隠す。
   順位・名前・勝ち抜け/失格の表示・カードの枠や演出はそのまま。配置は保つ。 */
.score-board.is-scores-hidden .player-card .score-layer,
.score-board.is-scores-hidden .player-card .score-bar,
.score-board.is-scores-hidden .player-card .wrong-marks { visibility: hidden !important; }
.scores-toggle-button[aria-pressed="true"] { color:#ffffff; background:#1565c0; border-color:#1565c0; }

/* ════════════════════════════════════════════════════════════════
   司会ダッシュボード（2026-11-27 作り直し）：web得点表示の管理画面にならう
   上のバー／ノードの横一列＋前へ・次へ（固定）／左にプレイヤー操作・右にたためるパネル／参加者は別画面
   ════════════════════════════════════════════════════════════════ */
body.is-host:not(.is-host-preview) #hostPanel { grid-template-rows: none; align-content: start; --host-bar-h: 60px; }
body.is-host:not(.is-host-preview) #hostPanel .host-bar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: var(--host-bar-h); box-sizing: border-box; padding: 8px 20px; background: var(--md-surface); border-bottom: 1px solid var(--md-outline); box-shadow: var(--md-elev-1);
}
#hostPanel .host-bar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
#hostPanel .host-brand { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--action-bg); color: var(--action-fg); font-weight: 900; flex: 0 0 auto; }
#hostPanel .host-bar-titles { display: grid; min-width: 0; }
#hostPanel .host-bar-titles .eyebrow { margin: 0; font-size: 11px; opacity: .7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
#hostPanel .host-bar-titles h1 { margin: 0; font-size: 15px; white-space: nowrap; }
body.is-host:not(.is-host-preview) #hostPanel .host-view-seg { position: static; display: inline-flex; gap: 0; padding: 3px; border: 1px solid var(--md-outline); border-radius: 999px; background: var(--md-surface-dim); overflow: visible; }
body.is-host:not(.is-host-preview) #hostPanel .host-view-seg button { min-height: 34px; padding: 4px 18px; border: 0; border-radius: 999px; color: var(--muted-fg); background: transparent; font-weight: 700; }
body.is-host:not(.is-host-preview) #hostPanel .host-view-seg button.is-active { color: var(--md-on-primary); background: var(--md-primary); }
#hostPanel .host-head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; min-width: 0; }
#hostPanel .host-head-actions > button { min-height: 36px; white-space: nowrap; }
#hostPanel .connection-status { margin: 0; font-size: 12px; opacity: .7; }
#hostPanel .host-bar-menu { position: relative; }
#hostPanel .host-bar-menu > summary { list-style: none; cursor: pointer; min-height: 36px; display: inline-flex; align-items: center; padding: 0 14px; border: 1px solid var(--md-outline); border-radius: 999px; font-weight: 700; font-size: 13px; }
#hostPanel .host-bar-menu > summary::-webkit-details-marker { display: none; }
#hostPanel .host-bar-menu-body { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; display: grid; gap: 10px; width: 280px; padding: 12px; border-radius: 12px; background: var(--md-surface); box-shadow: var(--md-elev-2); }
#hostPanel .host-bar-menu-body .host-status-card { display: grid; gap: 4px; padding: 0; box-shadow: none; }

/* 進行バー：1行目に「現在」と前へ・次へ、2行目にノードの横一列（スクロール） */
body.is-host:not(.is-host-preview) #hostPanel .host-flowbar {
  position: sticky; top: var(--host-bar-h); z-index: 25; display: grid; gap: 6px 12px;
  grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "now actions" "tabs tabs" "summary summary";
  padding: 10px 20px 8px; background: var(--md-surface-dim); border-bottom: 1px solid var(--md-outline);
}
#hostPanel .host-flowbar[hidden] { display: none !important; }
#hostPanel .host-flowbar-now { grid-area: now; display: flex; align-items: baseline; gap: 10px; min-width: 0; }
#hostPanel .host-flowbar-caption { font-size: 12px; font-weight: 700; opacity: .65; flex: 0 0 auto; }
#hostPanel #operationFlowSummary { font-size: 18px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hostPanel #flowNodeActions { grid-area: actions; display: flex; align-items: center; gap: 8px; margin: 0; }
#hostPanel #flowNodeActions[hidden] { display: none; }
#hostPanel #flowNodeActions button { min-height: 40px; white-space: nowrap; }
#hostPanel #flowNodeNextButton { min-width: 120px; font-size: 16px; font-weight: 800; }
#hostPanel #flowNodeNextTarget { max-width: 280px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .8; }
#hostPanel #flowNodeSummary { grid-area: summary; margin: 0; padding: 0; font-size: 12px; background: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hostPanel .flow-node-tabs { grid-area: tabs; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; gap: 4px; padding: 2px 2px 6px; scroll-snap-type: x proximity; scrollbar-width: thin; }
#hostPanel #flowNodeTabs .flow-node-tab { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; min-height: 34px; max-width: 240px; padding: 4px 12px 4px 10px; border-radius: 999px; border-left-width: 1px; scroll-snap-align: center; }
#hostPanel #flowNodeTabs .flow-node-tab-type { width: 8px; height: 8px; border-radius: 50%; background: var(--node-color, var(--panel-border)); font-size: 0; flex: 0 0 auto; opacity: 1; }
#hostPanel #flowNodeTabs .flow-node-tab-name { font-size: 13px; max-width: 210px; }
#hostPanel #flowNodeTabs .flow-node-tab[aria-selected="true"] .flow-node-tab-type { background: var(--action-fg); }

/* 本体：左にプレイヤー操作（大きく）、右にたためるパネル */
body.is-host:not(.is-host-preview) #hostPanel .host-game { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); gap: 16px; align-items: start; padding: 16px 20px 40px; }
body.is-host:not(.is-host-preview) #hostPanel .host-people { display: block; padding: 16px 20px 40px; }
#hostPanel .host-main[hidden] { display: none !important; }
#hostPanel .host-col-main, #hostPanel .host-col-side { display: grid; gap: 14px; align-content: start; min-width: 0; }
#hostPanel .host-col-main { container-type: inline-size; }
#hostPanel .host-col-main:has(> section[data-flow-visible="1"]:not([hidden])) > .host-empty-note { display: none; }
#hostPanel .host-empty-note { padding: 14px 18px; }
#hostPanel details.host-panel { display: block; padding: 0; overflow: hidden; }
#hostPanel details.host-panel > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 14px 18px; margin: 0; }
#hostPanel details.host-panel > summary::-webkit-details-marker { display: none; }
#hostPanel details.host-panel > summary::after { content: "▾"; margin-left: auto; opacity: .6; transition: transform .15s; }
#hostPanel details.host-panel:not([open]) > summary::after { transform: rotate(-90deg); }
#hostPanel details.host-panel > summary h2 { margin: 0; font-size: 15px; }
#hostPanel details.host-panel[open] > :not(summary) { margin-left: 18px; margin-right: 18px; }
#hostPanel details.host-panel[open] { padding-bottom: 14px; }
#hostPanel details.host-panel[open] > :not(summary) + :not(summary) { margin-top: 10px; }
#hostPanel details.host-panel label { display: grid; gap: 4px; }
#hostPanel details.host-panel label.check-field, #hostPanel details.host-panel label.inline-field { display: flex; align-items: center; gap: 6px; }
#hostPanel .host-panel-details > summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 12px; }
#hostPanel .host-panel-details > summary h2 { margin: 0; }
#hostPanel .host-panel-details > summary::-webkit-details-marker { display: none; }
#hostPanel .host-panel-details > summary::after { content: "▾"; margin-left: auto; opacity: .6; }
#hostPanel .host-panel-details[open] > .round-participant-list { margin-top: 12px; }

/* プレイヤー操作（web得点表示のプレイヤー表のように1人1行） */
#hostPanel .host-sheet .host-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
#hostPanel .host-sheet .host-card-head h2 { margin: 0; }
#hostPanel .host-sheet #roundControlSummary { margin: 0; }
#hostPanel .host-sheet .host-sheet-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 6px; }
#hostPanel .host-sheet .host-sheet-actions button { min-height: 34px; padding: 4px 12px; }
#hostPanel .host-rule-note { margin: 0; padding: 8px 12px; border-radius: 8px; background: var(--md-surface-dim); font-size: 12px; max-height: 5.5em; overflow: auto; }
#hostPanel .host-rule-note:empty { display: none; }
#hostPanel #roundControlList { gap: 6px; }
#hostPanel #roundControlList .round-control-row { grid-template-columns: minmax(120px, 1fr) minmax(0, 2.6fr) auto; gap: 12px; padding: 8px 12px; border-radius: 10px; }
#hostPanel #roundControlList .round-control-player strong { font-size: 15px; }
#hostPanel #roundControlList .round-control-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
#hostPanel #roundControlList .round-stat-control { gap: 2px; }
#hostPanel #roundControlList .round-stat-control > label { font-size: 11px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hostPanel #roundControlList .round-stat-stepper { grid-template-columns: 30px minmax(36px, 1fr) 30px; gap: 3px; }
#hostPanel #roundControlList .round-stat-stepper button, #hostPanel #roundControlList .round-stat-stepper input { height: 34px; min-height: 34px; }
#hostPanel #roundControlList .round-control-actions { grid-template-columns: repeat(3, 52px); grid-auto-rows: 34px; gap: 4px; align-self: center; }
#hostPanel #roundControlList .round-control-actions button { min-height: 34px; height: 34px; padding: 0 4px; font-size: 12px; }
#hostPanel #roundControlList .round-control-actions .is-correct span, #hostPanel #roundControlList .round-control-actions .is-wrong span { font-size: 15px; }
@container (max-width: 760px) {
  #hostPanel #roundControlList .round-control-row { grid-template-columns: minmax(0, 1fr) auto; }
  #hostPanel #roundControlList .round-control-stats { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 1100px) {
  body.is-host:not(.is-host-preview) #hostPanel .host-game { grid-template-columns: minmax(0, 1fr); }
  #hostPanel .host-head-actions .connection-status { display: none; }
}
@media (max-width: 820px) {
  body.is-host:not(.is-host-preview) #hostPanel .host-bar { height: auto; flex-wrap: wrap; }
  #hostPanel .host-head-actions { flex-wrap: wrap; }
  body.is-host:not(.is-host-preview) #hostPanel .host-flowbar { position: static; grid-template-columns: minmax(0, 1fr); grid-template-areas: "now" "actions" "tabs" "summary"; }
  #hostPanel #flowNodeActions { flex-wrap: wrap; }
}

#hostPanel .host-global-ops { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 16px; }
#hostPanel .host-global-ops-caption { font-size: 12px; font-weight: 700; opacity: .65; margin-right: 4px; }
#hostPanel .host-global-ops button { min-height: 34px; padding: 4px 14px; }
#hostPanel .host-global-ops #resetScoresButton { margin-left: auto; }

/* プレイヤー操作：閲覧画面と同じ並びの縦長カード。上から順位・名前・状態・変数（数字を押すと直せる）・○×／WIN LOSE／LOCK 名前。 */
#hostPanel #roundControlList.is-card-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 8px; align-items: stretch; }
#hostPanel #roundControlList.is-card-list .round-control-row { display: flex; flex-direction: column; gap: 8px; padding: 0 0 8px; border-radius: 10px; overflow: hidden; text-align: center; opacity: 1; }
#hostPanel #roundControlList.is-card-list .round-control-row.is-selected { outline: 3px solid var(--action-bg); outline-offset: -3px; }
#hostPanel #roundControlList.is-card-list .round-control-row.is-win { border-color: var(--correct-color, #e85c5c); }
#hostPanel #roundControlList.is-card-list .round-control-row.is-lose,
#hostPanel #roundControlList.is-card-list .round-control-row.is-locked { filter: saturate(.4); }
#hostPanel #roundControlList.is-card-list .round-control-row.is-lose .round-control-stats,
#hostPanel #roundControlList.is-card-list .round-control-row.is-lose .round-control-player { opacity: .6; }
#hostPanel #roundControlList.is-card-list .round-card-rank { min-height: 22px; padding: 2px 6px; background: var(--md-primary-container, var(--field-bg)); font-size: 12px; font-weight: 800; }
#hostPanel #roundControlList.is-card-list .round-control-player { display: grid; gap: 2px; padding: 0 8px; }
#hostPanel #roundControlList.is-card-list .round-control-player strong { font-size: 16px; line-height: 1.25; white-space: normal; overflow-wrap: anywhere; overflow: visible; }
#hostPanel #roundControlList.is-card-list .round-control-player span { font-size: 11px; white-space: nowrap; }
#hostPanel #roundControlList.is-card-list .round-control-row.is-win .round-control-player span { color: var(--correct-color, #e85c5c); }
#hostPanel #roundControlList.is-card-list .round-control-row.is-lose .round-control-player span { color: var(--wrong-color, #4455e7); }
#hostPanel #roundControlList.is-card-list .round-control-stats { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; padding: 0 6px; flex: 1 1 auto; align-content: start; }
#hostPanel #roundControlList.is-card-list .round-stat-control { display: grid; gap: 0; }
#hostPanel #roundControlList.is-card-list .round-stat-control > label { font-size: 10px; font-weight: 700; opacity: .7; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hostPanel #roundControlList.is-card-list .round-stat-control.is-unlabeled { opacity: .7; }
#hostPanel #roundControlList.is-card-list .round-stat-stepper { display: grid; grid-template-columns: 22px minmax(0, 1fr) 22px; gap: 2px; align-items: center; }
#hostPanel #roundControlList.is-card-list .round-stat-stepper button { width: 22px; height: 28px; min-height: 28px; padding: 0; border-radius: 6px; font-size: 13px; opacity: .55; }
#hostPanel #roundControlList.is-card-list .round-stat-stepper button:hover { opacity: 1; }
/* 数字は大きく、枠なし。押すと（フォーカスで）枠が出て打ち直せる。 */
#hostPanel #roundControlList.is-card-list .round-stat-stepper input { height: 32px; min-height: 32px; padding: 0 2px; border: 1px solid transparent; border-radius: 6px; background: transparent; font-size: 22px; font-weight: 800; text-align: center; cursor: text; -moz-appearance: textfield; }
#hostPanel #roundControlList.is-card-list .round-stat-stepper input::-webkit-outer-spin-button,
#hostPanel #roundControlList.is-card-list .round-stat-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#hostPanel #roundControlList.is-card-list .round-stat-stepper input:hover { border-color: var(--md-outline, var(--panel-border)); }
#hostPanel #roundControlList.is-card-list .round-stat-stepper input:focus { border-color: var(--action-bg); background: var(--field-bg); outline: none; }
#hostPanel #roundControlList.is-card-list .round-control-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: auto; gap: 4px; padding: 0 6px; align-self: stretch; }
#hostPanel #roundControlList.is-card-list .round-control-actions button { width: 100%; min-height: 32px; height: 32px; padding: 0 2px; border-radius: 8px; font-size: 12px; font-weight: 800; }
#hostPanel #roundControlList.is-card-list .round-control-actions button[data-round-judge-player] { min-height: 42px; height: 42px; }
#hostPanel #roundControlList.is-card-list .round-control-actions button[data-round-judge-player] span { font-size: 20px; }
#hostPanel #roundControlList.is-card-list .round-control-actions button[data-round-toggle-name] { font-size: 11px; }

/* 司会ダッシュボードはシンプルで四角い見た目にする（丸いタブ・角丸・横の色線・影は使わない）。
   色は塗り分けで使う：ノードは種類ごとの色、今のノードはその色で塗りつぶし。 */
#hostPanel, #hostPanel *, #hostPanel *::before, #hostPanel *::after { border-radius: 0 !important; }
body.is-host:not(.is-host-preview) #hostPanel .host-card,
body.is-host:not(.is-host-preview) #hostPanel details.host-panel { box-shadow: none; border: 1px solid var(--md-outline); }
body.is-host:not(.is-host-preview) #hostPanel .host-bar { box-shadow: none; }
body.is-host:not(.is-host-preview) #hostPanel .host-view-seg { padding: 0; gap: 0; border: 1px solid var(--md-outline); }
body.is-host:not(.is-host-preview) #hostPanel .host-view-seg button { min-height: 36px; padding: 4px 20px; }
#hostPanel .host-bar-menu > summary { border: 1px solid var(--md-outline); }
#hostPanel .host-bar-menu-body { box-shadow: none; border: 1px solid var(--md-outline); }

/* ノード：種類ごとに淡い色で塗る。今のノードは濃い色で塗り、文字は白。「次へ」の行き先は先頭に「次▶」。 */
#hostPanel #flowNodeTabs .flow-node-tab {
  border: 1px solid color-mix(in srgb, var(--node-color, #6b7280) 45%, var(--field-bg));
  border-left-width: 1px; border-left-style: solid;
  background: color-mix(in srgb, var(--node-color, #6b7280) 14%, var(--field-bg));
  min-height: 36px; padding: 4px 12px; gap: 4px;
}
#hostPanel #flowNodeTabs .flow-node-tab-type { display: none; }
#hostPanel #flowNodeTabs .flow-node-tab[data-node-type="round"] { --node-color: #2563eb; }
#hostPanel #flowNodeTabs .flow-node-tab[data-node-type="group"] { --node-color: #9333ea; }
#hostPanel #flowNodeTabs .flow-node-tab[data-node-type="written"] { --node-color: #d97706; }
#hostPanel #flowNodeTabs .flow-node-tab[data-node-type="screen"], #hostPanel #flowNodeTabs .flow-node-tab[data-node-type="display"] { --node-color: #059669; }
#hostPanel #flowNodeTabs .flow-node-tab[data-node-type="end"] { --node-color: #4b5563; }
#hostPanel #flowNodeTabs .flow-node-tab.is-next { border-style: solid; border-color: color-mix(in srgb, var(--node-color, #6b7280) 45%, var(--field-bg)); }
#hostPanel #flowNodeTabs .flow-node-tab.is-next .flow-node-tab-name::before { content: "次▶ "; color: var(--node-color, #6b7280); font-weight: 900; }
#hostPanel #flowNodeTabs .flow-node-tab[aria-selected="true"] { background: var(--node-color, #374151); border-color: var(--node-color, #374151); color: #ffffff; }
#hostPanel #flowNodeTabs .flow-node-tab:hover:not([aria-selected="true"]) { background: color-mix(in srgb, var(--node-color, #6b7280) 26%, var(--field-bg)); }

/* プレイヤーのカード・ボタン：枠1本・影なし・色の塗りで区別 */
#hostPanel #roundControlList.is-card-list .round-control-row { border: 1px solid var(--md-outline); }
#hostPanel #roundControlList.is-card-list .round-control-row.is-selected { outline: 3px solid var(--action-bg); outline-offset: -3px; }
#hostPanel .assignment-target-bar { border: 1px solid var(--md-outline); }

/* 閲覧画面と同じく横一列（人数分の列）。狭いときは横にスクロール。 */
#hostPanel #roundControlList.is-card-list { grid-template-columns: repeat(var(--round-card-count, 6), minmax(104px, 1fr)); overflow-x: auto; padding-bottom: 4px; }
#hostPanel #roundControlList.is-card-list { grid-template-columns: repeat(var(--round-card-count, 6), minmax(86px, 1fr)); }
#hostPanel #roundControlList.is-card-list .round-stat-stepper { grid-template-columns: 18px minmax(0, 1fr) 18px; }
#hostPanel #roundControlList.is-card-list .round-stat-stepper button { width: 18px; }
#hostPanel #roundControlList.is-card-list .round-control-actions button[data-round-toggle-name], #hostPanel #roundControlList.is-card-list .round-control-actions button[data-round-lock-player] { font-size: 11px; }
body.is-host:not(.is-host-preview) #hostPanel .host-game { grid-template-columns: minmax(0, 1fr) minmax(300px, 360px); }
#hostPanel #roundControlList.is-card-list .round-control-actions button[data-round-force-player], #hostPanel #roundControlList.is-card-list .round-control-actions button[data-round-lock-player], #hostPanel #roundControlList.is-card-list .round-control-actions button[data-round-toggle-name] { font-size: 11px; letter-spacing: 0; padding: 0; overflow: hidden; }
#hostPanel #roundControlList.is-card-list .round-control-actions button[data-round-force-player] span { font-size: 12px; }
#hostPanel .assignment-target-bar { align-items: stretch; }
#hostPanel #groupAssignmentList .assignment-target-tile { align-content: center; }
#hostPanel #roundControlReverseButton[aria-pressed="true"] { background: #f59e0b; border-color: #f59e0b; color: #1f1300; font-weight: 800; }

/* 発表（合計DP上位など）：名前の下に合計DP。出した人は軽く浮き上がって出る。 */
.flow-roster-card.is-announce { grid-template-rows: auto var(--roster-divider-size, 1px) minmax(0, 1fr) auto; }
.flow-roster-card.is-announce.is-divider-hidden { grid-template-rows: auto minmax(0, 1fr) auto; }
.flow-roster-card.is-announce.is-rank-hidden { grid-template-rows: minmax(0, 1fr) auto; }
.flow-roster-card.is-announce .flow-roster-dp { text-align: center; font-size: calc(var(--roster-name-size, 30px) * 0.5); font-weight: 900; line-height: 1.1; letter-spacing: .02em; }
.flow-roster-card.is-announce-new { animation: announce-in .45s ease-out; }
@keyframes announce-in { from { opacity: 0; transform: translateY(18px) scale(.96); } to { opacity: 1; transform: none; } }
#hostPanel .announce-actions #announceNextButton { min-width: 180px; min-height: 44px; font-size: 16px; font-weight: 800; }
#hostPanel .announce-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 12px; margin: 0; padding-left: 0; list-style: none; }
#hostPanel .announce-list li { padding: 6px 10px; border: 1px solid var(--md-outline); opacity: .55; }
#hostPanel .announce-list li.is-revealed { opacity: 1; font-weight: 700; }
#hostPanel .announce-list li.is-next { opacity: 1; border-color: var(--action-bg); border-width: 2px; }
/* 発表：合計DPの行・所属の行のぶんカードを高くする（--roster-extra-height。名前の欄は通常の大きさのまま）。 */

/* 司会画面のタイマー表示も数字を同じ幅に（横ブレ防止）。 */
.timer-readout { font-variant-numeric: tabular-nums; }
.timer-readout .stage-timer-digit { display: inline-block; width: 1ch; text-align: center; }

/* Lock時のカードを「そのまま」にした時（例：決勝のセット獲得＝WIN 表示）は、得点欄の背景も変えない。 */
.player-card.is-locked.is-lock-undimmed:not(.is-win):not(.is-lose) .score-area { background: transparent; }

/* 名札の所属・大学名（名前の下の行）。 */
.flow-roster-text { min-width: 0; overflow: hidden; font-size: var(--roster-text-size, 12px); font-weight: 700; line-height: 1.2; text-align: center; white-space: nowrap; text-overflow: ellipsis; opacity: .9; }

/* ターンオーバー：札の裏にペーパー順位のマーク（1st など）。めくると、マークが光って広がり → 札が斜めにはけ →
   名前が左から差し込み → 所属がふわっと出る（2人以上まとめてめくる時は少しずつずらす）。 */
.score-board.is-turnover-board .flow-roster-cell { position: relative; overflow: hidden; }
.score-board.is-turnover-board .flow-roster-cell.is-face-down { visibility: visible; } /* 空き枠は通常は見せないが、ターンオーバーでは伏せた札として見せる */
.turnover-cover {
  position: absolute; inset: 0; z-index: 2;
  display: grid; place-content: center; justify-items: center; gap: calc(var(--roster-card-height, 104px) * 0.06);
  overflow: hidden;
  background:
    linear-gradient(115deg, transparent 0 46%, rgba(255, 255, 255, 0.05) 46% 54%, transparent 54%),
    linear-gradient(160deg, #20242d, #0d0f14);
  border: 2px solid rgba(255, 255, 255, 0.16);
  color: #fff;
}
.turnover-mark {
  font-size: calc(var(--roster-card-height, 104px) * 0.5);
  font-weight: 900; font-style: italic; line-height: 1; letter-spacing: .02em;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}
.turnover-mark-bar { width: 38%; height: max(3px, calc(var(--roster-card-height, 104px) * 0.035)); background: var(--mark-accent, #fff); }
/* 光の筋（めくる時に横切る） */
.turnover-cover::after {
  content: ""; position: absolute; inset: -20% auto -20% -60%; width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: skewX(-18deg); opacity: 0;
}
.flow-roster-cell.is-reveal-new .turnover-cover { animation: turnover-cover-out 1.1s cubic-bezier(.7, 0, .3, 1) both; animation-delay: var(--flip-delay, 0ms); }
.flow-roster-cell.is-reveal-new .turnover-cover::after { animation: turnover-shine .55s ease-out both; animation-delay: var(--flip-delay, 0ms); }
.flow-roster-cell.is-reveal-new .turnover-mark { animation: turnover-mark-pop 1.1s cubic-bezier(.2, .8, .2, 1) both; animation-delay: var(--flip-delay, 0ms); }
.flow-roster-cell.is-reveal-new .turnover-mark-bar { animation: turnover-bar 1.1s cubic-bezier(.2, .8, .2, 1) both; animation-delay: var(--flip-delay, 0ms); }
.flow-roster-cell.is-reveal-new .flow-roster-rank,
.flow-roster-cell.is-reveal-new .flow-roster-divider { animation: turnover-fade .4s ease-out both; animation-delay: calc(var(--flip-delay, 0ms) + .65s); }
.flow-roster-cell.is-reveal-new .flow-roster-name-area { animation: turnover-name-in .55s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--flip-delay, 0ms) + .7s); }
.flow-roster-cell.is-reveal-new .flow-roster-text { animation: turnover-text-in .45s ease-out both; animation-delay: calc(var(--flip-delay, 0ms) + 1s); }
@keyframes turnover-shine { 0% { left: -60%; opacity: 0; } 20% { opacity: 1; } 100% { left: 120%; opacity: 0; } }
@keyframes turnover-mark-pop {
  0% { transform: scale(1); letter-spacing: .02em; }
  30% { transform: scale(1.08); letter-spacing: .06em; text-shadow: 0 0 18px var(--mark-accent, #fff), 0 2px 0 rgba(0, 0, 0, 0.35); }
  55% { transform: scale(1.04); letter-spacing: .05em; opacity: 1; }
  100% { transform: scale(.85) translateY(-30%); letter-spacing: .14em; opacity: 0; }
}
@keyframes turnover-bar { 0% { width: 38%; } 30% { width: 86%; } 60% { width: 86%; opacity: 1; } 100% { width: 100%; opacity: 0; } }
@keyframes turnover-cover-out {
  0%, 45% { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); }
  100% { clip-path: polygon(130% 0, 100% 0, 100% 100%, 100% 100%); }
}
@keyframes turnover-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes turnover-name-in { from { opacity: 0; transform: translateX(-14%); clip-path: inset(0 100% 0 0); } to { opacity: 1; transform: none; clip-path: inset(0 0 0 0); } }
@keyframes turnover-text-in { from { opacity: 0; transform: translateY(40%); } to { opacity: .9; transform: none; } }
.flow-roster-cell.is-reveal-new .turnover-cover { animation-fill-mode: both; }
/* ── ターンオーバー「ブレード」（表示編集 → アニメーション → ターンオーバーのめくり方）──
   0〜0.38s マークが色ずれノイズで揺れ、枠が順位色に光る → 0.38s 光の刃が斜めに走る →
   0.52s 札が刃の線で2つに割れて飛ぶ・下から順位色の帯 → 0.7s 帯が右へ抜ける →
   0.85s 順位の帯が上から落ち、名前がぼかし・字間広めから決まる → 1.1s 所属 → カードの縁が光って消える。 */
.tb-cover { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }
.tb-half {
  position: absolute; inset: 0;
  display: grid; place-content: center; justify-items: center; gap: calc(var(--roster-card-height, 104px) * 0.06);
  color: #fff;
  background:
    repeating-linear-gradient(109deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 9px),
    linear-gradient(160deg, #1d212b, #08090c);
}
.tb-half.is-a { clip-path: polygon(0 0, 64% 0, 36% 100%, 0 100%); }
.tb-half.is-b { clip-path: polygon(64% 0, 100% 0, 100% 100%, 36% 100%); }
.tb-mark {
  position: relative;
  font-size: calc(var(--roster-card-height, 104px) * 0.5);
  font-weight: 900; font-style: italic; line-height: 1; letter-spacing: .02em;
}
.tb-bar { width: 38%; height: max(3px, calc(var(--roster-card-height, 104px) * 0.035)); background: var(--mark-accent, #fff); box-shadow: 0 0 10px var(--mark-accent, #fff); }
.tb-frame { position: absolute; inset: 0; border: 2px solid rgba(255, 255, 255, 0.14); }
.tb-wipe { position: absolute; inset: 0; background: var(--mark-accent, #fff); opacity: 0; transform-origin: right center; }
.tb-blade {
  position: absolute; left: 50%; top: -40%; width: max(4px, calc(var(--roster-card-height, 104px) * 0.035)); height: 180%;
  background: #fff; box-shadow: 0 0 10px #fff, 0 0 26px var(--mark-accent, #fff), 0 0 48px var(--mark-accent, #fff);
  transform: translateX(-50%) rotate(19deg) scaleY(0); opacity: 0;
}
/* 伏せている間：光がゆっくり札の上を通る（札ごとにずらす）。 */
.score-board.is-turnover-blade .flow-roster-cell.is-face-down .tb-half.is-b::after {
  content: ""; position: absolute; inset: -10% auto -10% -50%; width: 30%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.07), transparent);
  transform: skewX(-19deg);
  animation: tb-idle 4.2s ease-in-out infinite; animation-delay: var(--idle-delay, 0s);
}
@keyframes tb-idle { 0%, 55% { left: -50%; } 100% { left: 130%; } }
/* めくる */
.score-board.is-turnover-blade .is-reveal-new .tb-mark { animation: tb-glitch .4s steps(2, end) both; animation-delay: var(--flip-delay, 0ms); }
.score-board.is-turnover-blade .is-reveal-new .tb-frame { animation: tb-frame 1.1s ease-out both; animation-delay: var(--flip-delay, 0ms); }
.score-board.is-turnover-blade .is-reveal-new .tb-blade { animation: tb-blade .45s cubic-bezier(.6, 0, .2, 1) both; animation-delay: calc(var(--flip-delay, 0ms) + .34s); }
.score-board.is-turnover-blade .is-reveal-new .tb-half.is-a { animation: tb-split-a .6s cubic-bezier(.7, 0, .2, 1) both; animation-delay: calc(var(--flip-delay, 0ms) + .5s); }
.score-board.is-turnover-blade .is-reveal-new .tb-half.is-b { animation: tb-split-b .6s cubic-bezier(.7, 0, .2, 1) both; animation-delay: calc(var(--flip-delay, 0ms) + .5s); }
.score-board.is-turnover-blade .is-reveal-new .tb-wipe { animation: tb-wipe .75s cubic-bezier(.7, 0, .2, 1) both; animation-delay: calc(var(--flip-delay, 0ms) + .5s); }
.score-board.is-turnover-blade .is-reveal-new .flow-roster-rank { animation: tb-rank-drop .4s cubic-bezier(.2, .9, .2, 1.2) both; animation-delay: calc(var(--flip-delay, 0ms) + .85s); }
.score-board.is-turnover-blade .is-reveal-new .flow-roster-divider { animation: tb-divider .45s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--flip-delay, 0ms) + .9s); }
.score-board.is-turnover-blade .is-reveal-new .flow-roster-name-area { animation: tb-name-in .55s cubic-bezier(.15, .85, .25, 1) both; animation-delay: calc(var(--flip-delay, 0ms) + .88s); }
.score-board.is-turnover-blade .is-reveal-new .flow-roster-text { animation: tb-text-in .45s ease-out both; animation-delay: calc(var(--flip-delay, 0ms) + 1.1s); }
.score-board.is-turnover-blade .is-reveal-new .flow-roster-card { animation: tb-card-glow 1s ease-out both; animation-delay: calc(var(--flip-delay, 0ms) + .9s); }
@keyframes tb-glitch {
  0% { transform: none; text-shadow: none; }
  20% { transform: translate(-3px, 1px) skewX(-6deg); text-shadow: 4px 0 #ff2a55, -4px 0 #22e4ff; }
  40% { transform: translate(3px, -1px); text-shadow: -5px 0 #ff2a55, 5px 0 #22e4ff; clip-path: inset(10% 0 35% 0); }
  60% { transform: translate(-2px, 0) skewX(4deg); text-shadow: 3px 0 #ff2a55, -3px 0 #22e4ff; clip-path: inset(45% 0 5% 0); }
  80% { transform: translate(1px, 0); text-shadow: 0 0 18px var(--mark-accent, #fff); clip-path: none; }
  100% { transform: scale(1.06); text-shadow: 0 0 22px var(--mark-accent, #fff); }
}
@keyframes tb-frame { 0% { border-color: rgba(255, 255, 255, 0.14); box-shadow: none; } 28% { border-color: var(--mark-accent, #fff); box-shadow: inset 0 0 24px var(--mark-accent, #fff); } 48% { opacity: 1; border-color: var(--mark-accent, #fff); } 70%, 100% { opacity: 0; } }
@keyframes tb-blade {
  0% { transform: translateX(-50%) rotate(19deg) scaleY(0); transform-origin: top; opacity: 1; }
  45% { transform: translateX(-50%) rotate(19deg) scaleY(1); opacity: 1; }
  100% { transform: translateX(-50%) rotate(19deg) scaleY(1) scaleX(.2); opacity: 0; }
}
@keyframes tb-split-a { 0% { transform: none; opacity: 1; } 100% { transform: translate(-22%, -14%) rotate(-5deg); opacity: 0; } }
@keyframes tb-split-b { 0% { transform: none; opacity: 1; } 100% { transform: translate(22%, 14%) rotate(5deg); opacity: 0; } }
@keyframes tb-wipe { 0% { opacity: 1; transform: scaleX(1); } 35% { opacity: 1; transform: scaleX(1); } 100% { opacity: 1; transform: scaleX(0); } }
@keyframes tb-rank-drop { from { transform: translateY(-110%); } to { transform: none; } }
@keyframes tb-divider { from { transform: scaleX(0); } to { transform: none; } }
@keyframes tb-name-in { 0% { opacity: 0; filter: blur(10px); transform: scaleX(1.35); letter-spacing: .4em; } 60% { opacity: 1; filter: blur(0); } 100% { opacity: 1; filter: none; transform: none; letter-spacing: normal; } }
@keyframes tb-text-in { from { opacity: 0; transform: translateY(-60%); } to { opacity: .9; transform: none; } }
@keyframes tb-card-glow { 0% { box-shadow: inset 0 0 0 3px var(--mark-accent, #fff), inset 0 0 34px var(--mark-accent, #fff); } 100% { box-shadow: inset 0 0 0 0 transparent, inset 0 0 0 transparent; } }

@media (prefers-reduced-motion: reduce) {
  .flow-roster-cell.is-reveal-new .tb-cover { display: none; }
  .flow-roster-cell.is-face-down .tb-half::after { animation: none !important; }
  .flow-roster-cell.is-reveal-new .turnover-cover { display: none; }
  .flow-roster-cell.is-reveal-new * { animation: none !important; }
}

/* ── 読み上げスライド：画面の上下中央に横長の帯（後ろの画面はそのまま）──
   帯の中は 左に番号（Q.1 / A.1）、真ん中に問題か答え、右にカウント。見た目は司会画面の「スライドの見た目」で変える。 */
.qa-slide {
  position: absolute; inset: 0; z-index: 47; /* 得点・タイマー（45）より上、待機画面などの自由画面（50）より下 */
  display: grid; place-items: center; pointer-events: none;
  font-family: var(--qa-font, 'Noto Sans JP', sans-serif);
}
.qa-band {
  width: var(--qa-width, 90%); height: var(--qa-height, 36vh);
  transform: translateY(var(--qa-offset, 0px));
  display: grid; grid-template-columns: auto minmax(0, 1fr);
  overflow: hidden; color: var(--qa-text, #fff); background: var(--qa-bg, rgba(13, 17, 23, .92));
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
}
.qa-band-label {
  display: grid; place-items: center; min-width: calc(var(--qa-label-size, 40px) * 3.2); padding: 0 .5em;
  color: #fff; background: var(--qa-q, #22b8c8);
  font-size: var(--qa-label-size, 40px); font-weight: 900; font-style: italic; line-height: 1; letter-spacing: .02em;
}
.qa-slide.is-answer .qa-band-label { background: var(--qa-a, #e85c5c); }
.qa-band-main { min-width: 0; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr); gap: 4%; padding: 3% 3.5%; box-sizing: border-box; }
.qa-slide.has-sub .qa-band-main { grid-template-rows: minmax(0, 26%) minmax(0, 1fr); }
.qa-band-fit { min-width: 0; min-height: 0; display: flex; align-items: center; overflow: hidden; }
.qa-band-text, .qa-band-sub, .qa-band-wait { width: 100%; margin: 0; text-align: var(--qa-align, left); overflow-wrap: anywhere; word-break: auto-phrase; /* 日本語は文節で折り返す */ }
.qa-band-text { font-weight: 800; line-height: 1.4; }
.qa-band-text.is-answer { font-weight: 900; line-height: 1.2; }
.qa-band-sub { font-weight: 700; line-height: 1.35; opacity: .62; }
.qa-band-sub-box { border-bottom: 1px solid currentColor; border-bottom-color: rgba(255, 255, 255, .16); }
.qa-band-wait { font-weight: 700; opacity: .5; }
/* カウント（制限時間）：問題文の帯の外。帯の下・帯の上（top は JS）・画面の右下。円が減り、数字が1秒ごとに弾む。0 になったら赤く。 */
.qa-slide-count { position: absolute; left: 50%; transform: translateX(-50%); width: var(--qa-count-size, 120px); height: var(--qa-count-size, 120px); display: grid; place-items: center; color: var(--qa-text, #fff); --count-progress: 1; }
.qa-slide-count.is-corner { left: auto; right: 3vw; bottom: 4vh; transform: none; }
.qa-slide-count.is-number { width: auto; min-width: var(--qa-count-size, 120px); padding: 0 .3em; box-sizing: border-box; background: var(--qa-bg, rgba(13, 17, 23, .92)); }
.qa-slide-count svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.qa-slide-count-track { fill: var(--qa-bg, rgba(13, 17, 23, .92)); stroke: rgba(255, 255, 255, .14); stroke-width: 7; }
.qa-slide-count-bar { fill: none; stroke: var(--qa-count, #ffd400); stroke-width: 7; stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: calc(100 - var(--count-progress) * 100); }
.qa-slide-count-digit { position: relative; font-size: calc(var(--qa-count-size, 120px) * .56); font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.qa-slide-count.is-number .qa-slide-count-digit { font-size: calc(var(--qa-count-size, 120px) * .8); color: var(--qa-count, #ffd400); }
.qa-slide-count-digit.is-tick { animation: qa-count-tick .35s cubic-bezier(.2, .9, .2, 1.3); }
.qa-slide-count.is-done .qa-slide-count-digit { color: #ff5a5a; }
.qa-slide-count.is-done .qa-slide-count-track { stroke: rgba(255, 90, 90, .45); }
@keyframes qa-count-tick { from { transform: scale(1.3); } to { transform: none; } }
/* 出し方：帯が開く（中央から左右へ）／ふわっと／なし。文字は帯のあとに出る。 */
.qa-slide.anim-slide.is-band-enter .qa-band { animation: qa-band-open .4s cubic-bezier(.2, .8, .2, 1) both; }
.qa-slide.anim-slide.is-band-enter .qa-band-label { animation: qa-fade-in .3s ease-out .2s both; }
.qa-slide.anim-slide.is-text-enter .qa-band-main { animation: qa-text-in .4s cubic-bezier(.2, .8, .2, 1) .22s both; }
.qa-slide.anim-slide.is-text-enter.is-answer .qa-band-main { animation-delay: 0s; }
.qa-slide.anim-fade.is-band-enter .qa-band { animation: qa-fade-in .35s ease-out both; }
.qa-slide.anim-fade.is-text-enter .qa-band-main { animation: qa-fade-in .35s ease-out both; }
.qa-slide:not(.anim-none) .qa-slide-count { animation: qa-fade-in .25s ease-out both; }
.qa-slide.anim-none .qa-slide-count-digit.is-tick { animation: none; }
@keyframes qa-band-open { from { clip-path: inset(0 50% 0 50%); } to { clip-path: inset(0 0 0 0); } }
@keyframes qa-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes qa-text-in { from { opacity: 0; transform: translateY(12%); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .qa-slide * { animation: none !important; } }
/* 司会：読み上げスライドの操作 */
#hostPanel .qa-slide-controls { display: grid; gap: 6px; margin: 8px 0; padding: 8px 10px; border: 1px solid var(--md-outline); }
#hostPanel .qa-slide-controls-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#hostPanel .qa-slide-next { min-width: 220px; min-height: 44px; font-size: 16px; font-weight: 800; }
#hostPanel #qaSlideCountInput { width: 56px; }
