:root {
  --bg: #f3efe4;
  --panel: rgba(255, 252, 246, 0.88);
  --panel-strong: #fffaf1;
  --ink: #1e2a22;
  --muted: #5f695e;
  --line: rgba(30, 42, 34, 0.12);
  --accent: #1f6a43;
  --accent-strong: #164c30;
  --accent-soft: #d9ead8;
  --gold: #c69b3a;
  --danger: #8b3b2f;
  --shadow: 0 24px 60px rgba(45, 54, 38, 0.12);
  --radius: 24px;
  --radius-small: 14px;
  --font-display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --font-body: "Avenir Next", "Segoe UI", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(198, 155, 58, 0.18), transparent 24rem),
    radial-gradient(circle at bottom right, rgba(31, 106, 67, 0.18), transparent 28rem),
    linear-gradient(180deg, #f7f1e3 0%, #efe8d8 100%);
  font-family: var(--font-body);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, #1a6d44, #0f5734);
  box-shadow: 0 10px 30px rgba(15, 87, 52, 0.22);
}

.topbar-inner {
  width: min(1400px, calc(100% - 2rem));
  margin: 0 auto;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 1.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  color: white;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: block;
  flex: 0 0 42px;
  object-fit: cover;
  border-radius: 50%;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: rgba(255, 255, 255, 0.75);
}

.topnav {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-left: 0.5rem;
}

.topnav a {
  padding: 0.62rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.08));
  color: white;
  text-decoration: none;
  white-space: nowrap;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: background 120ms ease, transform 120ms ease, border-color 120ms ease;
}

.topnav a:hover {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.12));
  border-color: rgba(255, 255, 255, 0.34);
  transform: translateY(-1px);
}

.app-shell {
  width: min(1400px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

.hero,
.panel,
.card {
  backdrop-filter: blur(12px);
}

.hero {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 1.5rem;
  padding: 2rem;
  border: 1px solid var(--line);
  border-radius: 32px;
  background: linear-gradient(135deg, rgba(255, 249, 240, 0.92), rgba(238, 246, 236, 0.84));
  box-shadow: var(--shadow);
}

.eyebrow,
.section-kicker,
.event-meta,
label span {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.76rem;
  color: var(--muted);
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
}

h1 {
  margin-top: 0.25rem;
  font-size: clamp(2rem, 4vw, 4.1rem);
  line-height: 0.95;
  max-width: 12ch;
}

.hero-compact h1 {
  max-width: none;
  white-space: nowrap;
}

.hero-copy {
  max-width: 58ch;
  color: var(--muted);
  font-size: 1.03rem;
}

.hero-links a {
  color: var(--accent-strong);
  font-weight: 600;
}

.stat {
  padding: 1rem 1.1rem;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
}

.stat strong {
  display: block;
  font-size: 1.9rem;
  font-family: var(--font-display);
}

.stat span {
  color: var(--muted);
}

.main-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.panel {
  padding: 1.4rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-wide {
  grid-column: 1 / -1;
}

.panel-header,
.event-heading,
.toolbar,
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.attendance-grid .panel-header {
  align-items: end;
  margin-bottom: 0.75rem;
}

.attendance-grid .panel-header input {
  max-width: 220px;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-small);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
}

.button,
input,
select {
  font: inherit;
}

.button {
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  padding: 0.72rem 1rem;
  cursor: pointer;
}

.button:hover {
  background: var(--accent-strong);
}

.button-muted {
  background: white;
  color: var(--ink);
  border: 1px solid var(--line);
}

.button-muted:hover {
  background: #f6f3eb;
}

.button-danger {
  background: var(--danger);
}

.button-danger:hover {
  background: #6f2f25;
}

.hidden {
  display: none;
}

body[data-authenticated="true"] [data-auth-only].hidden {
  display: inline-flex;
}

body[data-admin="true"] [data-admin-only].hidden {
  display: inline-flex;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin: 1rem 0 1.25rem;
  align-items: start;
}

label {
  display: grid;
  gap: 0.45rem;
  align-content: start;
}

.checkbox-field {
  align-content: start;
}

label input,
label select,
.toolbar input,
.panel-header select {
  width: 100%;
  padding: 0.8rem 0.95rem;
  border-radius: var(--radius-small);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  align-self: start;
}

.form-actions {
  grid-column: span 4;
  justify-content: flex-end;
}

.form-actions-split {
  justify-content: flex-start;
}

.event-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1rem 0;
}

.event-card,
.card {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel-strong);
}

.event-card {
  padding: 0.35rem;
  min-width: 220px;
}

.event-card.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: linear-gradient(180deg, #fcfff9, #f2f8f0);
}

.event-select-button {
  width: 100%;
  padding: 0.85rem 0.95rem;
  text-align: left;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.competition-tab-active {
  background: linear-gradient(180deg, #fcfff9, #e4f1e6);
  box-shadow: inset 0 0 0 1px var(--accent);
}

#competition-tabs {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

#competition-tabs .event-select-button {
  width: auto;
  min-width: auto;
  white-space: nowrap;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  font-size: 0.95rem;
}

.event-card p,
.event-card strong,
.competition-summary p {
  margin: 0;
}

.event-card p {
  color: var(--muted);
  margin: 0.35rem 0.7rem 0.55rem;
}

.card {
  padding: 1rem;
}

.attendance-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}

.player-picker {
  max-height: 520px;
  overflow: auto;
  display: grid;
  gap: 0.45rem;
  padding-right: 0.2rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.72rem 0.84rem;
  border-radius: 14px;
  background: #f7f3ea;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
}

.field-label {
  display: block;
  margin-bottom: 0.45rem;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.table-wrap {
  overflow: auto;
  margin-top: 0.85rem;
}

.course-form-table {
  grid-column: 1 / -1;
}

.course-holes-toggle {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  overflow: hidden;
}

.course-holes-toggle summary {
  cursor: pointer;
  list-style: none;
  padding: 0.95rem 1rem;
  font-weight: 600;
}

.course-holes-toggle summary::-webkit-details-marker {
  display: none;
}

.course-holes-toggle summary::after {
  content: "+";
  float: right;
  color: var(--accent-strong);
}

.course-holes-toggle[open] summary::after {
  content: "-";
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 0.82rem 0.75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

thead th {
  position: sticky;
  top: 0;
  background: #fbf7ee;
  z-index: 1;
}

td input[type="number"] {
  width: 92px;
  padding: 0.55rem 0.65rem;
  border-radius: 12px;
  border: 1px solid var(--line);
}

#event-score-body td {
  padding: 0.6rem 0.45rem;
}

#event-score-body td input[type="number"] {
  width: 72px;
  padding: 0.45rem 0.5rem;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.34rem 0.7rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.88rem;
}

.pill.muted {
  background: #f0ece2;
  color: var(--muted);
}

.pill.pill-bad {
  background: #f4d9d3;
  color: #8b3b2f;
}

.pill.pill-mid {
  background: #f4e8b8;
  color: #7a5a12;
}

.pill.pill-good {
  background: #d9ead8;
  color: #164c30;
}

.penalty-cell {
  display: grid;
  gap: 0.2rem;
}

.penalty-cell strong {
  font-size: 0.95rem;
}

.penalty-cell small {
  color: var(--muted);
  font-size: 0.74rem;
}

.form-grid-span {
  grid-column: 1 / -1;
}

.hole-badge {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: #ece7db;
  color: var(--ink);
  font-weight: 700;
}

.hole-badge-active {
  background: var(--accent);
  color: white;
}

.podium {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  align-items: end;
}

.podium-card {
  display: grid;
  gap: 0.35rem;
  padding: 1rem;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  text-align: center;
}

.podium-card span {
  font-size: 2rem;
  font-family: var(--font-display);
}

.podium-card-1 {
  min-height: 180px;
  background: linear-gradient(180deg, #fff8dd, #f7ead2);
}

.podium-card-2,
.podium-card-3 {
  min-height: 150px;
}

.competition-summary {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.9rem;
}

.results-list {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.45rem;
}

.nearest-pin-row {
  align-items: end;
  margin-top: 0.8rem;
}

.empty-state {
  padding: 1.5rem;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.5);
}

@media (max-width: 1080px) {
  .hero,
  .main-grid,
  .attendance-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-actions {
    grid-column: auto;
  }
}

@media (max-width: 720px) {
  .topbar-inner,
  .panel-header,
  .event-heading,
  .toolbar,
  .form-actions {
    align-items: stretch;
  }

  .topbar-inner,
  .panel-header,
  .event-heading {
    flex-direction: column;
  }

  .topbar-inner {
    width: min(100%, calc(100% - 1rem));
    padding: 0.75rem 0;
  }

  .brand {
    width: 100%;
  }

  .topnav {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.2rem;
    margin-left: 0;
  }

  .topnav a,
  body[data-authenticated="true"] .topnav [data-auth-only].hidden,
  body[data-admin="true"] .topnav [data-admin-only].hidden {
    display: inline-flex;
    width: auto;
    flex: 0 0 auto;
    text-align: center;
  }

  .app-shell {
    width: min(100%, calc(100% - 1rem));
    padding: 1rem 0 2rem;
  }

  .hero,
  .panel,
  .card {
    border-radius: 20px;
  }

  .hero {
    padding: 1.25rem;
  }

  .hero-compact h1 {
    white-space: normal;
  }

  h1 {
    max-width: none;
    font-size: clamp(1.8rem, 9vw, 2.5rem);
    line-height: 1;
  }

  .hero-copy {
    font-size: 0.98rem;
  }

  .toolbar,
  .form-actions {
    flex-direction: column;
  }

  .toolbar input,
  .toolbar .button,
  .panel-header .button,
  .form-actions .button {
    width: 100%;
  }

  .event-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.25rem;
  }

  .event-card {
    min-width: 180px;
  }

  .attendance-grid {
    gap: 0.75rem;
  }

  .player-picker {
    max-height: 320px;
  }

  th,
  td {
    padding: 0.7rem 0.55rem;
    font-size: 0.92rem;
  }

  td input[type="number"] {
    width: 76px;
  }

  #event-score-body td {
    padding: 0.45rem 0.3rem;
  }

  #event-score-body td input[type="number"] {
    width: 56px;
    padding: 0.4rem 0.35rem;
  }

  .podium {
    grid-template-columns: 1fr;
  }
}
