/**
 * 対戦表・トーナメント表作成ツール - 専用スタイル
 */

/* ====================
   モード切替タブ
   ==================== */
.tm-mode-tabs {
	display: flex;
	border-bottom: 1px solid var(--color-border);
}

.tm-mode-tab {
	flex: 1;
	padding: 14px 16px;
	font-family: var(--font-display);
	font-size: 14px;
	font-weight: 700;
	color: var(--color-text-muted);
	background: var(--color-bg);
	border: none;
	border-bottom: 3px solid transparent;
	cursor: pointer;
	transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.tm-mode-tab:hover {
	color: var(--color-text);
	background: var(--color-white);
}

.tm-mode-tab.active {
	color: var(--color-primary);
	background: var(--color-white);
	border-bottom-color: var(--color-primary);
}

/* ====================
   結果エリア共通
   ==================== */
.result-area {
	background: var(--color-white);
	border: 1px solid var(--color-border);
	border-radius: var(--radius);
	margin-bottom: 32px;
	overflow: hidden;
}

.result-header {
	padding: 14px 20px;
	border-bottom: 1px solid var(--color-border);
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.result-title {
	font-family: var(--font-display);
	font-size: 15px;
	font-weight: 700;
	color: var(--color-text);
	margin: 0;
}

.result-actions {
	display: flex;
	gap: 12px;
}

.result-footer {
	padding: 14px 20px;
	border-top: 1px solid var(--color-border);
	display: flex;
	justify-content: flex-end;
	gap: 12px;
}

/* ====================
   セクションタイトル
   ==================== */
.tm-section-title {
	font-family: var(--font-display);
	font-size: 14px;
	font-weight: 700;
	color: var(--color-text);
	margin: 0 0 12px;
	padding: 0 20px;
}

/* ====================
   対戦マトリックス
   ==================== */
.tm-matrix-wrapper {
	padding: 20px;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.tm-matrix {
	border-collapse: collapse;
	width: auto;
	min-width: 100%;
	font-size: 13px;
}

.tm-matrix th,
.tm-matrix td {
	padding: 8px 12px;
	border: 1px solid var(--color-border);
	text-align: center;
	white-space: nowrap;
}

.tm-matrix th {
	background: var(--color-primary);
	color: var(--color-white);
	font-family: var(--font-display);
	font-weight: 700;
	font-size: 12px;
}

.tm-matrix th.tm-corner {
	background: var(--color-primary-dark, var(--color-primary));
}

.tm-matrix td.tm-name-cell {
	background: var(--color-primary);
	color: var(--color-white);
	font-family: var(--font-display);
	font-weight: 700;
	font-size: 12px;
	text-align: left;
}

.tm-matrix td.tm-diagonal {
	background: var(--color-bg);
	color: var(--color-text-muted);
}

.tm-matrix td.tm-match-cell {
	background: var(--color-white);
	font-size: 12px;
	color: var(--color-text-muted);
}

/* ====================
   対戦カード一覧
   ==================== */
.tm-match-list-wrapper {
	padding: 20px 0;
	border-top: 1px solid var(--color-border);
}

.tm-match-list {
	padding: 0 20px;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
	gap: 8px;
}

.tm-match-card {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 14px;
	background: var(--color-bg);
	border: 1px solid var(--color-border);
	border-radius: var(--radius);
	font-size: 13px;
}

.tm-match-number {
	font-family: var(--font-display);
	font-size: 11px;
	font-weight: 700;
	color: var(--color-white);
	background: var(--color-primary);
	padding: 2px 8px;
	border-radius: 10px;
	white-space: nowrap;
	flex-shrink: 0;
}

.tm-match-vs {
	color: var(--color-text);
	font-weight: 500;
}

.tm-match-vs .tm-vs-label {
	color: var(--color-accent);
	font-weight: 700;
	margin: 0 4px;
}

.tm-match-bye {
	color: var(--color-text-muted);
	font-style: italic;
}

.tm-match-round-label {
	font-family: var(--font-display);
	font-size: 13px;
	font-weight: 700;
	color: var(--color-text);
	margin-bottom: 8px;
	padding: 0 4px;
	grid-column: 1 / -1;
}

.tm-match-round-label + .tm-match-round-label {
	margin-top: 8px;
}

/* ====================
   トーナメントブラケット
   ==================== */
.tm-bracket-wrapper {
	padding: 20px;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

.tm-bracket {
	display: flex;
	align-items: stretch;
	min-width: fit-content;
}

/* ブラケット列 */
.tm-bracket-col {
	display: flex;
	flex-direction: column;
	flex-shrink: 0;
}

.tm-bracket-col-header {
	text-align: center;
	font-family: var(--font-display);
	font-size: 12px;
	font-weight: 700;
	color: var(--color-text-muted);
	padding-bottom: 12px;
	white-space: nowrap;
	min-height: 24px;
	display: flex;
	align-items: flex-end;
	justify-content: center;
}

.tm-bracket-col-body {
	display: flex;
	flex-direction: column;
	flex: 1;
}

/* 試合スロット */
.tm-game-slot {
	flex: 1;
	display: flex;
	align-items: center;
	position: relative;
	min-height: 72px;
}

/* ラウンド列からコネクターへの水平線 */
.tm-round-with-exit .tm-game-slot::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 100%;
	width: 12px;
	height: 0;
	border-top: 2px solid var(--color-border);
}

/* シード */
.tm-seed {
	width: 140px;
	height: 32px;
	display: flex;
	align-items: center;
	padding: 0 10px;
	font-size: 13px;
	font-weight: 500;
	color: var(--color-text);
	background: var(--color-white);
	border: 1px solid var(--color-border);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	box-sizing: border-box;
}

.tm-seed:first-child {
	border-radius: var(--radius) var(--radius) 0 0;
	border-bottom: none;
}

.tm-seed:last-child:not(:first-child) {
	border-radius: 0 0 var(--radius) var(--radius);
}

.tm-seed:only-child {
	border-radius: var(--radius);
}

.tm-seed.tm-bye {
	color: var(--color-text-muted);
	background: var(--color-bg);
	font-style: italic;
}

.tm-seed.tm-seed-tbd {
	color: var(--color-text-muted);
	background: var(--color-bg);
}

.tm-seed.tm-seed-winner {
	border: 2px solid var(--color-accent);
	border-radius: var(--radius);
	justify-content: center;
	font-size: 16px;
}

.tm-seed-number {
	font-size: 11px;
	font-weight: 700;
	color: var(--color-text-muted);
	margin-right: 6px;
	flex-shrink: 0;
}

/* ====================
   ブラケット接続線
   ==================== */

/* コネクター列 */
.tm-bracket-connector-col {
	margin: 0 12px;
}

.tm-connector-group {
	flex: 1;
	display: flex;
	flex-direction: column;
	width: 24px;
	position: relative;
}

/* 4分割: spacer → line-top → line-bottom → spacer */
.tm-cg-spacer {
	flex: 1;
}

.tm-cg-line-top {
	flex: 1;
	border-top: 2px solid var(--color-border);
	border-right: 2px solid var(--color-border);
}

.tm-cg-line-bottom {
	flex: 1;
	border-bottom: 2px solid var(--color-border);
	border-right: 2px solid var(--color-border);
}

/* コネクターから次ラウンドへの水平線 */
.tm-connector-group::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 100%;
	width: 12px;
	height: 0;
	border-top: 2px solid var(--color-border);
}

/* 決勝→優勝の接続線 */
.tm-bracket-final-connector {
	flex-shrink: 0;
	margin: 0 4px;
}

.tm-final-line {
	flex: 1;
	display: flex;
	align-items: center;
}

.tm-final-line-inner {
	width: 20px;
	border-top: 2px solid var(--color-border);
}

/* 優勝列 */
.tm-bracket-winner-col .tm-game-slot {
	min-height: 0;
}

/* ====================
   レスポンシブ対応
   ==================== */
@media (max-width: 600px) {
	.tm-mode-tab {
		padding: 12px 10px;
		font-size: 13px;
	}

	.tm-matrix-wrapper {
		padding: 16px;
	}

	.tm-match-list {
		padding: 0 16px;
		grid-template-columns: 1fr;
	}

	.tm-bracket-wrapper {
		padding: 16px;
	}

	.tm-seed {
		width: 110px;
		font-size: 11px;
		padding: 0 6px;
	}

	.result-header {
		padding: 12px 16px;
		flex-direction: column;
		align-items: flex-start;
		gap: 8px;
	}

	.result-actions {
		width: 100%;
		justify-content: flex-end;
	}

	.result-footer {
		padding: 12px 16px;
		flex-direction: column;
	}

	.result-footer .btn-secondary {
		width: 100%;
	}

	.tm-section-title {
		padding: 0 16px;
	}

	.tm-match-list-wrapper {
		padding: 16px 0;
	}
}
