:root{
  --bg: #0b1020;
  --card: rgba(255,255,255,.06);
  --card2: rgba(255,255,255,.10);
  --stroke: rgba(255,255,255,.12);
  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.70);
  --brand: #7c5cff;
  --brand2: #2ee59d;
  --danger: #ff4d6d;
  --shadow: 0 16px 60px rgba(0,0,0,.35);
  --radius: 18px;
  --radius-lg: 26px;
}

*{ box-sizing: border-box; }
html, body{ height: 100%; }
body{
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background:
    radial-gradient(1200px 700px at 20% -10%, rgba(124,92,255,.35), transparent 60%),
    radial-gradient(1000px 700px at 90% 10%, rgba(46,229,157,.22), transparent 55%),
    radial-gradient(1000px 900px at 40% 120%, rgba(124,92,255,.18), transparent 60%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.container{
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
}

.header{
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(11,16,32,.72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--stroke);
}

.header__inner{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
}

.brand{
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand__logo{
  width: 42px;
  height: 42px;
  border-radius: 14px;
  object-fit: cover;
  box-shadow: var(--shadow);
  flex-shrink: 0;
  display: block;
}
.brand__name{ font-weight: 800; }
.brand__tagline{ font-size: 12px; color: var(--muted); }

.nav{ display: flex; gap: 8px; }
.nav__btn{
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--stroke);
  padding: 8px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.nav__btn:hover{ color: var(--text); border-color: rgba(255,255,255,.22); }
.nav__btn.is-active{
  color: var(--text);
  background: rgba(124,92,255,.18);
  border-color: rgba(124,92,255,.45);
}

.main{
  padding: 22px 0 26px;
}

.eyebrow{
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.panel__title{
  font-size: 18px;
  font-weight: 900;
  margin-top: 2px;
}

.card{
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card--soft{
  background: rgba(255,255,255,.04);
  box-shadow: none;
}
.card--map{
  padding: 0;
  overflow: hidden;
}

h1,h2,h3{ margin: 0 0 10px; }
p{ margin: 0 0 12px; }
.muted{ color: var(--muted); }
.strong{ font-weight: 800; }

.form{ margin-top: 12px; display: grid; gap: 14px; }
.grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.grid-2{
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 14px;
  align-items: start;
}
@media (max-width: 900px){
  .grid-2{ grid-template-columns: 1fr; }
  .grid{ grid-template-columns: 1fr; }
  .nav{ flex-wrap: wrap; justify-content: flex-end; }
}

.field{ display: grid; gap: 6px; }
.field__label{ font-size: 13px; color: var(--muted); }
input{
  width: 100%;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.20);
  color: var(--text);
  outline: none;
}
input:focus{
  border-color: rgba(124,92,255,.65);
  box-shadow: 0 0 0 3px rgba(124,92,255,.20);
}

.checkbox{
  display: flex;
  gap: 10px;
  align-items: flex-start;
  color: var(--muted);
  line-height: 1.35;
}
.checkbox input{ width: 18px; height: 18px; margin-top: 2px; }

.actions{ display: flex; gap: 10px; flex-wrap: wrap; }
.btn{
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.06);
  color: var(--text);
  border-radius: 14px;
  padding: 10px 12px;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.btn--sm{
  padding: 7px 10px;
  border-radius: 12px;
  font-size: 12px;
}
.btn:hover{ background: rgba(255,255,255,.10); border-color: rgba(255,255,255,.22); }
.btn:active{ transform: translateY(1px); }
.btn:disabled{ opacity: .55; cursor: not-allowed; }
.btn--primary{
  background: linear-gradient(135deg, rgba(124,92,255,.95), rgba(46,229,157,.85));
  border-color: rgba(255,255,255,.18);
  color: #061023;
  font-weight: 800;
}
.btn--ghost{
  background: transparent;
}
.btn--danger{
  background: rgba(255,77,109,.10);
  border-color: rgba(255,77,109,.35);
}
.btn--danger:hover{
  background: rgba(255,77,109,.16);
  border-color: rgba(255,77,109,.50);
}

.row{ display: flex; gap: 12px; align-items: center; }
.row--space{ justify-content: space-between; }
.pill{
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(0,0,0,.18);
  color: var(--muted);
  font-size: 12px;
}
.pill.is-on{
  background: rgba(46,229,157,.12);
  border-color: rgba(46,229,157,.38);
  color: rgba(255,255,255,.9);
}
.pill.is-off{
  background: rgba(255,77,109,.10);
  border-color: rgba(255,77,109,.35);
}

.stats{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}
.stats--2{
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 10px;
}
@media (max-width: 520px){
  .stats{ grid-template-columns: 1fr; }
}
.stat{
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  padding: 12px;
  background: rgba(0,0,0,.18);
}
.stat__label{ color: var(--muted); font-size: 12px; }
.stat__value{ font-size: 22px; font-weight: 900; margin-top: 6px; }

.notice{
  margin-top: 14px;
  border-radius: 16px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.16);
  color: var(--muted);
  min-height: 46px;
}
.notice.is-good{
  border-color: rgba(46,229,157,.34);
  background: rgba(46,229,157,.10);
  color: rgba(255,255,255,.92);
}
.notice.is-warn{
  border-color: rgba(255,170,0,.35);
  background: rgba(255,170,0,.10);
  color: rgba(255,255,255,.92);
}

.details{
  margin-top: 12px;
  color: var(--muted);
}
.details summary{ cursor: pointer; }
.details ul{ margin: 10px 0 0; }

.sep{
  border: none;
  height: 1px;
  background: rgba(255,255,255,.12);
  margin: 16px 0;
}

.list{ display: grid; gap: 10px; }
.list__row{
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.14);
}

.map{
  height: 520px;
  width: 100%;
}
@media (max-width: 900px){
  .map{ height: 460px; }
}
.map__hint{
  padding: 10px 12px 14px;
  border-top: 1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.10);
  font-size: 12px;
}

/* Fullscreen play layout: map + side panel overlay */
.play{
  position: relative;
  height: calc(100dvh - 74px);
  min-height: 620px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.10);
  box-shadow: var(--shadow);
  background: rgba(0,0,0,.18);
}
.play::after{
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 460px at 80% 20%, rgba(124,92,255,.10), transparent 55%),
    radial-gradient(900px 520px at 10% 120%, rgba(46,229,157,.10), transparent 60%),
    linear-gradient(180deg, rgba(0,0,0,.12), rgba(0,0,0,.00) 30%, rgba(0,0,0,.14));
  mix-blend-mode: screen;
  opacity: .75;
}
.play__map{
  position: absolute;
  inset: 0;
}
.play .map{
  height: 100%;
  width: 100%;
}
.weather-fx{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  opacity: .85;
  mix-blend-mode: screen;
}
.play__panel{
  position: absolute;
  top: 14px;
  right: 14px;
  width: min(420px, calc(100% - 28px));
  z-index: 5;
}
.play__card{
  backdrop-filter: blur(16px);
  background: rgba(11,16,32,.62);
  border-color: rgba(255,255,255,.14);
}
.panel__hint{
  margin-top: 10px;
  font-size: 12px;
}

@media (max-width: 720px){
  .play{
    height: calc(100dvh - 64px);
    min-height: 560px;
  }
  .play__panel{
    left: 14px;
    right: 14px;
    top: auto;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    width: auto;
    max-height: 56vh; /* leave visible map area to drag */
    overflow: hidden;
  }
  .play__card{
    padding: 14px;
    border-radius: var(--radius-lg);
    box-shadow: 0 18px 65px rgba(0,0,0,.48);
  }
  .stats{
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Collapsible panel: keep map draggable */
.play.is-panel-collapsed .play__panel{
  max-height: none;
  overflow: visible;
}
.play.is-panel-collapsed .play__card{
  padding: 12px 14px;
}
.play.is-panel-collapsed .stats,
.play.is-panel-collapsed .actions,
.play.is-panel-collapsed .notice,
.play.is-panel-collapsed details,
.play.is-panel-collapsed .panel__hint{
  display: none !important;
}

/* Mobile map gestures */
#map{
  touch-action: pan-x pan-y;
}

/* App-like bottom sheet affordance on mobile */
.sheet-handle{
  display: none;
}
@media (max-width: 720px){
  .sheet-handle{
    display: grid;
    place-items: center;
    margin: -2px 0 10px;
  }
  .sheet-handle::before{
    content: "";
    width: 46px;
    height: 5px;
    border-radius: 999px;
    background: rgba(255,255,255,.26);
  }

  .play__panel{
    border-radius: var(--radius-lg);
  }
  .play__card{
    max-height: 56vh;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Make primary actions feel like native controls */
  .actions{
    gap: 10px;
  }
  .btn{
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce){
  .btn{ transition: none; }
  .play__card{ scroll-behavior: auto; }
}

/* Reduce visible tile seams / grid lines on some phones */
.leaflet-tile{
  outline: 1px solid transparent;
  border: 0.5px solid transparent;
  box-shadow: 0 0 1px rgba(0,0,0,.01);
  image-rendering: auto;
}
.leaflet-tile-container{
  transform: translateZ(0);
}
.maplibregl-canvas{
  outline: none;
  transform: translateZ(0.001px);
  backface-visibility: hidden;
  image-rendering: auto;
}
.maplibregl-canvas-container{
  background: #070a14;
}

@media (max-width: 520px){
  .stats{ grid-template-columns: 1fr; }
  .stats--2{ grid-template-columns: 1fr; }
}

.footer{
  border-top: 1px solid var(--stroke);
  padding: 18px 0 26px;
  background: rgba(0,0,0,.12);
}
.footer__inner{
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.view[hidden]{ display: none !important; }

/* Leaflet tweaks */
.leaflet-control-attribution{
  background: rgba(0,0,0,.45) !important;
  color: rgba(255,255,255,.75) !important;
  border-radius: 10px !important;
  padding: 4px 8px !important;
}
.leaflet-bar a{
  background: rgba(0,0,0,.40) !important;
  color: rgba(255,255,255,.85) !important;
  border-color: rgba(255,255,255,.18) !important;
}
.leaflet-bar a:hover{ background: rgba(0,0,0,.55) !important; }

/* 3D map container helper */
.map.is-3d{
  background: #070a14;
}

.leaderboard{
  display: grid;
  gap: 10px;
  margin-top: 12px;
}
.leaderboard__row{
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.14);
}
.leaderboard__pos{
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 900;
  background: rgba(124,92,255,.18);
  border: 1px solid rgba(124,92,255,.35);
}
.leaderboard__name{ font-weight: 800; }
.leaderboard__meta{ color: var(--muted); font-size: 12px; }
.leaderboard__score{ font-weight: 900; }

body.is-tv .header,
body.is-tv .footer{
  display: none;
}
body.is-tv .container{
  width: calc(100% - 32px);
}
body.is-tv .card{
  padding: 22px;
}
