/* ===== 席替え画面 ===== */

:root {
  --seatchange-accent: #1f75ff;
  --seatchange-accent-strong: #0f5fe0;
  --seatchange-accent-soft: rgba(31, 117, 255, 0.15);
  --seatchange-shadow-accent: 0 12px 26px rgba(31, 117, 255, 0.28);
  --seatchange-shadow-accent-strong: 0 6px 14px rgba(31, 117, 255, 0.22);
}

main.seatchange {
  max-width: 420px;
  margin: 0 auto;
  padding: 16px;
}

.seatchange__section {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 0 28px 28px;
}

@media (max-width: 360px) {
  main.seatchange {
    padding: 12px;
  }
}

/* セクションの表示制御 */
.seatchange__section--result {
  display: flex;
}

.seatchange__section--result[hidden] {
  display: none;
}

.seatchange__section--editor {
  position: relative;
  gap: 20px;
}

/* 設定画面の見出し */
.editor__heading {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
}

/* 入力フィールド全体 */
.editor__field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* フィールドのヘッダー行 */
.editor__field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

/* ラベル共通 */
.editor__label {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
}

/* テキスト入力 */
.editor__input {
  padding: 12px 18px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface-alt);
  font-size: 16px;
  transition: border var(--transition-base), box-shadow var(--transition-base);
}

.editor__input:focus {
  outline: none;
  border-color: var(--seatchange-accent);
  box-shadow: 0 0 0 4px var(--seatchange-accent-soft);
}

.editor__input::placeholder {
  color: var(--color-text-muted);
}

.editor__input[type="number"] {
  appearance: textfield;
}

.editor__input[type="number"]::-webkit-inner-spin-button,
.editor__input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* 参加者名入力欄 */
.editor__textarea {
  padding: 12px 18px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface-alt);
  font-size: 16px;
  font-family: inherit;
  resize: vertical;
  min-height: 96px;
  transition: border var(--transition-base), box-shadow var(--transition-base);
}

.editor__textarea:focus {
  outline: none;
  border-color: var(--seatchange-accent);
  box-shadow: 0 0 0 4px var(--seatchange-accent-soft);
}

.editor__textarea::placeholder {
  color: var(--color-text-muted);
}

.participants-gender {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface-alt);
}

.participants-gender__header {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.participants-gender__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}

.participants-gender__list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
}

.participants-gender__list::-webkit-scrollbar {
  width: 6px;
}

.participants-gender__list::-webkit-scrollbar-thumb {
  background: rgba(120, 137, 162, 0.35);
  border-radius: 6px;
}

.participants-gender__list::-webkit-scrollbar-track {
  background: transparent;
}

.participants-gender__item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}

.participants-gender__name {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 40%;
  min-width: 0;
}

.participants-gender__options {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  column-gap: 6px;
  row-gap: 4px;
  flex-wrap: wrap;
  flex: 1 1 auto;
}

.participants-gender__radio {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 16px;
  border: 1px solid var(--color-border);
  background: #fff;
  font-size: 12px;
  color: var(--color-text);
  cursor: pointer;
  transition: border var(--transition-base), box-shadow var(--transition-base);
}

.participants-gender__radio--checked {
  border-color: var(--seatchange-accent);
  box-shadow: 0 0 0 2px var(--seatchange-accent-soft);
}

.participants-gender__radio:focus-within {
  border-color: var(--seatchange-accent);
  box-shadow: 0 0 0 2px var(--seatchange-accent-soft);
}

.participants-gender__radio input {
  margin: 0;
  accent-color: var(--seatchange-accent);
}

.participants-gender__radio-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text);
}

.participants-gender__radio input:checked + .participants-gender__radio-label {
  color: var(--seatchange-accent);
}

.participants-gender__empty {
  font-size: 16px;
  color: var(--color-text-muted);
  text-align: center;
  padding: 8px 0;
}

/* 手動 / 自動トグル */
.editor__toggle {
  display: flex;
  border-radius: 20px;
  padding: 2px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-alt);
  overflow: hidden;
}

.editor__toggle-button {
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  background: transparent;
  color: var(--color-text-muted);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  cursor: pointer;
}

/* トグルのアクティブ状態 */
.editor__toggle-button--active {
  background: var(--seatchange-accent);
  color: #fff;
  box-shadow: var(--seatchange-shadow-accent);
}

/* エラーメッセージ */
.editor__error-message {
  padding: 12px 18px;
  border-radius: var(--radius-pill);
  background: var(--color-danger-soft);
  border: 1px solid rgba(255, 122, 138, 0.24);
  color: var(--color-danger);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}

/* 確定ボタン */
.editor__confirm-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 16px 24px;
  border-radius: var(--radius-pill);
  background: var(--seatchange-accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow-raised);
  margin-top: 8px;
  transition: background var(--transition-base), transform var(--transition-base),
    box-shadow var(--transition-base);
}

/* 確定ボタンのホバー */
.editor__confirm-button:hover {
  background: var(--seatchange-accent-strong);
  box-shadow: var(--seatchange-shadow-accent);
}

/* 確定ボタンのアクティブ */
.editor__confirm-button:active {
  transform: translateY(1px);
  box-shadow: var(--seatchange-shadow-accent-strong);
}

/* 座席レイアウト設定 */
.seat-layout {
  display: flex;
  align-items: end;
  gap: 16px;
}

/* 行・列の入力ボックス */
.seat-layout__control {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 72px;
}

.seat-layout__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}

.seat-layout__value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding: 12px 18px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-alt);
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  text-align: center;
  line-height: 1;
  transition: border var(--transition-base), box-shadow var(--transition-base);
  appearance: textfield;
}

/* 行・列入力のプレースホルダー */
.seat-layout__value::placeholder {
  color: var(--color-text-muted);
  opacity: 1;
}

/* 行×列の区切りマーク */
.seat-layout__symbol {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
}

.seat-layout__symbol::before,
.seat-layout__symbol::after {
  content: "";
  position: absolute;
  width: 4px;
  height: 20px;
  background: var(--color-text);
  border-radius: 2px;
}

/* 区切りマーク（斜線） */
.seat-layout__symbol::before {
  transform: rotate(45deg);
}

.seat-layout__symbol::after {
  transform: rotate(-45deg);
}

/* 数値入力のスピンボタン非表示 */
.seat-layout__value::-webkit-inner-spin-button,
.seat-layout__value::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* 行・列入力のフォーカス時 */
.seat-layout__value:focus-visible {
  outline: none;
  border-color: var(--seatchange-accent);
  box-shadow: 0 0 0 4px var(--seatchange-accent-soft);
}

/* ===== 結果画面 ===== */

/* 結果画面本体 */
.seatchange__section--result {
  position: relative;
  gap: 24px;
  align-items: center;
  text-align: center;
}

/* 結果タイトル */
.result__heading {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}

/* 結果のサマリー */
.result__summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  color: var(--color-text-muted);
  font-size: 14px;
}

/* 行列情報のラベル */
.result__layout {
  margin: 0;
  color: var(--color-text);
  font-weight: 600;
}

/* 参加者数の注記 */
.result__note {
  margin: 0;
}

/* 席順結果のスクロール領域 */
.result__board-wrapper {
  width: 100%;
  padding: 8px 0;
  border-radius: var(--radius-medium);
  background: var(--color-surface-alt);
  overflow: auto;
  max-height: min(60vh, 480px);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* 席配置グリッド */
.result__board {
  --seat-columns: 1;
  --seat-rows: 1;
  --seat-scale: 1;
  --seat-base-size: 72px;
  --seat-index-column-base: calc(var(--seat-base-size) * 0.05);
  --seat-index-row-base: calc(var(--seat-base-size) * 0.01);
  --seat-cell-size: calc(var(--seat-base-size) * var(--seat-scale));
  --seat-index-column-size: calc(var(--seat-index-column-base) * var(--seat-scale));
  --seat-index-row-size: calc(var(--seat-index-row-base) * var(--seat-scale));
  --seat-gap: calc(12px * var(--seat-scale));
  --seat-padding: calc(16px * var(--seat-scale));
  display: grid;
  grid-template-columns: minmax(var(--seat-index-column-size), var(--seat-index-column-size))
    repeat(var(--seat-columns), minmax(var(--seat-cell-size), var(--seat-cell-size)));
  grid-template-rows: minmax(var(--seat-index-row-size), var(--seat-index-row-size))
    repeat(var(--seat-rows), minmax(var(--seat-cell-size), var(--seat-cell-size)));
  gap: var(--seat-gap);
  padding: var(--seat-padding);
  margin: 0 auto;
  width: max-content;
  list-style: none;
  position: relative;
  touch-action: none;
}

.result__index {
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  align-self: center;
  font-size: clamp(10px, 12px * var(--seat-scale), 16px);
  font-weight: 500;
  color: var(--color-text);
  opacity: 0.7;
  line-height: 1;
  z-index: 0;
}

.result__index--column,
.result__index--corner {
  position: sticky;
  top: 0;
  background: linear-gradient(
    to bottom,
    var(--color-surface-alt),
    rgba(250, 250, 255, 0.75)
  );
  width: var(--seat-index-column-size);
  z-index: 2;
}

.result__index--row,
.result__index--corner {
  position: sticky;
  left: 0;
  background: linear-gradient(
    to right,
    var(--color-surface-alt),
    rgba(250, 250, 255, 0.75)
  );
  height: var(--seat-index-row-size);
  z-index: 1;
}

.result__index--corner {
  z-index: 3;
}

/* 参加者の席カード */
.result__seat {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--seat-cell-size);
  height: var(--seat-cell-size);
  border-radius: 12px;
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  font-size: clamp(12px, 16px * var(--seat-scale), 24px);
  font-weight: 600;
  color: var(--color-text);
  box-shadow: 0 4px 12px rgba(18, 24, 38, 0.06);
  text-align: center;
  word-break: break-word;
  line-height: 1.2;
  padding: calc(4px * var(--seat-scale));
}

.result__seat--male {
  background: #cfe5ff;
  border-color: #8bbcf5;
}

.result__seat--female {
  background: #ffd4ea;
  border-color: #f79ec4;
}

.result__seat--unknown {
  background: #e2f6d7;
  border-color: #a6dda0;
}

/* 空席カード */
.result__seat--empty {
  color: var(--color-text-muted);
  border-style: dashed;
  font-size: clamp(10px, 12px * var(--seat-scale), 18px);
}

/* 再度 席替え開始ボタン */
.result__reshuffle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 16px 24px;
  border-radius: var(--radius-pill);
  background: var(--seatchange-accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  box-shadow: var(--shadow-button);
  transition: background var(--transition-base),
    box-shadow var(--transition-base), transform var(--transition-base);
}

/* 再抽選ボタンのホバー */
.result__reshuffle:hover {
  background: var(--seatchange-accent-strong);
  box-shadow: var(--seatchange-shadow-accent);
}

/* 再抽選ボタンのアクティブ */
.result__reshuffle:active {
  transform: translateY(1px);
  box-shadow: var(--seatchange-shadow-accent-strong);
}
