:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #6b7785;
  --accent: #1b6ec2;
  --accent-dark: #155290;
  --border: #d8dee5;
  --excluded: #fdecea;
  --excluded-text: #8a1f15;
  --good: #e8f4ec;
  --good-text: #1f6f3f;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  line-height: 1.5;
}

header {
  background: var(--accent);
  color: white;
  padding: 1.25rem 2rem;
}
header h1 { margin: 0 0 0.25rem; font-size: 1.5rem; }
header .subtitle { margin: 0; opacity: 0.9; font-size: 0.9rem; }

main {
  max-width: 1100px;
  margin: 1.5rem auto;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
}
.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  color: var(--accent-dark);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}
.row label {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  color: var(--muted);
  gap: 0.25rem;
}

input[type="text"], input[type="number"], select {
  font-size: 1rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: white;
  min-width: 140px;
}

button {
  font-size: 0.95rem;
  padding: 0.55rem 1rem;
  border-radius: 5px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  cursor: pointer;
}
button:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
button.secondary { background: white; color: var(--accent); }
button.primary { background: var(--accent); font-size: 1.05rem; padding: 0.7rem 1.5rem; }
button:disabled { opacity: 0.55; cursor: not-allowed; }

.muted { color: var(--muted); font-size: 0.85rem; }
.hidden { display: none !important; }

.member-info {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background: #eef4fb;
  border-radius: 5px;
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  font-size: 0.95rem;
}

.table-scroll {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 5px;
  margin-bottom: 0.75rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
#scoresTable { table-layout: fixed; }
th, td {
  text-align: left;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
}
th {
  background: #f0f3f6;
  position: sticky;
  top: 0;
  font-weight: 600;
}
td input, td select {
  width: 100%;
  min-width: 0;
  padding: 0.3rem 0.4rem;
  font-size: 0.85rem;
}

#scoresTable .col-date       { width: 130px; }
#scoresTable .col-event      { width: 56px; }
#scoresTable .col-discipline { width: 105px; }
#scoresTable .col-shot       { width: 56px; }
#scoresTable .col-broke      { width: 56px; }
#scoresTable .col-pct        { width: 64px; }
#scoresTable .col-club       { width: auto; }
#scoresTable .col-source     { width: 72px; }
#scoresTable .col-del        { width: 36px; }
#scoresTable th, #scoresTable td {
  padding: 0.4rem 0.35rem;
  overflow: hidden;
}
#scoresTable td input, #scoresTable td select {
  box-sizing: border-box;
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
/* Narrow numeric/short-text inputs: force a tight width regardless of cell sizing */
#scoresTable input[data-field="event"],
#scoresTable input[data-field="targets"],
#scoresTable input[data-field="broke"] {
  width: 42px;
  max-width: 42px;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
  text-align: center;
}
td button.delete {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 0.2rem 0.5rem;
  font-size: 1rem;
}
td button.delete:hover { color: #c0392b; background: transparent; }

.handicap-box {
  margin-top: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.75rem 1rem;
}
.handicap-box legend { padding: 0 0.5rem; color: var(--accent-dark); font-weight: 600; }

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}
.result-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}
.result-card h3 {
  margin: 0 0 0.5rem;
  color: var(--accent-dark);
  font-size: 1.05rem;
}
.result-card .big {
  font-size: 2rem;
  font-weight: 700;
  margin: 0.25rem 0;
}
.result-card .label-badge {
  display: inline-block;
  background: var(--good);
  color: var(--good-text);
  border-radius: 4px;
  padding: 0.2rem 0.6rem;
  font-weight: 600;
}
.result-card .summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0.25rem 0;
}
.result-card details {
  margin-top: 0.75rem;
  font-size: 0.85rem;
}
.result-card details summary {
  cursor: pointer;
  color: var(--accent);
  margin-bottom: 0.4rem;
}
.excluded-row {
  background: var(--excluded);
  color: var(--excluded-text);
  padding: 0.25rem 0.5rem;
  border-radius: 3px;
  margin: 0.2rem 0;
  font-size: 0.85rem;
}
.included-row {
  background: var(--good);
  color: var(--good-text);
  padding: 0.25rem 0.5rem;
  border-radius: 3px;
  margin: 0.2rem 0;
  font-size: 0.85rem;
}
.note {
  background: #fff7e6;
  border-left: 3px solid #d18b00;
  padding: 0.4rem 0.6rem;
  margin: 0.4rem 0;
  font-size: 0.85rem;
}

footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--muted);
  font-size: 0.8rem;
}

@media (max-width: 600px) {
  main { padding: 0 0.5rem; }
  .card { padding: 1rem; }
  table { font-size: 0.8rem; }
}
