/* Functional over beautiful: system fonts, one accent colour, mobile-first. */

:root {
  --accent: #1a7a4a;
  --accent-dark: #14603a;
  --ink: #1c1c1e;
  --muted: #6b7280;
  --bg: #f5f5f7;
  --card: #ffffff;
  --danger: #b42318;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: #fff;
}

.topbar .brand { font-weight: 600; white-space: nowrap; }

/* Profile chip + dropdown (native <details>, no JS). */

.profile-menu { position: relative; }

.profile-menu summary {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  list-style: none;
  cursor: pointer;
  color: #fff;
  font-size: 0.95rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.15);
  white-space: nowrap;
}

.profile-menu summary::-webkit-details-marker { display: none; }

.profile-menu summary:hover, .profile-menu[open] summary { background: rgb(255 255 255 / 0.28); }

.profile-menu .menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.45rem);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.18);
  padding: 0.4rem;
  min-width: 200px;
  z-index: 20;
}

.menu-note {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem 0.5rem;
  border-bottom: 1px solid #ececee;
  margin-bottom: 0.3rem;
}

.menu .menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  margin: 0;
}

.menu .menu-item:hover { background: #f3f4f6; color: var(--danger); }

.topbar form { display: inline; }

.linklike {
  background: none;
  border: none;
  color: #fff;
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.card {
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.08);
  margin: 1rem auto;
  max-width: 640px;
  padding: 1.25rem;
}

.card.narrow { max-width: 420px; margin-top: 14vh; text-align: center; }

.card.wide { max-width: 1080px; }

/* Dashboard (landing page) layout */
.dashboard {
  max-width: 1080px;
  margin: 1rem auto;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.dashboard .card { max-width: none; margin: 0; }

.dash-top {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
  align-items: start;
}

.league-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  align-items: start;
}

.section-heading { margin: 0.5rem 0 0; padding: 0 0.25rem; }

.admin-actions { list-style: none; margin: 0.5rem 0; padding: 0; }

.admin-actions li { padding: 0.55rem 0; border-top: 1px solid #ececee; display: flex; flex-direction: column; gap: 0.15rem; }

.admin-actions li:first-child { border-top: none; }

h1 { font-size: 1.4rem; margin: 0 0 0.75rem; }

p { line-height: 1.5; }

input[type="search"] {
  width: 100%;
  font-size: 1rem;
  padding: 0.65rem 1rem 0.65rem 2.5rem;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  margin: 0.75rem 0 0.25rem;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4.5-4.5'/%3E%3C/svg%3E") no-repeat 0.9rem center / 1.05rem;
  -webkit-appearance: none;
}

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

input[type="email"], input[type="text"], input[type="number"], input[type="date"],
select, textarea {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
  padding: 0.65rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  margin-bottom: 0.75rem;
  -webkit-appearance: none;
  appearance: none;
}

textarea { resize: vertical; min-height: 5.5rem; }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  padding-right: 2.4rem;
}

textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

input[type="submit"], button[type="submit"] {
  width: 100%;
  margin-top: 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.7rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

input[type="submit"]:hover, button[type="submit"]:hover { background: var(--accent-dark); }

.flash {
  max-width: 640px;
  margin: 0.75rem auto 0;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.95rem;
}

.flash.notice { background: #e7f6ee; color: var(--accent-dark); }

.flash.alert { background: #fdecea; color: var(--danger); }

/* --- shared bits for list/table screens --- */

.muted { color: var(--muted); font-size: 0.9rem; }

.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.btn-small {
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  white-space: nowrap;
}

.header-actions { display: flex; gap: 0.5rem; align-items: center; }

.partner-list { margin: 0.75rem 0 1rem; }

.partner-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0;
  border-top: 1px solid #ececee;
}

.partner-row:first-child { border-top: none; }

.partner-row label { margin: 0; font-weight: 500; }

.partner-row input { width: 7rem; margin: 0; }

.inline-move { display: flex; gap: 0.4rem; align-items: center; }

.inline-move select { margin-bottom: 0; }

.btn-small.btn-secondary { background: #fff; color: var(--accent-dark); border: 1px solid var(--accent); }

.plain-list { list-style: none; margin: 0.5rem 0 0; padding: 0; }

.plain-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid #ececee;
}

table { width: 100%; border-collapse: collapse; margin: 0.5rem 0 0.75rem; }

th, td { text-align: left; padding: 0.45rem 0.5rem 0.45rem 0; border-bottom: 1px solid #ececee; }

th { font-size: 0.85rem; color: var(--muted); font-weight: 600; }

.field-row { display: flex; gap: 0.75rem; }

/* Toggle switches: real checkboxes underneath, switch look on top. */

.switch-list { margin: 1.25rem 0 0; display: flex; flex-direction: column; }

.switch-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 0;
  border-top: 1px solid #ececee;
  margin: 0;
  cursor: pointer;
}

.switch-row:last-child { border-bottom: 1px solid #ececee; }

.switch-row > span { display: flex; flex-direction: column; gap: 0.1rem; }

input[type="checkbox"].switch {
  appearance: none;
  -webkit-appearance: none;
  width: 51px;
  height: 31px;
  border-radius: 999px;
  background: #d1d5db;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
  transition: background 0.2s ease;
}

input[type="checkbox"].switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.25);
  transition: transform 0.2s ease;
}

input[type="checkbox"].switch:checked { background: var(--accent); }

input[type="checkbox"].switch:checked::before { transform: translateX(20px); }

input[type="checkbox"].switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  input[type="checkbox"].switch, input[type="checkbox"].switch::before { transition: none; }
}

.radio-row { display: flex; gap: 0.9rem; font-size: 0.9rem; }

.radio-row label { display: inline-flex; align-items: center; gap: 0.3rem; margin: 0; }

.field-row > span { flex: 1; }

label { display: block; font-size: 0.9rem; margin-bottom: 0.25rem; color: var(--ink); }

h2 { font-size: 1.1rem; margin: 1.25rem 0 0.5rem; }

.danger-zone { margin-top: 2rem; border-top: 1px solid #ececee; padding-top: 0.75rem; }

.linklike-danger {
  background: none;
  border: none;
  color: var(--danger);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.topbar nav { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }

.topbar nav a {
  color: #fff;
  text-decoration: none;
  font-size: 0.95rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
}

.topbar nav a:hover { background: rgb(255 255 255 / 0.12); }

.topbar nav a.current { background: rgb(255 255 255 / 0.22); font-weight: 600; }

.topbar nav a.brand { padding-left: 0; margin-right: 0.4rem; }

.topbar nav a.brand:hover { background: none; }

/* Recent-rounds game cards */

.game-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.7rem;
  margin-top: 0.75rem;
  align-items: start;
}

.game-card {
  background: #eef7f1;
  border: 1px solid #d6ebde;
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.game-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.08);
}

@media (prefers-reduced-motion: reduce) {
  .game-card { transition: none; }
  .game-card:hover { transform: none; }
}

.game-card__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}

.game-card__course { font-weight: 700; font-size: 1.05rem; }

.game-card__date { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }

.game-card__meta { color: var(--muted); font-size: 0.85rem; margin: 0.15rem 0 0.6rem; }

.game-card__scores { list-style: none; margin: 0; padding: 0; }

.game-card__scores li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.4rem 0;
  border-top: 1px solid #dcebe1;
}

.game-card__scores li:first-child { border-top: none; }

.game-card__scores .who { font-weight: 500; }

.game-card__scores .num strong { font-size: 1.05rem; }

.game-card__scores small { color: var(--muted); font-size: 0.8rem; font-weight: 400; }

.bet-row { padding: 0.8rem 0; }

.bet-row > span { display: flex; flex-direction: column; gap: 0.3rem; }

.bet-head { display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; }

.bet-head strong { font-size: 1.05rem; }

.bet-stake { color: var(--accent-dark); font-weight: 500; }

.bet-desc { line-height: 1.45; }

.overdue { color: var(--danger); margin-left: 0.4rem; }

.nowrap { white-space: nowrap; }

.index-chart { width: 100%; height: auto; margin: 0.25rem 0 0.5rem; }

.chart-range { display: flex; gap: 0.4rem; margin: 0.5rem 0; }

.chart-range a {
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--accent-dark);
  border: 1px solid #d6ebde;
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
}

.chart-range a.current { background: var(--accent); color: #fff; border-color: var(--accent); }

.index-badge {
  background: var(--accent);
  color: #fff;
  font-size: 1.3rem;
  font-weight: 700;
  padding: 0.35rem 0.9rem;
  border-radius: 10px;
}

.note-badge {
  display: inline-block;
  background: #fff7e6;
  color: #8a5a00;
  border-radius: 6px;
  font-size: 0.8rem;
  padding: 0.1rem 0.45rem;
  margin: 0.1rem 0.2rem 0.1rem 0;
}

tr.best8 td { background: #e7f6ee; }

tr.best8 td:first-child { border-radius: 6px 0 0 6px; }

tr.best8 td:last-child { border-radius: 0 6px 6px 0; }

tr.unqualified td { color: var(--muted); }

.league-card h2 { margin-top: 0; font-size: 1.15rem; }

/* keep league tables readable on narrow phones */
@media (max-width: 460px) {
  .league-card { padding: 1rem 0.85rem; }
  .league-card th, .league-card td { padding: 0.4rem 0.35rem 0.4rem 0; font-size: 0.92rem; }
}

/* Guide page */

.guide h2 { margin-top: 1.75rem; border-top: 1px solid #ececee; padding-top: 1.25rem; }

.guide h3 { font-size: 1rem; margin: 1.25rem 0 0.4rem; }

.guide ol li { margin-bottom: 0.5rem; line-height: 1.5; }

.guide .formula {
  background: #f3f4f6;
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  font-weight: 600;
  text-align: center;
}

.guide .example {
  background: #e7f6ee;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 0.6rem 0.9rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

.menu a.menu-item { text-decoration: none; }

.menu a.menu-item:hover { color: var(--accent-dark); }

/* Floating quick-entry button — always reachable, never scrolls away. */

.fab {
  position: fixed;
  right: 1rem;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  z-index: 50;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  line-height: 1;
  text-decoration: none;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.25);
}

.fab span { margin-top: -0.15rem; }

.fab:hover { background: var(--accent-dark); }

.fab:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

/* Player picker pills (hidden checkboxes, tappable name chips). */

.pill-checks { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.25rem 0 1rem; }

.pill-checks label {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0.45rem 0.9rem;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  font-size: 0.95rem;
  cursor: pointer;
  user-select: none;
}

.pill-checks input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pill-checks label:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.pill-checks label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.card details { margin: 0.75rem 0; }

.card details summary { cursor: pointer; color: var(--accent-dark); font-size: 0.95rem; }

.card details[open] { background: #fafafa; border-radius: 8px; padding: 0.65rem 0.75rem 0.25rem; }

.card details[open] summary { margin-bottom: 0.9rem; }
