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

:root {
  --green: #1d6b3a;
  --green-dark: #14512b;
  --bg: #f4f6f4;
  --card: #ffffff;
  --text: #1c2321;
  --muted: #6b7770;
  --border: #d8ded9;
  --danger: #a33;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

header {
  background: var(--green);
  color: #fff;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

header h1 { font-size: 1.2rem; }

nav { display: flex; gap: 0.4rem; }

nav button {
  background: var(--green-dark);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
}
nav button.active { background: #fff; color: var(--green-dark); font-weight: 600; }
nav button:disabled { opacity: 0.45; cursor: default; }

main { max-width: 720px; margin: 1rem auto; padding: 0 0.75rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
}

h2 { font-size: 1.1rem; margin-bottom: 0.75rem; }
.sub { font-weight: 400; font-size: 0.8rem; color: var(--muted); display: block; }
.muted { color: var(--muted); }
.hint { font-size: 0.8rem; color: var(--muted); margin: 0.5rem 0; }
.empty { color: var(--muted); }

.player-info {
  list-style: none;
  padding: 0;
  margin: -0.25rem 0 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.player-info strong { color: var(--text); font-weight: 600; }

/* forms */
.form-grid { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.75rem; }

label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.85rem; }

input, select {
  padding: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  background: #fff;
  color: var(--text);
}

.player-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem 0.75rem;
  margin-bottom: 0.6rem;
}
.player-row legend { font-size: 0.8rem; color: var(--muted); padding: 0 0.3rem; }
.player-row .p-name { width: 10rem; }
.player-row .p-hcp { width: 5rem; }

.actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 0.75rem; }

button.primary, button.secondary, button.danger {
  border: none;
  border-radius: 6px;
  padding: 0.55rem 1rem;
  font-size: 0.95rem;
  cursor: pointer;
}
button.primary { background: var(--green); color: #fff; }
button.secondary { background: var(--border); color: var(--text); }
button.danger { background: none; border: 1px solid var(--danger); color: var(--danger); }

/* scorecard */
.table-wrap { overflow-x: auto; }

.score-table { border-collapse: collapse; width: 100%; }
.score-table th, .score-table td {
  border: 1px solid var(--border);
  padding: 0.3rem 0.4rem;
  text-align: center;
  font-size: 0.9rem;
}
.score-table thead th { background: var(--green); color: #fff; }
.score-table thead .sub { color: #cde3d4; }

.score-cell { position: relative; min-width: 3.5rem; }
.score-cell input { width: 3rem; text-align: center; padding: 0.25rem; border-radius: 4px; }
.dots { position: absolute; top: 1px; left: 3px; font-size: 0.6rem; color: var(--green); }

.sum-row td { background: #eef3ee; font-weight: 600; }
.sum-row.total td { background: #dce9df; }

#scorecard tbody tr[data-hole] { cursor: pointer; }

/* hålvy */
.hole-nav { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.hole-nav h2 { margin: 0; text-align: center; }
.hole-nav button { min-width: 3rem; min-height: 3rem; font-size: 1.4rem; }

.hole-player {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.hole-player:last-child { border-bottom: none; }

.stepper { display: flex; align-items: center; gap: 0.6rem; }
.step-btn {
  width: 3.25rem;
  height: 3.25rem;
  border: none;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}
.step-btn:disabled { opacity: 0.35; cursor: default; }
.hole-score { font-size: 2rem; font-weight: 600; min-width: 2.5rem; text-align: center; }

/* signering */
.sig-player {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.sig-player:last-child { border-bottom: none; }
.sig-player .actions { margin-top: 0.35rem; }

.sig-canvas {
  display: block;
  width: 100%;
  height: 120px;
  margin-top: 0.25rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: #fff;
  /* Krävs för att signeringen inte ska scrolla sidan på mobil. */
  touch-action: none;
}

.sig-thumb { height: 2rem; vertical-align: middle; }

/* history */
.round-item summary { cursor: pointer; font-weight: 600; }
.round-item .table-wrap { margin-top: 0.75rem; }
.round-item .player-info { margin: 0.75rem 0 0; }
.sig-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin: 0.75rem 0 0;
}
