.teams {
  background-color: #f6f7fa;
  padding: 2rem;
  color: black;
  width: 100%;
  max-width: 1400px;
  margin: 2rem auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  flex-direction: column;
  border-radius: 1rem;
  gap: 2.5rem;

  /* 検索欄 */
  .teams-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    width: 100%;
    margin: 0.5rem 0 0.75rem;
  }

  .teams-search label {
    font-weight: 700;
  }

  .teams-search input {
    padding: 0.5rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 1rem;
  }

  .teams-search button {
    background-color: #315bab;
    color: #fff;
    padding: 0.5rem 0.9rem;
    border-radius: 0.5rem;
    border: none;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s;

    &:hover {
      background-color: #254374;
    }
  }

  .teams-search button.secondary {
    background-color: #6b7280;

    &:hover {
      background-color: #4b5563;
    }
  }

  .teams-search__result {
    color: #6b7280;
    font-size: 0.9rem;
    margin-left: auto;
  }

  .teams-search__box {
    position: relative;
    flex: 1;
    min-width: 200px;
  }

  /* テーブル：横4列 */
  .teams-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
  }

  .teams-table tbody {
    display: flex;
    flex-wrap: nowrap;
    gap: 1.5rem;
    width: 100%;
  }

  .teams-table tr {
    display: flex;
    gap: 1.5rem;
    width: 100%;
    flex: 1;
  }

  .teams-table td {
    flex: 1 1 calc(25% - 1.5rem);
    min-width: 200px;
    vertical-align: top;
  }

  /* チームカード */
  .team {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
  }

  .team h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 800;
    text-align: center;
  }

  .members {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-height: none;
    overflow-y: visible;
  }

  .members li {
    line-height: 1.6;
    font-size: 0.95rem;
  }

  /* クラスコード検索ハイライト */
  .class-code {
    transition: background-color 0.2s, color 0.2s;
  }

  .class-code.is-hit {
    font-weight: 700;
  }

  /* チームごとのハイライトカラー */
  .team-red .class-code.is-hit {
    background-color: #ef4444;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
  }

  .team-blue .class-code.is-hit {
    background-color: #3b82f6;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
  }

  .team-green .class-code.is-hit {
    background-color: #22c55e;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
  }

  .team-yellow .class-code.is-hit {
    background-color: #f59e0b;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
  }

  /* カラーテーマ */
  .team-red {
    border-left: 4px solid #ef4444;
  }

  .team-red h3 {
    color: #ef4444;
  }

  .team-blue {
    border-left: 4px solid #3b82f6;
  }

  .team-blue h3 {
    color: #3b82f6;
  }

  .team-green {
    border-left: 4px solid #22c55e;
  }

  .team-green h3 {
    color: #22c55e;
  }

  .team-yellow {
    border-left: 4px solid #f59e0b;
  }

  .team-yellow h3 {
    color: #f59e0b;
  }

  /* サジェストリスト */
  .teams-suggest {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #d1d5db;
    border-top: none;
    border-radius: 0 0 0.5rem 0.5rem;
    max-height: 200px;
    overflow-y: auto;
    display: none;
    list-style: none;
    margin: 0;
    padding: 0;
    z-index: 10;

    &.is-open {
      display: block;
    }

    li {
      padding: 0.5rem 1rem;
      cursor: pointer;
      transition: background-color 0.1s;

      &:hover,
      &.is-active {
        background-color: #e3eeff;
      }
    }
  }

  li {
    list-style: none;
    margin-bottom: 0.5rem;
  }
}

/* レスポンシブ */
@media (max-width: 1200px) {
  .teams {
    .teams-table td {
      flex: 1 1 calc(50% - 1.5rem);
    }
  }
}

@media (max-width: 768px) {
  .teams {
    padding: 1rem;

    .teams-table td {
      flex: 1 1 100%;
    }

    .teams-search {
      flex-direction: column;
    }

    .teams-search__result {
      margin-left: 0;
    }
  }
}
