/* =====================================================================
   PANJAT PINANG KEMERDEKAAN — Tampilan Publik
   Tema: Festival Merdeka klasik (merah-putih + emas)
   Font: Barlow Condensed (display) + Barlow (body)
   ===================================================================== */
:root {
  --merah: #D9251D;
  --merah-tua: #7A1017;
  --merah-terang: #E8452B;
  --putih: #FFFFFF;
  --emas: #F2B705;
  --emas-tua: #C8890A;
  --hijau: #1F7A3D;
  --krem: #FFF4EC;
  --tinta: #3A1013;
  --muted: #9a6a55;

  --shadow-sm: 0 2px 8px rgba(122, 16, 23, .18);
  --shadow-md: 0 8px 24px rgba(122, 16, 23, .22);
  --radius: 16px;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Barlow', system-ui, -apple-system, sans-serif;
  color: var(--tinta);
  background: var(--krem);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, .display { font-family: 'Barlow Condensed', 'Barlow', sans-serif; }

/* ---------- Panggung ---------- */
.stage { position: fixed; inset: 0; overflow: hidden; }
#pinang-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#pinang-canvas:active { cursor: grabbing; }

/* ---------- Umbul-umbul / bunting ---------- */
.bunting {
  position: fixed; top: 0; left: 0; right: 0; height: 26px;
  display: flex; z-index: 6; pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .18));
}
.bunting span {
  flex: 1 1 auto;
  height: 18px;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  animation: sway 3.5s var(--ease) infinite alternate;
}
.bunting span:nth-child(odd) { background: var(--merah); }
.bunting span:nth-child(even) { background: var(--putih); }
.bunting span:nth-child(3n) { background: var(--emas); }
@keyframes sway { from { transform: translateY(0); } to { transform: translateY(3px); } }

/* ---------- Header ---------- */
.topbar {
  position: fixed; top: 30px; left: 0; right: 0; z-index: 5;
  display: flex; justify-content: center; padding: 0 14px;
  pointer-events: none;
}
.brand {
  pointer-events: auto;
  display: flex; align-items: center; gap: 12px;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(8px);
  border: 2px solid rgba(217, 37, 29, .18);
  border-radius: 999px;
  padding: 8px 18px 8px 10px;
  box-shadow: var(--shadow-md);
  max-width: min(94vw, 620px);
}
.brand .emblem {
  width: 44px; height: 44px; flex: 0 0 44px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff5b4d, var(--merah));
  display: grid; place-items: center;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .5);
}
.brand .emblem svg { width: 26px; height: 26px; }
.brand .txt { min-width: 0; }
.brand h1 {
  margin: 0; font-size: clamp(18px, 4.4vw, 26px); line-height: 1;
  letter-spacing: .5px; text-transform: uppercase; color: var(--merah-tua);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand p {
  margin: 2px 0 0; font-size: clamp(11px, 2.6vw, 13px);
  color: var(--emas-tua); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Panel statistik ---------- */
.stats {
  position: fixed; left: 14px; top: 96px; z-index: 5;
  display: flex; flex-direction: column; gap: 8px;
}
.chip {
  display: flex; align-items: center; gap: 9px;
  background: rgba(255, 255, 255, .86);
  border: 1.5px solid rgba(217, 37, 29, .16);
  border-radius: 14px; padding: 8px 12px;
  box-shadow: var(--shadow-sm); min-width: 150px;
}
.chip .ic { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 9px; display: grid; place-items: center; color: #fff; }
.chip .ic svg { width: 17px; height: 17px; }
.chip.leader .ic { background: var(--emas); }
.chip.count .ic { background: var(--merah); }
.chip.time .ic { background: var(--hijau); }
.chip .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: #9a6a55; font-weight: 700; line-height: 1; }
.chip .v { font-family: 'Barlow Condensed', sans-serif; font-size: 18px; font-weight: 700; color: var(--tinta); line-height: 1.1; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Kontrol zoom ---------- */
.zoom-ctrl {
  position: fixed; right: 14px; bottom: 96px; z-index: 5;
  display: flex; flex-direction: column; gap: 8px;
}
.zoom-ctrl button {
  width: 48px; height: 48px; border-radius: 14px; border: none;
  background: rgba(255, 255, 255, .92); color: var(--merah-tua);
  box-shadow: var(--shadow-md); cursor: pointer;
  display: grid; place-items: center;
  transition: transform .18s var(--ease), background .18s var(--ease);
}
.zoom-ctrl button:hover { background: #fff; transform: translateY(-2px); }
.zoom-ctrl button:active { transform: translateY(0) scale(.96); }
.zoom-ctrl button:focus-visible { outline: 3px solid var(--emas); outline-offset: 2px; }
.zoom-ctrl button svg { width: 22px; height: 22px; }
.zoom-ctrl .lead { background: var(--emas); color: #fff; }

/* ---------- Legenda / bantuan ---------- */
.legend {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 18px; z-index: 5;
  display: flex; gap: 14px; align-items: center;
  background: rgba(255, 255, 255, .86);
  border: 1.5px solid rgba(217, 37, 29, .16);
  border-radius: 999px; padding: 8px 16px;
  box-shadow: var(--shadow-sm); font-size: 12px; font-weight: 600;
  color: var(--merah-tua); max-width: 94vw;
}
.legend .dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; margin-right: 5px; vertical-align: -1px; }
.legend .hint { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend svg { width: 15px; height: 15px; }
.legend .sep { width: 1px; height: 16px; background: rgba(217, 37, 29, .2); }

.admin-link {
  position: fixed; right: 14px; top: 30px; z-index: 6;
  width: 40px; height: 40px; border-radius: 12px;
  background: rgba(255, 255, 255, .8); color: var(--merah-tua);
  display: grid; place-items: center; box-shadow: var(--shadow-sm); text-decoration: none; transition: background .18s var(--ease);
}
.admin-link:hover { background: #fff; }
.admin-link svg { width: 20px; height: 20px; }

/* ---------- Responsif ---------- */
@media (max-width: 720px) {
  .stats { top: auto; bottom: 74px; left: 10px; flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .chip { min-width: 0; padding: 6px 9px; }
  .chip .ic { width: 24px; height: 24px; flex-basis: 24px; }
  .chip .v { font-size: 15px; max-width: 84px; }
  .chip.time { display: none; }
  .zoom-ctrl { bottom: 132px; }
  .zoom-ctrl button { width: 44px; height: 44px; }
  .legend { font-size: 11px; gap: 8px; padding: 7px 12px; bottom: 12px; }
  .legend .hide-sm { display: none; }
  .topbar { top: 22px; }
}
@media (max-width: 420px) {
  .brand { padding: 6px 12px 6px 8px; gap: 8px; }
  .brand .emblem { width: 36px; height: 36px; flex-basis: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  .bunting span { animation: none; }
}

/* ---------- Hitung mundur ---------- */
#countdown {
  position: fixed; top: 88px; left: 50%; transform: translateX(-50%); z-index: 5;
  display: none; gap: 10px; max-width: 94vw; pointer-events: none; flex-wrap: wrap; justify-content: center;
}
.cd-card {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, .9); border: 2px solid rgba(217, 37, 29, .2);
  border-radius: 14px; padding: 7px 14px; box-shadow: var(--shadow-md);
}
.cd-card.cd-top { background: linear-gradient(135deg, #fff, #fff2ce); border-color: var(--emas); }
.cd-tag {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 800; font-size: 17px; color: #fff;
  background: var(--merah); border-radius: 9px; padding: 3px 9px; min-width: 30px; text-align: center; line-height: 1;
}
.cd-card.cd-top .cd-tag { background: var(--emas); }
.cd-mid { display: flex; flex-direction: column; line-height: 1.12; }
.cd-time { font-family: 'Barlow Condensed', sans-serif; font-size: 20px; font-weight: 800; color: var(--merah-tua); font-variant-numeric: tabular-nums; }
.cd-date { font-size: 11px; font-weight: 600; color: var(--emas-tua); }
@media (max-width: 720px) {
  #countdown { top: 78px; gap: 6px; }
  .cd-card { padding: 5px 10px; gap: 7px; }
  .cd-tag { font-size: 14px; padding: 2px 6px; }
  .cd-time { font-size: 16px; }
  .cd-date { font-size: 10px; }
}
@media (max-width: 380px) { .cd-date { display: none; } }

/* ---------- Popup detail pemain ---------- */
#player-popup {
  position: fixed; z-index: 20; display: none;
  width: 240px; padding: 16px 16px 14px;
  background: rgba(255, 255, 255, .97);
  border: 2px solid var(--merah);
  border-radius: 16px;
  box-shadow: 0 18px 44px rgba(122, 16, 23, .3);
  animation: pp-in .18s var(--ease);
}
@keyframes pp-in { from { opacity: 0; transform: translateY(6px) scale(.97); } to { opacity: 1; transform: none; } }
.pp-close {
  position: absolute; top: 8px; right: 8px; width: 26px; height: 26px;
  border: none; border-radius: 8px; background: #fff0ea; color: var(--merah-tua);
  font-size: 18px; line-height: 1; cursor: pointer; transition: background .15s var(--ease);
}
.pp-close:hover { background: #ffd9d0; }
.pp-rank {
  display: inline-grid; place-items: center; min-width: 40px; height: 30px; padding: 0 8px;
  border-radius: 9px; color: #fff; font-family: 'Barlow Condensed', sans-serif; font-weight: 800; font-size: 17px;
}
.pp-name { font-family: 'Barlow Condensed', sans-serif; font-size: 21px; font-weight: 700; color: var(--tinta); margin: 8px 0 2px; line-height: 1.1; }
.pp-points { font-family: 'Barlow Condensed', sans-serif; font-size: 26px; font-weight: 800; color: var(--merah); line-height: 1; }
.pp-points span { font-family: 'Barlow', sans-serif; font-size: 12px; font-weight: 600; color: var(--muted); }
.pp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.pp-grid > div { background: #fff4ec; border-radius: 10px; padding: 7px 9px; }
.pp-grid span { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .4px; color: #9a6a55; font-weight: 700; }
.pp-grid b { font-family: 'Barlow Condensed', sans-serif; font-size: 16px; color: var(--merah-tua); }
@media (max-width: 420px) { #player-popup { width: 210px; } }
