:root {
  color-scheme: light;
  --surface-1: #ffffff;
  --surface-2: #f4f8f4;
  --page: #eef3ee;
  --text-primary: #12231a;
  --text-secondary: #47594c;
  --text-muted: #7c8c80;
  --border: rgba(18, 35, 26, 0.1);
  --shadow-sm: 0 1px 2px rgba(15, 30, 20, 0.06);
  --shadow-md: 0 6px 20px rgba(15, 30, 20, 0.08);

  /* Greenly's brand ink, from the logo package (logos/Greenly/README.md). */
  --accent: #247a4f;
  --accent-2: color-mix(in srgb, #247a4f 80%, white);
  --accent-track: color-mix(in srgb, #247a4f 18%, white);
  --accent-ink: #ffffff;

  --gold: #c9971c; /* 1st place */
  --silver: #8a95a1; /* 2nd place */
  --bronze: #a5652f; /* 3rd place, also the punishment-banner accent */
  --critical: #c0392b;

  --floor-fill: #f6f2ea;
  --wall-stroke: #3b4a41;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #16201a;
    --surface-2: #1b271f;
    --page: #101711;
    --text-primary: #eef5ef;
    --text-secondary: #b3c2b6;
    --text-muted: #7f9285;
    --border: rgba(255, 255, 255, 0.09);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.35);
    --accent: #55b57e;
    --accent-2: color-mix(in srgb, #55b57e 70%, black);
    --accent-track: color-mix(in srgb, #55b57e 22%, black);
    --accent-ink: #08150c;
    --floor-fill: #241f18;
    --wall-stroke: #9aab9f;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #16201a;
  --surface-2: #1b271f;
  --page: #101711;
  --text-primary: #eef5ef;
  --text-secondary: #b3c2b6;
  --text-muted: #7f9285;
  --border: rgba(255, 255, 255, 0.09);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.35);
  --accent: #55b57e;
  --accent-2: color-mix(in srgb, #55b57e 70%, black);
  --accent-track: color-mix(in srgb, #55b57e 22%, black);
  --accent-ink: #08150c;
  --floor-fill: #241f18;
  --wall-stroke: #9aab9f;
}

* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
}
a {
  color: inherit;
}

header.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 18px;
}
.brand-mark {
  display: block;
}
/* Ink mark reads on light surfaces, white mark on dark -- same swap as the
   accent tokens above, just keyed off the actual logo files instead of a
   CSS color. */
.brand-mark-dark {
  display: none;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .brand-mark-light {
    display: none;
  }
  :root:where(:not([data-theme="light"])) .brand-mark-dark {
    display: block;
  }
}
:root[data-theme="dark"] .brand-mark-light {
  display: none;
}
:root[data-theme="dark"] .brand-mark-dark {
  display: block;
}
nav.tabs {
  display: flex;
  gap: 4px;
}
nav.tabs button {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}
nav.tabs button.active {
  background: var(--accent-track);
  color: var(--accent);
}

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}
.card h2,
.card h3 {
  margin-top: 0;
}

.event-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.event-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  cursor: pointer;
  text-align: left;
  width: 100%;
  color: inherit;
}
.event-row:hover {
  border-color: var(--accent);
}
.event-row .theme {
  font-weight: 700;
}
.event-row .meta {
  color: var(--text-muted);
  font-size: 13px;
}
.event-row .played-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-track);
  color: var(--accent);
  white-space: nowrap;
}

table.standings {
  width: 100%;
  border-collapse: collapse;
}
table.standings th,
table.standings td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}
table.standings tr:first-child td {
  font-weight: 700;
}
.place-medal {
  display: inline-block;
  width: 1.6em;
}

form.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
}
input,
select,
textarea {
  font: inherit;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-primary);
}
.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.row > * {
  flex: 1;
  min-width: 140px;
}

button.btn {
  font: inherit;
  font-weight: 700;
  padding: 9px 16px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}
button.btn.secondary {
  background: var(--surface-2);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
button.btn-sm {
  font-size: 13px;
  padding: 5px 10px;
  border-radius: 8px;
}

.scorecard-grid {
  display: grid;
  grid-template-columns: 1fr 90px;
  gap: 8px 12px;
  align-items: center;
}
.scorecard-grid .player-name {
  font-weight: 600;
}

.floorplan-wrap {
  width: 100%;
  margin-top: 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow: hidden;
}
#floorplanSvg {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none; /* dragging on the map shouldn't also scroll the page */
  cursor: crosshair;
}
.fp-label text {
  font-size: 20px;
  fill: var(--text-muted);
  text-anchor: middle;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
}
.fp-label-draggable text {
  cursor: grab;
  fill: var(--accent);
  font-weight: 600;
}
.fp-handle {
  fill: var(--surface-1);
  stroke: var(--accent);
  stroke-width: 2.5;
  cursor: grab;
}
.map-item {
  cursor: grab;
}
.map-item-locked {
  cursor: default;
}

.palette {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.palette-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.palette-item:active {
  cursor: grabbing;
}
.map-item-ghost {
  position: fixed;
  top: 0;
  left: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 1000;
  opacity: 0.85;
}

.banner {
  border-radius: 12px;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--bronze) 16%, var(--surface-1));
  border: 1px solid color-mix(in srgb, var(--bronze) 40%, var(--border));
  margin-bottom: 14px;
}
.banner .title {
  font-weight: 700;
  color: var(--bronze);
}

.hole-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hole-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  cursor: grab;
}
.hole-card.dragging {
  opacity: 0.5;
}
.hole-card .num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-track);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.hole-card .info {
  flex: 1;
}
.hole-card .nickname {
  font-weight: 700;
}
.hole-card .sub {
  color: var(--text-muted);
  font-size: 13px;
}

.empty {
  color: var(--text-muted);
  text-align: center;
  padding: 30px 10px;
}

.season-select {
  margin-bottom: 14px;
}

@media (max-width: 480px) {
  header.app-header {
    flex-wrap: wrap;
  }
  nav.tabs {
    order: 3;
    width: 100%;
    justify-content: space-between;
  }
}
