/*
 * $15 Team Builder — モバイルファースト。
 * ドラッグ&ドロップは実装しない（タップのみ）。
 */

.bf-tbd {
	/*
	 * F061-V2.1: sticky summaryの実高さをJS（renderBuilding）が測って上書きする。
	 * ここの値はJSが動く前／JSが失敗したときのフォールバック。
	 * カード一覧の下に確保する余白はこの変数から計算するので、
	 * summaryが2行に折り返して高くなっても最下段カードが隠れない。
	 */
	--bf-tbd-summary-h: 64px;

	max-width: 720px;
	margin: 0 auto;
	padding: 16px 16px 24px;
	font-family: inherit;
	color: #1a1a1a;

	/*
	 * F061-V2.1.1: ここは V2 まで `overflow-x: hidden` だった。
	 * しかし `overflow-x: hidden` は もう一方の軸の `visible` を `auto` へ
	 * 計算し直させるため（CSS Overflow 3）、この要素自体がスクロールコンテナ化し、
	 * 子の `position: sticky` の基準がビューポートではなく .bf-tbd になっていた。
	 * その結果 sticky summary が画面下部へ追従しない状態が V2 本番から続いていた
	 * （本番のDOMで祖先を全走査し、スクロールコンテナ化していたのは .bf-tbd だけで、
	 * テーマ側の main/content/container/body/html はすべて visible だと確認済み）。
	 *
	 * `overflow-x: clip` はスクロールコンテナを作らない（計算後も overflow-y は
	 * visible のまま）ため、横方向のはみ出し防止だけを維持したまま stickyが生きる。
	 * clip 非対応の古いブラウザでは宣言が無視され visible 相当になるが、
	 * 横スクロールの封じ込めは .bf-tbd-grid 側の `overflow-x: auto` で完結しており、
	 * ページ全体の横はみ出しは発生しない（desktop/390px幅の双方で実測確認済み）。
	 */
	overflow-x: clip;
}

.bf-tbd-hero {
	text-align: center;
	margin-bottom: 20px;
}

.bf-tbd-hero__eyebrow {
	font-size: 12px;
	letter-spacing: 0.12em;
	color: #666;
	margin: 0 0 4px;
}

.bf-tbd-hero__title {
	font-size: 28px;
	font-weight: 800;
	margin: 0 0 8px;
}

.bf-tbd-lead {
	font-size: 14px;
	color: #444;
	margin: 0;
}

.bf-tbd-noscript,
.bf-tbd-loading,
.bf-tbd-error {
	text-align: center;
	padding: 24px 12px;
	color: #666;
}

/* ---- Tier sections ---- */

/*
 * F061-V2.1（overlap修正）: sticky summaryは`position: sticky`で
 * #bf-tbd-app内を移動するが、止まる位置は「containing blockの下端」になる。
 * V2ではsummaryに`margin-bottom: -96px`が付いていたため、containing blockの
 * 下端が96px引き上げられ、**summaryの最終停止位置がカードグリッドの上に
 * 重なっていた**（本番実測で最下段カードが常時57px＝バー高さ分隠れていた）。
 *
 * 修正方針:
 *   1. summaryから負のbottom marginを外す（横方向の-16pxだけ残す）。
 *   2. カード一覧を.bf-tbd-tiersで包み、その下に「バー高さ＋余白」を確保する。
 *      これによりバーがビューポート下端に張り付いている間も、最下段カードは
 *      バーの上まで完全にスクロールできる。
 *   3. 高さはJSが実測して--bf-tbd-summary-hへ書き戻すので、
 *      バーが2行に折り返して高くなっても破綻しない。
 */
.bf-tbd-tiers {
	padding-bottom: calc(var(--bf-tbd-summary-h) + 12px);
}

.bf-tbd-tier {
	margin-bottom: 20px;
}

.bf-tbd-tier__heading {
	font-size: 15px;
	font-weight: 700;
	margin: 0 0 8px;
	padding-left: 2px;
}

/*
 * 2026-10-28: モバイルも横スクロールをやめ、折り返すグリッドで全員を縦に並べる。
 * 390px幅で3列、768px以上は従来どおり140px基準のグリッド。
 */
.bf-tbd-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
	gap: 8px;
}

.bf-tbd-grid .bf-tbd-card {
	min-width: 0;
}

@media (max-width: 767px) {
	.bf-tbd-card__namebar {
		padding: 6px 8px;
		min-height: 34px;
	}

	.bf-tbd-card__name {
		font-size: 12px;
		word-break: break-word;
	}

	.bf-tbd-card__meta {
		padding: 6px 8px 7px;
	}
}

@media (min-width: 768px) {
	.bf-tbd-grid {
		grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
		gap: 10px;
	}
}

/* ---- Player card ---- */

.bf-tbd-card {
	display: block;
	width: 100%;
	text-align: left;
	border: 2px solid #ddd;
	border-radius: 10px;
	background: #fff;
	padding: 0;
	overflow: hidden;
	cursor: pointer;
	font: inherit;
	transition: border-color 0.12s ease, background-color 0.12s ease, transform 0.08s ease;
}

.bf-tbd-card:active {
	transform: scale(0.98);
}

/*
 * F061-V2.1: 名前帯だけをチームカラーで塗る（カード全体はベタ塗りにしない）。
 * background / color はJSがBF_TBD_Colorsの配色表からインラインで当てる
 * （PHP側で白/濃色をWCAGコントラスト比から自動選択済み）。
 * ここの値はteam_abbrが無い/配色表を読めなかった場合のフォールバック。
 */
.bf-tbd-card__namebar {
	background: #4b4b55;
	color: #fff;
	padding: 8px 10px;
	min-height: 38px;
	display: flex;
	align-items: center;
}

.bf-tbd-card__name {
	font-size: 13px;
	font-weight: 700;
	line-height: 1.25;
}

.bf-tbd-card__meta {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 6px;
	padding: 7px 10px 8px;
}

.bf-tbd-card__price {
	font-size: 13px;
	font-weight: 800;
	color: #b8860b;
}

.bf-tbd-card__team {
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.04em;
	color: #777;
}

.bf-tbd-card.is-selected {
	border-color: #1a7f37;
	background: #eafaf0;
}

/*
 * F061-V2.1: チェックマークは名前帯（チームカラー）の上に出るため、
 * 固定の緑ではなく帯の文字色を継承する（帯の文字色はPHP側でコントラスト比
 * 4.5以上になるよう自動選択済みなので、どのチームでも必ず読める）。
 * 選択状態そのものは緑の枠線＋メタ行の緑地でも示すので、色だけに依存しない。
 */
.bf-tbd-card.is-selected .bf-tbd-card__name::after {
	content: " \2713";
	color: currentColor;
}

.bf-tbd-card.is-disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

.bf-tbd-card.is-flash {
	border-color: #c62828;
	background: #fdecea;
}

/* ---- Sticky budget summary ---- */

.bf-tbd-summary {
	position: sticky;
	bottom: 0;
	left: 0;
	right: 0;
	background: #fff;
	border-top: 1px solid #ddd;
	padding: 10px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
	/* F061-V2.1: 負のbottom marginを外す（.bf-tbd-tiers側で余白を確保する）。 */
	margin: 0 -16px;
}

.bf-tbd-summary__stats {
	font-size: 13px;
	font-weight: 600;
}

.bf-tbd-summary__stats .bf-tbd-summary__budget.is-over {
	color: #c62828;
}

.bf-tbd-summary__button {
	border: none;
	border-radius: 999px;
	padding: 10px 20px;
	font-weight: 700;
	font-size: 14px;
	background: #1a7f37;
	color: #fff;
	cursor: pointer;
}

.bf-tbd-summary__button:disabled {
	background: #ccc;
	color: #888;
	cursor: not-allowed;
}

/* ---- Complete / Saved screen ---- */

.bf-tbd-complete {
	text-align: center;
}

.bf-tbd-complete-card {
	border: 2px solid #1a7f37;
	border-radius: 14px;
	padding: 20px 16px;
	margin: 12px 0 20px;
	background: #fff;
}

.bf-tbd-complete-card__brand {
	font-size: 11px;
	letter-spacing: 0.1em;
	color: #666;
	margin: 0 0 12px;
}

.bf-tbd-complete-card__list {
	list-style: none;
	margin: 0 0 12px;
	padding: 0;
	text-align: left;
}

.bf-tbd-complete-card__list li {
	display: flex;
	justify-content: space-between;
	padding: 6px 0;
	border-bottom: 1px dashed #eee;
	font-size: 14px;
}

.bf-tbd-complete-card__total {
	font-size: 18px;
	font-weight: 800;
}

.bf-tbd-complete-card__cta {
	font-size: 13px;
	font-weight: 700;
	color: #1a7f37;
	margin: 8px 0 0;
}

/* ---- Share buttons ---- */

.bf-tbd-share {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	justify-content: center;
	margin: 0 0 12px;
}

.bf-tbd-share__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: none;
	border-radius: 999px;
	padding: 9px 16px;
	font-weight: 700;
	font-size: 13px;
	cursor: pointer;
	text-decoration: none;
	font: inherit;
}

.bf-tbd-share__btn--x {
	background: #000;
	color: #fff;
}

.bf-tbd-share__btn--native {
	background: #1a7f37;
	color: #fff;
}

.bf-tbd-share__btn--copy {
	background: #f0f0f0;
	color: #1a1a1a;
}

.bf-tbd-share__message {
	text-align: center;
	font-size: 13px;
	font-weight: 700;
	color: #1a7f37;
	margin: 0 0 12px;
}

.bf-tbd-actions {
	display: flex;
	flex-direction: column;
	gap: 10px;
	align-items: center;
}

.bf-tbd-actions a,
.bf-tbd-actions button {
	display: inline-block;
	border: none;
	border-radius: 999px;
	padding: 12px 24px;
	font-weight: 700;
	font-size: 14px;
	cursor: pointer;
	text-decoration: none;
}

.bf-tbd-actions .bf-tbd-btn--primary {
	background: #1a7f37;
	color: #fff;
}

.bf-tbd-actions .bf-tbd-btn--secondary {
	background: #f0f0f0;
	color: #1a1a1a;
}

.bf-tbd-saved-message {
	font-weight: 700;
	color: #1a7f37;
	margin-bottom: 12px;
}
