:root {
  --black: #000000;
  --gold: #FFC700;
  --white: #FFFFFF;
  --light: #F4F4F3;
  --dark: #383838;
  --eco: #4ADE80;
  --trail: #FFC700;
  --boost: #EF4444;
  --off: #5B8DEF;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--black);
  color: var(--white);
  font-family: 'Poppins', sans-serif;
  overflow: hidden;
}

/* ---- full-bleed map ---- */
#mapEl { position: fixed; inset: 0; z-index: 0; background: #0c0c0c; }
.leaflet-container { background: #0c0c0c; font-family: 'Poppins', sans-serif; }
.leaflet-control-zoom { border: none !important; }
.leaflet-control-zoom a { background: #161616 !important; color: #eee !important; border: 1px solid #2c2c2c !important; }
.leaflet-control-attribution { background: rgba(0,0,0,.55) !important; color: #999 !important; }
.leaflet-control-attribution a { color: #bbb !important; }

/* ---- floating brand mark (top center) ---- */
.brand-float {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 600; display: flex; align-items: center; gap: 8px;
  background: rgba(10,10,10,.72); backdrop-filter: blur(8px);
  border: 1px solid #2a2a2a; border-radius: 100px; padding: 7px 16px 7px 10px;
  text-decoration: none; cursor: pointer; transition: border-color .15s, background .15s;
}
.brand-float:hover { border-color: #444; background: rgba(20,20,20,.82); }

.corner-card {
  position: fixed; top: 16px; right: 16px; z-index: 550; width: 260px;
  background: rgba(10,10,10,.9); backdrop-filter: blur(12px);
  border: 1px solid #2a2a2a; border-radius: 14px; padding: 16px 18px 14px;
  box-shadow: 0 16px 40px rgba(0,0,0,.5);
  opacity: 0; transform: translateY(-8px); pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.corner-card.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.corner-card-icon { font-size: 18px; margin-bottom: 8px; }
.corner-card p { font-size: 12px; color: #b5b5b5; line-height: 1.55; margin: 0 0 8px; }
.corner-card p:last-child { margin-bottom: 0; }
.corner-card a { color: var(--gold); text-decoration: none; }
.corner-card a:hover { text-decoration: underline; }
.corner-card-close {
  position: absolute; top: 8px; right: 8px; width: 22px; height: 22px;
  border-radius: 50%; background: transparent; border: none; color: #777;
  font-size: 16px; line-height: 1; cursor: pointer; display: flex;
  align-items: center; justify-content: center; transition: color .15s, background .15s;
}
.corner-card-close:hover { color: #ddd; background: rgba(255,255,255,.06); }
.logo-mark {
  width: 11px; height: 11px; flex-shrink: 0;
  background-image: url('../assets/images/logo.png');
  background-size: contain; background-repeat: no-repeat; background-position: center;
}
.brand-float .wordmark { font-size: 13.5px; font-weight: 700; letter-spacing: -0.01em; color: var(--white); }
.brand-float .tag { font-size: 9.5px; color: #8f8f8f; text-transform: uppercase; letter-spacing: .08em; margin-left: 6px; padding-left: 8px; border-left: 1px solid #333; }

/* ---- floating left panel ---- */
.panel {
  position: fixed; top: 16px; left: 16px; bottom: 16px; width: 340px; z-index: 500;
  background: rgba(10,10,10,.86); backdrop-filter: blur(14px);
  border: 1px solid #262626; border-radius: 16px;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,.5);
}
.panel-scroll { overflow-y: auto; padding: 18px 18px 16px; flex: 1; }
.panel-scroll::-webkit-scrollbar { width: 6px; }
.panel-scroll::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }

.panel h1 { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.panel-header-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.info-btn {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  background: #1b1b1b; border: 1px solid #333; color: #999;
  font-size: 13px; line-height: 1; cursor: pointer; display: flex;
  align-items: center; justify-content: center; padding: 0;
  transition: border-color .15s, color .15s;
}
.info-btn:hover { border-color: var(--gold); color: var(--gold); }
.panel .sub { color: #9a9a9a; font-size: 12.5px; margin: 0 0 18px; line-height: 1.5; }
.panel h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #8a8a8a; margin: 18px 0 12px; font-weight: 600; }
.panel h2:first-of-type { margin-top: 0; }

/* ---- unit toggle ---- */
.unit-toggle {
  position: relative; display: flex; background: #1b1b1b; border: 1px solid #333;
  border-radius: 100px; padding: 3px; margin-bottom: 16px;
}
.unit-toggle .slider {
  position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px);
  background: var(--gold); border-radius: 100px; transition: transform .22s cubic-bezier(.4,0,.2,1);
}
.unit-toggle.imperial .slider { transform: translateX(100%); }
.unit-toggle button {
  flex: 1; border: none; background: transparent; color: #999; font-family: 'Poppins';
  font-weight: 600; font-size: 12px; padding: 8px 0; border-radius: 100px; cursor: pointer;
  position: relative; z-index: 1; transition: color .18s;
}
.unit-toggle button.active { color: #171200; }

/* ---- form fields ---- */
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12.5px; color: #c9c9c9; margin-bottom: 5px; font-weight: 500; }
.field input[type=number], .field select {
  width: 100%; background: #1b1b1b; border: 1px solid #333; color: var(--white);
  padding: 9px 11px; border-radius: 8px; font-family: 'Poppins'; font-size: 13.5px;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--gold); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.tier-toggles { display: flex; gap: 6px; flex-wrap: wrap; }
.tier-toggle {
  flex: 1; min-width: 60px; text-align: center;
  background: #1b1b1b; border: 1px solid #333; color: #999;
  border-radius: 8px; padding: 9px 6px; font-family: 'Poppins'; font-weight: 600;
  font-size: 12.5px; cursor: pointer; transition: all .15s; user-select: none;
}
.tier-toggle.on { background: rgba(255,199,0,.12); border-color: var(--gold); color: var(--gold); }
.tier-toggle:hover { border-color: #555; }
.tier-toggle.on:hover { border-color: var(--gold); }
.tier-toggle.excluded { border-style: dashed; }
.tier-toggle.excluded.on { background: rgba(239,68,68,.12); border-color: var(--boost); border-style: solid; color: var(--boost); }

.dropzone {
  border: 1.5px dashed #3d3d3d; border-radius: 10px; padding: 16px 12px; text-align: center;
  cursor: pointer; transition: border-color .15s, background .15s; margin-bottom: 10px;
}
.dropzone:hover, .dropzone.drag { border-color: var(--gold); background: #161310; }
.dropzone .fname { font-size: 12px; color: var(--gold); margin-top: 5px; word-break: break-all; }
.dropzone .hint { font-size: 11px; color: #7a7a7a; margin-top: 3px; }
.dropzone svg { width: 19px; height: 19px; stroke: #8f8f8f; }

.btn {
  width: 100%; background: var(--gold); color: #171200; border: none; border-radius: 9px;
  padding: 12px; font-family: 'Poppins'; font-weight: 700; font-size: 13.5px; cursor: pointer;
  transition: transform .1s, box-shadow .15s;
}
.btn:hover { box-shadow: 0 0 0 3px rgba(255,199,0,.18); }
.btn:active { transform: scale(.98); }
.btn:disabled { background: #3a3a3a; color: #777; cursor: not-allowed; box-shadow: none; }

.btn-ghost {
  width: 100%; background: transparent; color: var(--gold); border: 1px solid #3a3524; border-radius: 9px;
  padding: 9px; font-family: 'Poppins'; font-weight: 600; font-size: 12px; cursor: pointer; margin-top: 7px;
}
.btn-ghost:hover { border-color: var(--gold); }

.locbtn {
  display: flex; align-items: center; gap: 6px; justify-content: center;
  width: 100%; background: #1b1b1b; border: 1px solid #333; color: #ddd; border-radius: 9px;
  padding: 9px; font-family: 'Poppins'; font-weight: 600; font-size: 12px; cursor: pointer; margin-bottom: 14px;
}
.locbtn:hover { border-color: #555; }
.locbtn svg { width: 14px; height: 14px; stroke: var(--gold); }

/* ---- results ---- */
.verdict {
  display: flex; align-items: flex-start; gap: 9px; padding: 11px 13px; border-radius: 10px; margin-bottom: 14px;
  font-size: 12.5px; font-weight: 600; line-height: 1.4;
}
.verdict.ok { background: rgba(74,222,128,.1); border: 1px solid rgba(74,222,128,.35); color: var(--eco); }
.verdict.warn { background: rgba(255,199,0,.1); border: 1px solid rgba(255,199,0,.4); color: var(--gold); }
.verdict.bad { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.35); color: var(--boost); }
.verdict .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; margin-top: 4px; }

.closecall-note {
  font-size: 11.5px; color: var(--gold); background: rgba(255,199,0,.06);
  border: 1px solid rgba(255,199,0,.25); border-radius: 9px; padding: 9px 12px;
  margin: -6px 0 14px; line-height: 1.5;
}

.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat { background: #151515; border: 1px solid #262626; border-radius: 11px; padding: 11px 13px; }
.stat .k { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: #8a8a8a; margin-bottom: 5px; }
.stat .v { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.stat .v.small { font-size: 13.5px; font-weight: 600; }

.legend { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.legend .item { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: #c9c9c9; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

.chart-wrap { background: #151515; border: 1px solid #262626; border-radius: 12px; padding: 12px 12px 6px; margin-bottom: 14px; }
#elevChart { max-height: 130px; }
.chart-hint { font-size: 10.5px; color: #777; margin-top: 6px; line-height: 1.4; }

.footnote { font-size: 10.5px; color: #666; line-height: 1.55; padding-top: 14px; border-top: 1px solid #222; margin-top: 4px; }
.footnote b { color: #999; }
.footnote-row { margin-top: 8px; }
.footnote a { color: var(--gold); text-decoration: none; }
.footnote a:hover { text-decoration: underline; }

.divider { height: 1px; background: #222; margin: 16px 0; }

/* ---- leaflet popup theme ---- */
.leaflet-popup-content-wrapper { background: #161616; color: #fff; border-radius: 10px; border: 1px solid #333; }
.leaflet-popup-tip { background: #161616; }
.popup-mode { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.popup-row { font-size: 12px; color: #bbb; display: flex; justify-content: space-between; gap: 14px; }

.you-marker { background: var(--gold); width: 14px; height: 14px; border-radius: 50%; border: 3px solid rgba(255,199,0,.35); box-shadow: 0 0 0 2px #000; }

.dead-marker {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--boost); color: #fff; font-weight: 800; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #1a0505; box-shadow: 0 0 0 3px rgba(239,68,68,.3), 0 2px 8px rgba(0,0,0,.5);
}

/* ---- actionable "what would help" suggestions ---- */
.fix-section { margin-bottom: 14px; }
.fix-note { font-size: 12px; color: #bbb; margin-bottom: 10px; line-height: 1.5; }
.fix-card {
  display: flex; gap: 11px; align-items: flex-start;
  background: #151515; border: 1px solid #262626; border-radius: 11px;
  padding: 12px 13px; margin-bottom: 8px;
}
.fix-card--primary { border-color: rgba(255,199,0,.4); background: rgba(255,199,0,.06); }
.fix-icon { font-size: 18px; line-height: 1; flex-shrink: 0; margin-top: 1px; }
.fix-title { font-size: 13px; font-weight: 700; margin-bottom: 3px; }
.fix-desc { font-size: 11.5px; color: #a8a8a8; line-height: 1.45; }

/* ---- first-visit disclaimer overlay ---- */
.overlay-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.65); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.overlay-backdrop.visible { opacity: 1; pointer-events: auto; }
.overlay-card {
  background: #131313; border: 1px solid #2a2a2a; border-radius: 16px;
  padding: 28px 26px 24px; max-width: 360px; width: 100%;
  box-shadow: 0 30px 70px rgba(0,0,0,.6);
  transform: translateY(8px); transition: transform .2s ease;
}
.overlay-backdrop.visible .overlay-card { transform: translateY(0); }
.overlay-icon { font-size: 26px; margin-bottom: 10px; }
.overlay-card h3 { font-size: 16px; font-weight: 700; margin: 0 0 10px; letter-spacing: -0.01em; }
.overlay-card p { font-size: 13px; color: #b5b5b5; line-height: 1.6; margin: 0 0 20px; }
.overlay-card .btn { width: auto; padding: 10px 22px; }

/* ---- mobile ---- */
.panel-handle { display: none; } /* only relevant on mobile — see media query */

@media (max-width: 760px) {
  .panel {
    top: 0; left: 0; right: 0; bottom: auto; width: auto;
    max-height: 66vh; border-radius: 0 0 18px 18px;
    box-shadow: 0 12px 30px rgba(0,0,0,.55);
    transition: max-height .25s ease;
  }
  .panel.collapsed { max-height: 54px; }
  .panel-handle {
    display: flex; flex-direction: column; align-items: center; gap: 5px;
    width: 100%; flex-shrink: 0; background: transparent; border: none;
    padding: 11px 0 9px; cursor: pointer; font-family: 'Poppins';
  }
  .panel-handle-bar { width: 38px; height: 4px; border-radius: 2px; background: #444; }
  .panel-handle-text { font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: #888; }
  .brand-float { display: none; }
  .corner-card { display: none; }
}
