:root {
  --navy: #206bc4;
  --navy-dark: #1a56a0;
  --primary: #206bc4;
  --primary-dark: #1a56a0;
  --line: #e6e8eb;
  --yellow: #fff176;
  --blue: #a9cbe8;
  --red: #e63946;
  --orange: #f4a259;
  --grey: #7d848f;
  --bg: #f4f6fb;
  --text: #1a2234;
  --text-muted: #6b7480;
  --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 1px 1px rgba(0, 0, 0, 0.03);
}
* { box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Top bar */
.navbar-shell {
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  max-width: 1400px;
  margin: 0 auto;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-left img {
  height: 36px;
  width: auto;
  border-radius: 6px;
}
.topbar-left .club-name {
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.avatar-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex: 0 0 auto;
}
.topbar-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar-profile-text { line-height: 1.3; }
.topbar-right .username {
  font-weight: 700;
  color: var(--text);
  display: block;
}
.topbar-role {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
}
.topbar-nav {
  display: flex;
  gap: 4px;
  font-size: 13.5px;
  padding: 0 24px;
  max-width: 1400px;
  margin: 0 auto;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.topbar-nav a {
  text-decoration: none;
  color: var(--text-muted);
  padding: 11px 12px;
  border-bottom: 2px solid transparent;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}
.topbar-nav a i { font-size: 16px; }
.topbar-nav a:hover {
  color: var(--navy);
  text-decoration: none;
}
.topbar-nav a.active {
  color: var(--navy);
  border-bottom-color: var(--navy);
}
.btn, button, input[type=submit] {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  color: var(--text);
}
.btn:hover, button:hover { background: #f4f6fb; }
.btn-primary {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}
.btn-primary:hover { background: var(--navy-dark); border-color: var(--navy-dark); }
.btn-danger {
  color: var(--red);
  border-color: var(--red);
}
.btn-danger:hover { background: #fdeeee; }

.container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 24px;
}

.stats-grid {
  display: grid;
  gap: 14px;
  max-width: 1300px;
  margin: 0 auto;
}

.page-pretitle {
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 2px;
}

h1 {
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.2px;
  margin: 0 0 20px;
  color: var(--text);
}
h2 { font-size: 16px; font-weight: 700; color: var(--text); margin-top: 0; }

.card-box {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--card-shadow);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data-table th, table.data-table td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
}
table.data-table th {
  background: var(--navy);
  color: #fff;
}
table.data-table tr:nth-child(even) { background: #fafafa; }

.form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
  max-width: 420px;
}
.form-row label { font-size: 13px; font-weight: 600; color: var(--text); }
input[type=text], input[type=password], input[type=email], input[type=date], input[type=file], select, textarea {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text);
}
input[type=text]:focus, input[type=password]:focus, input[type=email]:focus, input[type=date]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(32, 107, 196, 0.15);
}
.form-actions { display: flex; gap: 8px; margin-top: 16px; }

.alert {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
}
.alert-success { background: #e6f6ea; border: 1px solid #97d9a8; color: #1a6b31; }
.alert-error { background: #fdeeee; border: 1px solid #f3b6b6; color: #9c1c1c; }

.login-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.login-logo-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}
.login-logo-row img { height: 36px; width: auto; border-radius: 6px; }
.login-logo-row .club-name { font-weight: 700; font-size: 20px; color: var(--text); }
.login-box {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 32px;
  width: 360px;
  max-width: 100%;
  box-shadow: var(--card-shadow);
}
.login-box h1 {
  font-size: 20px;
  text-align: center;
  margin: 0 0 22px;
}
.login-field-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.login-field-label a { font-size: 12.5px; }
.password-wrap { position: relative; }
.password-wrap input { width: 100%; padding-right: 36px; }
.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 2px 4px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 15px;
}
.remember-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin: 4px 0 18px;
}
.remember-row input { width: auto; }

/* Kanban board */
.board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  max-width: 1300px;
  margin: 0 auto;
}
.column {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  min-height: 300px;
}
.column-header {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-weight: bold;
  padding: 10px 10px;
  border-radius: 8px 8px 0 0;
  font-size: 14px;
}
.team-notes-btn {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.team-notes-btn:hover { background: rgba(255,255,255,0.28); }
.notes-badge {
  background: var(--yellow);
  color: #1a1a1a;
  border-radius: 10px;
  padding: 0 6px;
  font-size: 10px;
  font-weight: bold;
  min-width: 14px;
  text-align: center;
}
.notes-badge:empty { display: none; }
.column-body {
  padding: 8px;
  flex: 1;
  min-height: 200px;
}
.player-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px 6px 8px;
  margin-bottom: 6px;
  background: #fafafa;
  cursor: grab;
  font-size: 13px;
  display: flex;
  flex-direction: row;
  gap: 8px;
  user-select: none;
}
.player-num {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
}
.highlight-red .player-num { background: #fff; color: var(--red); }
.player-info { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.player-card.dragging { opacity: 0.5; }
.player-name { font-weight: bold; }
.player-meta { font-size: 11px; color: #555; display: flex; gap: 8px; flex-wrap: wrap; }
.tag { background: #eee; border-radius: 3px; padding: 0 4px; }
.highlight-yellow { background: var(--yellow); }
.highlight-blue { background: var(--blue); }
.highlight-red { background: var(--red); }
.highlight-red .player-name, .highlight-red .player-meta { color: #fff; }
.highlight-red .tag { color: #1a1a1a; }
.highlight-orange { background: var(--orange); }
.highlight-grey { background: var(--grey); }
.highlight-grey .player-name, .highlight-grey .player-meta { color: #fff; }
.highlight-grey .tag { color: #1a1a1a; }
.highlight-grey .player-num { background: #fff; color: var(--grey); }
.highlight-grey .mini-btn { color: #dcdee2; }
.highlight-grey .mini-btn:hover { color: #fff; }
.sortable-ghost { opacity: 0.3; }
.board-readonly .player-card { cursor: default; }
.legend {
  max-width: 1300px;
  margin: 18px auto 0;
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 12px;
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 14px; border: 1px solid var(--line); border-radius: 3px; }

.edit-row {
  display: flex;
  gap: 8px;
  margin: 4px 0 16px;
  max-width: 1300px;
  margin-left: auto;
  margin-right: auto;
  font-size: 13px;
  align-items: center;
  flex-wrap: wrap;
}
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; }
.card-btns { display: flex; gap: 6px; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; }
.mini-btn {
  font-size: 10px;
  color: #999;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.mini-btn:hover { color: var(--navy); text-decoration: underline; background: none; }

/* Mini-btn (notes/edit/stats/remove) contrast per highlight background */
.highlight-yellow .mini-btn,
.highlight-blue .mini-btn,
.highlight-orange .mini-btn { color: var(--navy); opacity: 0.75; }
.highlight-yellow .mini-btn:hover,
.highlight-blue .mini-btn:hover,
.highlight-orange .mini-btn:hover { opacity: 1; }
.highlight-red .mini-btn { color: #f9d8d8; }
.highlight-red .mini-btn:hover { color: #fff; }

.autosave-indicator {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: var(--navy);
  color: #fff;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.autosave-indicator.show { opacity: 1; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  width: 340px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-box h3 { margin-top: 0; color: var(--navy); }

.helper-text { font-size: 14px; color: #1a56a0; margin-top: -6px; }

/* Match availability status indicators (dropdown for coaches, tag for admin's read-only view) */
.status-select {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: inherit;
  font-size: 12px;
  font-weight: bold;
}
.status-select-available, .status-tag-available { background: var(--blue); color: #1a1a1a; }
.status-select-maybe, .status-tag-maybe { background: var(--yellow); color: #1a1a1a; }
.status-select-not_available, .status-tag-not_available { background: var(--red); color: #fff; }
.status-tag { padding: 2px 8px; border-radius: 3px; font-size: 12px; font-weight: bold; }

textarea {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  width: 100%;
}

.notes-modal-box { width: 420px; max-width: 90vw; }
.notes-list {
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.note-item {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
}
.note-text {
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 4px;
}
.note-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: #777;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ============================================
   Mobile responsive (tablets and phones)
   ============================================ */
@media (max-width: 768px) {
  .container { padding: 14px; }

  h1 { font-size: 19px; margin-bottom: 14px; }
  h2 { font-size: 16px; }

  /* Top bar wraps and centers on narrow screens */
  .topbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 14px;
  }
  .topbar-left { flex: 1 1 auto; }
  .topbar-left img { height: 32px; }
  .topbar-left .club-name { font-size: 15px; }
  .topbar-right { gap: 8px; font-size: 12px; }
  .topbar-nav {
    order: 3;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 12px;
  }
  .topbar-nav a { padding: 5px 8px; }

  /* Stat cards stack instead of sitting side by side */
  .stats-grid { grid-template-columns: 1fr !important; }

  /* Add-player form stacks full width */
  .edit-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .edit-row input, .edit-row select, .edit-row button {
    width: 100% !important;
  }

  /* Kanban board becomes a horizontally swipeable row of columns,
     similar to Trello's mobile layout, since dragging cards between
     stacked full-width columns is awkward with a touchscreen. */
  .board {
    display: flex !important;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 10px;
    padding-bottom: 10px;
    -webkit-overflow-scrolling: touch;
  }
  .column {
    flex: 0 0 82vw;
    min-width: 240px;
    scroll-snap-align: start;
  }

  .player-card { touch-action: manipulation; }

  .card-box { padding: 14px; }

  .form-row { max-width: 100%; }

  table.data-table { font-size: 12px; }
  table.data-table th, table.data-table td { padding: 6px 8px; }

  .login-box { width: 90vw; padding: 24px 18px; }

  .modal-box { padding: 18px; }

  .legend {
    gap: 10px;
    font-size: 11px;
  }
}

@media (max-width: 420px) {
  .column { flex-basis: 88vw; }
  .topbar-left .club-name { font-size: 13px; }
}


/* ---- Mobile board (tap-to-move view) ---- */
.mobile-team-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 4px 10px;
  -webkit-overflow-scrolling: touch;
}
.mobile-team-tab {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.mobile-team-tab.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.mobile-team-count {
  opacity: 0.75;
  font-weight: 500;
  margin-left: 2px;
}
.mobile-add-form {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.mobile-add-form.show { display: block; }
.mobile-more-details {
  display: none;
  margin-bottom: 8px;
}
.mobile-more-details.show { display: block; }
.mobile-card-list {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mobile-player-card {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 5px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--card-shadow);
  padding: 14px 16px;
  cursor: pointer;
  min-height: 44px;
}
.mobile-player-card:active { background: #f7f9fc; }
.mobile-player-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.mobile-player-card.highlight-blue { border-left-color: var(--blue); }
.mobile-player-card.highlight-yellow { border-left-color: var(--yellow); }
.mobile-player-card.highlight-orange { border-left-color: var(--orange); }
.mobile-player-card.highlight-grey { border-left-color: var(--grey); }
.mobile-player-card.highlight-red { border-left-color: var(--red); }

@media (max-width: 480px) {
  #actionSheet .modal-box,
  #editModal .modal-box,
  #notesModal .modal-box,
  #statsModal .modal-box {
    width: 100%;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    margin: 0;
    max-height: 85vh;
    overflow-y: auto;
  }
  #actionSheet.show, #editModal.show, #notesModal.show, #statsModal.show {
    align-items: flex-end;
  }
  .mobile-player-card { padding: 16px; }
  .btn { min-height: 44px; }
}

/* Distinct styling for "also on another board" badges - visually
   different from bat/bowl/wk/PIN tags at a glance, since they mean
   something different (this player has a card elsewhere too) and were
   getting lost among the other tags. */
.tag-other-board {
  background: #ede4fb;
  color: #5b3aa8;
  font-weight: 600;
}
