/* Lakelegends styles */
:root {
  --navy: #0b3954;
  --navy-2: #124d6e;
  --teal: #2ec4b6;
  --teal-dark: #1f9e92;
  --orange: #ff6b35;
  --sand: #f4f1e8;
  --bg: #fbfaf6;
  --surface: #ffffff;
  --text: #13222e;
  --muted: #5b6b78;
  --border: #dde3e8;
  --danger: #c0392b;
  --success-bg: #e3f6f3;
  --error-bg: #fdecea;
  --info-bg: #e8f1f8;
  --radius: 12px;
  --shadow: 0 4px 18px rgba(11, 57, 84, 0.08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1820;
    --surface: #13232e;
    --text: #e8eef2;
    --muted: #9fb0bd;
    --border: #23384a;
    --sand: #13232e;
    --success-bg: #12352f;
    --error-bg: #3a1c19;
    --info-bg: #142c40;
    --shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
main { flex: 1; }
a { color: var(--teal-dark); }
@media (prefers-color-scheme: dark) { a { color: var(--teal); } }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.4rem); }
h2 { font-size: 1.4rem; margin-top: 1.6em; }
h3 { font-size: 1.1rem; }
img { max-width: 100%; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.section { padding: 32px 0 48px; }
.section .wrap, .wrap.section { padding-left: 16px; padding-right: 16px; }
.section-alt { background: var(--sand); }
.narrow { max-width: 460px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.85rem; font-weight: normal; }
.lead { font-size: 1.15rem; }
.prose { max-width: 720px; }
.inline { display: inline; }

/* Header */
.site-header { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 1000; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.2rem; letter-spacing: 0.02em; }
.nav { display: flex; align-items: center; gap: 4px 16px; flex-wrap: wrap; }
.nav a, .nav .link-button { color: #dceef3; text-decoration: none; font-size: 0.95rem; }
.nav a:hover, .nav .link-button:hover { color: #fff; }
.nav .btn { color: var(--navy); }

/* Buttons */
.btn {
  display: inline-block;
  background: var(--teal);
  color: var(--navy);
  border: 0;
  border-radius: 999px;
  padding: 10px 20px;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
.btn:hover { background: #45d3c6; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-large { padding: 14px 28px; font-size: 1.05rem; }
.btn-small { padding: 6px 14px; font-size: 0.9rem; }
.btn-secondary { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1.5px var(--border); }
.btn-secondary:hover { background: rgba(46, 196, 182, 0.12); }
.btn-ghost { background: transparent; color: #fff; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.7); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.12); }
.btn-whatsapp { background: #25d366; color: #073b1e; }
.btn-whatsapp:hover { background: #3ee07b; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--teal-dark); cursor: pointer; text-decoration: underline; }
.danger { color: var(--danger) !important; }
.icon-btn { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; width: 32px; height: 32px; cursor: pointer; color: var(--text); }

/* Flash */
.flashes { padding-top: 16px; }
.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 12px; background: var(--info-bg); }
.flash-success { background: var(--success-bg); }
.flash-error { background: var(--error-bg); }

/* Hero */
.hero {
  position: relative;
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 55%, #1b7f8c 100%);
  color: #fff;
  padding: 72px 0 120px;
  overflow: hidden;
}
.hero-inner { position: relative; z-index: 1; max-width: 820px; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.8rem; color: var(--teal); margin: 0 0 12px; font-weight: 700; }
.hero h1 { font-size: clamp(2.2rem, 6vw, 3.6rem); margin-bottom: 24px; }
.quotes { position: relative; min-height: 5.5em; margin-bottom: 28px; }
.quote {
  position: absolute; inset: 0; margin: 0;
  font-size: clamp(1.1rem, 2.6vw, 1.4rem);
  border-left: 4px solid var(--teal);
  padding-left: 16px;
  opacity: 0;
  transition: opacity 0.8s ease;
}
.quote.is-active { opacity: 1; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-waves { position: absolute; bottom: -1px; left: 0; width: 100%; height: 90px; fill: var(--bg); }

/* Cards */
.cards { display: grid; gap: 20px; }
.cards.three { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.card h2 { margin-top: 0; }
.card-icon { font-size: 2rem; margin-bottom: 8px; }
.steps { padding-left: 1.2em; max-width: 720px; }
.steps li { margin-bottom: 12px; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 16px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.form label.choice { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: normal; padding: 6px 0; }
.form label.choice input { margin-top: 5px; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number],
input[type=datetime-local], textarea, select {
  font: inherit;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--teal); outline-offset: 1px; border-color: var(--teal); }
fieldset { border: 1.5px solid var(--border); border-radius: var(--radius); padding: 8px 16px 12px; margin: 0; }
legend { font-weight: 700; padding: 0 6px; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.two-cols > * { min-width: 0; }
@media (max-width: 520px) { .two-cols { grid-template-columns: 1fr; } }
.inline-label { flex-direction: row !important; align-items: center; gap: 10px !important; font-weight: normal !important; }
.inline-label select { width: auto; }

/* Page head */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.meta { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 6px; }

/* Tags */
.tag { display: inline-block; font-size: 0.78rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: rgba(46, 196, 182, 0.15); color: var(--text); }
.tag-private { background: rgba(255, 107, 53, 0.15); }
.tag-live { background: var(--teal); color: var(--navy); }
.tag-upcoming { background: rgba(11, 57, 84, 0.12); }
.tag-finished { background: var(--border); }

/* Maps */
.map { height: 420px; border-radius: var(--radius); border: 1px solid var(--border); z-index: 0; }
.map-large { height: min(65vh, 600px); }
.map-editor { height: 480px; }
@media (max-width: 640px) { .map, .map-editor { height: 340px; } }
.legend { display: flex; align-items: center; gap: 6px 14px; flex-wrap: wrap; font-size: 0.9rem; color: var(--muted); }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: -8px; }
.dot-live { background: var(--teal); }
.dot-soon { background: #8fb3c8; }
.dot-joined { background: var(--orange); }

.race-pin span {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: #8fb3c8; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  font-size: 17px;
}
.race-pin.is-live span { background: var(--teal); }
.race-pin.is-joined span { background: var(--orange); }
.race-popup { display: flex; flex-direction: column; gap: 4px; min-width: 180px; }
.race-popup .btn { margin-top: 6px; text-align: center; color: var(--navy) !important; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #fff; color: #13222e; }
.leaflet-popup-content .muted { color: #5b6b78; }

.mark-icon span {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--orange); color: #fff; font-weight: 700; font-size: 14px;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}
.mark-icon.is-start span { background: var(--navy); }

/* Race form */
.race-form-grid { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 24px; align-items: start; }
@media (max-width: 860px) { .race-form-grid { grid-template-columns: 1fr; } }
.race-form-fields { display: flex; flex-direction: column; gap: 16px; }
.map-tools { display: flex; gap: 8px; margin-bottom: 8px; }
.map-help { margin: 0 0 8px; color: var(--muted); font-size: 0.92rem; }
.marks-list { padding-left: 1.5em; display: flex; flex-direction: column; gap: 8px; }
.marks-list li { display: flex; gap: 6px; align-items: center; }
.marks-list li::marker { font-weight: 700; }
.marks-list .radius { flex-direction: row !important; align-items: center; gap: 2px !important; font-weight: normal !important; }
.marks-list .radius input { width: 80px; }

/* Race page */
.race-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 28px; margin-top: 16px; }
@media (max-width: 860px) { .race-grid { grid-template-columns: 1fr; } }
.race-grid h2:first-child { margin-top: 0; }
.description { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.leaderboard { list-style: none; padding: 0; margin: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.leaderboard li { display: grid; grid-template-columns: 36px 1fr auto; grid-template-areas: "rank who value" "rank when when"; gap: 0 10px; padding: 10px 14px; border-top: 1px solid var(--border); }
.leaderboard li:first-child { border-top: 0; }
.leaderboard .rank { grid-area: rank; font-weight: 800; font-size: 1.2rem; color: var(--muted); align-self: center; }
.leaderboard li:nth-child(1) .rank { color: #d4a017; }
.leaderboard li:nth-child(2) .rank { color: #9aa5ad; }
.leaderboard li:nth-child(3) .rank { color: #b0703a; }
.leaderboard .who { grid-area: who; font-weight: 600; }
.leaderboard .value { grid-area: value; font-weight: 700; white-space: nowrap; }
.leaderboard .when { grid-area: when; font-size: 0.82rem; }
.leaderboard li.is-me { background: rgba(255, 107, 53, 0.08); }
.share { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.share-url { font-size: 0.85rem; }
.race-admin { margin-top: 24px; display: flex; gap: 20px; flex-wrap: wrap; font-size: 0.92rem; }

/* Lists and tables */
.race-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.race-list li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.race-list a { font-weight: 600; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.table th, .table td { text-align: left; padding: 10px 14px; border-top: 1px solid var(--border); white-space: nowrap; }
.table thead th { border-top: 0; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }

/* Upload */
.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 860px) { .upload-grid { grid-template-columns: 1fr; } }
.dropzone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 16px;
  text-align: center;
  align-items: center;
  cursor: pointer;
  font-weight: normal !important;
}
.dropzone.is-over, .dropzone:hover { border-color: var(--teal); background: rgba(46, 196, 182, 0.06); }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.sources dl { margin: 0; }
.sources dt { font-weight: 700; margin-top: 10px; }
.sources dd { margin: 2px 0 0; color: var(--muted); font-size: 0.94rem; }

/* Footer */
.site-footer { background: var(--navy); color: #b8d3de; font-size: 0.88rem; margin-top: 40px; }
.site-footer a { color: #dceef3; }
.footer-inner { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding-top: 20px; padding-bottom: 20px; }
.race-popup-item { display: flex; flex-direction: column; gap: 4px; }
.race-popup-item + .race-popup-item { border-top: 1px solid #dde3e8; padding-top: 10px; margin-top: 6px; }

/* Featured race tiles on the home page */
.race-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
@media (max-width: 900px) { .race-tiles { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .race-tiles { grid-template-columns: 1fr; } }
.race-tile {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; color: var(--text); text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
}
.race-tile:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(11, 57, 84, 0.14); }
.race-thumb { height: 170px; background: #dfe8ec; pointer-events: none; z-index: 0; }
.race-tile-body { padding: 16px 18px 18px; }
.race-tile-body h3 { margin-bottom: 8px; }
.race-tile-facts { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin: 8px 0 0; font-size: 0.92rem; font-weight: 600; }
.race-tile-create {
  align-items: center; justify-content: center; text-align: center; gap: 8px;
  min-height: 280px; border: 2px dashed var(--teal); box-shadow: none; background: transparent; padding: 24px;
}
.race-tile-create .plus {
  display: flex; align-items: center; justify-content: center;
  width: 96px; height: 96px; border-radius: 50%;
  background: var(--teal); color: var(--navy); font-size: 64px; font-weight: 300; line-height: 1;
}
.race-tile-create-text { font-size: 1.2rem; font-weight: 700; }
.mark-icon.is-finish span { background: #2a9d8f; }
.finish-choice { margin-top: 12px; }
.narrow-wide { max-width: 720px; }
.account-block { margin-bottom: 20px; }
.danger-zone { border-color: rgba(192, 57, 43, 0.4); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #d9483a; }
.policy h2 { font-size: 1.2rem; }
.policy-table td, .policy-table th { white-space: normal; vertical-align: top; }
.policy .table { margin: 8px 0 16px; border: 1px solid var(--border); border-radius: var(--radius); }
