:root {
  --wood-dark: #5a3a1b;
  --wood-mid: #7a4f27;
  --wood-light: #9c6b38;
  --cream: #fff8ec;
  --green-1: #2ec27e;
  --green-2: #1fa968;
  --amber-1: #ffb224;
  --amber-2: #f08c00;
  --panel-bg: rgba(10, 46, 24, .92);
  --radius: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: 'Poppins', system-ui, sans-serif;
  color: #fff;
  overflow: hidden;
}

/* ===================== LAYOUT ===================== */
.page {
  position: relative;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- HEADER (same as homepage) ---------- */
header {
  flex: 0 0 auto;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px clamp(14px, 3vw, 40px);
  /* pattern texture layered over a green-to-black gradient */
  background:
    linear-gradient(100deg, rgba(27, 94, 32, .92) 0%, rgba(10, 46, 24, .95) 45%, rgba(0, 0, 0, .96) 100%),
    url('pattern-2.webp');
  background-size: cover, 240px;
  background-position: center, center;
  background-repeat: no-repeat, repeat;
  background-blend-mode: normal, overlay;
  border-bottom: 2px solid white;
  box-shadow: 0 4px 18px rgba(0,0,0,.4);
  animation: slideDown .7s ease both;
}
header img.logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.5));
}
header .org { line-height: 1.3; text-shadow: 0 2px 6px rgba(0,0,0,.7); }
header .org .l1 { font-weight: 700; font-size: clamp(.74rem, 1.5vw, .98rem); letter-spacing: .4px; }
header .org .l2 { font-weight: 500; font-size: clamp(.62rem, 1.2vw, .8rem); opacity: .92; }

.back-home {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--cream);
  font-weight: 600;
  font-size: .85rem;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(0,0,0,.25);
  border: 1px solid rgba(255,215,120,.35);
  transition: background .2s ease, transform .15s ease;
  white-space: nowrap;
}
.back-home:hover { background: rgba(0,0,0,.45); transform: translateY(-2px); }

/* ---------- MAP ---------- */
.map-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}
#map { position: absolute; inset: 0; }

/* loading / no-key notice */
.map-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  background: #11351f;
  color: #d8f3e3;
  font-size: .95rem;
  line-height: 1.6;
}

/* ===================== GAME-UI BUTTONS ===================== */
/* floating custom actions (Filter / Rekap) */
.map-actions {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: fadeInLeft .6s ease .2s both;
}

.game-btn {
  --c1: var(--green-1);
  --c2: var(--green-2);
  position: relative;
  display: inline-flex;
  align-items: stretch;
  min-width: 150px;
  border: none;
  cursor: pointer;
  background: transparent;
  color: #fff;
  filter: drop-shadow(0 5px 0 rgba(0,0,0,.3));
  transition: transform .15s ease, filter .15s ease;
  isolation: isolate;
}
.game-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, var(--c1), var(--c2));
  border-radius: 10px;
  border-top: 2px solid rgba(255,255,255,.4);
  clip-path: polygon(0 0, 100% 0, 100% 72%, 90% 100%, 0 100%);
}
.game-btn .ico {
  flex: 0 0 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 6px 0 6px 6px;
  border-radius: 8px;
  background: rgba(255,255,255,.9);
  color: var(--c2);
}
.game-btn .ico svg { width: 20px; height: 20px; }
.game-btn .txt {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 12px 16px 12px 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-size: .92rem;
  text-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.game-btn:hover { transform: translateY(-3px) scale(1.03); filter: drop-shadow(0 8px 0 rgba(0,0,0,.32)); }
.game-btn:active { transform: translateY(2px); filter: drop-shadow(0 2px 0 rgba(0,0,0,.3)); }
.game-btn.alt { --c1: var(--amber-1); --c2: var(--amber-2); }
.game-btn.alt .ico { color: var(--amber-2); }

/* ===================== DRAWERS ===================== */
.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  width: min(380px, 88vw);
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  backdrop-filter: blur(8px);
  box-shadow: 0 0 40px rgba(0,0,0,.5);
  transition: transform .4s cubic-bezier(.22,.61,.36,1);
}
.drawer--left { left: 0; border-right: 4px solid var(--wood-dark); transform: translateX(-105%); }
.drawer--right { right: 0; border-left: 4px solid var(--wood-dark); transform: translateX(105%); }
.drawer.open { transform: translateX(0); }

.drawer-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px;
  background:
    repeating-linear-gradient(180deg,
      var(--wood-mid) 0, var(--wood-mid) 20px,
      var(--wood-dark) 21px, var(--wood-mid) 22px);
  border-bottom: 3px solid var(--wood-dark);
}
.drawer-head h2 {
  font-family: 'Baloo 2', cursive;
  font-size: 1.25rem;
  letter-spacing: 1px;
  color: var(--cream);
  text-shadow: 0 1px 0 #3a2410, 0 2px 4px rgba(0,0,0,.5);
}
.drawer-close {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  border: none;
  border-radius: 8px;
  background: rgba(0,0,0,.3);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  transition: background .2s ease, transform .2s ease;
}
.drawer-close:hover { background: rgba(0,0,0,.55); transform: rotate(90deg); }

.drawer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px;
}

/* ---------- FILTER FORM ---------- */
.filter-group { margin-bottom: 20px; animation: fadeUp .4s ease both; }
.filter-group > label.group-title {
  display: block;
  font-weight: 700;
  font-size: .82rem;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: #ffe3a0;
  margin-bottom: 10px;
}
.filter-group select,
.filter-group input[type="search"] {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,215,120,.3);
  background: rgba(0,0,0,.25);
  color: #fff;
  font-size: .9rem;
  outline: none;
  transition: border-color .2s ease, background .2s ease;
}
.filter-group select:focus,
.filter-group input[type="search"]:focus {
  border-color: var(--green-1);
  background: rgba(0,0,0,.4);
}
.filter-group select option { color: #111; }

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .2s ease;
}
.check:hover { background: rgba(255,255,255,.08); }
.check input { width: 18px; height: 18px; accent-color: var(--green-1); }
.check .dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; }

.drawer-foot {
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  padding: 14px 18px;
  border-top: 2px solid rgba(255,215,120,.25);
  background: rgba(0,0,0,.2);
}
.btn-wood {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  font-size: .82rem;
  color: #fff;
  background: linear-gradient(180deg, var(--green-1), var(--green-2));
  border-top: 2px solid rgba(255,255,255,.4);
  box-shadow: 0 4px 0 rgba(0,0,0,.3);
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn-wood.ghost { background: linear-gradient(180deg, #6b7280, #4b5563); }
.btn-wood:hover { transform: translateY(-2px); box-shadow: 0 6px 0 rgba(0,0,0,.3); }
.btn-wood:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.3); }

/* ---------- REKAP LIST ---------- */
.rekap-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.stat {
  padding: 12px;
  border-radius: 12px;
  background: rgba(0,0,0,.25);
  border: 1px solid rgba(255,215,120,.25);
  text-align: center;
  animation: popIn .4s cubic-bezier(.17,.67,.3,1.4) both;
}
.stat .num { font-family: 'Baloo 2', cursive; font-size: 1.6rem; font-weight: 800; color: #ffe3a0; }
.stat .lbl { font-size: .72rem; opacity: .85; text-transform: uppercase; letter-spacing: .5px; }

.data-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  margin-bottom: 10px;
  border-radius: 12px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  cursor: pointer;
  transition: background .2s ease, transform .2s ease, border-color .2s ease;
  animation: fadeUp .4s ease both;
}
.data-item:hover {
  background: rgba(255,255,255,.12);
  transform: translateX(4px);
  border-color: rgba(255,215,120,.4);
}
.data-item .marker {
  flex: 0 0 auto;
  width: 12px; height: 12px;
  border-radius: 50%;
  margin-top: 5px;
}
.data-item .info h4 { font-size: .95rem; margin-bottom: 2px; }
.data-item .info p { font-size: .78rem; opacity: .8; line-height: 1.4; }
.data-item .badge {
  margin-left: auto;
  flex: 0 0 auto;
  font-size: .68rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

/* status colors (shared by legend, checkboxes, markers, badges) */
.c-belum { background: #e5484d; color: #fff; }
.c-sudah { background: #2ec27e; color: #06351f; }

/* ===================== LOADING SCREEN ===================== */
.loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 24px;
  /* darker green-to-black gradient + pattern texture */
  background:
    radial-gradient(circle at 50% 42%, rgba(13, 48, 24, .95) 0%, rgba(5, 24, 13, .98) 42%, #000 100%),
    url('pattern-2.webp');
  background-size: cover, 240px;
  background-position: center, center;
  background-repeat: no-repeat, repeat;
  background-blend-mode: normal, multiply;
  text-align: center;
  transition: opacity .6s ease, visibility .6s ease;
}
.loader.hide { opacity: 0; visibility: hidden; }

.loader-char {
  width: clamp(110px, 36vw, 150px);
  max-width: 150px;
  height: auto;                 /* keeps the 320:573 ratio -> max 150 x 269 */
  filter: drop-shadow(0 16px 28px rgba(0,0,0,.6));
  animation: charIn .7s cubic-bezier(.17,.67,.3,1.3) both, charBob 2.6s ease-in-out .8s infinite;
}

.loader-text {
  font-family: 'Baloo 2', cursive;
  font-size: clamp(1rem, 3.4vw, 1.4rem);
  font-weight: 700;
  letter-spacing: .5px;
  color: var(--cream);
  text-shadow: 0 2px 10px rgba(0,0,0,.6);
  animation: fadeUp .6s ease .3s both;
}
.loader-text .dots i {
  display: inline-block;
  animation: blinkDot 1.2s infinite;
}
.loader-text .dots i:nth-child(2) { animation-delay: .2s; }
.loader-text .dots i:nth-child(3) { animation-delay: .4s; }

.loader-bar {
  width: clamp(160px, 60vw, 240px);
  height: 7px;
  border-radius: 999px;
  background: rgba(255,255,255,.15);
  overflow: hidden;
  animation: fadeUp .6s ease .4s both;
}
.loader-bar span {
  display: block;
  height: 100%;
  width: 40%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green-1), var(--amber-1));
  animation: loaderSlide 1.4s ease-in-out infinite;
}

@keyframes charIn { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes charBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
@keyframes blinkDot { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }
@keyframes loaderSlide {
  0% { transform: translateX(-120%); }
  50% { transform: translateX(120%); }
  100% { transform: translateX(360%); }
}

/* ===================== LEGEND FOOTER ===================== */
.legend {
  font-size: .75rem;
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 10;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 18px;
  padding: 10px 20px;
  width: max-content;
  max-width: calc(100% - 32px);
  border-radius: 999px;
  background: rgba(10, 46, 24, .9);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,215,120,.35);
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  /* animation keeps the translateX(-50%) centering intact */
  animation: legendIn .6s ease .3s both;
}
.legend .lg-title {
  font-family: 'Baloo 2', cursive;
  font-weight: 700;
  letter-spacing: 1px;
  color: #ffe3a0;
  font-size: .85rem;
  margin-right: 4px;
}
.legend .lg-item { display: inline-flex; align-items: center; gap: 7px; font-size: .8rem; }
.legend .lg-dot { width: 13px; height: 13px; border-radius: 50%; box-shadow: 0 1px 2px rgba(0,0,0,.4); }

/* ===================== BACKDROP ===================== */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0,0,0,.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s ease, visibility .3s ease;
}
.backdrop.show { opacity: 1; visibility: visible; }

/* ===================== ANIMATIONS ===================== */
@keyframes slideDown { from { transform: translateY(-100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
/* legend fade-up that preserves the horizontal centering transform */
@keyframes legendIn {
  from { transform: translateX(-50%) translateY(16px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);    opacity: 1; }
}
@keyframes fadeInLeft { from { transform: translateX(-20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes popIn { from { transform: scale(0); } to { transform: scale(1); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ===================== RESPONSIVE ===================== */
/* tablet */
@media (max-width: 1024px) {
  header .org .l2 { display: none; }   /* keep header compact */
}

/* mobile */
@media (max-width: 680px) {
  header { gap: 10px; padding: 10px 14px; }
  header img.logo { width: 40px; height: 40px; }
  .back-home span.label { display: none; }   /* icon-only back button */
  .back-home { padding: 8px; }

  /* keep actions top-left (aligned with the map's Map/Satellite control),
     but collapse them to icon-only square buttons to save space. */
  .map-actions {
    top: 12px;
    left: 12px;
    gap: 10px;
  }
  .game-btn { min-width: 0; }
  .game-btn .txt { display: none; }            /* icon-only on mobile */
  .game-btn .ico {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    margin: 4px;
  }
  .game-btn::before {
    /* square-ish chip instead of the wide wood plank shape */
    clip-path: none;
    border-radius: 10px;
  }

  /* drawers slide up from the bottom (sheet style) */
  .drawer {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 72vh;
    border-radius: 18px 18px 0 0;
    border: none;
    border-top: 4px solid var(--wood-dark);
  }
  .drawer--left, .drawer--right { transform: translateY(105%); }
  .drawer.open { transform: translateY(0); }

  /* legend pinned to the very bottom, kept to one compact line */
  .legend {
    left: 8px;
    right: 8px;
    bottom: 10px;
    transform: none;
    width: auto;
    max-width: none;
    gap: 2px 8px;
    padding: 6px 10px;
    font-size: .6rem;
    border-radius: 14px;
    animation: fadeUp .6s ease .3s both;   /* no translateX on full-width mobile legend */
  }
  .legend .lg-title { font-size: .62rem; margin-right: 2px; }
  .legend .lg-item { font-size: .6rem; gap: 5px; padding: 1px 3px; }
  .legend .lg-dot { width: 9px; height: 9px; }
  .legend .lg-count { font-size: .6rem; }
}

/* very small phones: tighten the icon buttons a touch */
@media (max-width: 380px) {
  .map-actions { top: 10px; left: 10px; gap: 8px; }
  .game-btn .ico { width: 36px; height: 36px; }
}
