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

html, body { height: 100%; }

body {
  background: #0a0a0f;
  color: #f2f2f5;
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  overflow-x: hidden;
}

#app { min-height: 100vh; display: flex; flex-direction: column; padding: 18px 24px 12px; }

/* ---------- Header ---------- */
header {
  display: flex; justify-content: space-between; align-items: center;
  gap: 24px; padding: 6px 4px 16px;
  border-bottom: 3px solid #e62117;
}
h1 {
  font-size: 44px; font-weight: 900; letter-spacing: 1px; line-height: 1;
  color: #ffffff;
}
h1::after {
  content: ""; display: block; height: 5px; width: 180px; margin-top: 8px;
  background: linear-gradient(90deg, #e62117, #f5c518);
  border-radius: 3px;
}
.subtitle { margin-top: 10px; font-size: 17px; color: #b9b9c4; }

.header-stats { display: flex; align-items: center; gap: 16px; }
.stat-box {
  background: #17171f; border: 2px solid #2c2c38; border-radius: 12px;
  padding: 10px 20px; text-align: center; min-width: 130px;
}
.stat-label { display: block; font-size: 13px; letter-spacing: 2px; color: #9a9aa8; text-transform: uppercase; }
.stat-value { display: block; font-size: 38px; font-weight: 900; line-height: 1.1; color: #ffffff; font-variant-numeric: tabular-nums; }
.countdown-box { border-color: #f5c518; }
.countdown-box .stat-value { color: #f5c518; }
.countdown-box.urgent .stat-value { color: #ff5252; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.35; } }

.live-badge {
  display: flex; align-items: center; gap: 9px;
  background: #e62117; color: #fff; font-weight: 900; font-size: 26px;
  letter-spacing: 2px; padding: 14px 22px; border-radius: 12px;
}
.live-dot { width: 16px; height: 16px; border-radius: 50%; background: #fff; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; transform: scale(0.8); } }

.closed-banner {
  margin-top: 14px; text-align: center; font-size: 26px; font-weight: 900;
  letter-spacing: 1px; color: #0a0a0f; background: #f5c518;
  padding: 12px; border-radius: 10px;
}
.hidden { display: none !important; }

/* ---------- Main layout ---------- */
main { display: grid; grid-template-columns: 1fr 380px; gap: 20px; margin-top: 18px; flex: 1; }

#board { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: repeat(4, 1fr); gap: 14px; }

.candidate {
  display: flex; align-items: center; gap: 14px;
  background: #17171f; border: 2px solid #2c2c38; border-radius: 14px;
  padding: 20px 18px; cursor: pointer; position: relative;
  transition: border-color 0.15s ease, transform 0.1s ease;
}
.candidate:hover { border-color: #e62117; }
.candidate.flash { animation: flash 0.6s ease; }
@keyframes flash { 0% { background: #3a1512; } 100% { background: #17171f; } }
.candidate.leader { border-color: #f5c518; box-shadow: 0 0 0 1px #f5c518, 0 0 22px rgba(245, 197, 24, 0.18); }

.rank {
  position: absolute; top: -11px; left: 14px;
  background: #2c2c38; color: #fff; font-weight: 900; font-size: 14px;
  padding: 2px 10px; border-radius: 20px; letter-spacing: 1px;
}
.candidate.leader .rank { background: #f5c518; color: #0a0a0f; }

.cand-num {
  font-size: 46px; font-weight: 900; color: #f5c518; line-height: 1;
  min-width: 66px; text-align: center; font-variant-numeric: tabular-nums;
}
.avatar {
  width: 74px; height: 74px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 27px; font-weight: 900; color: #fff;
  border: 3px solid rgba(255, 255, 255, 0.35);
}
.cand-info { flex: 1; min-width: 0; }
.cand-name { font-size: 27px; font-weight: 900; letter-spacing: 0.5px; }
.cand-votes { font-size: 16px; color: #b9b9c4; margin-top: 4px; font-variant-numeric: tabular-nums; }
.bar-track { height: 12px; background: #26262f; border-radius: 6px; margin-top: 10px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: #e62117; transition: width 0.4s ease; }
.candidate.leader .bar-fill { background: linear-gradient(90deg, #e62117, #f5c518); }
.cand-pct {
  font-size: 34px; font-weight: 900; color: #fff; min-width: 92px;
  text-align: right; font-variant-numeric: tabular-nums;
}

/* ---------- Sidebar / feeds ---------- */
#sidebar { display: flex; flex-direction: column; gap: 16px; }
.panel {
  background: #121218; border: 2px solid #2c2c38; border-radius: 14px;
  padding: 14px 16px; flex: 1; min-height: 0; display: flex; flex-direction: column;
}
.panel h2 {
  font-size: 19px; font-weight: 900; letter-spacing: 1.5px; color: #f5c518;
  border-bottom: 2px solid #2c2c38; padding-bottom: 10px; margin-bottom: 10px;
}
.feed { list-style: none; overflow-y: auto; max-height: 300px; }
.feed li {
  padding: 8px 4px; border-bottom: 1px solid #22222c; font-size: 16px;
  display: flex; justify-content: space-between; gap: 10px;
}
.feed li .who { color: #d7d7de; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed li .what { font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.feed li .what.good { color: #4ade80; }
.feed li .what.bad { color: #ff5252; }
.feed-empty { color: #7a7a88; font-size: 15px; padding: 6px 4px; }

/* ---------- Control bar ---------- */
#controlBar {
  display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px;
  margin-top: 18px; padding: 14px 16px;
  background: #121218; border: 2px solid #2c2c38; border-radius: 14px;
}
.control-group { display: flex; flex-direction: column; gap: 5px; }
.control-group label { font-size: 13px; color: #9a9aa8; letter-spacing: 0.5px; }
.control-group input {
  background: #0a0a0f; color: #fff; border: 2px solid #3a3a48; border-radius: 8px;
  padding: 9px 12px; font-size: 17px; width: 150px; outline: none;
}
.control-group input:focus { border-color: #f5c518; }
.control-group input.error { border-color: #ff5252; animation: shake 0.3s ease; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
#voteNumber { width: 90px; text-align: center; font-weight: 900; font-size: 20px; }

.btn {
  background: #26262f; color: #fff; border: 2px solid #3a3a48; border-radius: 9px;
  padding: 10px 16px; font-size: 15px; font-weight: 700; cursor: pointer;
}
.btn:hover { border-color: #f5c518; }
.btn-primary { background: #e62117; border-color: #e62117; }
.btn-primary:hover { border-color: #ff6b61; }
.btn-danger { background: #3a1512; border-color: #7f1d1d; color: #fca5a5; }
.btn-ghost { background: transparent; }
.btn-toggle { opacity: 0.65; }
.btn-toggle.active { opacity: 1; border-color: #4ade80; color: #4ade80; }
.divider { width: 2px; align-self: stretch; background: #2c2c38; }

#obsHint { margin-top: 10px; font-size: 13px; color: #7a7a88; text-align: center; }
#obsHint code { background: #1c1c26; padding: 2px 6px; border-radius: 5px; color: #c9c9d4; }

/* Mode bersih untuk OBS: sembunyikan panel kontrol dan petunjuk */
body.clean #controlBar, body.clean #obsHint { display: none; }
body.clean main { flex: 1; }
body.clean .feed { max-height: 340px; }

/* Layar kecil tetap terbaca */
@media (max-width: 1100px) {
  main { grid-template-columns: 1fr; }
  #board { grid-template-columns: 1fr; }
  h1 { font-size: 32px; }
}
