/* ==========================================
   カラーテーマ
========================================== */

:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #d1d5db;
  --accent: #111827;
  --danger: #b91c1c;
}


/* ==========================================
   基本設定
========================================== */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Hiragino Kaku Gothic ProN",
    "Yu Gothic",
    Meiryo,
    sans-serif;
}


/* ==========================================
   ヘッダー
========================================== */

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;

  padding: 16px;

  background: var(--accent);
  color: #ffffff;
}

header h1 {
  margin: 0;
  font-size: 20px;
}

header p {
  margin: 4px 0 0;
  font-size: 12px;
  opacity: 0.75;
}


/* ==========================================
   ナビゲーション
========================================== */

nav {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

nav form {
  display: flex;
  align-items: center;
  margin: 0;
}

nav a,
.link-button {
  display: inline-flex;
  align-items: center;

  padding: 0;
  border: 0;

  background: none;
  color: #ffffff;

  font: inherit;
  font-weight: 600;
  line-height: 1;

  text-decoration: none;

  cursor: pointer;
}


/* ==========================================
   メイン領域
========================================== */

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px;
}


/* ==========================================
   見出し
========================================== */

h2,
h3 {
  margin-top: 0;
}


/* ==========================================
   カード
========================================== */

.card {
  margin-bottom: 16px;
  padding: 18px;

  background: var(--card);

  border: 1px solid #e5e7eb;
  border-radius: 14px;

  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
}


/* ==========================================
   ページ上部
========================================== */

.page-head,
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;

  margin-bottom: 16px;
}

.page-head h2,
.page-head p {
  margin: 0;
}

.page-head p {
  margin-top: 4px;
  color: var(--muted);
}

.actions,
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}


/* ==========================================
   ボタン
========================================== */

button,
.button {
  display: inline-block;

  padding: 10px 14px;

  border: 0;
  border-radius: 9px;

  font-size: 14px;
  font-weight: 700;
  text-decoration: none;

  cursor: pointer;

  transition:
    background-color 0.2s ease,
    color 0.2s ease,
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.primary {
  background: var(--accent);
  color: #ffffff;
}

.secondary {
  background: #e5e7eb;
  color: var(--text);
}

.danger {
  background: #fee2e2;
  color: var(--danger);
}

.large {
  padding: 13px 20px;
}

.small {
  padding: 5px 10px;
}

.small-button {
  padding: 6px 9px;
}


/* ==========================================
   ボタンのホバー
========================================== */

.page-head .actions .button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
}

.page-head .actions .button.primary:hover {
  background: #374151;
  color: #ffffff;
}

.page-head .actions .button.secondary:hover {
  background: #cbd5e1;
  color: #111827;
}

.page-head .actions .button:active {
  transform: translateY(0);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
}


/* ==========================================
   フォーム
========================================== */

.stack {
  display: grid;
  gap: 14px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.full {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 5px;

  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px;

  border: 1px solid var(--line);
  border-radius: 9px;

  background: #ffffff;
  color: var(--text);

  font: inherit;
}

textarea {
  min-height: 330px;
  line-height: 1.6;
}

.narrow {
  max-width: 430px;
  margin: 50px auto;
}

.sticky-actions {
  position: sticky;
  bottom: 0;

  padding: 12px 0;

  background: rgba(244, 246, 248, 0.94);
  text-align: right;
}


/* ==========================================
   テーブル
========================================== */

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 11px;

  border-bottom: 1px solid #e5e7eb;

  text-align: left;
  white-space: nowrap;
}

.pill {
  padding: 4px 9px;

  background: #eef2f7;

  border-radius: 999px;

  font-size: 12px;
}


/* ==========================================
   試合入力
========================================== */

.match-row {
  display: grid;
  grid-template-columns:
    100px
    1.2fr
    1.2fr
    100px
    110px
    1.3fr
    62px;
  gap: 9px;
  align-items: end;

  padding: 12px 0;

  border-bottom: 1px solid #e5e7eb;
}

.score {
  display: flex;
  align-items: center;
  gap: 4px;
}

.score input {
  min-width: 45px;
}

.wide {
  min-width: 150px;
}


/* ==========================================
   補助テキスト
========================================== */

.muted {
  color: var(--muted);
}

.error {
  color: var(--danger);
}

.center {
  text-align: center;
}


/* ==========================================
   メタ情報
========================================== */

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.meta-grid div {
  display: grid;
  gap: 4px;
}

.meta-grid span {
  color: var(--muted);
  font-size: 12px;
}


/* ==========================================
   納会資料全体
========================================== */

.banquet-sheet {
  max-width: 900px;
  margin: 0 auto;
  padding: 48px;

  background: #ffffff;
}

.banquet-sheet > h1 {
  margin: 20px 0 44px;

  text-align: center;
  text-decoration: underline;
  font-size: 1.8rem;
}

.banquet-sheet > h2 {
  margin: 0 0 18px;

  text-align: center;
  font-size: 1.45rem;
}

.center {
  text-align: center;
}


/* ==========================================
   個人戦の納会資料表示
========================================== */

.player-result {
  position: relative;

  max-width: 620px;
  margin: 38px auto;
}

.player-result-heading {
  position: relative;

  display: flex;
  justify-content: center;
  align-items: center;

  margin-bottom: 10px;
}

.player-result-heading h3 {
  display: inline-block;

  margin: 0;
  padding: 0 8px 2px;

  border-bottom: 1px solid var(--text);

  font-size: 1.2rem;
  font-weight: 600;
  text-align: center;
}

.player-edit-button {
  position: absolute;
  right: 0;
}

.individual-match-list {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
}

.individual-match-row {
    display: grid;
    grid-template-columns: 110px 380px;
    column-gap: 8px;
    align-items: baseline;

    margin: 3px auto;

    font-size: 1.08rem;
    line-height: 1.55;
}

.individual-round {
  text-align: right;
  white-space: nowrap;
}

.individual-result-text {
  text-align: left;
}


/* ==========================================
   団体戦の納会資料表示
========================================== */

.team-result {
  margin-top: 48px;
}

.team-result > h2 {
  margin: 0 0 6px;

  text-align: center;
  font-size: 1.3rem;
  font-weight: 500;
}

.team-overall-result {
  margin: 0 0 4px;

  text-align: center;
  font-size: 1.12rem;
}

.team-result > h2 {
    margin: 0 0 6px;

    text-align: center;

    font-size: 1.45rem;
    font-weight: 700;
}

.team-score-sheet {
  max-width: 560px;
  margin: 0 auto 30px;
}


/* 学校名 */

.team-header {
  display: grid;
  grid-template-columns: 190px 100px 190px;
  align-items: center;

  margin-bottom: 4px;

  font-size: 1.18rem;
  font-weight: 500;
}

.home-team-name,
.away-team-name {
  text-align: center;
}


/* 各選手の試合 */

.team-match-list {
  display: grid;
  gap: 2px;
}

.team-match-row {
  display: grid;
  grid-template-columns: 1fr 120px 1fr;
  align-items: center;

  min-height: 24px;

  font-size: 1.08rem;
  line-height: 1.45;
}

.team-home-player {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 8px;
}

.team-position {
  text-align: right;
  font-weight: 500;
}

.team-player-name {
  text-align: left;
}

.team-center-score {
  display: grid;
  grid-template-columns: 1fr 16px 1fr;
  align-items: center;

  text-align: center;
}

.home-technique {
  text-align: right;
}

.away-technique {
  text-align: left;
}

.team-score-separator {
  text-align: center;
}

.team-draw-text:first-child {
  text-align: right;
}

.team-draw-text:last-child {
  text-align: left;
}

.team-away-player {
  text-align: left;
  padding-left: 20px;
}

.away-team-name,
.team-away-player {
  transform: translateX(30px);
}

.home-team-name,
.team-home-player {
  transform: translateX(30px);
}

/* 団体戦の合計 */

.team-total-row {
  display: grid;
  grid-template-columns: 1fr 120px 1fr;
  align-items: center;

  margin-top: 4px;

  font-size: 1.08rem;
}

.team-total {
  font-size: 1.08rem;
}

.home-total {
  padding-right: 16px;
  text-align: right;
}

.away-total {
  padding-left: 16px;
  text-align: left;
}


/* 編集・削除ボタン */

.result-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;

  margin-top: 20px;
}

.result-actions form {
  margin: 0;
}




@media (min-width: 701px) and (max-width: 1300px) {

  .team-score-sheet {
    width: 82%;
    max-width: 760px;
    margin: 0 auto 24px;
  }

  .team-header,
  .team-match-row,
  .team-total-row {
    grid-template-columns:
      minmax(220px, 1fr)
      120px
      minmax(160px, 1fr);

    width: 100%;
  }

  /* 電通大側 */
  .team-home-player {
    grid-template-columns:
      40px
      minmax(0, 1fr);

    gap: 5px;
    min-width: 0;

    transform: translateX(50px);
  }

  /* 中央 */
  .team-center-score {
    grid-template-columns:
      minmax(0, 1fr)
      12px
      minmax(0, 1fr);

    min-width: 0;
    white-space: nowrap;
  }

  /* 相手側 */
  .team-away-player {
    width: 100%;
    min-width: 0;

    text-align: left;
    padding-left: 18px;
    padding-right: 0;

    white-space: nowrap;
    transform: translateX(50px);
  }

  /* 学校名 */
  .home-team-name {
    text-align: center;
    transform: translateX(30px);
  }

  .away-team-name {
    text-align: center;
    transform: translateX(-40px);
  }

  /* 合計 */
  .home-total,
  .away-total {
    transform: none;
  }
}



/* ==========================================
   スマホ用 団体戦表示
========================================== */

@media (max-width: 700px) {

  main {
    padding: 12px;
  }

  .banquet-sheet {
    width: 100%;
    padding: 28px 12px;
  }

  .team-result {
    margin-top: 42px;
  }

  .team-result > h2 {
    font-size: 1.35rem;
  }

  .team-overall-result {
    font-size: 1rem;
  }


  /* 団体戦をカード幅に収める */
  .team-score-sheet {
    width: 100%;
    max-width: 100%;
    margin: 0 auto 24px;
  }


  /* 学校名 */
  .team-header {
    grid-template-columns:
      minmax(0, 1fr)
      110px
      minmax(0, 1fr);

    width: 100%;
    font-size: 0.98rem;
  }


  /* 選手 */
  .team-match-row {
    grid-template-columns:
      minmax(0, 1fr)
      110px
      minmax(0, 1fr);

    width: 100%;
    min-height: 24px;

    font-size: 0.88rem;
  }


  /* 左側：ポジション＋選手名 */
  .team-home-player {
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 4px;

    min-width: 0;
    transform: translateX(20px);
  }

  .team-position {
    white-space: nowrap;
  }

  .team-player-name {
    white-space: nowrap;
  }


  /* 中央：取得本 */
  .team-center-score {
  position: relative;
  display: grid;

  grid-template-columns:
    1fr
    10px
    1fr;

  min-width: 0;
  white-space: nowrap;
  overflow: visible;
}

.team-center-score .home-technique {
  text-align: right;
  white-space: nowrap;
}

.team-center-score .team-score-separator {
  text-align: center;
  white-space: nowrap;
}

.team-center-score .away-technique {
  text-align: left;
  white-space: nowrap;
}


  /* 右側：相手選手 */
  .team-away-player {
    min-width: 0;
    padding-left: 60px;

    text-align: left;
    white-space: nowrap;

    transform: none;
  }


  /* 学校名を動かさない */
  .home-team-name,
  .away-team-name {
    transform: none;
  }


  /* 合計 */
  .team-total-row {
    grid-template-columns:
      minmax(0, 1fr)
      110px
      minmax(0, 1fr);

    width: 100%;

    font-size: 0.95rem;
  }

  .home-total {
    padding-right: 8px;
  }

  .away-total {
    padding-left: 8px;
  }
}

/* ==========================================
   印刷
========================================== */

@media print {
  header,
  .page-head,
  .player-edit-button,
  .result-actions,
  body > main > form {
    display: none !important;
  }

  body,
  main {
    margin: 0;
    padding: 0;

    background: #ffffff;
  }

  .card,
  .banquet-sheet {
    max-width: none;
    margin: 0;
    padding: 0;

    border: 0;
    box-shadow: none;
  }
}


input[type="date"] {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}

input[type="date"]::-webkit-date-and-time-value {
  text-align: left;
  min-width: 0;
}

/* ==========================================
   ハンバーガーメニュー
========================================== */

.menu-toggle {
  display: none;
}


/* 800px以下 */
@media (max-width: 800px) {

  header {
    display: block;
  }

  .header-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }

  .header-title-row h1 {
    margin: 0;
    white-space: nowrap;
  }

  .menu-toggle {
    display: block;

    margin-left: 16px;
    padding: 4px 8px;

    border: 0;
    background: transparent;

    color: inherit;
    font-size: 1.8rem;
    line-height: 1;

    cursor: pointer;
  }

  .site-nav {
    display: none;

    width: 100%;
    margin-top: 14px;
  }

  .site-nav.is-open {
    display: flex;
    flex-direction: column;
    align-items: flex-start;

    gap: 4px;
  }

  .site-nav a,
  .site-nav .link-button {
    white-space: nowrap;
  }

  .site-nav form {
    margin: 0;
  }
}

@media (max-width: 1300px) {

  .page-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }

  .page-head h2 {
    width: 100%;
  }

  .page-head .actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
}

@media (max-width: 700px) {

  .page-head .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .page-head .actions .button {
    text-align: center;
  }
}

/* ==========================================
   タブレット・スマホ 試合編集フォーム
========================================== */

@media (max-width: 800px) {

  .match-row {
    grid-template-columns: 1fr 1fr;
    gap: 10px;

    margin-bottom: 10px;
    padding: 12px;

    background: #fafafa;

    border: 1px solid #e5e7eb;
    border-radius: 10px;
  }

  .match-row label {
    min-width: 0;
  }

  .match-row input,
  .match-row select {
    width: 100%;
    min-width: 0;
  }

  .match-row .wide,
  .match-row .remove-row {
    grid-column: 1 / -1;
  }

  .score {
    min-width: 0;
  }
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;

  margin-top: 28px;
}

.draw-score {
  grid-column: 1 / -1;
  justify-self: center;

  white-space: nowrap;
  word-break: keep-all;
}

.team-center-score {
  position: relative;
}