/* ==============================
   Layout
============================== */
.page {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  margin: 30px auto;
  gap: 30px;
  max-width: 1200px;
  padding: 0 20px;
}

h2[id] {
  scroll-margin-top: 80px;
}

/* ==============================
   Content wrapper
============================== */
.contents {
  flex: 1;
  max-width: 1200px;
  padding: 0;
  background: none;
  text-align: left;
  box-sizing: border-box;
}

.graybox {
  background: #f8f9fa;
  padding: 20px;
}

/* Responsive layout for tablets/mobile */
@media (max-width: 768px) {
  .page {
    flex-direction: column;
    padding: 0 10px;
  }
  .contents {
    width: 100%;
    max-width: 100%;
  }
}

/* ==============================
   Leaderboard Table Base
============================== */
.leaderboard {
  margin: 16px 0 24px;
  overflow-x: auto; /* Allow horizontal scroll on small screens */
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 1.0rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
  table-layout: fixed; /* Fix column widths for stable layout */
}

/* Header cells */
.leaderboard-table thead th {
  padding: 12px 12px;
  text-align: center;
  font-size: 1.0rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #666;
  background: #f5f5f5;
  border-bottom: 1px solid #ddd;
  height: 42px; /* Fixed height for header rows */
}

/* Body cells */
.leaderboard-table tbody td {
  height: 48px; /* Fixed row height so table height never changes */
  padding: 0 12px;
  line-height: 48px; /* Vertically center text */
  text-align: center;
  border-bottom: 1px solid #eee;
}

/* ==============================
   Row Hover (table or chart-linked)
============================== */

/* Highlight row when:
   - hovered directly
   - JS adds .row-hover when chart is hovered */
.leaderboard-table tbody tr:hover,
.leaderboard-table tbody tr.row-hover {
  background-color: #f0f6ff;
  transition: none; /* Instant highlight */
}

/* ==============================
   Rank Styling
============================== */
.leaderboard-table tbody tr.rank-1 {
  background: #fffdf2; /* Light gold */
  font-weight: 600;
}

.leaderboard-table tbody tr.rank-2,
.leaderboard-table tbody tr.rank-3 {
  font-weight: 500;
}

/* Hover has priority over rank styling */
.leaderboard-table tbody tr.rank-1:hover,
.leaderboard-table tbody tr.rank-2:hover,
.leaderboard-table tbody tr.rank-3:hover,
.leaderboard-table tbody tr.rank-1.row-hover,
.leaderboard-table tbody tr.rank-2.row-hover,
.leaderboard-table tbody tr.rank-3.row-hover {
  background-color: #f0f6ff !important;
}

/* ==============================
   Vertical Divider between Test & Validation
============================== */

/* First header row: “Test data | Validation data” */
.leaderboard-table thead tr:first-child th:nth-child(4) {
  border-left: 2px solid #ddd;
}

/* Second header row: divider before first val metric */
.leaderboard-table thead tr:nth-child(2) th:nth-child(5),
/* Body: divider before first val metric column */
.leaderboard-table tbody td:nth-child(7) {
  border-left: 2px solid #ddd;
}

/* ==============================
   Rank Cell / Medals
============================== */
.rank-cell {
  text-align: left;
  white-space: nowrap;
}

.medal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.8rem;
}

.medal-gold   { background: #ffd700; }
.medal-silver { background: #c0c0c0; }
.medal-bronze { background: #cd7f32; }

/* ==============================
   Chart Container
============================== */
.chart-container {
  width: 80%;
  height: 350px;
  margin: auto;
  text-align: center;
}

/* ==============================
   Small screen adjustments
============================== */
@media (max-width: 480px) {
  .leaderboard-table thead th,
  .leaderboard-table tbody td {
    padding: 6px 8px;
    font-size: 0.8rem;
  }
  .chart-container {
    height: 250px;
  }
}

/* ==============================
   Pagination
============================== */
.pagination button {
  background-color: #e0e0e0;
  color: #333;
  margin-top: 5px;
  border: 1px solid #ccc;
  padding: 0.5rem 1rem;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
}

.pagination button:hover {
  background-color: #d0d0d0;
  border-color: #bbb;
}

.pagination button:disabled {
  background-color: #f0f0f0;
  color: #aaa;
  cursor: not-allowed;
}

.pagination span {
  color: #666;
  font-size: 0.95rem;
  margin: 0 0.5rem;
}

.leaderboard-table td.name-cell {
  white-space: normal;
  text-align: left;
  font-size: 14px;
  line-height: 1.15;          /* ← ここを小さく */
  overflow-wrap: anywhere;
  word-break: break-word;
}

.baseline-row {
  background-color: rgba(0, 200, 120, 0.1);
}