* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', sans-serif;
  background: #272224;
  color: #e0e0e0;
  min-height: 100vh;
}

/* ── HEADER ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 2rem;
  background: #222021;
  border-bottom: 2px solid #AC9D6C;
  flex-wrap: wrap;
  gap: 1rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.header-logo {
  height: 150px;
  width: auto;
}

.header-title h1 {
  font-size: 1.6rem;
  color: #AC9D6C;
  line-height: 1.2;
}

.header-title p {
  color: #888;
  font-size: 0.85rem;
  margin-top: 0.2rem;
}

.header-right {
  text-align: right;
}

#last-updated {
  color: #e0e0e0;
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 0.2rem;
}

#sim-count {
  color: #888;
  font-size: 0.85rem;
  margin-top: 0.3rem;
}

#refresh-note {
  color: #666;
  font-size: 0.75rem;
  margin-top: 0.3rem;
}

/* ── LEGEND + TABS ROW ── */
#legend-tab-bar {
  display: flex;
  align-items: center;
  background: #1e1c1d;
  border-bottom: 1px solid #333;
  padding: 0.6rem 2rem;
  gap: 0.75rem;
  position: relative;
  min-height: 48px;
}

/* ── TAB BUTTONS ── */
#tab-bar {
  display: flex;
  gap: 0.75rem;
  flex-shrink: 0;
}

.tab {
  background: #222021;
  border: 1px solid #333;
  color: #888;
  padding: 0.4rem 1.1rem;
  cursor: pointer;
  font-size: 0.9rem;
  border-radius: 6px;
  transition: all 0.15s;
}

.tab:hover {
  color: #e0e0e0;
  border-color: #AC9D6C;
}

.tab.active {
  color: #AC9D6C;
  border-color: #AC9D6C;
  background: #2a2527;
}

/* ── FORECAST LEGEND ── */
#forecast-legend {
  display: flex;
  gap: 1.5rem;
  font-size: 0.9rem;
  color: #aaa;
  flex-wrap: wrap;
  align-items: center;
  margin-left: auto;
}

#forecast-legend span {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.dot { font-size: 22px; }

/* ── SIMULATION LEGEND ── */
#simulation-legend {
  display: flex;
  align-items: center;
  flex: 1;
  font-size: 0.9rem;
  color: #aaa;
}

#sim-click-hint {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  color: #AC9D6C;
  font-weight: bold;
  white-space: nowrap;
  font-size: 1.2rem;
}

#sim-legend-right {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  margin-left: auto;
}

#sim-legend-right span {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tab-content { display: block; }
.tab-content.hidden { display: none; }

/* ── TOP SCROLLBAR ── */
#forecast-scroll-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem 1.5rem 0.5rem 1.5rem;
}

#scroll-left-btn,
#scroll-right-btn {
  background: #222021;
  border: 1px solid #AC9D6C;
  color: #AC9D6C;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

#scroll-left-btn:hover,
#scroll-right-btn:hover {
  background: #AC9D6C;
  color: #222021;
}

#forecast-top-scrollbar {
  overflow-x: scroll;
  overflow-y: hidden;
  height: 18px;
  flex: 1;
  background: #222021;
  border-radius: 4px;
  border: 1px solid #333;
}

#forecast-top-scrollbar::-webkit-scrollbar {
  height: 18px;
}

#forecast-top-scrollbar::-webkit-scrollbar-track {
  background: #222021;
  border-radius: 4px;
}

#forecast-top-scrollbar::-webkit-scrollbar-thumb {
  background: #AC9D6C;
  border-radius: 4px;
  border: 3px solid #222021;
}

#forecast-top-scrollbar::-webkit-scrollbar-thumb:hover {
  background: #c4b47e;
}

#forecast-top-scrollbar-inner {
  height: 1px;
}

/* ── FORECAST VIEW ── */
#forecast-container {
  padding: 1.5rem;
  position: relative;
  width: 100%;
  overflow: hidden;
}

.forecast-table-wrapper {
  display: flex;
  align-items: flex-start;
  width: 100%;
}

.forecast-fixed {
  flex-shrink: 0;
  z-index: 2;
  background: #272224;
  border-right: 2px solid #AC9D6C;
}

.forecast-scroll {
  flex: 1;
  overflow-x: scroll;
  -webkit-overflow-scrolling: touch;
  min-width: 0;
}

#forecast-table-fixed {
  border-collapse: collapse;
  font-size: 0.9rem;
}

#forecast-table-fixed thead tr {
  background: #222021;
  color: #AC9D6C;
}

#forecast-table-fixed thead th {
  font-size: 1rem;
  padding: 0.6rem 1.25rem 0.6rem 0.75rem;
  border-bottom: 1px solid #2a2a2a;
  white-space: nowrap;
  vertical-align: bottom;
}

#forecast-table-fixed tbody td {
  padding: 0.4rem 1.25rem 0.4rem 0.75rem;
  border-bottom: 1px solid #2a2a2a;
  white-space: nowrap;
  font-size: 0.9rem;
  font-weight: 600;
  color: #e0e0e0;
  background: #272224;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#forecast-table-fixed tbody tr.ineligible td {
  color: #777;
}

#forecast-table-fixed tbody tr:hover td {
  background: #222021;
  cursor: pointer;
}

#forecast-table-scroll {
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 800px;
}

#forecast-table-scroll thead tr {
  background: #222021;
  color: #AC9D6C;
}

#forecast-table-scroll thead th {
  font-size: 1rem;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #2a2a2a;
  white-space: nowrap;
  vertical-align: bottom;
}

#forecast-table-scroll tbody td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid #2a2a2a;
  white-space: nowrap;
}

#forecast-table-scroll tbody tr.ineligible {
  color: #777;
}

#forecast-table-scroll tbody tr:hover {
  background: #222021;
  cursor: pointer;
}

#forecast-table-scroll th:nth-child(6),
#forecast-table-scroll td:nth-child(6) {
  border-right: 1px solid #AC9D6C;
}

/* ── RANK BAR ── */
.rank-header {
  min-width: 200px;
  padding-bottom: 0.25rem !important;
}

.rank-scale {
  position: relative;
  height: 20px;
  font-size: 0.7rem;
  color: #666;
}

.rank-bar-wrapper {
  position: relative;
  height: 32px;
  min-width: 60px;
}

.rank-bar-track {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: #333;
  transform: translateY(-50%);
}

.rank-bar {
  position: relative;
  width: 100%;
  height: 32px;
}

.rank-bar span {
  position: absolute;
  transform: translate(-50%, -50%);
  top: 50%;
  line-height: 1;
  cursor: default;
}

/* ── SIMULATION VIEW ── */
#main-table-container {
  padding: 1.5rem;
  position: relative;
}

#sim-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

table#main-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.95rem;
  min-width: 600px;
}

table#main-table thead tr {
  background: #222021;
  color: #AC9D6C;
}

table#main-table thead th {
  font-size: 1rem;
  padding: 0.75rem 1rem;
  text-align: center;
  border-bottom: 1px solid #2a2a2a;
  white-space: nowrap;
}

table#main-table thead th:nth-child(3),
table#main-table thead th:nth-child(4),
table#main-table thead th:nth-child(5) {
  white-space: normal;
  max-width: 80px;
  line-height: 1.3;
}

table#main-table tbody td {
  padding: 0.75rem 1rem;
  text-align: center;
  border-bottom: 1px solid #2a2a2a;
  white-space: nowrap;
}

table#main-table thead th:nth-child(n+7),
table#main-table tbody td:nth-child(n+7) {
  text-align: left;
}

table#main-table tbody tr {
  cursor: pointer;
  transition: background 0.15s;
}

table#main-table tbody tr:hover { background: #222021; }
table#main-table tbody tr.eligible { color: #e0e0e0; }
table#main-table tbody tr.ineligible { color: #777; }

/* ── STICKY RANK COLUMN ── */
table#main-table th.sim-sticky-col,
table#main-table td.sim-sticky-col {
  position: sticky;
  left: 0;
  z-index: 4;
  background: #272224;
  width: 60px;
  min-width: 60px;
  max-width: 60px;
  padding: 0.75rem 0.25rem;
  font-size: 1rem;
}

table#main-table thead th.sim-sticky-col {
  background: #222021;
  z-index: 5;
}

table#main-table tbody tr:hover td.sim-sticky-col {
  background: #222021;
}

/* ── STICKY CLUB COLUMN ── */
table#main-table th.sim-sticky-col-2,
table#main-table td.sim-sticky-col-2 {
  position: sticky;
  left: 60px;
  z-index: 3;
  background: #272224;
  width: 160px;
  min-width: 160px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: -40px 0 0 #272224;
}

table#main-table thead th.sim-sticky-col-2 {
  background: #222021;
  z-index: 4;
  box-shadow: -40px 0 0 #222021;
}

table#main-table tbody tr:hover td.sim-sticky-col-2 {
  background: #222021;
  box-shadow: -40px 0 0 #222021;
}

table#main-table th.sim-border-right,
table#main-table td.sim-border-right {
  border-right: 1px solid #AC9D6C;
}

.win-pct {
  font-weight: bold;
  color: #AC9D6C;
}

.bar-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.bar {
  height: 8px;
  background: #AC9D6C;
  border-radius: 4px;
  min-width: 2px;
}

/* ── CLUB DETAIL ── */
.hidden { display: none; }

#club-detail-view {
  padding: 1.5rem;
}

#club-detail { max-width: 1200px; }

#back-btn {
  background: none;
  border: 1px solid #AC9D6C;
  color: #AC9D6C;
  padding: 0.5rem 1rem;
  cursor: pointer;
  border-radius: 4px;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

#back-btn:hover { background: #AC9D6C; color: white; }

#detail-club-name {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: #AC9D6C;
}

#detail-stats {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.stat-box {
  background: #222021;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  text-align: center;
  min-width: 100px;
  flex: 1;
}

.stat-box .value {
  font-size: 1.4rem;
  font-weight: bold;
  color: #AC9D6C;
}

.stat-box .label {
  font-size: 0.75rem;
  color: #888;
  margin-top: 0.25rem;
}

#detail-games {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}

.game-card {
  background: #222021;
  padding: 0.75rem;
  border-radius: 8px;
  border-left: 3px solid #2a2a2a;
}

.game-card.complete { border-left-color: #4caf50; }
.game-card.live { border-left-color: #ff9800; }
.game-card.upcoming { border-left-color: #888; }

.game-card .game-title {
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 0.4rem;
}

.game-card .game-placing { font-size: 1rem; font-weight: bold; }

.game-card .game-points {
  font-size: 0.8rem;
  color: #AC9D6C;
  margin-top: 0.25rem;
}

.game-card .game-status {
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

.games-section-header {
  grid-column: 1 / -1;
  font-size: 0.85rem;
  font-weight: 600;
  color: #AC9D6C;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.5rem 0;
  border-bottom: 1px solid #333;
  margin-bottom: 0.5rem;
}

.games-section-gap {
  grid-column: 1 / -1;
  height: 1rem;
}

/* ── MOBILE ── */
@media (max-width: 768px) {
  header {
    padding: 1rem;
    gap: 0.75rem;
  }

  .header-logo { height: 60px; }
  .header-title h1 { font-size: 1.1rem; }
  .header-title p { font-size: 0.75rem; }

  .header-right {
    width: 100%;
    text-align: left;
  }

  #last-updated { font-size: 0.95rem; }
  #sim-count { font-size: 0.8rem; }

  #legend-tab-bar {
    padding: 0.6rem 1rem;
    flex-wrap: wrap;
    gap: 0.6rem;
  }

  #forecast-legend {
    font-size: 0.8rem;
    gap: 0.75rem;
  }

  #sim-click-hint {
    position: static;
    transform: none;
    white-space: normal;
    font-size: 0.8rem;
    text-align: center;
    width: 100%;
    order: -1;
  }

  #simulation-legend {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
  }

  #sim-legend-right {
    justify-content: center;
  }

  .dot { font-size: 16px; }

  #forecast-container,
  #main-table-container,
  #club-detail-view {
    padding: 1rem;
  }

  #forecast-scroll-controls {
    margin: 0.5rem 1rem 0.25rem 1rem;
  }

  #detail-club-name { font-size: 1.2rem; }

  .stat-box {
    min-width: 80px;
    padding: 0.5rem 0.75rem;
  }

  .stat-box .value { font-size: 1.1rem; }
  .stat-box .label { font-size: 0.7rem; }

  #detail-games {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }
}

@media (max-width: 480px) {
  .header-left { gap: 0.75rem; }
  .header-logo { height: 44px; }
  .header-title h1 { font-size: 0.95rem; }

  #tab-bar { width: 100%; }

  .tab {
    flex: 1;
    text-align: center;
    font-size: 0.85rem;
    padding: 0.4rem 0.5rem;
  }

  #detail-stats { gap: 0.5rem; }
  .stat-box { min-width: 70px; }
}

.live-dot {
  color: #e94560;
  font-size: 20px;
  margin-right: 4px;
  animation: pulse 1.5s infinite;
  display: inline-flex;
  align-items: center;
  line-height: 1;
  position: relative;
  top: -1px;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}