:root { font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial; }
body { margin: 0; background: #f7f7fb; color: #111; }
.top { padding: 20px 18px 8px; }
h1 { margin: 0 0 4px; font-size: 22px; }
.muted { color: #666; }
.card { background: white; margin: 12px 12px 24px; padding: 16px; border-radius: 14px; box-shadow: 0 1px 10px rgba(0,0,0,.06); }
.tabs { display: flex; gap: 8px; padding: 0 12px; flex-wrap: wrap; }
.tab { border: 1px solid #ddd; background: white; padding: 10px 12px; border-radius: 12px; cursor: pointer; }
.tab.active { border-color: #333; }
.panel { display: none; }
.panel.show { display: block; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin: 10px 0; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
input { padding: 10px; border: 1px solid #ddd; border-radius: 10px; min-width: 0; max-width: 100%; box-sizing: border-box; }
.btn { padding: 10px 12px; border: 0; border-radius: 10px; background: #111; color: #fff; cursor: pointer; }
.btn.secondary { background: #444; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.pre { background: #f3f4f6; padding: 12px; border-radius: 12px; white-space: pre-wrap; }
table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th, td { border-bottom: 1px solid #eee; text-align: left; padding: 10px; font-size: 13px; }
th { background: #fafafa; }
code { background: #f3f4f6; padding: 2px 6px; border-radius: 6px; }
/* =========================
   Match winner highlighting on history screen
   ========================= */

.win {
  color: #0a7a2f;
  font-weight: 700;
}
/* =========================
   Score update page
   ========================= */
.embedWrap {
  margin-top: 12px;
  border: 1px solid #eee;
  border-radius: 14px;
  overflow: hidden;
  background: white;
}
.embedWrap iframe {
  display: block;
  width: 100%;
}
/* =========================
   Defaulter list page
   ========================= */
.pillRow { display:flex; flex-wrap:wrap; gap:8px; }
.pill { display:inline-block; padding:6px 10px; border-radius:999px; font-size:13px; border:1px solid #ddd; background:#fff; }
.pill-warn { border-color:#f2c94c; background:#fff8db; }

/* =========================
   Contribution page
   ========================= */
/* Add or verify this in styles.css */
.row { 
  display: flex; 
  flex-wrap: wrap; 
  gap: 10px; 
  align-items: center; /* Changed from 'end' to 'center' for better button alignment */
  margin: 10px 0; 
}

/* Ensures the 'a' tag button looks the same as the 'button' tag */
a.btn {
  display: inline-block;
  line-height: 1.2;
  text-align: center;
}

/* Fix for mobile input sizing */
#tab-predict input {
    width: 100%;
    padding: 12px; /* Larger tap target */
    font-size: 16px; /* Prevents iOS auto-zoom on focus */
    border: 1px solid #ccc;
    border-radius: 4px;
    margin-top: 5px;
}

/* Ensure labels don't cramp the inputs */
#tab-predict .row label {
    display: block;
    width: 100%;
    margin-bottom: 15px;
}

/* Ensure select text is visible on all mobile themes */
select {
  -webkit-appearance: none; /* Removes default iOS styling */
  -moz-appearance: none;
  appearance: none;
  background-color: #ffffff !important;
  color: #000000 !important;
  opacity: 1 !important;
  border: 1px solid #ccc;
  padding: 12px;
  font-size: 16px; /* Prevents auto-zoom on iPhone */
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23007CB2%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fxml%3E");
  background-repeat: no-repeat;
  background-position: right 0.7em top 50%;
  background-size: 0.65em auto;
}

/* Responsive: stacked card rows for small screens */
@media (max-width: 640px) {
  :root { font-size: 16px; }
  .card { margin: 8px 8px 20px; padding: 14px; border-radius: 12px; }
  .tabs { gap: 6px; padding: 8px; }
  .tab { flex: 1 1 48%; padding: 12px 10px; font-size: 16px; text-align: center; min-width: 110px; }
  .row { gap: 8px; align-items: stretch; }
  label { width: 100%; }
  input, select { width: 100%; min-width: 0; font-size: 16px; padding: 12px; }
  .btn, a.btn { width: 100%; padding: 12px; font-size: 16px; }
  .pre { font-size: 15px; }

  /* History controls: stack inputs and make search button full-width */
  #tab-history .row { flex-direction: column; align-items: stretch; }
  #tab-history .row label { margin-bottom: 6px; }
  #btnSearch { margin-top: 6px; }

  /* Table: show as compact cards but keep Date / Court / Team 1 on first row
     and Team 2 + Score below for better readability on narrow screens */
  table { border: 0; }
  thead { display: none; }
  tbody { display: block; }
  tbody tr { display: block; margin: 0 0 12px; border: 1px solid #eee; border-radius: 10px; background: #fff; padding: 10px; }
  th, td { border: 0; }

  /* Make first three columns share the top row */
  td { box-sizing: border-box; padding: 8px 8px; vertical-align: top; font-size: 16px; }
  td[data-label="Date"], td[data-label="Court"], td[data-label="Teams"] {
    display: inline-block;
    min-width: 0;
  }

  /* Team 2 and Score go full width below */
  td[data-label="Score"] {
    display: block;
    width: 100%;
    margin-top: 8px;
  }

  /* Show label above each value for clarity (history table only) */
  .history-table td:before { content: attr(data-label) ": "; display: inline-block; color: #666; font-weight: 600; margin-right: 6px; }
  .history-table td[data-label="Team 2"]:before, .history-table td[data-label="Score"]:before { display: inline-block; }

  .win { font-weight: 700; }
}

  /* Player stats: show small per-row labels on narrow screens (card-like rows) */
  .players-table { border: 0; }
  .players-table thead { display: none; }
  .players-table tbody { display: block; }
  .players-table tbody tr { display: block; margin: 0 0 10px; border: 1px solid #eee; border-radius: 8px; background: #fff; padding: 8px; }
  /* Player name stays full-width; the other four metrics appear inline on a single row */
  .players-table td:first-child { display: block; width: 100%; padding: 6px 8px; box-sizing: border-box; }
  .players-table td:not(:first-child) { display: inline-block; width: 24%; padding: 6px 8px; box-sizing: border-box; vertical-align: top; }
  .players-table td:before { content: attr(data-label); display: block; font-size: 12px; color: #666; font-weight: 600; margin-bottom: 4px; }
  .players-table .player-link { color: inherit; text-decoration: none; cursor: pointer; position: relative; }
  .players-table .player-link::after { content: " (view)"; font-size: 12px; color: #666; opacity: 0; transition: opacity .15s ease; margin-left: 6px; }
  .players-table .player-link:hover::after { opacity: 1; }
  .upload-btn { border: 0; background: transparent; font-size: 1.0em; margin-left: 8px; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
  .upload-btn:hover { background: #f0f0f0; }


/* Coffee fund table: stack cells on small screens for better readability */
@media (max-width: 640px) {
  .coffee-table { width: 100%; border: 0; margin-bottom: 12px; }
  .coffee-table thead { display: none; }
  .coffee-table tbody { display: block; }
  .coffee-table tbody tr { display: block; padding: 10px; border: 1px solid #eee; border-radius: 10px; background: #fff; }
  .coffee-table td { display: block; width: 100%; padding: 8px 10px; box-sizing: border-box; font-size: 18px; }
  .coffee-table td:before { content: attr(data-label) ": "; color: #666; font-weight: 600; margin-right: 6px; }
}

  /* Allocate reasonable widths on narrow screens: Date, Court, Score on first row and Teams takes remaining space */
  td[data-label="Date"] { display: inline-block; width: 28%; min-width: 56px; }
  td[data-label="Court"] { display: inline-block; width: 22%; min-width: 66px; }
  td[data-label="Score"] { display: inline-block; width: 32%; min-width: 48px; text-align: right; }
  td[data-label="Teams"] { display: inline-block; width: 98%; min-width: 100px; }

  /* Teams flex inside the Teams cell */
  .teams-flex { display: flex; gap: 12px; align-items: flex-start; }
  .team-col { flex: 1 1 0; min-width: 0; line-height: 1.15; padding-right: 6px; }
  .team-vs { align-self: center; color: #666; white-space: nowrap; padding: 0 8px; }
  .team-col.team1, .team-col.team2 { word-break: break-word; }

  /* Make score visually stand out when in first row */
  .score-cell { font-weight: 700; color: #111; }
