/* ===== グローバルスタイル ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', 'Hiragino Sans', 'Yu Gothic', 'Meiryo', sans-serif;
  background: #FFF;
  min-height: 100vh;
  color: #333;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 10px;
}

/* ===== ヘッダー ===== */
.main-header {
  background: #262E37;
  color: #fff;
  backdrop-filter: blur(10px);
  padding: 20px 0;
  margin-bottom: 0;
}

.main-header h1 {
  font-size: 2rem;
  font-weight: bold;
  margin-bottom: 8px;
}

.last-updated {
  font-size: 0.9rem;
}

/* ===== タブナビゲーション ===== */
.view-tabs {
  backdrop-filter: blur(10px);
  margin-bottom: 30px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.view-tabs .container {
  display: flex;
  gap: 10px;
  padding: 15px 10px;
}

.tab-btn {
  background: #7790ED;
  border: none;
  padding: 20px 10px;
  font-size: 0.96rem;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.3s ease;
  position: relative;
}

.tab-btn:hover {
  background: rgba(102, 126, 234, 0.1);
  color: #667eea;
}

.tab-btn.active {
  background: #3447D2;
  color: white;
}

/* ===== メインコンテンツ ===== */
main {
  padding-bottom: 50px;
}

.view-section {
  display: none;
  animation: fadeIn 0.3s ease;
  background: #FFF;
}

.view-section.active {
  display: block;
  background: #FFF;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/*=====マップ====*/
h2 {
            font-size: 1.5rem;
            color: #262e37;
            margin-top: 0;
            margin-bottom: 20px;
            border-bottom: 1px solid #eee;
            padding-bottom: 10px;
        }

        h3 {
            font-size: 1.1rem;
            margin-bottom: 10px;
            color: #262e37;
        }

        
        .map-section {
            margin-bottom: 30px;
        }

        
        .map-image {
            width: 100%;       
            height: auto;      
            display: block;    
            background-color: #e0e0e0; 
        }
        
        

        /* --- 2x2 グリッド --- */
        .map-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 20px;
        }

/* ===== タイムラインビュー ===== */
.timeline-controls {
  background: #7790ED;
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 20px;
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.control-group label {
  font-weight: 600;
  color: #fff;
}

.control-group select {
  padding: 8px 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 0.95rem;
  background: white;
  cursor: pointer;
  transition: all 0.2s ease;
}

.control-group select:hover {
  border-color: #667eea;
}

.control-group select:focus {
  outline: none;
  border-color: #667eea;
}

.timeline-wrapper {
  background: #E4E9FB;
  padding: 30px;
  border-radius: 12px;
  overflow-x: auto;
}

.timeline-chart {
  position: relative;
  min-width: 100%;
}

.timeline-header {
  display: flex;
  padding-bottom: 10px;
  margin-bottom: 20px;
  font-weight: 600;
  color: #FFF;
  position: sticky;
  top: 0;
  background: #667eea;
  z-index: 10;
}

.timeline-col-court {
  width: 120px;
  flex-shrink: 0;
}

.timeline-col-sport {
  width: 150px;
  flex-shrink: 0;
}

.timeline-col-chart {
  flex: 1;
  background-color: #667eea;
  min-width: 600px;
  position: relative;
}

.timeline-body {
  position: relative;
}

.timeline-row {
  display: flex;
  align-items: center;
  min-height: 60px;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.2s ease;
}

.timeline-row:hover {
  background: rgba(102, 126, 234, 0.03);
}

.timeline-label {
  padding: 10px;
  font-size: 0.9rem;
  color: #555;
}

.timeline-grid {
  position: relative;
  flex: 1;
  min-width: 600px;
  height: 60px;
}

.timeline-grid-lines {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
}

.timeline-grid-line {
  flex: 1;
  border-left: 1px solid #e8e8e8;
  position: relative;
}

.timeline-grid-line:first-child {
  border-left: 2px solid #ddd;
}

.timeline-time-label {
  position: absolute;
  top: -25px;
  left: 0;
  font-size: 0.75rem;
  color: #3447D2;
  white-space: nowrap;
  transform: translateX(-50%);
}

.timeline-bar {
  position: absolute;
  height: 40px;
  top: 10px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 0.85rem;
  color: white;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  overflow: hidden;
}

.timeline-bar:hover {
  transform: translateY(-2px);
  z-index: 5;
}

.timeline-bar-content {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

.timeline-bar.status-scheduled {
  background: #7790ED;
}

.timeline-bar.status-in-progress {
  background: #3447D2;
  animation: pulse 2s infinite;
}

.timeline-bar.status-finished {
  background: #E4E9FB;
  opacity: 0.7;
}

.timeline-bar.status-delayed {
  background: #3447D2;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.85;
  }
}

.timeline-bar .delay-badge {
  background: rgba(255, 255, 255, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  margin-left: auto;
  flex-shrink: 0;
}

/* ===== ニュースセクション ===== */
#news-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 20px;
}

.news-item {
  background: #E4E9FB;
  padding: 24px;
  border-radius: 12px;
  transition: all 0.3s ease;
}

.news-item:hover {
  transform: translateY(-4px);
}

.news-item h3 {
  color: #000;
  margin-bottom: 12px;
  font-size: 1.2rem;
}

.news-item p {
  color: #000;
  line-height: 1.6;
  margin-bottom: 12px;
}

.news-item small {
  color: #999;
  font-size: 0.85rem;
}

/* ===== トーナメント表 (縦向き + アコーディオン) ===== */

/* スポーツごとのラッパー (アコーディオンのコンテナ) */
.tournament-sport-container {
  background: #fff;
  margin-bottom: 15px; /* アコーディオン間のマージンを調整 */
  border-radius: 12px;
  /*box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);*/
  /* overflow-x はコンテンツ側に移動 */
}

/* --- アコーディオン トリガー (h2 をラップ) --- */
.accordion-trigger {
  width: 100%;
  background: #7790ED;
  border: none;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  border-radius: 12px; /* 閉じてる時は角丸 */
  transition: border-radius 0.3s ease;
  text-align: left; /* button のデフォルト中央揃えを解除 */
}
.accordion-trigger.active {
  /* 開いてる時は下の角を直角に */
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
.accordion-trigger h2 {
  color: #ffffff;
  margin: 0; /* button内のh2のマージンをリセット */
  padding: 0;
  border: none;
  font-size: 1.5em; /* サイズ調整 */
}
.accordion-icon {
  font-size: 1.5em;
  color: #ffffff;
  transition: transform 0.3s ease;
  flex-shrink: 0; /* アイコンが縮まないように */
  margin-left: 15px;
}
.accordion-trigger.active .accordion-icon {
  transform: rotate(180deg); /* 開いたらアイコンを回転 */
}

/* --- アコーディオン コンテンツ (トーナメント表) --- */
.accordion-content {
  /* デフォルトで非表示、高さ0 */
  max-height: 0;
  overflow: hidden; /* 高さが0の時は中身を隠す */
  transition: max-height 0.3s ease-out;

  /* !!! 要望1(横スクロール)対応 !!! */
  /* トーナメント表がはみ出た場合、このエリア内でのみ横スクロール */
  overflow-x: auto; 
  
  /*padding: 0 20px 20px 20px; /* 内側にパディング */
  background: #fff;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
}


/* トーナメントのルート (最上位の決勝戦を中央に配置) */
.bracket {
  display: flex;
  /*justify-content: center;*/
  /* 最小幅を確保し、それ以下はスクロール */
  min-width: 400px;
  padding-top: 20px; /* アコーディオンヘッダーとの余白 */
}

/* 1試合分のノード (試合ボックス + 子コンテナ) */
.match-node {
  display: flex;
  flex-direction: column; /* [試合ボックス] が [子] の上に来る */
  align-items: center;
  position: relative;
  flex-shrink: 0; /* 縮小させない */
}

/* 子ノード (前の2試合) を格納するコンテナ */
.bracket-children {
  display: flex;
  position: relative;
  width: 100%; /* 親ノードの幅全体に広がる */
}

/* .bracket-children 直下の .match-node (つまり子試合) */
.bracket-children > .match-node {
  flex: 1; /* 2つの子試合でスペースを均等に分ける */
  position: relative;
  /* 線を描画するためのスペースを上に確保 */
  padding-top: 20px;
}

/* 試合ボックス本体 */
.match-box {
  width: 200px; /* ボックスの幅を固定 */
  /*border: 1px solid #999;
  border-radius: 4px;
  background: #f9f9f9;*/
  margin: 10px;
  display: flex;
  flex-direction: row;
  /* 線が背後に回っても見えるように */
  position: relative;
  z-index: 1;
}
.match-box .team {
  padding: 8px 12px;
}
.match-box .team:first-child {
  /*border-bottom: 1px solid #ccc;*/
}
.match-box .match-meta {
  font-size: 0.8em;
  color: #555;
  padding: 5px 12px;
  border-top: 1px solid #ccc;
  background: #eee;
  text-align: center;
}

/* 試合結果 */
.winner {
  font-weight: bold;
  color: #f30100;
}
.loser {
  color: #888;
  text-decoration: line-through;
}


/* ===== 接続線 (縦向き) ===== */

/* 1. 親から子コンテナへの縦線 */
/* 子を持つノード（=1回戦以外）に適用 */
.match-node:has(> .bracket-children:not(:empty)) {
  padding-bottom: 20px; /* 縦線のスペース確保 */
}
/* 親の試合ボックスから真下に伸びる線 */
.match-node:has(> .bracket-children:not(:empty)) > .match-box::after {
  content: "";
  position: absolute;
  width: 2px;
  height: 20px; /* padding-bottom と合わせる */
  background: #999;
  /* ボックスの真下中央から */
  left: 50%;
  bottom: -10px; /* padding-bottom 分だけ下へ */
  transform: translateX(-50%);
  z-index: 0;
}

/* 2. 子コンテナ内の横線 */
.bracket-children::before {
  content: "";
  position: absolute;
  height: 2px;
  background: #999;
  /* 親からの縦線と接続 */
  top: 0;
  /* 左右の子の中心を繋ぐ */
  /* 左の子(flex:1)の中央(25%)から右の子(flex:1)の中央(75%)まで */
  left: 25%;
  right: 25%;
  z-index: 0;
}
/* 子が1つ（不戦勝など）の場合は横線を描画しない */
.bracket-children:has(> .match-node:only-child)::before,
.bracket-children:has(> .match-node:empty)::before {
  display: none;
}
/* JSで .match-node が空で出力された場合の対応 */
.bracket-children:has(> .match-node:first-child:empty)::before,
.bracket-children:has(> .match-node:last-child:empty)::before {
    display: none;
}


/* 3. 子から横線への縦線 */
.bracket-children > .match-node::before {
  content: "";
  position: absolute;
  width: 2px;
  height: 20px; /* padding-top と合わせる */
  background: #999;
  /* 各子ノードの中央から */
  left: 50%;
  top: 0; /* padding-top の開始位置へ */
  transform: translateX(-50%);
  z-index: 0;
}
/* 空のノード（不戦勝の相手側）には縦線を描画しない */
.match-node:empty::before {
    display: none;
}

/*NEW!!!!*/
/* 2. 左右の縦線を繋ぐ中央の横線（コの字の「横」部分 - 1本） */
.match-box::before {
    content: "";
    position: absolute;
    height: 2px;
    background: #999999;
    top: 0; /* ★ match-boxの上端（paddingの開始位置）に配置 ★ */
    /* 縦線の外側まで横線を伸ばすための位置計算 */
    left: 12.5%; 
    right: 12.5%; 
    z-index: 1; 
}

/* 親ノードへの縦線（既存の接続線）を上書きしないよう::afterは未使用 */
.match-box .team::after {
    content: none;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .match-box {
    width: 160px; /* ボックス幅を少し狭くする */
  }
  .match-box .team {
    font-size: 0.9em;
    padding: 6px 25px;
  }
  .bracket {
    min-width: 320px; /* 最小幅を狭くする */
  }
  .accordion-trigger h2 {
    font-size: 1.2em;
  }
}