/* Comikanesia Live Vote — mobile-first.
   Palet turunan comikanesia.id (navy #070644, gold #d9a94f, cyan). */
:root {
  --bg-deep: #04042e;
  --navy: #080a4a;
  --navy-glow: #14309a;
  --admin-bg: #05052c;
  --admin-bg-2: #080a3d;

  --gold: #ddb05a;
  --gold-hi: #edc677;
  --gold-lo: #c99a43;
  --cyan: #4aa8ec;
  --white: #f4f5fa;
  --err: #f08a7c;

  --text-2: rgba(226, 231, 255, 0.74);
  --text-3: rgba(226, 231, 255, 0.5);
  --line: rgba(150, 170, 255, 0.18);
  --line-strong: rgba(170, 190, 255, 0.34);
  --surface: rgba(130, 150, 255, 0.07);
  --surface-2: rgba(130, 150, 255, 0.12);
  --field: rgba(4, 4, 46, 0.7);

  --f-h: "Play", "Plus Jakarta Sans", sans-serif;
  --f-b: "Plus Jakarta Sans", system-ui, sans-serif;

  --pad: clamp(16px, 5vw, 32px);
  --radius: 20px;
  --radius-md: 14px;
  --radius-sm: 12px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 12px 32px rgba(0, 0, 20, 0.35);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --t-micro: 0.72rem;
  --t-body: clamp(0.9rem, 3.6vw, 1rem);

  /* Ikon panah gaya "broken" (Iconsax), sama dengan comikanesia.id */
  --i-right: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath stroke='%23000' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M12.9 7.94l2.62 2.62c.77.77.77 2.03 0 2.8L9 19.87M9 4.04l1.04 1.04'/%3E%3C/svg%3E");
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { min-height: 100%; }

body {
  font-family: var(--f-b);
  color: var(--white);
  background: var(--bg-deep);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Latar halaman vote: radial navy + grid samar (hero comikanesia.id) ── */
.stage {
  position: relative;
  isolation: isolate;
  background:
    radial-gradient(120% 80% at 50% -10%, var(--navy-glow) 0%, var(--navy) 48%, var(--bg-deep) 100%)
    var(--bg-deep);
}
.stage::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.22;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(85% 70% at 70% 30%, #000, transparent 75%);
          mask-image: radial-gradient(85% 70% at 70% 30%, #000, transparent 75%);
}

/* ── Latar halaman admin: navy polos, tanpa grid ── */
.admin-bg {
  background: linear-gradient(180deg, var(--admin-bg-2) 0%, var(--admin-bg) 45%) var(--admin-bg);
}

:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.eyebrow {
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--cyan);
}

/* ── Top bar ───────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px var(--pad);
  padding-top: max(12px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
}
.topbar-logo { height: 30px; width: auto; display: block; }

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: var(--t-micro);
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-2);
  background: var(--surface);
}
.live-pill.is-closed { color: var(--err); }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }
.live-pill.is-closed .live-dot { background: var(--err); }

/* ── Intro ─────────────────────────────────────────────────── */
.intro { padding: 22px var(--pad) 14px; }
.intro-title {
  margin-top: 8px;
  font-family: var(--f-h);
  font-weight: 700;
  font-size: clamp(1.75rem, 8vw, 2.75rem);
  line-height: 1.05;
}
.intro-sub { margin-top: 8px; font-size: var(--t-body); font-weight: 500; color: var(--text-2); }
/* ── Arena: mobile = kartu ditumpuk ────────────────────────── */
.arena {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  gap: 10px;
  padding: 8px var(--pad) 24px;
}

/* Kartu flat ala comikanesia.id: transparan, border putih tipis.
   Umpan balik sentuh: border jadi emas + latar sedikit hangat. */
.candidate {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 22px 20px 20px;
  font: inherit;
  color: var(--white);
  text-align: left;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease), transform 0.15s var(--ease);
}
@media (hover: hover) {
  .candidate:hover { border-color: rgba(217, 169, 79, 0.55); background-color: rgba(217, 169, 79, 0.05); }
  .candidate:hover .cta { background: var(--gold-hi); }
  .candidate:hover .cta-arrow { transform: translateX(3px); }
}
.candidate:active { transform: scale(0.99); border-color: rgba(217, 169, 79, 0.75); background-color: rgba(217, 169, 79, 0.08); }

.candidate .label { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.candidate .idx {
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--cyan);
}
.candidate .name {
  font-family: var(--f-h);
  font-weight: 700;
  font-size: clamp(1.9rem, 9vw, 2.6rem);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tombol emas polos khas comikanesia.id */
.candidate .cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 12px 18px;
  border-radius: 10px;
  color: #070644;
  background: #d9a94f;
  transition: background-color 0.2s var(--ease);
}
.candidate:active .cta { background: #c99a43; }
.candidate .cta-label {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.03em;
}
.candidate .cta-arrow {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  background: currentColor;
  -webkit-mask: var(--i-right) center / contain no-repeat;
          mask: var(--i-right) center / contain no-repeat;
  transition: transform 0.2s var(--ease);
}

/* Pemisah VS: garis tipis dengan label di tengah */
.vs {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: var(--t-micro);
  font-weight: 800;
  letter-spacing: 0.3em;
  color: var(--text-3);
}
.vs::before,
.vs::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.14);
}

/* ── Footer ────────────────────────────────────────────────── */
.foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px var(--pad) max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* ── Overlay (konfirmasi / loading / terima kasih) ─────────── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  flex-direction: column;
  padding: var(--pad);
  padding-top: max(var(--pad), env(safe-area-inset-top));
  padding-bottom: max(var(--pad), env(safe-area-inset-bottom));
  color: var(--white);
  background:
    radial-gradient(120% 70% at 50% 0%, var(--navy-glow) 0%, var(--navy) 55%, var(--bg-deep) 100%)
    var(--bg-deep);
  animation: rise 0.35s var(--ease);
}
.overlay.show { display: flex; }
@keyframes rise { from { transform: translateY(100%); } to { transform: translateY(0); } }

.overlay .o-top {
  display: flex;
  justify-content: space-between;
  font-size: var(--t-micro);
  font-weight: 800;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--cyan);
}
.overlay .o-mid { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.overlay .o-mega {
  font-family: var(--f-h);
  font-weight: 700;
  font-size: clamp(2.6rem, 13vw, 5rem);
  line-height: 1;
}
.overlay .o-name {
  margin-top: 12px;
  font-family: var(--f-h);
  font-weight: 700;
  font-size: clamp(1.5rem, 7vw, 2.4rem);
  line-height: 1.1;
  color: var(--gold-hi);
}
.overlay .o-text { margin-top: 12px; max-width: 34ch; font-size: var(--t-body); font-weight: 500; color: var(--text-2); }
.overlay .o-actions { display: flex; flex-direction: column; gap: 10px; }

/* ── Tombol ────────────────────────────────────────────────── */
.btn,
.btn-gold,
.btn-ghost {
  width: 100%;
  min-height: 52px;
  padding: 14px 18px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-position 0.25s var(--ease), background-color 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.15s var(--ease), opacity 0.2s;
}
.btn, .btn-gold {
  border: 0;
  color: #0a0a3c;
  background: linear-gradient(180deg, var(--gold-hi) 0%, var(--gold) 50%, var(--gold-lo) 100%);
  background-size: 100% 200%;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset, 0 6px 16px rgba(221, 176, 90, 0.2);
}
.btn.ghost, .btn-ghost {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--white);
  box-shadow: none;
}
@media (hover: hover) {
  .btn:hover, .btn-gold:hover { background-position: 0 100%; }
  .btn.ghost:hover, .btn-ghost:hover { background-color: var(--surface-2); border-color: rgba(190, 205, 255, 0.55); }
  .btn-warn:hover { border-color: var(--err); background-color: rgba(240, 138, 124, 0.08); }
}
.btn:active, .btn-gold:active, .btn-ghost:active { transform: scale(0.98); }
.btn[disabled], .btn-gold[disabled], .btn-ghost[disabled] { opacity: 0.45; cursor: default; }
.btn-warn { color: var(--err); border-color: rgba(240, 138, 124, 0.4); }

.spin {
  display: inline-block;
  width: 24px; height: 24px;
  border: 3px solid var(--gold);
  border-top-color: transparent;
  border-radius: 50%;
  animation: rot 0.7s linear infinite;
}
@keyframes rot { to { transform: rotate(360deg); } }

/* ── Admin: umum ───────────────────────────────────────────── */
.hidden { display: none !important; }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.section-title {
  font-size: var(--t-micro);
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* ── Admin: login ──────────────────────────────────────────── */
.login-wrap { flex: 1; display: flex; align-items: center; padding: 24px var(--pad); }
.login-card {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-radius: var(--radius);
}
.login-card .intro-title { margin-top: -8px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-2);
}
.field input {
  min-height: 48px;
  padding: 12px 14px;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: var(--white);
  background: var(--field);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.field input::placeholder { color: var(--text-3); }
.field input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(221, 176, 90, 0.22); }

.msg { font-size: var(--t-body); font-weight: 700; color: var(--white); }
.msg:empty { display: none; }
.msg-muted { font-size: 0.85rem; font-weight: 500; color: var(--text-3); }

/* ── Admin: dashboard (juga untuk layar LED) ───────────────── */
.dash-live {
  position: fixed;
  inset: 0;
  z-index: 40;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.board { padding: var(--pad); display: flex; flex-direction: column; gap: 12px; }
.board-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 8px; }
.board-logo { height: clamp(22px, 6vw, 40px); width: auto; display: block; }

.score-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.score-cell {
  --accent: var(--gold);
  padding: 16px 14px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.score-cell.cand-cyan { --accent: var(--cyan); }
.score-label {
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-2);
  overflow-wrap: anywhere;
}
.score-label::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  margin-right: 8px;
  border-radius: 2px;
  background: var(--accent);
  vertical-align: 0.05em;
}
.score-num {
  margin-top: 10px;
  font-family: var(--f-h);
  font-weight: 700;
  font-size: clamp(2.6rem, 14vw, 7rem);
  line-height: 0.95;
  font-variant-numeric: tabular-nums;
}
.score-unit {
  margin-top: 4px;
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
}

.vs-split {
  flex-shrink: 0;
  height: 8px;
  display: flex;
  gap: 2px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(150, 170, 255, 0.12);
}
.vs-split-fill { height: 100%; transition: width 0.6s var(--ease); }
.vs-split-left  { background: var(--gold); }
.vs-split-right { background: var(--cyan); }

.board-row { display: grid; gap: 10px; }
.board-total { padding: 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.board-total span:first-child {
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-2);
}
.board-total span:last-child {
  font-family: var(--f-h);
  font-weight: 700;
  font-size: clamp(1.8rem, 8vw, 3.2rem);
  font-variant-numeric: tabular-nums;
}

.board-donut {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.donut { width: clamp(84px, 24vw, 170px); height: auto; aspect-ratio: 1; flex-shrink: 0; transform: rotate(-90deg); }
.donut-track { fill: none; stroke: rgba(150, 170, 255, 0.12); stroke-width: 24; }
.donut-seg { fill: none; stroke-width: 24; transition: stroke-dasharray 0.6s var(--ease), stroke-dashoffset 0.6s var(--ease); }
.donut-seg-left  { stroke: var(--gold); }
.donut-seg-right { stroke: var(--cyan); }

.donut-legend { flex: 1; max-width: 360px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.legend-row { display: flex; align-items: center; gap: 10px; }
.legend-dot { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.legend-dot-left  { background: var(--gold); }
.legend-dot-right { background: var(--cyan); }
.legend-name { font-weight: 700; font-size: var(--t-body); overflow-wrap: anywhere; }
.legend-pct {
  margin-left: auto;
  padding-left: 12px;
  font-family: var(--f-h);
  font-weight: 700;
  font-size: clamp(1.2rem, 5vw, 1.7rem);
  font-variant-numeric: tabular-nums;
}

/* Panel kontrol admin */
.dash-controls {
  padding: 8px var(--pad) max(var(--pad), env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.control-card { padding: 18px 16px; display: flex; flex-direction: column; gap: 14px; }
.control-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.status-chip {
  font-size: var(--t-micro);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-2);
}
.status-chip.is-closed { color: var(--err); }

/* HP pendek (mis. 320×640): rapatkan supaya muat satu layar */
@media (max-height: 700px) and (max-width: 719px) {
  .intro { padding-top: 14px; padding-bottom: 8px; }
  .arena { padding-bottom: 14px; }
  .candidate { gap: 14px; padding: 16px; }
  .candidate .cta { min-height: 46px; padding: 10px 16px; }
}

/* ── Layar lebih lebar ─────────────────────────────────────── */
@media (min-width: 720px) {
  .arena { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: stretch; gap: 20px; max-width: 1040px; width: 100%; margin: 0 auto; }
  .candidate { padding: 26px; gap: 28px; justify-content: space-between; }
  .candidate .name { font-size: clamp(1.8rem, 3.6vw, 2.6rem); }
  .vs { align-self: stretch; flex-direction: column; gap: 12px; }
  .vs::before, .vs::after { flex: 1; width: 1px; height: auto; }
  .overlay .o-actions { flex-direction: row-reverse; max-width: 560px; }
  .board-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); align-items: stretch; }
  .board-total { flex-direction: column; align-items: flex-start; justify-content: center; }
  .dash-controls { max-width: 640px; }
}

/* LED / laptop: hasil di kiri, panel kontrol jadi sidebar */
@media (min-width: 1100px) {
  .dash-live { flex-direction: row; align-items: stretch; }
  .board { flex: 1; min-width: 0; min-height: 100dvh; gap: 18px; }
  .board-logo { height: 44px; }
  .score-grid { flex: 1; gap: 18px; }
  .score-cell { display: flex; flex-direction: column; justify-content: center; padding: 28px 32px; }
  .score-label { font-size: clamp(1rem, 1.3vw, 1.5rem); }
  .score-num { font-size: clamp(7rem, 13vw, 16rem); }
  .score-unit { font-size: clamp(0.85rem, 1vw, 1.1rem); }
  .vs-split { height: 12px; }
  .board-total span:last-child { font-size: clamp(3rem, 4.5vw, 5rem); }
  .donut { width: clamp(150px, 12vw, 220px); }
  .legend-name { font-size: clamp(1rem, 1.3vw, 1.4rem); }
  .legend-pct { font-size: clamp(1.6rem, 2.4vw, 2.6rem); }
  .dash-controls {
    width: 380px;
    max-width: none;
    flex-shrink: 0;
    padding: var(--pad) 24px;
    overflow-y: auto;
    border-left: 1px solid var(--line);
    background: rgba(130, 150, 255, 0.035);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
