:root {
  color-scheme: light;
  --green-950: #102e27;
  --green-900: #173f35;
  --green-800: #235548;
  --green-100: #dfece5;
  --cream: #f7f1e3;
  --paper: #fffdf7;
  --ink: #18342d;
  --muted: #66736e;
  --danger: #9a352e;
  --success: #236b4f;
  --shadow: 0 20px 55px rgba(16, 46, 39, .14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--cream); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: radial-gradient(circle at 12% 12%, rgba(255,255,255,.9), transparent 32rem), linear-gradient(150deg, #fbf7ed, var(--cream));
}
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }

.brand-bar {
  padding: max(1rem, env(safe-area-inset-top)) 1.1rem 1rem;
  background: var(--green-900);
  color: white;
}
.brand { display: inline-flex; align-items: center; gap: .75rem; color: inherit; text-decoration: none; }
.brand-logo {
  display: block;
  width: 2.8rem;
  height: 2.8rem;
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 50%;
  object-fit: cover;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1.05rem; letter-spacing: .02em; }
.brand small { margin-top: .12rem; color: #d7e5df; }

.app-shell {
  width: min(100% - 2rem, 76rem);
  margin: 0 auto;
  padding: clamp(1.4rem, 4vw, 3rem) 0 max(2rem, env(safe-area-inset-bottom));
}
.card { border: 1px solid rgba(23,63,53,.12); border-radius: 1.35rem; background: var(--paper); box-shadow: var(--shadow); }
.auth-card { width: min(100%, 32rem); margin: 0 auto; padding: clamp(1.4rem, 5vw, 2.4rem); }
.auth-card h1 { margin: .2rem 0 .7rem; font-family: Georgia, serif; font-size: clamp(2rem, 8vw, 3rem); line-height: 1.04; }
.auth-logo { display: block; width: clamp(7rem, 32vw, 10rem); height: clamp(7rem, 32vw, 10rem); margin: .4rem auto 1.35rem; border-radius: 50%; object-fit: cover; }
.auth-card .auth-title { margin: 0 0 1.65rem; text-align: center; font-size: clamp(1.65rem, 6vw, 2.15rem); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.auth-card p { line-height: 1.55; }
.intro { color: var(--muted); }
.eyebrow { margin: 0; color: var(--green-800); font-size: .76rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }

.field { margin: 1.45rem 0; }
.field label { display: block; margin-bottom: .65rem; font-weight: 750; }
.field-guidance { margin: .5rem 0 0; color: var(--muted); font-size: .86rem; line-height: 1.45; }
.field input, .field select {
  width: 100%;
  min-height: 3.25rem;
  padding: .72rem .85rem;
  border: 1px solid #aebbb5;
  border-radius: .75rem;
  background: white;
  color: var(--ink);
}
.field input:focus, .field select:focus, button:focus-visible { outline: 3px solid rgba(35,85,72,.24); outline-offset: 2px; }
.button { min-height: 3.25rem; padding: .72rem 1rem; border: 1px solid var(--green-800); border-radius: .75rem; font-weight: 780; }
.button:disabled { cursor: wait; opacity: .65; }
.primary { background: var(--green-900); color: white; }
.secondary { background: transparent; color: var(--green-900); }
.text-button { border-color: transparent; background: transparent; color: var(--green-800); }
.full-width { width: 100%; }
.compact { min-height: 2.7rem; white-space: nowrap; }
.back-button { margin: -.3rem 0 1.2rem; padding: .4rem 0; border: 0; background: transparent; color: var(--green-800); font-weight: 750; }

.auth-actions, .confirm-actions { display: grid; gap: .9rem; margin-top: 1.75rem; }
#loginButton { margin-top: .35rem; }
.admin-sign-in-link { margin-top: .75rem; text-align: center; }
.admin-sign-in-link .button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.confirmed-name { margin: 1.2rem 0 .4rem; color: var(--green-900); font-family: Georgia, serif; font-size: 1.6rem; font-weight: 700; }
.security-note { margin: 1.4rem 0 0; color: var(--muted); font-size: .88rem; }
.warning { color: var(--danger); }
.message { min-height: 1.4rem; margin: .9rem 0 0; color: var(--success); font-weight: 650; }
.message.error { color: var(--danger); }

.member-shell { width: 100%; }
.member-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.member-header h1 { margin: .55rem 0 0; font-family: Georgia, serif; font-size: clamp(1.5rem, 5vw, 1.75rem); line-height: 1.1; }
.member-greeting { margin: 0; color: var(--muted); font-size: .95rem; font-weight: 700; }
.refresh-button { min-height: 2.6rem; padding: .5rem .8rem; font-size: .88rem; }
.golf-days-list { display: grid; gap: .7rem; }
.golf-day-card { padding: 0; overflow: hidden; border-radius: 1rem; box-shadow: 0 8px 28px rgba(16, 46, 39, .09); }
.cancelled-event-card { display: grid; gap: 7px; padding: 18px; }
.event-summary-button {
  display: block;
  width: 100%;
  min-height: 3rem;
  padding: .9rem 1rem 1rem;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}
.event-summary-button:hover { background: #faf8f1; }
.event-summary-button:focus-visible { outline: 3px solid rgba(35,85,72,.28); outline-offset: -3px; }
.event-summary-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; }
.event-summary-date { display: block; min-width: 0; font-size: .95rem; font-weight: 400; line-height: 1.35; overflow-wrap: anywhere; }
.event-summary-course { display: block; margin-top: .28rem; font-family: Georgia, serif; font-size: clamp(1.125rem, 4.7vw, 1.25rem); font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.event-summary-format, .event-summary-tee, .event-summary-availability, .event-summary-registration { display: block; margin-top: .24rem; line-height: 1.35; overflow-wrap: anywhere; }
.event-summary-format { color: var(--ink); }
.event-summary-tee { color: var(--muted); font-size: .875rem; }
.event-summary-availability, .event-summary-registration { font-size: .95rem; }
.event-summary-notes { display: block; margin-top: .42rem; color: var(--muted); font-size: .875rem; line-height: 1.42; overflow-wrap: anywhere; white-space: pre-wrap; }
.golf-day-date, .tee-sheet-date { margin: .35rem 0 0; color: var(--muted); line-height: 1.4; }
.status-badge, .you-badge {
  display: inline-flex;
  align-items: center;
  width: max-content;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 800;
}
.status-badge { flex: 0 0 auto; padding: .35rem .6rem; background: var(--green-100); color: var(--green-900); text-transform: capitalize; }
.status-closed { background: #ece8de; color: #5d625f; }
.status-full { background: #f3dfdb; color: #7f312b; }
.golf-day-summary { display: grid; gap: .8rem; margin: 1.2rem 0; }
.golf-day-summary-item { min-width: 0; padding: .8rem; border-radius: .75rem; background: #f3f6f1; }
.golf-day-summary dt { color: var(--muted); font-size: .78rem; font-weight: 750; }
.golf-day-summary dd { margin: .25rem 0 0; font-weight: 780; line-height: 1.35; overflow-wrap: anywhere; }
.event-notes { margin: 1rem 0; padding: .9rem 1rem; border-left: .25rem solid var(--green-800); border-radius: .45rem; background: #f8f3e7; }
.event-notes h3, .event-notes h4 { margin: 0 0 .4rem; font-size: .95rem; }
.event-notes p { margin: 0; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; }
.booking-actions { margin: 1rem 0; padding: 1rem; border: 1px solid rgba(23,63,53,.14); border-radius: .9rem; background: var(--paper); }
.booking-actions-heading h3, .add-player-tools h4, .cancellation-tools h4 { margin: 0; font-family: Georgia, serif; font-size: 1.1rem; }
.booking-actions-heading p, .action-guidance { margin: .35rem 0 0; color: var(--muted); line-height: 1.45; }
.booking-action-form { display: grid; gap: .65rem; margin-top: .75rem; }
.booking-action-form .field { margin: 0; }
.booking-action-form .button { align-self: end; }
.add-player-tools, .cancellation-tools { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid rgba(23,63,53,.12); }
.managed-registrations { display: grid; gap: .5rem; margin-top: .7rem; }
.managed-registration { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .45rem .55rem; border-radius: .65rem; background: #f3f6f1; }
.managed-registration span { min-width: 0; overflow-wrap: anywhere; }
.managed-registration .button { flex: 0 0 auto; min-height: 2.65rem; }
.tee-sheet-event-details { grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); }
.dashboard-state { padding: 1.4rem; text-align: center; }
.dashboard-state .spinner { margin: 0 auto .9rem; }
.dashboard-state h3, .dashboard-state p { margin: .3rem 0; }
.dashboard-state p { color: var(--muted); line-height: 1.5; }

.tee-sheet-view { min-width: 0; }
.tee-sheet-back { min-height: 2.75rem; margin: -.35rem 0 .65rem; }
.tee-sheet-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; }
.tee-sheet-heading h2 { margin: .2rem 0 0; font-family: Georgia, serif; font-size: clamp(1.45rem, 5.5vw, 2rem); line-height: 1.12; overflow-wrap: anywhere; }
.tee-group { margin-top: 1rem; padding: 1rem; border: 1px solid rgba(23,63,53,.13); border-radius: .9rem; background: white; }
.tee-group-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.tee-group h3 { margin: 0; font-family: Georgia, serif; font-size: 1.25rem; }
.tee-group-heading p { margin: 0; font-weight: 800; }
.tee-positions { display: grid; gap: .45rem; margin: .85rem 0 0; padding: 0; list-style: none; }
.tee-positions li { display: grid; grid-template-columns: 2rem minmax(0, 1fr); align-items: center; gap: .65rem; min-height: 2.7rem; }
.tee-positions .team-heading { display: block; min-height: 0; margin: .55rem 0 -.1rem 2.65rem; color: var(--green-800); font-size: .8rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.tee-positions .team-heading.incomplete-team { color: var(--danger); }
.position-box { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .45rem .65rem; min-height: 2.7rem; padding: .5rem .65rem; border-radius: .65rem; background: #f3f6f1; }
.empty-position { color: var(--muted); }
.position-number { display: grid; width: 1.75rem; height: 1.75rem; place-items: center; border-radius: 50%; background: var(--green-100); color: var(--green-900); font-size: .8rem; font-weight: 850; }
.position-player { min-width: 0; overflow-wrap: anywhere; }
.tee-booking-cancel { display: grid; width: 2.5rem; height: 2.5rem; flex: 0 0 2.5rem; place-items: center; padding: 0; color: #a72f2f; border: 0; border-radius: 50%; background: transparent; font-size: 1.6rem; font-weight: 850; cursor: pointer; }
.tee-booking-cancel:hover, .tee-booking-cancel:focus-visible { background: #f9dddd; outline: 2px solid #a72f2f; outline-offset: 1px; }
.tee-booking-actions { display: flex; width: 100%; align-items: center; flex-wrap: wrap; gap: .5rem; }
.tee-booking-change { min-height: 2.5rem; padding: 0; color: var(--green-800); border: 0; background: transparent; font-weight: 850; text-decoration: underline; cursor: pointer; }
.tee-booking-move { min-height: 2.7rem; flex: 1 1 13rem; }
.you-badge { padding: .25rem .5rem; background: var(--green-900); color: white; }
.unallocated-group { background: #f8f3e7; }
.unallocated-list { display: grid; gap: .5rem; margin: .8rem 0 0; padding-left: 1.25rem; }
.unallocated-list li { padding-left: .2rem; }
.unallocated-list .you-badge { margin-left: .6rem; }
.member-footer {
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(23,63,53,.14);
}
.member-footer .button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }

.spinner {
  display: block;
  width: 2rem;
  height: 2rem;
  margin-bottom: 1.2rem;
  border: 3px solid var(--green-100);
  border-top-color: var(--green-800);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
.hidden { display: none !important; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (min-width: 40rem) {
  .auth-actions, .confirm-actions { grid-template-columns: 1fr 1fr; }
  .golf-days-list { grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); }
  .golf-day-summary { grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); }
  .brand-bar { padding-inline: 2rem; }
  .booking-action-form { grid-template-columns: repeat(2, minmax(0, 1fr)) auto; }
}
@media (min-width: 64rem) {
  .tee-sheet-view #teeSheetContent { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
  .tee-sheet-view #teeSheetContent.hidden { display: none; }
  .tee-sheet-view #teeSheetContent > .unallocated-group { grid-column: 1 / -1; }
  .tee-group { margin-top: 0; }
  .booking-actions { padding: 1.25rem; }
}
@media (max-width: 28rem) {
  .app-shell { width: min(100% - 1.25rem, 76rem); }
  .member-header { align-items: flex-end; }
  .member-footer { display: grid; }
  .member-footer .compact { width: 100%; }
  .tee-sheet-heading { align-items: flex-start; }
  .managed-registration { align-items: stretch; flex-direction: column; }
  .managed-registration .button { width: 100%; }
}
@media (max-height: 36rem) {
  .app-shell { padding-top: .75rem; }
  .auth-card { padding-block: 1rem; }
}
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
