:root {
  --fairway-900: #1b3a2b;
  --fairway-700: #2c5540;
  --fairway-600: #3f6f52;
  --fairway-100: #e4ede6;
  --sand-50: #faf7f0;
  --sand-100: #f3ecdc;
  --sand-200: #e8ddc4;
  --gold-500: #b08d3e;
  --gold-600: #93732e;
  --ink-900: #22271f;
  --ink-600: #52594c;
  --white: #ffffff;
  --danger: #a8432c;
  --shadow: 0 2px 10px rgba(27, 58, 43, 0.08);
  --radius: 10px;
}

* { box-sizing: border-box; }
img { max-width: 100%; height: auto; }

body {
  margin: 0;
  background: var(--sand-50);
  color: var(--ink-900);
  font-family: 'Zen Kaku Gothic New', -apple-system, BlinkMacSystemFont, 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
  font-weight: 500;
  line-height: 1.7;
}

h1, h2, h3 {
  font-family: 'Zen Old Mincho', serif;
  color: var(--fairway-900);
  letter-spacing: 0.02em;
  text-wrap: balance;
  margin: 0 0 0.4em;
}

a { color: var(--fairway-700); }

.tabular { font-variant-numeric: tabular-nums; }

.topbar {
  background: #075038;
  color: var(--sand-50);
  padding: 18px 24px;
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}
.topbar .brand {
  font-family: 'Zen Old Mincho', serif;
  font-size: 1.25rem;
  letter-spacing: 0.06em;
}
.topbar .brand .accent { color: var(--gold-500); }
.topbar .brand .brand-name {
  position: relative;
  display: inline-block;
  font-family: 'Zen Maru Gothic', sans-serif;
  font-weight: 900;
}
.topbar .brand .brand-name::after {
  content: "";
  position: absolute;
  left: 1px;
  right: -4px;
  bottom: -6px;
  height: 3px;
  border-radius: 99px;
  background: #f5b82e;
  transform: rotate(-1deg);
}
.topbar .brand .brand-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
  vertical-align: middle;
  border-radius: 6px;
}
.topbar .brand .brand-icon-3d {
  width: 44px;
  height: 44px;
  border-radius: 0;
  vertical-align: middle;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
}
.form-page .topbar .brand .brand-icon-3d {
  width: 32px;
  height: 32px;
}
.topbar .compname {
  font-size: 0.95rem;
  opacity: 0.85;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}

.card {
  background: var(--white);
  border: 1px solid var(--sand-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

details.card > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before {
  content: '▶';
  display: inline-block;
  font-size: 0.7em;
  color: var(--ink-600);
  transition: transform 0.15s;
  flex-shrink: 0;
}
details.card[open] > summary::before { transform: rotate(90deg); }
details.card > summary h2 { display: inline; margin: 0; }
details.card > summary ~ * { margin-top: 14px; }
details.card > summary ~ *:first-of-type { margin-top: 18px; }

.hero {
  text-align: center;
  padding: 56px 20px 40px;
}
.hero h1 { font-size: 2rem; }
.hero p { color: var(--ink-600); max-width: 46em; margin: 0.6em auto 0; }

.groups-title-band {
  text-align: center;
  padding: 26px 20px;
  margin: 8px 0 22px;
  border-top: 3px solid var(--gold-500);
  border-bottom: 3px solid var(--gold-500);
}
.groups-title-band h1 { margin: 0 0 6px; }
.groups-title-band h2 { margin: 0 0 8px; font-size: 1.15rem; color: var(--ink-600); font-family: inherit; }
.groups-title-band p { margin: 2px 0; }

.pairing-table th { background: var(--fairway-600); color: var(--white); border-color: var(--fairway-600); }
.pairing-table td { background: var(--sand-50); }
.pairing-table .btn-ghost { background: var(--fairway-600); color: var(--white); border: none; }
.pairing-table .btn-ghost:hover { background: var(--fairway-700); }

label {
  display: block;
  font-size: 1rem;
  color: var(--ink-600);
  margin-bottom: 4px;
  margin-top: 14px;
}
label:first-child { margin-top: 0; }

input[type=text], input[type=date], input[type=number], input[type=email], input[type=tel], input[type=url], input[type=password], textarea, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--sand-200);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 500;
  background: var(--sand-50);
  color: var(--ink-900);
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--fairway-600);
  outline-offset: 1px;
  background: var(--white);
}
textarea { resize: vertical; min-height: 70px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 999px;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
}
.btn-primary { background: var(--fairway-700); color: var(--white); }
.btn-primary:hover { background: var(--fairway-900); }
.btn-gold { background: var(--gold-500); color: var(--white); }
.btn-gold:hover { background: var(--gold-600); }
.btn-ghost { background: transparent; color: var(--fairway-700); border: 1px solid var(--sand-200); }
.btn-ghost:hover { background: var(--fairway-100); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid #e6c9c0; padding: 6px 12px; font-size: 0.85rem; }
.btn-sm { padding: 6px 14px; font-size: 0.85rem; }
.btn:disabled {
  background: var(--sand-200);
  color: var(--ink-600);
  cursor: not-allowed;
  box-shadow: none;
}
.btn:disabled:hover { background: var(--sand-200); transform: none; }

.tabs-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}
.tabs-cat {
  position: relative;
}
.tabs-cat-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border: 1px solid var(--sand-200);
  border-bottom: 3px solid var(--sand-200);
  border-radius: 999px;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink-600);
  cursor: pointer;
  box-shadow: var(--shadow);
  white-space: nowrap;
}
.tabs-cat-btn::after {
  content: '▾';
  color: var(--gold-600);
  font-size: 0.75rem;
  transition: transform 0.15s ease;
}
.tabs-cat-btn:hover { background: var(--fairway-100); }
.tabs-cat[data-cat="dayof"] .tabs-cat-btn { border-bottom-color: var(--danger); }
.tabs-cat[data-cat="ops"] .tabs-cat-btn { border-bottom-color: var(--fairway-600); }
.tabs-cat[data-cat="prize"] .tabs-cat-btn { border-bottom-color: var(--gold-500); }
.tabs-cat[data-cat="print"] .tabs-cat-btn { border-bottom-color: var(--ink-600); }
.tabs-cat-btn.current { color: var(--fairway-900); background: var(--fairway-100); }
.tabs-cat.open .tabs-cat-btn::after,
.tabs-cat:hover .tabs-cat-btn::after { transform: rotate(180deg); }
.tabs-submenu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 10;
  flex-direction: column;
  gap: 2px;
  min-width: 220px;
  max-width: 90vw;
  margin-top: 4px;
  background: var(--white);
  border: 1px solid var(--sand-200);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px -8px rgba(27, 58, 43, 0.28);
  padding: 8px;
}
.tabs-cat.open .tabs-submenu,
.tabs-cat:hover .tabs-submenu { display: flex; }
.tabs-submenu .tab-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-left: 4px solid var(--sand-200);
  padding: 10px 14px 10px 11px;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--ink-600);
  cursor: pointer;
  border-radius: 4px;
  white-space: nowrap;
}
.tabs-submenu .tab-btn:hover { background: var(--sand-100); }
.tabs-submenu .tab-btn.active { color: var(--fairway-900); background: var(--fairway-100); font-weight: 700; }
.tabs-cat[data-cat="dayof"] .tabs-submenu .tab-btn { border-left-color: var(--danger); }
.tabs-cat[data-cat="ops"] .tabs-submenu .tab-btn { border-left-color: var(--fairway-600); }
.tabs-cat[data-cat="prize"] .tabs-submenu .tab-btn { border-left-color: var(--gold-500); }
.tabs-cat[data-cat="print"] .tabs-submenu .tab-btn { border-left-color: var(--ink-600); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--sand-200); vertical-align: top; white-space: nowrap; }
th { color: var(--ink-600); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; }
td.wrap-text { white-space: normal; }
.table-wrap { overflow-x: auto; }
.table-wrap table { width: max-content; min-width: 100%; }

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--fairway-100);
  color: var(--fairway-900);
  font-size: 0.78rem;
}
.pill.warn { background: #f3e3cf; color: var(--gold-600); }
.pill.muted { background: var(--sand-100); color: var(--ink-600); }
.pill.gender-male { background: #dde5d0; color: #4a5c33; }
.pill.gender-female { background: #f2e6b8; color: #7a5f14; }

.or-divider {
  display: flex;
  align-items: center;
  color: var(--ink-600);
  font-size: 0.82rem;
  margin: 18px 0;
}
.or-divider::before, .or-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--sand-200);
}
.or-divider span { padding: 0 12px; }

.copybox {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--sand-50);
  border: 1px dashed var(--sand-200);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.9rem;
}
.copybox input { flex: 1; border: none; background: transparent; padding: 0; font-weight: 700; color: var(--ink-900); }
.copybox a {
  flex: 1;
  font-weight: 700;
  color: var(--fairway-700);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.copybox a:hover { text-decoration: underline; }

.form-wrap, .wide-wrap { max-width: 640px; }
@media (min-width: 860px) {
  .form-wrap { max-width: 1040px; }
  .wide-wrap { max-width: 960px; }
}
.pairing-table th, .pairing-table td { text-align: center; white-space: nowrap; }
/* 公開の組み合わせ詳細：1組＝1行、メンバーは左から右へ横並び */
.group-detail-list { display: flex; flex-direction: column; gap: 12px; }
.group-detail-list > .card {
  margin: 0; min-width: 0;
  display: grid; grid-template-columns: 170px minmax(0, 1fr); column-gap: 16px; align-items: start;
}
.group-detail-list > .card > h3 { line-height: 1.6; }
.group-members { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(var(--gm-cols, 4), minmax(0, 1fr)); gap: 8px; }
.group-members li {
  min-width: 0;
  background: var(--sand-50); border: 1px solid var(--sand-200); border-radius: 8px; padding: 8px 10px;
}
.group-members .gm-name { display: block; font-weight: 700; }
.group-members .gm-meta { display: block; margin-top: 2px; font-size: 0.78rem; line-height: 1.5; color: var(--ink-600); }
@media (max-width: 900px) {
  .group-members { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .group-detail-list > .card { grid-template-columns: 1fr; }
}

/* スマホ：組み合わせ表の要約は元の表形式のまま、文字を小さくして横幅に収める（横スクロールなし） */
@media (max-width: 640px) {
  .groups-title-band { padding: 20px 14px; }
  .groups-title-band h1 { font-size: 1.45rem; line-height: 1.45; text-wrap: balance; }
  .groups-title-band h2 { font-size: 1.05rem; }
  .table-wrap .pairing-table { width: 100%; min-width: 0; table-layout: fixed; }
  .pairing-table th, .pairing-table td {
    padding: 6px 2px;
    font-size: 0.58rem;
    line-height: 1.35;
    white-space: normal;
    word-break: break-all;
    letter-spacing: 0;
  }
  .pairing-table th { font-size: 0.5rem; text-transform: none; letter-spacing: 0; }
  .pairing-table th:nth-child(1), .pairing-table td:nth-child(1) { width: 8%; }
  .pairing-table th:nth-child(2), .pairing-table td:nth-child(2) { width: 10%; }
  .pairing-table th:last-child, .pairing-table td:last-child { width: 9%; }
  .pairing-table td:last-child .btn { padding: 4px 3px; font-size: 0.54rem; }
}


.item-row-fields {
  display: grid;
  grid-template-columns: 1.6fr 1.3fr 0.8fr 0.9fr auto;
  gap: 8px;
  align-items: end;
}
@media (min-width: 860px) {
  .item-row-fields {
    grid-template-columns: minmax(220px, 1.6fr) 260px minmax(120px, 1fr) minmax(120px, 1fr) auto;
    gap: 12px;
  }
}
@media (max-width: 640px) {
  .item-row-fields { grid-template-columns: 1fr; }
}
.mi-qty-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.mi-qty-wrap .mi-qty {
  width: 108px;
  flex: none;
  padding-left: 6px;
  padding-right: 6px;
}
.mi-forall-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  color: var(--ink-900);
  white-space: nowrap;
  margin: 0;
}
.mi-forall-label input[type=checkbox] {
  width: 32px;
  height: 32px;
  margin: 0;
}

.board {
  display: block;
}
.board-col {
  background: var(--sand-100);
  border-radius: var(--radius);
  padding: 12px;
}
.board-col.pool {
  background: var(--fairway-100);
  position: sticky;
  top: 0;
  z-index: 3;
  margin-bottom: 14px;
  box-shadow: 0 6px 12px -8px rgba(27, 58, 43, 0.35);
}
.board-col.pool .item-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
/* 未割当が多いと画面を占領して、下の賞の欄が見えずドラッグできなくなるため、高さに上限を付けて枠内でスクロールさせる */
.board-col.pool {
  max-height: 34vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.board-col.pool .item-card {
  flex: 0 1 160px;
  margin-bottom: 0;
}
.board-awards {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.board-awards .board-col {
  flex: 0 0 165px;
}
.board-col h3 { font-size: 0.95rem; margin-bottom: 2px; }
/* 組み合わせ板（管理画面）：1組＝1行、メンバーは左から右へ横並び */
#groupsBoard .board-awards { flex-direction: column; gap: 10px; }
#groupsBoard .board-awards .board-col {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) 110px;
  grid-template-areas: "title list del" "course list del" "time list del" "sum list del";
  grid-template-rows: auto auto auto 1fr;
  column-gap: 14px;
  align-items: start;
}
#groupsBoard .board-col .group-drag-handle { grid-area: title; }
#groupsBoard .board-col .group-course-select { grid-area: course; }
#groupsBoard .board-col .group-time-input { grid-area: time; }
#groupsBoard .board-col .sum { grid-area: sum; margin-bottom: 0; }
/* メンバーのカードは「1行に4枚」の等分幅。グリッドのauto-fillだと行の高さを4枚縦積みで見積もってしまうため、折り返しで並べる */
#groupsBoard .board-col .min-list {
  grid-area: list;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: flex-start;
  min-height: 56px;
}
#groupsBoard .board-col .min-list .item-card {
  flex: 0 0 calc((100% - 24px) / 4);
  max-width: calc((100% - 24px) / 4);
  min-width: 0;
  margin-bottom: 0;
}
@media (max-width: 900px) {
  #groupsBoard .board-col .min-list .item-card { flex-basis: calc((100% - 8px) / 2); max-width: calc((100% - 8px) / 2); }
}
#groupsBoard .board-col .delGroupBtn { grid-area: del; margin-top: 0 !important; }
@media (max-width: 640px) {
  #groupsBoard .board-awards .board-col {
    grid-template-columns: 1fr;
    grid-template-areas: "title" "course" "time" "sum" "list" "del";
    grid-template-rows: none;
  }
  #groupsBoard .board-col .delGroupBtn { margin-top: 6px !important; }
}
.board-col .sum { font-size: 0.82rem; color: var(--ink-600); margin-bottom: 8px; }
.board-col .sum.over { color: var(--danger); }
.item-card {
  position: relative;
  background: var(--white);
  border: 1px solid var(--sand-200);
  border-radius: 8px;
  padding: 8px 10px 8px 26px;
  margin-bottom: 8px;
  font-size: 0.85rem;
  cursor: grab;
  box-shadow: 0 1px 3px rgba(27,58,43,0.06);
}
.item-card.selected { outline: 2px solid var(--fairway-600); background: var(--fairway-100); }
.select-hint { font-size: 0.78rem; color: var(--ink-600); margin-bottom: 6px; }
.select-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.ctx-menu { position: fixed; z-index: 1000; min-width: 200px; background: var(--white); border: 1px solid var(--sand-200); border-radius: 8px; box-shadow: 0 8px 24px rgba(27,58,43,0.22); padding: 4px; }
.ctx-menu button { display: block; width: 100%; text-align: left; background: transparent; border: none; border-radius: 6px; padding: 8px 12px; font-size: 0.88rem; font-weight: 500; cursor: pointer; color: var(--ink-900); }
.ctx-menu button:hover { background: var(--fairway-100); }
.select-bar[hidden], .select-hint[hidden] { display: none; }
.select-bar-count { font-weight: 700; font-size: 0.88rem; }
.item-card .name { font-weight: 600; }
.item-card .meta { color: var(--ink-600); font-size: 0.78rem; margin-top: 2px; }
.item-card.sortable-ghost { opacity: 0.3; }
.item-card.pinned { background: var(--sand-50); border-color: var(--gold-500); cursor: default; }
.item-card .pin-toggle {
  position: absolute;
  top: 6px;
  left: 4px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 2px;
  opacity: 0.55;
}
.item-card .pin-toggle:hover { opacity: 1; }
.item-card.pinned .pin-toggle { opacity: 1; }
.participant-card { position: relative; }
.min-list { min-height: 40px; }

.empty-note { color: var(--ink-600); font-size: 0.85rem; padding: 10px 4px; }

.notice {
  background: var(--fairway-100);
  border: 1px solid var(--fairway-600);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: 0.9rem;
}
.notice.danger { background: #fbeae4; border-color: var(--danger); }

.summary-strip {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.stat {
  background: var(--white);
  border: 1px solid var(--sand-200);
  border-radius: var(--radius);
  padding: 14px 18px;
  min-width: 140px;
}
.stat .num { font-family: 'Zen Old Mincho', serif; font-size: 1.5rem; color: var(--fairway-900); }
.stat .lbl { font-size: 0.8rem; color: var(--ink-600); }

footer.sitefoot {
  text-align: center;
  padding: 30px 20px;
  color: var(--ink-600);
  font-size: 0.8rem;
}

@media (max-width: 640px) {
  .wrap { padding: 18px 14px 60px; }
  .card { padding: 16px; }
  .hero { padding: 40px 16px 28px; }
  .hero h1 { font-size: 1.5rem; }
  .topbar { padding: 14px 16px; }
  .board-awards .board-col { flex-basis: 130px; }
  .board-col.pool .item-card { flex-basis: 130px; }
  .tabs-menu { gap: 6px; }
  .tabs-cat-btn { padding: 8px 12px; font-size: 0.82rem; }
  .tabs-submenu { min-width: 0; width: 100%; max-width: none; }
}

@media print {
  .no-print { display: none !important; }
  body { background: var(--white); }
}

/* コース設定から自動計算されている組のスタート時間（手入力不可であることを見た目でも示す） */
.group-time-input.is-auto {
  background: var(--sand-50, #faf7f0);
  color: var(--fairway-900, #075038);
  font-weight: 700;
  cursor: default;
}

/* 組ごとドラッグして順番を入れ替えるための取っ手（組カードの見出し） */
.group-drag-handle {
  cursor: grab;
  user-select: none;
}
.group-drag-handle::before {
  content: '⠿';
  margin-right: 6px;
  opacity: 0.45;
  font-weight: 400;
}
.group-drag-handle:active { cursor: grabbing; }

/* 協賛一覧：協賛者からのメッセージ（吹き出し） */
.pr-from { margin: 12px 0 10px; font-size: 0.82rem; font-weight: 700; color: var(--fairway-700); }
.pr-bubble {
  position: relative;
  background: var(--fairway-100);
  border: 1px solid var(--fairway-600);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 0.9rem;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}
.pr-bubble::before, .pr-bubble::after {
  content: '';
  position: absolute;
  left: 22px;
  border-style: solid;
  border-width: 0 8px 9px;
  border-color: transparent;
}
.pr-bubble::before { top: -10px; border-bottom-color: var(--fairway-600); }
.pr-bubble::after { top: -8px; border-bottom-color: var(--fairway-100); }

/* 賞品ふりわけ：未割当の並べ替え・絞り込み */
.pool-tools {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 6px 0 10px;
  padding: 4px 0;
  background: var(--fairway-100);
}
.pool-tools .pool-q { flex: 1 1 200px; min-width: 160px; width: auto; margin: 0; padding: 6px 10px; font-size: 0.85rem; }
.pool-tools select { width: auto; margin: 0; padding: 6px 8px; font-size: 0.85rem; }
