/* =========================================================
   Design tokens — matches curling.tatertech.net (SpudSheet)
   ========================================================= */
:root {
  /* Brand */
  --color-primary: #1e5fa8;
  --color-primary-dark: #154480;
  --color-primary-light: #dbeafe;

  /* Surfaces */
  --color-bg: #f3f4f6;
  --color-surface: #ffffff;
  --color-header-bg: #1a2e4a;
  --color-banner-bg: #2e4a7a;
  --color-banner-text: #b5d4f4;

  /* Text */
  --color-text: #1f2937;
  --color-heading: #111827;
  --color-muted: #6b7280;

  /* Form / border */
  --color-border: #d1d5db;
  --color-input-bg: #ffffff;

  /* Table */
  --color-table-head-bg: #f9fafb;
  --color-table-row-hover: #f0f4ff;

  /* Status */
  --color-error: #dc2626;
  --color-green-bg: #dcfce7;
  --color-green-text: #166534;
  --color-amber-bg: #fef3c7;
  --color-amber-text: #92400e;
  --color-red-bg: #fee2e2;
  --color-red-text: #991b1b;

  /* League banners */
  --color-al-banner-bg: #c8102e;
  --color-al-banner-text: #ffffff;

  /* Scoreboard bar */
  --color-scoreboard-bg: #e9ebee;
  --color-scoreboard-border: rgba(0, 0, 0, 0.09);
  --color-scoreboard-text: #1f2937;
  --color-scoreboard-muted: #6b7280;
  --color-scoreboard-live: #16a34a;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'Roboto Condensed', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* =========================================================
   Header
   ========================================================= */
.header {
  background: var(--color-header-bg);
  color: #fff;
}

.headerInner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.titleIcon {
  font-size: 1.6rem;
  color: #fbbf24;
  flex-shrink: 0;
}

.titleBlock {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.title {
  font-weight: 700;
  font-size: 1.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subtitle {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.65);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.livePulseDot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.livePulseLabel {
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.refreshBtn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.9);
  border-radius: 5px;
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 34px;
  min-width: 34px;
  transition: background 0.15s;
}

.refreshBtn:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* =========================================================
   Scoreboard bar
   ========================================================= */
.scoreboardBar {
  background: var(--color-scoreboard-bg);
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--color-scoreboard-border);
}

.scoreboardDate {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.9rem;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--color-scoreboard-text);
  border-right: 1px solid var(--color-scoreboard-border);
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.scoreboardNav {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: rgba(0, 0, 0, 0.4);
  cursor: pointer;
  padding: 0 0.7rem;
  min-width: 36px;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.12s;
}

.scoreboardNav:hover {
  color: var(--color-heading);
}

.scoreboardTrack {
  display: flex;
  overflow-x: auto;
  scroll-behavior: smooth;
  flex: 1;
  min-width: 0;
  scrollbar-width: none;
}

.scoreboardTrack::-webkit-scrollbar {
  display: none;
}

.gameCard {
  flex-shrink: 0;
  width: 148px;
  padding: 0.45rem 0.65rem;
  border-right: 1px solid var(--color-scoreboard-border);
  color: var(--color-scoreboard-text);
  font-size: 0.72rem;
}

.gameCard.noGames {
  width: auto;
  padding: 0.6rem 1rem;
  color: var(--color-scoreboard-muted);
  display: flex;
  align-items: center;
}

.gameCard .gameStatus {
  color: var(--color-scoreboard-muted);
  font-weight: 700;
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  font-size: 0.62rem;
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gameCard.live .gameStatus {
  color: var(--color-scoreboard-live);
}

.gameCard .gameTeamRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.12rem 0;
  gap: 0.4rem;
}

.gameCard .gameTeamRow.winner .gameScore,
.gameCard .gameTeamRow.winner .gameTeamAbbr {
  font-weight: 700;
}

.gameCard .gameTeamName {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  min-width: 0;
  overflow: hidden;
}

.gameCard .gameTeamName img {
  height: 16px;
  width: 16px;
  object-fit: contain;
  flex-shrink: 0;
}

.gameCard .gameTeamAbbr {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gameCard .gameScore {
  font-weight: 600;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .scoreboardDate { padding: 0.4rem 0.6rem; font-size: 0.6rem; }
  .gameCard { width: 118px; font-size: 0.65rem; padding: 0.4rem 0.5rem; }
}

/* =========================================================
   Tabs
   ========================================================= */
.tabBar {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1rem 0;
  display: flex;
  gap: 0.5rem;
}

.tabPill {
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  color: var(--color-muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.tabPill:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.tabPill.active {
  background: var(--color-banner-bg);
  border-color: var(--color-banner-bg);
  color: #fff;
}

.tabPill.active:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  color: #fff;
}

/* =========================================================
   Main
   ========================================================= */
.main {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem 1rem 2.5rem;
  flex: 1;
}

.status {
  padding: 0.75rem 0.25rem;
  font-size: 0.9rem;
  color: var(--color-muted);
}

.status.error {
  color: var(--color-error);
  font-weight: 600;
}

.view { display: block; }
.view[hidden] { display: none; }

.historyControls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.historyControls label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-muted);
}

.historyControls select {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-heading);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  cursor: pointer;
}

.historyControls select:hover {
  border-color: var(--color-primary);
}

.historySectionTitle {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-heading);
  margin: 1.5rem 0 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

#history-league .historySectionTitle {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.division-block {
  background: var(--color-surface);
  border-radius: 8px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  margin-bottom: 1.25rem;
}

.division-block:last-child { margin-bottom: 0; }

.division-block h3 {
  margin: 0;
  padding: 0.65rem 1rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-banner-text);
  background: var(--color-banner-bg);
}

.division-block h3.leagueBannerAL {
  background: var(--color-al-banner-bg);
  color: var(--color-al-banner-text);
}

.table-scroll { overflow-x: auto; }

table.standings {
  border-collapse: collapse;
  table-layout: fixed;
  width: 100%;
  font-size: calc(0.85rem + 2px);
}

table.standings th,
table.standings td {
  padding: 0.3rem 0.3rem;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px solid var(--color-border);
}

table.standings thead th {
  background: var(--color-table-head-bg);
  color: var(--color-muted);
  font-weight: 700;
  font-size: calc(0.7rem + 2px);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--color-border);
}

table.standings td.team-cell,
table.standings th.team-cell {
  text-align: left;
  font-weight: 700;
  color: var(--color-heading);
  position: sticky;
  left: 0;
  background: var(--color-surface);
  z-index: 1;
}

table.standings thead th.team-cell {
  background: var(--color-table-head-bg);
}

table.standings tbody tr:hover td {
  background: var(--color-table-row-hover);
}

table.standings tbody tr:hover td.team-cell {
  background: var(--color-table-row-hover);
}

.team-name {
  color: var(--color-muted);
  font-weight: 400;
  font-size: calc(0.78rem + 2px);
  margin-left: 5px;
}

.team-logo {
  height: 18px;
  width: 18px;
  object-fit: contain;
  vertical-align: middle;
  margin-right: 4px;
  flex-shrink: 0;
}

th.logo-head {
  padding: 0.3rem 0.15rem;
}

.team-logo-header {
  height: 20px;
  width: 20px;
  max-width: 100%;
  object-fit: contain;
  vertical-align: middle;
}

.team-logo-diag {
  height: 18px;
  width: 18px;
  max-width: 100%;
  object-fit: contain;
  vertical-align: middle;
  filter: grayscale(1);
  opacity: 0.32;
}

td.diag {
  background: var(--color-bg);
}

td.nc {
  color: var(--color-muted);
  font-size: calc(0.75rem + 2px);
}

td.magic-num {
  font-weight: 700;
  color: var(--color-primary-dark);
}

/* Day-over-day magic number changes: down 1 = amber, down 2+ (e.g. a
   doubleheader swept, or a rival losing twice) = red. */
td.magic-num.mn-down1 {
  background: var(--color-amber-bg);
}
td.magic-num.mn-down2 {
  background: var(--color-red-bg);
}

.mn-arrow {
  display: inline-block;
  margin-left: 2px;
  font-size: 0.55rem;
  line-height: 1;
  vertical-align: middle;
  color: var(--color-amber-text);
}
.mn-arrow.mn-arrow-double {
  color: var(--color-red-text);
  letter-spacing: -2px;
}

/* Playoff-cutoff dividers in the League Standings table:
   bold line after the 3 division leaders, and after all 6 current playoff teams. */
tr.lineTop3 td {
  border-bottom: 3px solid var(--color-heading);
}
tr.lineTop6 td {
  border-bottom: 3px solid var(--color-error);
}

tr.clinched-division td.team-cell,
tr.clinched-division td.record-cell {
  background: var(--color-green-bg);
}
tr.clinched-wildcard td.team-cell,
tr.clinched-wildcard td.record-cell {
  background: var(--color-amber-bg);
}
tr.eliminated td.team-cell,
tr.eliminated td.record-cell {
  background: var(--color-red-bg);
  color: var(--color-muted);
}

.status-tag {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  margin-left: 6px;
  padding: 0.1rem 0.4rem;
  border-radius: 20px;
  vertical-align: middle;
  letter-spacing: 0.03em;
}
.status-tag.div { background: var(--color-green-text); color: #fff; }
.status-tag.wc { background: var(--color-amber-text); color: #fff; }
.status-tag.elim { background: var(--color-red-text); color: #fff; }

/* =========================================================
   Legend
   ========================================================= */
.legendCard {
  margin-top: 1.25rem;
  background: var(--color-surface);
  border-radius: 8px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
  padding: 1rem 1.25rem;
}

.legendTitle {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-heading);
  margin-bottom: 0.5rem;
}

.legendText {
  color: var(--color-muted);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.legend-list {
  list-style: none;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.pill {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.65rem;
  border-radius: 20px;
}

.pillGreen { background: var(--color-green-bg); color: var(--color-green-text); }
.pillAmber { background: var(--color-amber-bg); color: var(--color-amber-text); }
.pillRed { background: var(--color-red-bg); color: var(--color-red-text); }

.legendNote {
  font-size: 0.8rem;
  color: var(--color-muted);
}

/* =========================================================
   Footer
   ========================================================= */
.footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 1rem;
  font-size: 0.72rem;
  color: var(--color-muted);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  flex-wrap: wrap;
  text-align: center;
}

.footer .sep { opacity: 0.5; }

a, button {
  touch-action: manipulation;
}

@media (max-width: 640px) {
  .headerInner { padding: 0 0.75rem; gap: 0.5rem; }
  .title { font-size: 0.95rem; }
  .subtitle { display: none; }
  .livePulseLabel { display: none; }
  .refreshBtn .btnLabel { display: none; }
  .refreshBtn { padding: 0.4rem; }
  .tabBar { padding: 0.75rem 0.75rem 0; gap: 0.4rem; }
  .tabPill { flex: 1; text-align: center; padding: 0.55rem 0.5rem; }
  .main { padding: 0.85rem 0.75rem 2rem; }

  /* Let the standings table use its natural (readable) width and scroll
     horizontally instead of being force-squeezed to fit the screen — with
     20+ columns in the League view, fixed-percentage widths become
     illegibly small on a phone. The team column stays sticky via
     .table-scroll/.team-cell so context is never lost while scrolling. */
  table.standings { table-layout: auto; font-size: calc(0.6rem + 2px); }
  table.standings colgroup col { width: auto !important; }
  .table-scroll { -webkit-overflow-scrolling: touch; }
  table.standings th, table.standings td { padding: 0.3rem 0.4rem; }
  table.standings td.team-cell, table.standings th.team-cell { min-width: 68px; }
  th.logo-head, table.standings td.magic-num, table.standings td.nc, table.standings td.diag { min-width: 30px; }
  .team-logo { height: 14px; width: 14px; margin-right: 2px; }
  .team-logo-header { height: 15px; width: 15px; }
  .team-logo-diag { height: 14px; width: 14px; }
  .status-tag { display: none; }
  .mn-arrow { display: none; }
}
