@charset "UTF-8";

/* =========================================================
   共通変数・ベーススタイル（全体・部門選択画面）
========================================================= */
:root {
  --bg-gradient: linear-gradient(135deg, #1e3a8a 0%, #0f172a 100%);
  --bg-light: #f5f5f5; /* 試合詳細用背景 */
  --card-bg: #ffffff;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --muted: #64748b;
  --text-main: #0f172a;
  --radius-lg: 20px;
  --radius-md: 12px;
  --gap: 16px;
  --max-width: 1100px;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
  color: var(--text-main);
  background: var(--bg-light); /* デフォルトはライトグレー */
}

/* 部門選択画面だけは専用の背景グラデーションを適用する場合 */
body.select-page {
  background: var(--bg-gradient);
}

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px 16px 40px;
  box-sizing: border-box;
}

/* =========================================================
   検索エリアのデザイン（個人戦・団体戦共通）
========================================================= */
.search-card {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border-left: 6px solid #0056b3; /* 青い左線 */
    padding: 20px;
    margin-bottom: 25px;
}
.search-title {
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
    margin: 0 0 15px 0;
}
.search-input-wrapper {
    position: relative;
    max-width: 600px;
    width: 100%;
}
/* .search-input-wrapper input {
    width: 100%;
    padding: 12px 100px 12px 40px;
    font-size: 1em;
    border: 2px solid #0056b3;
    border-radius: 30px;
    box-sizing: border-box;
    outline: none;
} */
.search-input-wrapper input[type="search"] {
    width: 100%;
    padding: 12px 100px 12px 40px;
    font-size: 1em;
    border: 2px solid #0056b3;
    border-radius: 30px;
    box-sizing: border-box;
    outline: none;
}
.search-input-wrapper input:focus {
    box-shadow: 0 0 5px rgba(0, 86, 179, 0.3);
}
.search-input-wrapper .search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #0056b3;
    font-size: 1.1em;
}
.search-input-wrapper button {
    position: absolute;
    right: 4px;
    top: 4px;
    bottom: 4px;
    background-color: #0056b3;
    color: #fff;
    border: none;
    border-radius: 26px;
    padding: 0 25px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}
.search-input-wrapper button:hover {
    background-color: #004494;
}

/* =========================================================
   個人戦 (department-detail.php) 用スタイル
========================================================= */
.search-bar {
  background: var(--card-bg);
  padding: 20px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
  border-left: 4px solid var(--accent);
}

.search-form {
  display: flex;
  gap: 10px;
}

@media (max-width: 480px) {
  .search-form { flex-direction: column; }
}

input[type="text"], input[type="search"] {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 1rem;
  width: 100%;
}

.btn-submit {
  padding: 12px 24px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}

.clear-btn {
  padding: 12px 20px;
  background: #e2e8f0;
  color: #475569;
  text-decoration: none;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  font-weight: 600;
}

.match-card {
  background: var(--card-bg);
  padding: 16px;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  border: 1px solid #ddd;
}

/* 試合会場・日時のヘッダー（個人・団体統一） */
.match-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 16px;
  border-bottom: 1px solid #eee;
  padding-bottom: 8px;
}
.meta-left { font-weight: 500; }
.meta-right {
  background: #f5f5f5;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
}
@media (max-width: 480px) {
  .match-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .meta-right { align-self: flex-end; }
}

/* 勝敗バッジ */
.winner-label {
  color: #fff;
  background-color: #d9534f;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
}
.loser-label {
  color: #fff;
  background-color: #0275d8;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
}

/* 技の丸囲み */
.tech-mark {
  margin: 0 2px;
  font-weight: 600;
  color: #333;
}
.tech-a, .tech-b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75em;
  height: 1.75em;
  border-radius: 50%;
  border: 2.5px solid #d9534f;
  font-weight: 800;
}
/* =========================================================
   補足：個人戦用レイアウト（パソコン・スマホ両対応の確実な指定）
========================================================= */

/* 対戦グリッドレイアウトの強制修正 */
.match-row {
  display: grid !important;
  grid-template-columns: 1fr auto 1fr !important;
  align-items: center;
  width: 100% !important; /* 横幅いっぱいに広げる */
  gap: 20px;
}

@media (max-width: 640px) {
  .match-row {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
}

/* 選手のコンテナ */
.player-container {
  display: flex !important;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.player-container.left-side {
  justify-content: flex-start !important; /* 選手Aは左寄せ */
}

.player-container.right-side {
  justify-content: flex-end !important; /* 選手Bは右寄せ */
}

@media (max-width: 640px) {
  .player-container.left-side,
  .player-container.right-side {
    justify-content: center !important; /* スマホ時は中央寄せ */
  }
}

.player-info {
  font-size: 1.15rem;
  font-weight: 500;
  white-space: nowrap; /* 不自然な名前の改行を防ぐ */
}

.win-active {
  font-weight: 800;
  color: #000000;
}

.team-name {
  color: var(--muted);
  font-size: 0.85rem;
  display: block;
}

/* 中間の技スコア表示 */
.tech-center {
  white-space: nowrap;
  padding: 6px 16px;
  background: #f8fafc;
  border-radius: 30px;
  border: 1px solid #e2e8f0;
  font-weight: bold;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
}

/* 判定・備考テキスト */
.judgement-text {
  display: block !important;
  width: 100%;
  box-sizing: border-box;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 16px;
  background: #f8fafc;
  padding: 8px;
  border-radius: 6px;
  font-weight: 500;
}
/* =========================================================
   団体戦 (department-team.php) 用スタイル
========================================================= */
.summary {
  background: white;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
  border-left: 4px solid #007bff;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid #f0f0f0;
}
.team-vs {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}
.team-name {
  flex: 1;
  text-align: center;
}
.team-name-text {
  font-size: 1.3em;
  font-weight: bold;
  margin-bottom: 5px;
}
.team-number {
  color: #666;
  font-size: 0.9em;
}
.vs-divider {
  font-weight: bold;
  color: #999;
  padding: 0 20px;
  font-size: 1.2em;
}
.score-display {
  background: #f9f9f9;
  padding: 20px;
  border-radius: 5px;
  margin: 15px 0;
}
.score-row {
  display: flex;
  justify-content: space-around;
  align-items: center;
  margin-bottom: 15px;
}
.score-team {
  text-align: center;
  flex: 1;
}
.score-label {
  font-size: 0.9em;
  color: #666;
  margin-bottom: 5px;
}
.score-value {
  font-size: 2.5em;
  font-weight: bold;
}
.win-count-row {
  text-align: center;
  padding-top: 15px;
  border-top: 1px solid #e0e0e0;
}
.toggle-details-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 12px 30px;
  border-radius: 25px;
  font-size: 1em;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  transition: all 0.3s ease;
}
.toggle-details-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}
.collapsible-content {
  overflow: hidden;
  transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
}

/* スコアシート用のスタイル（テーブル版） */
.scoresheet-container {
  margin-top: 25px;
  overflow-x: auto;
  padding: 10px 0;
}
.scoresheet {
  border: 3px solid #111;
  border-collapse: collapse;
  table-layout: fixed;
  margin: 0 auto;
  width: fit-content;
}
.col-team { width: 80px; }
.col-pos { width: 140px; }
.col-stat { width: 80px; }
.col-rep { width: 80px; }
.scoresheet thead th {
  border: 2px solid #111;
  padding: 10px 4px;
  font-weight: 700;
  font-size: 15px;
  text-align: center;
  background: #fafafa;
}
.scoresheet tbody.team-block { border-top: 3px solid #111; }
.scoresheet td {
  border: 2px solid #111;
  vertical-align: top;
  padding: 0;
}
.team-name-cell {
  text-align: center;
  vertical-align: middle !important;
  font-weight: bold;
  font-size: 1em;
  padding: 8px 4px !important;
}
.team-red { background: #ffe6e6; color: #d9534f; }
.team-white { background: #e6f2ff; color: #0275d8; }
.pos-inner { display: flex; flex-direction: column; min-height: 160px; }
.pos-top, .pos-bottom { flex: 1; display: flex; min-height: 76px; }
.pos-top { border-bottom: 2px dashed #111; }
.sub-left {
  width: 30px;
  min-width: 30px;
  border-right: 1px solid #111;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sub-right {
  flex: 1;
  padding: 6px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.tech-display {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 4px;
}
.tech-badge {
  background: #007bff;
  color: #fff;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.8em;
  font-weight: bold;
}
.player-name {
  font-weight: bold;
  font-size: 0.85em;
  word-break: keep-all;
}
.stat-inner { display: flex; flex-direction: column; height: 100%; min-height: 160px; }
.stat-top, .stat-bottom {
  flex: 1; display: flex; align-items: center; justify-content: center;
  font-size: 1.4em; font-weight: bold;
}
.rep-inner { display: flex; flex-direction: column; min-height: 160px; }
.rep-top, .rep-bottom {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 6px; font-size: 0.85em;
}
.rep-top { border-bottom: 2px dashed #111; }

@media (max-width: 768px) {
  .team-vs { flex-direction: column; gap: 10px; }
  .col-team { width: 50px; }
  .col-pos { width: 100px; }
  .col-stat { width: 60px; }
  .col-rep { width: 60px; }
  .sub-left { width: 22px; min-width: 22px; }
}

/* =========================================================
   部門選択画面 (tournament-departments.php) 用スタイル
========================================================= */
/* ヘッダー */
.select-page .header {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
  color: #ffffff;
}

@media (min-width: 600px) {
  .select-page .header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.select-page h1 {
  margin: 0 0 8px 0;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.select-page .meta {
  color: #93c5fd;
  font-size: 0.95rem;
  font-weight: 500;
}

.select-page .back {
  display: inline-flex;
  align-items: center;
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 600;
  backdrop-filter: blur(4px);
  transition: background 0.2s;
}

.select-page .back:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* メインカード */
.select-page .card {
  background: var(--card-bg);
  padding: 24px;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
}

.select-page .card-title-area {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid #f1f5f9;
  padding-bottom: 16px;
  margin-bottom: 20px;
}

.select-page .card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.select-page .card-subtitle {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
}

/* 2カラムレイアウト */
.select-page .two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  align-items: start;
}

@media (max-width: 768px) {
  .select-page .two-col {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

.select-page .col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.select-page .col h3 {
  margin: 0 0 4px 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 部門ボタン */
.select-page .dept {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  min-height: 52px;
  box-sizing: border-box;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.select-page .dept:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 10px 15px -3px rgba(37, 99, 243, 0.1);
}

.select-page .dept .left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.select-page .dept .name {
  font-weight: 700;
  font-size: 1rem;
}

.select-page .dept .sub {
  color: var(--muted);
  font-size: 0.85rem;
}

.select-page .badge {
  background: #eff6ff;
  color: var(--accent);
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  border: 1px solid #dbeafe;
}

/* 0件の表現 */
.select-page .dept.zero {
  opacity: 0.55;
  background: #f1f5f9;
}
.select-page .dept.zero .badge {
  background: #e2e8f0;
  color: var(--muted);
  border-color: #cbd5e1;
}

.select-page .empty {
  padding: 16px;
  color: var(--muted);
  background: #f8fafc;
  border-radius: var(--radius-md);
  border: 1px dashed #cbd5e1;
  font-size: 0.9rem;
  text-align: center;
}

.select-page .note {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 24px;
  text-align: center;
  background: #f8fafc;
  padding: 10px;
  border-radius: 8px;
}

/* =========================================
   フッター（企画・制作・保守）のデザイン
========================================= */
footer {
  width: fit-content;
  margin: 0 auto 30px auto;
  border: 1px solid #ccc;
  padding: 15px 25px;
  border-radius: 8px;
  background-color: #fff;
}

.school-name {
  text-align: left;
  margin: 0 0 5px 0;
  color: #666;
  font-size: 0.9rem;
  line-height: 1.2;
}

.school-name:last-child {
  margin-bottom: 0;
}
