:root {
  --purple: #4E2A84;
  --purple-dark: #371D5C;
  --gold: #C9A24B;
  --ink: #1C1420;
  --ink-soft: #6B6470;
  --bg: #F5F3F7;
  --card: #FFFFFF;
  --line: #E3DEEA;
  --green: #2E7D4F;
  --red: #C0392B;
  --amber: #B8860B;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.app-header {
  background: var(--purple);
  color: white;
  padding: 14px 16px;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.app-header .title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.app-header h1 {
  font-size: 17px;
  margin: 0;
  letter-spacing: 0.2px;
  font-weight: 800;
}

.app-header .eyebrow {
  font-family: "Courier New", Courier, monospace;
  font-size: 10.5px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
}

nav.tabs {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}

nav.tabs a {
  flex: 1;
  text-align: center;
  padding: 9px 6px;
  border-radius: 8px;
  background: rgba(255,255,255,0.12);
  color: white;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

nav.tabs a.active {
  background: var(--gold);
  color: var(--purple-dark);
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 14px 90px;
}

.coach-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 7px 10px;
  margin-top: 10px;
  font-size: 12.5px;
}

.coach-banner button {
  background: none;
  border: none;
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  text-decoration: underline;
  padding: 0;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 14px;
  margin-bottom: 12px;
}

label.field-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--purple);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

select, input[type=text], input[type=number], textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  padding: 11px 12px;
  font-size: 16px;
  color: var(--ink);
  background: white;
  font-family: inherit;
}

select:focus, input:focus, textarea:focus {
  outline: 2px solid var(--purple);
  outline-offset: 1px;
  border-color: var(--purple);
}

textarea { resize: vertical; min-height: 56px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 9px;
  padding: 11px 16px;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.btn-primary { background: var(--purple); color: white; }
.btn-primary:active { background: var(--purple-dark); }
.btn-gold { background: var(--gold); color: var(--purple-dark); }
.btn-ghost { background: var(--line); color: var(--ink); }
.btn-danger { background: #FBEAEA; color: var(--red); }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; }

.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.player-row:last-child { border-bottom: none; }

.bib-badge {
  min-width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--purple);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}

.player-info { flex: 1; min-width: 0; }
.player-name { font-weight: 700; font-size: 15px; }
.player-sub { font-size: 12.5px; color: var(--ink-soft); }

.rating-pill {
  min-width: 30px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  color: white;
}
.r-unrated { background: var(--line); color: var(--ink-soft); }
.r-1, .r-2 { background: var(--red); }
.r-3 { background: var(--amber); }
.r-4, .r-5 { background: var(--green); }

.rating-picker {
  display: flex;
  gap: 8px;
  margin: 10px 0 14px;
}
.rating-btn {
  flex: 1;
  aspect-ratio: 1;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: white;
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
}
.rating-btn.selected {
  border-color: var(--purple);
  background: var(--purple);
  color: white;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28,20,32,0.45);
  z-index: 30;
  display: flex;
  align-items: flex-end;
}
.sheet {
  background: white;
  width: 100%;
  border-radius: 18px 18px 0 0;
  padding: 18px 16px 20px;
  max-height: 85vh;
  overflow-y: auto;
}
.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--line);
  border-radius: 4px;
  margin: 0 auto 14px;
}
.sheet-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--purple);
  margin-bottom: 2px;
}
.sheet-sub { font-size: 13px; color: var(--ink-soft); margin-bottom: 14px; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-soft);
}
.empty-state .big { font-size: 15px; font-weight: 700; color: var(--ink); margin-bottom: 4px; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: white;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  z-index: 50;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; }

.section-title {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--ink-soft);
  margin: 22px 0 8px;
}

.row-2 { display: flex; gap: 10px; }
.row-2 > * { flex: 1; }

table.agg-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 13.5px;
}
table.agg-table th {
  background: var(--purple);
  color: white;
  padding: 9px 8px;
  text-align: left;
  font-size: 12px;
}
table.agg-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.agg-table tr:last-child td { border-bottom: none; }
.avg-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  color: white;
  font-weight: 800;
  font-size: 12.5px;
}
.note-chip {
  display: block;
  font-size: 11.5px;
  color: var(--ink-soft);
  margin-top: 2px;
}
.note-chip b { color: var(--ink); }

.status-select {
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: none;
  color: white;
  cursor: pointer;
}
.status-active { background: var(--green); }
.status-bubble { background: var(--amber); }
.status-cut { background: var(--red); }

a.email-link {
  color: var(--purple);
  font-weight: 600;
  text-decoration: underline;
  font-size: 13px;
  word-break: break-all;
}

.search-result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
}
.search-result-row:last-child { border-bottom: none; }
.search-result-info { flex: 1; min-width: 0; }
.search-result-name { font-weight: 700; font-size: 15px; }
.search-result-sub { font-size: 12.5px; color: var(--ink-soft); }

.inline-checkin-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 4px 4px;
  border-top: 1px dashed var(--line);
  margin-top: 6px;
}
.inline-checkin-row input {
  width: 70px;
  flex: none;
  text-align: center;
  padding: 8px 6px;
}

.photo-capture-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.photo-thumb {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--line);
  flex-shrink: 0;
  background: var(--line);
}
.photo-thumb-lg {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--purple);
  flex-shrink: 0;
  background: var(--line);
}
.photo-btn-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 9px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  background: var(--line);
  color: var(--ink);
  font-family: inherit;
}

.loading-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gold);
  animation: pulse 1s infinite ease-in-out;
}
@keyframes pulse { 0%,100%{opacity:.3} 50%{opacity:1} }

.name-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.name-gate .card { width: 100%; max-width: 380px; }
.name-gate h2 { color: var(--purple); margin-top: 0; }
