:root{
  --asphalt:#000000;
  --asphalt-2:#121212;
  --asphalt-3:#1C1C1C;
  --line:#333333;
  --paint:#F5C518;
  --paint-dim:#8A6D0A;
  --court-green:#3ED27E;
  --amber:#FF9F1C;
  --chalk:#FFFFFF;
  --chalk-dim:#B3B3B3;
  --shell:#000000;
  --shell-blur:rgba(0,0,0,0.85);
}
body.light{
  --asphalt:#FFFFFF;
  --asphalt-2:#F5F5F5;
  --asphalt-3:#EAEAEA;
  --line:#D0D0D0;
  --paint:#9C7A0A;
  --paint-dim:#F2E4B8;
  --court-green:#1C9A5B;
  --amber:#C2600C;
  --chalk:#000000;
  --chalk-dim:#4A4A4A;
  --shell:#FFFFFF;
  --shell-blur:rgba(255,255,255,0.85);
}
body, .sidebar, .header, .tabbar, .courtrow, .gamecard, .statbox, .badge,
.rowlink, .search, .mapcard, .presencecard, .theme-toggle{
  transition:background .25s ease, background-color .25s ease, border-color .25s ease, color .25s ease;
}
*{box-sizing:border-box; -webkit-tap-highlight-color:transparent;}
html,body{margin:0; padding:0; height:100%; background:var(--asphalt);}
body{
  font-family:'Manrope','Segoe UI',system-ui,sans-serif;
  color:var(--chalk);
  display:flex;
  min-height:100vh;
  background:
    radial-gradient(circle at 12% 0%, rgba(245,197,24,0.07), transparent 38%),
    radial-gradient(circle at 90% 100%, rgba(255,255,255,0.04), transparent 45%),
    var(--asphalt);
}
h1,h2,h3,.display{
  font-family:'Archivo Black','Arial Black',sans-serif;
  text-transform:uppercase;
  letter-spacing:0.01em;
  margin:0;
}
::-webkit-scrollbar{ width:8px; }
::-webkit-scrollbar-thumb{ background:var(--line); border-radius:8px; }

/* ---------- SIDEBAR ---------- */
.sidebar{
  width:220px; flex:none; background:var(--shell); border-right:1px solid var(--line);
  display:flex; flex-direction:column; padding:22px 14px; gap:4px;
  position:sticky; top:0; height:100vh;
}
.brand{ display:flex; align-items:center; gap:8px; padding:6px 10px 26px; }
.brand .mark{
  width:30px; height:30px; border-radius:8px; background:var(--paint);
  display:flex; align-items:center; justify-content:center;
  font-family:'Archivo Black',sans-serif; color:#000000; font-size:14px;
}
.brand b{ font-family:'Archivo Black',sans-serif; font-size:16px; letter-spacing:0.02em;}
.brand-logo-img{ height:45px; width:auto; display:block; }
.navitem{
  display:flex; align-items:center; gap:12px; padding:11px 12px; border-radius:10px;
  color:var(--chalk-dim); font-size:13.5px; font-weight:700; cursor:pointer;
  transition:background .15s ease, color .15s ease;
  text-decoration:none;
}
.navitem:hover{ background:var(--asphalt-3); color:var(--chalk); }
.navitem.on{ background:rgba(245,197,24,0.12); color:var(--paint); }
.navitem .ic{ width:18px; text-align:center; }
.sidebar-foot{ margin-top:auto; padding:12px 10px; }
.sidebar-foot .loc{ font-size:11px; color:var(--chalk-dim); letter-spacing:0.06em; text-transform:uppercase; }
.sidebar-foot .city{ font-size:13px; font-weight:800; margin-top:2px;}

/* ---------- MAIN ---------- */
.main{ flex:1; min-width:0; display:flex; flex-direction:column; }
.header{
  display:flex; align-items:center; justify-content:space-between;
  padding:26px 34px 18px; border-bottom:1px solid var(--line);
  position:sticky; top:0; background:var(--shell-blur); backdrop-filter:blur(8px); z-index:20;
}
.header .eyebrow{ font-size:10.5px; letter-spacing:0.16em; color:var(--paint); text-transform:uppercase; font-weight:800; margin-bottom:4px;}
.header .title{ font-size:24px; }
.search{
  display:flex; align-items:center; gap:8px; padding:10px 16px; background:var(--asphalt-2);
  border:1px solid var(--line); border-radius:10px; color:var(--chalk-dim); font-size:13px; width:280px;
}
.avatarpill{
  width:38px; height:38px; border-radius:10px; background:linear-gradient(135deg, var(--paint), #8A6D0A);
  display:flex; align-items:center; justify-content:center; font-family:'Archivo Black',sans-serif; color:#000000; font-size:15px; cursor:pointer;
  text-decoration:none;
}
.headerright{ display:flex; align-items:center; gap:12px; }
.theme-toggle{
  width:38px; height:38px; border-radius:10px; background:var(--asphalt-2);
  border:1px solid var(--line); color:var(--chalk); font-size:16px;
  display:flex; align-items:center; justify-content:center; cursor:pointer; flex:none;
}
.theme-toggle:hover{ border-color:var(--paint-dim); }

.content{ padding:26px 34px 60px; }
.view{ display:none; }
.view.active{ display:block; animation:fade .25s ease; }
@keyframes fade{ from{opacity:0; transform:translateY(6px);} to{opacity:1; transform:translateY(0);} }

.section-label{ font-size:11.5px; letter-spacing:0.14em; text-transform:uppercase; color:var(--chalk-dim); font-weight:800; margin:26px 0 12px;}
.section-label:first-child{ margin-top:0; }

/* Map + court grid */
.layout-2col{ display:grid; grid-template-columns:1.3fr 1fr; gap:22px; align-items:start; }
.mapcard{
  height:360px; border-radius:20px; position:relative; overflow:hidden;
  border:1px solid var(--line);
}
#leafletMap{ position:absolute; inset:0; z-index:1; }
.leaflet-container{ background:var(--asphalt-2) !important; font-family:inherit; }
.pin-icon{ width:14px; height:14px; border-radius:50%; box-shadow:0 0 0 6px rgba(0,0,0,0.25); }
.pin-icon.live{ background:var(--court-green); animation:pulse 1.8s infinite; }
.pin-icon.recent{ background:var(--amber); }
.pin-icon.quiet{ background:var(--chalk-dim); }
@keyframes pulse{ 0%{box-shadow:0 0 0 0 rgba(62,210,126,0.5)} 70%{box-shadow:0 0 0 14px rgba(62,210,126,0)} 100%{box-shadow:0 0 0 0 rgba(62,210,126,0)} }
.you{ position:absolute; bottom:16px; right:18px; font-size:10px; color:var(--chalk-dim); letter-spacing:0.1em; text-transform:uppercase; z-index:5;}
.legend{ position:absolute; top:16px; left:18px; display:flex; gap:14px; font-size:10.5px; color:var(--chalk-dim); z-index:5; background:var(--shell-blur); padding:6px 10px; border-radius:8px;}
.legend span{ display:flex; align-items:center; gap:5px; }
.legend i{ width:8px; height:8px; border-radius:50%; display:inline-block; }
.leaflet-popup-content-wrapper{ background:var(--asphalt-2); color:var(--chalk); border:1px solid var(--line); }
.leaflet-popup-tip{ background:var(--asphalt-2); }
.leaflet-popup-content b{ display:block; margin-bottom:3px; }
.leaflet-popup-content a{ color:var(--paint); font-weight:700; text-decoration:none; }

.courtrow{
  padding:15px; background:var(--asphalt-2); border:1px solid var(--line);
  border-radius:14px; display:flex; gap:12px; align-items:center; cursor:pointer;
  transition:border-color .15s ease, transform .1s ease; margin-bottom:10px;
}
.courtrow:hover{ border-color:var(--paint-dim); transform:translateX(2px); }
.courtrow .dot{ width:9px; height:9px; border-radius:50%; flex:none; }
.dot.live{ background:var(--court-green); box-shadow:0 0 0 4px rgba(62,210,126,0.15);}
.dot.recent{ background:var(--amber); }
.dot.quiet{ background:var(--chalk-dim); }
.courtrow .meta{ flex:1; }
.courtrow .name{ font-size:14.5px; font-weight:800; }
.courtrow .sub{ font-size:11.5px; color:var(--chalk-dim); margin-top:3px; }
.courtrow .dist{ font-size:11px; color:var(--chalk-dim); text-align:right; flex:none; }

.cta{
  display:inline-block; padding:13px 22px; text-align:center;
  background:var(--paint); color:#000000; font-weight:800; letter-spacing:0.03em;
  border-radius:12px; font-size:13.5px; text-transform:uppercase; border:none; cursor:pointer;
  box-shadow:0 10px 20px -8px rgba(245,197,24,0.5);
  text-decoration:none;
}
.cta.ghost{ background:transparent; color:var(--chalk); border:1.5px solid var(--line); box-shadow:none; }
.cta:active{ transform:scale(0.98); }
.cta:disabled{ opacity:0.5; cursor:not-allowed; }

/* Court detail */
.courtdetail{ display:grid; grid-template-columns:1.4fr 1fr; gap:26px; align-items:start; }
.hero{
  height:220px; border-radius:20px; position:relative; overflow:hidden;
  background:linear-gradient(160deg, #1A1400 0%, #0D0A00 60%, #000000 100%);
  border:1px solid var(--line); display:flex; align-items:flex-end; padding:20px;
}
.hero::before{ content:""; position:absolute; inset:0; background:repeating-radial-gradient(circle at 30% 40%, rgba(245,197,24,0.10) 0 2px, transparent 2px 70px); }
.hero .hooptag{ position:relative; font-size:12px; color:var(--amber); font-weight:800; letter-spacing:0.08em; text-transform:uppercase; }
.statgrid{ display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-top:16px; }
.statbox{ background:var(--asphalt-2); border:1px solid var(--line); border-radius:12px; padding:13px 15px; }
.statbox .k{ font-size:10px; color:var(--chalk-dim); text-transform:uppercase; letter-spacing:0.1em; }
.statbox .v{ font-size:15px; font-weight:800; margin-top:4px; }
.badgewrap{ display:flex; flex-wrap:wrap; gap:8px; margin-top:16px; }
.badge{ font-size:11.5px; padding:7px 12px; border-radius:10px; background:var(--asphalt-2); border:1px solid var(--line); color:var(--chalk-dim); }

.presencecard{
  padding:20px; border-radius:18px;
  background:linear-gradient(135deg, rgba(62,210,126,0.12), rgba(62,210,126,0.02));
  border:1px solid rgba(62,210,126,0.35);
}
.presencecard .num{ font-family:'Archivo Black',sans-serif; font-size:44px; color:var(--court-green); line-height:1; }
.presencecard .lbl{ font-size:12px; color:var(--chalk-dim); margin-top:4px; }
.presencecard .next{ font-size:12px; color:var(--chalk-dim); margin-top:10px; }
.presencecard .cta{ width:100%; margin-top:16px; }

/* Games */
.filterrow{ display:flex; gap:8px; margin-bottom:18px; flex-wrap:wrap; }
.filterchip{ font-size:12px; padding:9px 15px; border-radius:20px; background:var(--asphalt-2); border:1px solid var(--line); color:var(--chalk-dim); cursor:pointer; }
.filterchip.on{ background:var(--paint); border-color:var(--paint); color:#000000; font-weight:800; }
.gamesgrid{ display:grid; grid-template-columns:repeat(auto-fill, minmax(260px,1fr)); gap:16px; }
.gamecard{ padding:18px; background:var(--asphalt-2); border:1px solid var(--line); border-radius:16px; }
.gamecard .row1{ display:flex; justify-content:space-between; align-items:flex-start;}
.gamecard .gname{ font-size:15.5px; font-weight:800; }
.gamecard .gtime{ font-size:11.5px; color:var(--amber); font-weight:700;}
.gamecard .gsub{ font-size:12px; color:var(--chalk-dim); margin:5px 0 12px; }
.fillbar{ height:6px; border-radius:4px; background:var(--line); overflow:hidden; margin-bottom:12px; }
.fillbar > i{ display:block; height:100%; background:var(--court-green); }
.gamecard .row2{ display:flex; justify-content:space-between; align-items:center; }
.tag{ font-size:11px; padding:4px 9px; border-radius:20px; background:rgba(255,255,255,0.06); color:var(--chalk-dim);}
.tag.hot{ background:rgba(245,197,24,0.14); color:var(--paint); font-weight:700;}
.joinbtn{ font-size:11.5px; font-weight:800; text-transform:uppercase; color:var(--paint); background:rgba(245,197,24,0.12); border:1px solid var(--paint-dim); padding:9px 16px; border-radius:10px; cursor:pointer;}
.joinbtn:disabled{ opacity:0.5; cursor:not-allowed; }
.joinbtn.joined{ background:rgba(62,210,126,0.14); color:var(--court-green); border-color:rgba(62,210,126,0.4); }

/* Check-in */
.checkinwrap{ display:flex; flex-direction:column; align-items:center; justify-content:center; padding:50px 20px; text-align:center; gap:20px; }
.ring{ width:180px; height:180px; border-radius:50%; border:2px dashed var(--court-green); display:flex; align-items:center; justify-content:center; position:relative; }
.ring::before{ content:""; position:absolute; inset:16px; border-radius:50%; background:rgba(62,210,126,0.08); animation:pulse 1.8s infinite;}
.ring .big{ font-family:'Archivo Black',sans-serif; font-size:48px; color:var(--court-green); position:relative;}
.checkinwrap h2{ font-size:24px; }
.checkinwrap p{ font-size:13.5px; color:var(--chalk-dim); max-width:320px; line-height:1.6; margin:0;}
.stampfeed{ font-size:12px; color:var(--chalk-dim); }
.stampfeed b{ color:var(--chalk); }
.checkinbtns{ display:flex; gap:10px; }

/* Profile */
.profilehead{ display:flex; gap:18px; align-items:center; margin-bottom:24px; }
.avatar{ width:76px; height:76px; border-radius:18px; background:linear-gradient(135deg, var(--paint), #8A6D0A); display:flex; align-items:center; justify-content:center; font-family:'Archivo Black',sans-serif; font-size:26px; color:#000000; }
.profilehead .name{ font-size:21px; font-weight:800; }
.profilehead .pos{ font-size:12.5px; color:var(--paint); font-weight:700; margin-top:3px;}
.profilehead .loc{ font-size:11.5px; color:var(--chalk-dim); margin-top:3px;}
.profgrid{ display:grid; grid-template-columns:1fr 1fr; gap:22px; }
.rowlink{ padding:15px 17px; background:var(--asphalt-2); border:1px solid var(--line); border-radius:12px; display:flex; justify-content:space-between; align-items:center; font-size:13.5px; margin-bottom:10px; }
.rowlink .l{ color:var(--chalk-dim); }
.rowlink .r{ font-weight:700; }

/* ---------- MOBILE TAB BAR (hidden on desktop) ---------- */
.tabbar{
  display:none;
  position:fixed; left:0; right:0; bottom:0; z-index:60;
  justify-content:space-around; align-items:center;
  padding:8px 4px calc(10px + env(safe-area-inset-bottom));
  background:var(--shell-blur); backdrop-filter:blur(10px);
  border-top:1px solid var(--line);
}
.tabbar .tabitem{
  display:flex; flex-direction:column; align-items:center; gap:3px;
  color:var(--chalk-dim); font-size:9.5px; letter-spacing:0.03em; text-transform:uppercase;
  font-weight:700; padding:6px 10px; border-radius:10px; min-width:56px;
  text-decoration:none;
}
.tabbar .tabitem .ic{ font-size:19px; line-height:1; }
.tabbar .tabitem.on{ color:var(--paint); }

@media (max-width: 880px){
  body{ padding-bottom:0; }
  .sidebar{ display:none; }
  .tabbar{ display:flex; }

  .header{
    padding:16px 16px 12px;
    flex-wrap:wrap;
    row-gap:12px;
  }
  .header .title{ font-size:20px; }
  .header .eyebrow{ font-size:10px; }
  .headerright{ width:100%; gap:10px; }
  .search{ width:auto; flex:1; padding:11px 14px; font-size:13px; }
  .avatarpill{ width:38px; height:38px; flex:none; }

  .content{ padding:16px 16px calc(88px + env(safe-area-inset-bottom)); }

  .layout-2col, .courtdetail, .profgrid{ grid-template-columns:1fr; gap:16px; }
  .mapcard{ height:220px; border-radius:16px; }
  .legend{ font-size:9.5px; gap:10px; top:12px; left:14px; }

  .section-label{ margin:20px 0 10px; font-size:11px; }

  .courtrow{ padding:13px; border-radius:12px; }
  .courtrow .name{ font-size:14px; }
  .courtrow .sub{ font-size:11px; }

  .hero{ height:170px; border-radius:16px; padding:16px; }
  .statgrid{ grid-template-columns:1fr 1fr; gap:8px; }
  .statbox{ padding:11px 13px; border-radius:10px; }
  .badgewrap{ gap:6px; }
  .badge{ font-size:11px; padding:6px 10px; }

  .presencecard{ padding:18px; border-radius:16px; }
  .presencecard .num{ font-size:38px; }

  .gamesgrid{ grid-template-columns:1fr; gap:12px; }
  .gamecard{ padding:15px; border-radius:14px; }
  .filterrow{ flex-wrap:nowrap; overflow-x:auto; padding-bottom:4px; -webkit-overflow-scrolling:touch; }
  .filterrow::-webkit-scrollbar{ display:none; }
  .filterchip{ flex:none; }

  .checkinwrap{ padding:30px 16px; gap:16px; }
  .ring{ width:150px; height:150px; }
  .ring .big{ font-size:40px; }
  .checkinwrap h2{ font-size:20px; }
  .checkinwrap p{ font-size:13px; }
  .checkinbtns{ flex-direction:column; width:100%; }
  .checkinbtns .cta{ width:100%; }

  .profilehead{ margin-bottom:18px; }
  .avatar{ width:62px; height:62px; border-radius:14px; font-size:22px; }
  .profilehead .name{ font-size:18px; }
  .rowlink{ padding:13px 15px; font-size:13px; }

  .cta{ padding:14px 20px; font-size:13px; }
}

/* ---------- SPLASH ---------- */
.splash{
  position:fixed; inset:0; z-index:999;
  background:var(--asphalt);
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  transition:opacity .5s ease;
}
.splash.hide{ opacity:0; pointer-events:none; }
.splash-logo{ display:flex; flex-direction:column; align-items:center; gap:2px; }
.splash-mark{
  width:64px; height:64px; border-radius:18px; background:var(--paint);
  display:flex; align-items:center; justify-content:center;
  font-family:'Archivo Black',sans-serif; font-size:26px; color:#000000;
  box-shadow:0 16px 34px -12px rgba(245,197,24,0.6);
  margin-bottom:16px;
}
.splash-word{ font-family:'Archivo Black',sans-serif; font-size:22px; letter-spacing:0.03em; color:var(--chalk); }
.splash-logo-img{ width:min(140px, 40vw); height:auto; display:block; }
.splash-tag{ font-size:10.5px; letter-spacing:0.16em; text-transform:uppercase; color:var(--chalk-dim); margin-top:6px; }
.splash-barwrap{
  position:absolute; left:50%; bottom:48px; transform:translateX(-50%);
  width:200px; height:4px; border-radius:4px; background:var(--line); overflow:hidden;
}
.splash-bar{ height:100%; width:0%; background:var(--paint); border-radius:4px; }

@media (max-width: 420px){
  .header .title{ font-size:18px; }
  .presencecard .num{ font-size:34px; }
  .ring{ width:130px; height:130px; }
  .ring .big{ font-size:34px; }
}

/* ---------- AUTH PAGES ---------- */
.authwrap{ flex:1; display:flex; align-items:center; justify-content:center; min-height:100vh; padding:24px; }
.authcard{ width:100%; max-width:380px; background:var(--asphalt-2); border:1px solid var(--line); border-radius:20px; padding:32px 28px; }
.authcard .brand{ padding:0 0 22px; justify-content:center; }
.authcard h1{ font-size:19px; text-align:center; margin-bottom:6px; }
.authcard .subtext{ font-size:12.5px; color:var(--chalk-dim); text-align:center; margin-bottom:22px; }
.field{ margin-bottom:14px; }
.field label{ display:block; font-size:11.5px; color:var(--chalk-dim); text-transform:uppercase; letter-spacing:0.06em; font-weight:700; margin-bottom:6px; }
.field input, .field select{
  width:100%; padding:12px 14px; background:var(--asphalt-3); border:1px solid var(--line);
  border-radius:10px; color:var(--chalk); font-size:14px; font-family:inherit;
}
.field input:focus, .field select:focus{ outline:none; border-color:var(--paint-dim); }
.autherr{ background:rgba(245,197,24,0.1); border:1px solid var(--paint-dim); color:var(--paint); font-size:12.5px; padding:10px 14px; border-radius:10px; margin-bottom:14px; }
.authcard .cta{ width:100%; margin-top:6px; }
.authlink{ text-align:center; font-size:12.5px; color:var(--chalk-dim); margin-top:18px; }
.authlink a{ color:var(--paint); font-weight:700; text-decoration:none; }
.modalbg{ position:fixed; inset:0; background:rgba(0,0,0,0.6); z-index:200; display:flex; align-items:center; justify-content:center; padding:20px; }
.modalcard{ width:100%; max-width:420px; background:var(--asphalt-2); border:1px solid var(--line); border-radius:20px; padding:26px; }
.modalcard h3{ font-size:16px; margin-bottom:16px; }
.modal-actions{ display:flex; gap:10px; margin-top:8px; }
.modal-actions .cta{ flex:1; }
