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

:root {
  --green:       #00e676;
  --green-dim:   #00b050;
  --green-glow:  rgba(0, 230, 118, 0.4);
  --display-bg:  #030e06;
  --urna-bg:     #1a2332;
  --urna-body:   #1e2c3a;
  --urna-edge:   #263545;
  --key-bg:      #2a3f55;
  --key-hover:   #3a5570;
  --key-shadow:  #0d1e2d;
  --orange:      #ff6f00;
  --white-key:   #e8e8e8;
  --text-green:  #00ff88;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: #0a0f1a;
  font-family: 'Share Tech Mono', monospace;
  color: var(--text-green);
}

/* ── Top bar ── */
.top-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 48px;
  background: linear-gradient(90deg, #0d1b2e, #162236);
  border-bottom: 1px solid #1e3a5a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
}
.top-bar-left { display: flex; align-items: center; gap: 10px; }
.flag-bar { display: flex; height: 20px; border-radius: 3px; overflow: hidden; }
.flag-green  { background: #009c3b; width: 8px; }
.flag-yellow { background: #ffdf00; width: 8px; }
.flag-blue   { background: #002776; width: 8px; }
.site-name { color: #e8f4fd; font-weight: bold; font-size: 14px; letter-spacing: 1px; }
.top-bar-right { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--green-dim); }
.user-name { color: #c8e6fa; font-size: 13px; }
.btn-topo {
  background: #1e3a5a; color: #8ecfef;
  border: 1px solid #2a5070; border-radius: 4px;
  padding: 4px 10px; font-size: 12px; text-decoration: none;
  transition: .2s;
}
.btn-topo:hover { background: #2a5a8a; color: #fff; }
.btn-login { background: #004a9f; color: #fff; border-color: #0060cc; }
.btn-sair  { background: #3a1010; color: #f88; border-color: #5a1a1a; }

/* ── Stage ── */
.urna-stage {
  height: 100vh;
  padding-top: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #0d1e35 0%, #060e1a 100%);
  position: relative;
  overflow: hidden;
}

/* Scanlines overlay */
.urna-stage::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.15) 2px,
    rgba(0,0,0,0.15) 4px
  );
  pointer-events: none;
  z-index: 50;
}

/* ── Screen management ── */
.screen { display: none; width: 100%; height: 100%; position: absolute; inset: 0; align-items: center; justify-content: center; gap: 24px; }
.screen[data-active="true"] { display: flex; }

/* ── Urna container ── */
.urna-container {
  width: min(480px, 95vw);
  background: linear-gradient(180deg, var(--urna-body) 0%, #162030 100%);
  border: 2px solid var(--urna-edge);
  border-radius: 18px 18px 24px 24px;
  box-shadow:
    0 0 60px rgba(0,0,0,0.8),
    0 0 0 1px rgba(255,255,255,0.05),
    inset 0 1px 0 rgba(255,255,255,0.05);
  overflow: hidden;
}

.urna-top-label {
  background: linear-gradient(180deg, #0f2035, #0a1825);
  text-align: center;
  padding: 8px;
  font-family: 'Orbitron', monospace;
  font-size: 10px;
  letter-spacing: 2px;
  color: #4a90c8;
  border-bottom: 1px solid #1a3a58;
}

/* ── Display ── */
.urna-display {
  background: var(--display-bg);
  margin: 12px;
  border-radius: 8px;
  border: 2px solid #0a2010;
  box-shadow:
    inset 0 0 30px rgba(0,80,0,0.3),
    0 0 15px rgba(0,200,80,0.1);
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* CRT scanlines on display */
.urna-display::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 3px,
    rgba(0, 255, 80, 0.03) 3px,
    rgba(0, 255, 80, 0.03) 4px
  );
  pointer-events: none;
}

.display-content {
  padding: 20px;
  width: 100%;
  text-align: center;
}

/* ── Welcome screen ── */
.tse-logo { font-size: 36px; margin-bottom: 4px; filter: drop-shadow(0 0 8px var(--green-glow)); }
.tse-title { font-family: 'Orbitron', monospace; font-size: 11px; letter-spacing: 3px; color: var(--green-dim); margin-bottom: 8px; }
.election-title { font-size: 13px; color: var(--text-green); margin-bottom: 6px; line-height: 1.4; }
.welcome-divider { color: var(--green-dim); margin: 8px 0; }
.welcome-msg { color: var(--green-dim); font-size: 13px; animation: blink 1.2s step-end infinite; }

/* ── Cargo label ── */
.cargo-label {
  font-family: 'Orbitron', monospace;
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--text-green);
  margin-bottom: 2px;
  text-shadow: 0 0 10px var(--green-glow);
}
.cargo-round  { font-size: 11px; color: var(--green-dim); margin-bottom: 2px; }
.cargo-cenario { font-size: 10px; color: #006633; margin-bottom: 8px; min-height: 14px; }

/* ── Seleção de estado ── */
.urna-display-estado {
  align-items: flex-start;
  overflow-y: auto;
}
.urna-display-estado .display-content {
  padding: 14px 16px;
  overflow-y: auto;
}
.geo-detect-btn {
  background: #00152a;
  color: #4ab8ff;
  border: 1px solid #1a5a8a;
  border-radius: 4px;
  padding: 7px 12px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  cursor: pointer;
  width: 100%;
  margin-bottom: 6px;
  transition: .2s;
}
.geo-detect-btn:hover { background: #002244; }
.geo-status {
  font-size: 11px;
  color: var(--green-dim);
  min-height: 15px;
  margin-bottom: 8px;
}
.estado-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}
.estado-btn {
  background: #010e05;
  color: var(--green);
  border: 1px solid #0a3a18;
  border-radius: 3px;
  padding: 7px 2px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  transition: .15s;
  letter-spacing: 1px;
}
.estado-btn:hover {
  background: var(--green-dim);
  color: #000;
  border-color: var(--green);
}
.display-divider { color: var(--green-dim); margin-bottom: 12px; letter-spacing: -1px; }

/* ── Candidatos Sidebar ── */
.candidatos-sidebar {
  width: 200px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  background: rgba(0,10,20,0.85);
  border: 1px solid #0a3a18;
  border-radius: 10px;
  padding: 10px 8px;
  margin-right: 20px;
  flex-shrink: 0;
  display: none;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
  scrollbar-color: #0a3a18 transparent;
}
.candidatos-sidebar.visible { display: flex; }
.sidebar-title {
  font-family: 'Orbitron', monospace;
  font-size: 9px;
  color: var(--green-dim);
  letter-spacing: 2px;
  text-align: center;
  padding-bottom: 6px;
  border-bottom: 1px solid #0a3a18;
  margin-bottom: 2px;
}
.sidebar-list { display: flex; flex-direction: column; gap: 5px; }
.sidebar-card {
  background: #010e05;
  border: 1px solid #0a3a18;
  border-radius: 5px;
  padding: 7px 8px;
  cursor: default;
  transition: background .15s, border-color .15s;
}
.sidebar-card.match {
  background: #002a0e;
  border-color: var(--green);
  box-shadow: 0 0 8px rgba(0,220,80,0.2);
}
.sidebar-number {
  font-family: 'Orbitron', monospace;
  font-size: 18px;
  color: var(--green);
  line-height: 1;
  margin-bottom: 3px;
  letter-spacing: 2px;
}
.sidebar-name {
  font-size: 11px;
  color: #cde;
  line-height: 1.2;
  font-weight: bold;
  text-transform: uppercase;
}
.sidebar-party {
  font-size: 10px;
  color: var(--green-dim);
  margin-top: 2px;
}
.sidebar-blank {
  font-size: 11px;
  color: var(--green-dim);
  text-align: center;
  padding: 8px 4px;
  border: 1px dashed #0a3a18;
  border-radius: 5px;
}
@media (max-width: 750px) {
  .candidatos-sidebar { display: none !important; }
}

/* ── Mobile candidatos toggle ── */
.mobile-candidatos-toggle {
  display: none;
  padding: 0 12px 6px;
  background: linear-gradient(180deg, #131e2b, #0d1620);
}
@media (max-width: 750px) {
  .mobile-candidatos-toggle { display: block; }
}
.mobile-candidatos-btn {
  background: #010e05;
  color: var(--green);
  border: 1px solid #0a3a18;
  border-radius: 4px;
  padding: 5px 12px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px;
  cursor: pointer;
  width: 100%;
  letter-spacing: 1px;
  transition: .15s;
}
.mobile-candidatos-btn:hover { background: #002a0e; }
.mobile-candidatos-list {
  display: none;
  position: fixed;
  z-index: 500;
  max-height: 200px;
  overflow-y: auto;
  background: #010a03;
  border: 1px solid var(--green-dim);
  border-radius: 6px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.8), 0 0 12px rgba(0,230,118,0.15);
  scrollbar-width: thin;
  scrollbar-color: #0a3a18 transparent;
}
.mobile-candidatos-list.open { display: block; }
.mobile-cand-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid #061a0a;
}
.mobile-cand-row:last-child { border-bottom: none; }
.mobile-cand-row.match { background: #002a0e; }
.mobile-cand-num {
  font-family: 'Orbitron', monospace;
  font-size: 15px;
  color: var(--green);
  min-width: 30px;
  letter-spacing: 1px;
}
.mobile-cand-name {
  font-size: 10px;
  color: #cde;
  font-weight: bold;
  text-transform: uppercase;
  flex: 1;
  text-align: left;
  line-height: 1.2;
}
.mobile-cand-party { font-size: 9px; color: var(--green-dim); }

/* ── Number input ── */
.typing-prompt { font-size: 12px; color: var(--green-dim); margin-bottom: 10px; }
.number-display { display: flex; justify-content: center; gap: 8px; margin-bottom: 8px; }
.digit-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 52px;
  background: #010a03;
  border: 2px solid var(--green-dim);
  border-radius: 4px;
  font-family: 'Orbitron', monospace;
  font-size: 26px;
  font-weight: 700;
  color: var(--text-green);
  text-shadow: 0 0 12px var(--green-glow);
  transition: border-color .2s;
}
.digit-box.active { border-color: var(--text-green); box-shadow: 0 0 8px var(--green-glow); }
.typing-hint { font-size: 10px; color: #2a6a3a; }

/* ── Candidate found ── */
.candidate-found {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  margin-bottom: 10px;
}
.candidate-photo-area {
  flex-shrink: 0;
  width: 80px; height: 95px;
  background: #010e05;
  border: 2px solid var(--green-dim);
  border-radius: 4px;
  overflow: hidden;
}
.candidate-photo-area img { width: 100%; height: 100%; object-fit: cover; }
.candidate-info { flex: 1; }
.candidate-number-display {
  font-family: 'Orbitron', monospace;
  font-size: 22px;
  color: var(--text-green);
  text-shadow: 0 0 10px var(--green-glow);
  margin-bottom: 4px;
}
.candidate-name-display { font-size: 13px; color: #e0ffe0; line-height: 1.3; margin-bottom: 4px; }
.candidate-party-display { font-size: 11px; color: var(--green-dim); }
.confirm-prompt { font-size: 11px; color: var(--green-dim); animation: blink 1.2s step-end infinite; }

/* ── Invalid ── */
.invalid-msg { color: #ff6060; }
.invalid-icon { font-size: 28px; margin-bottom: 8px; }
.invalid-sub { font-size: 11px; margin-top: 6px; color: #c05050; }

/* ── Blank vote ── */
.blank-msg { color: var(--green-dim); }
.blank-title { font-family: 'Orbitron', monospace; font-size: 14px; color: #e0e0e0; margin-bottom: 8px; }
.blank-sub { font-size: 12px; margin-bottom: 12px; }

/* ── Confirmed ── */
.confirmed-content { }
.confirmed-icon { font-size: 40px; color: var(--text-green); text-shadow: 0 0 20px var(--green-glow); margin-bottom: 8px; }
.confirmed-title { font-family: 'Orbitron', monospace; font-size: 16px; color: var(--text-green); margin-bottom: 8px; letter-spacing: 2px; }
.confirmed-sub { font-size: 12px; color: var(--green-dim); margin-bottom: 6px; }
.confirmed-next { font-size: 11px; color: #2a6a3a; margin-top: 8px; }

/* ── Done ── */
.done-content { }
.done-icon { font-size: 40px; margin-bottom: 8px; }
.done-title { font-family: 'Orbitron', monospace; font-size: 16px; color: var(--text-green); margin-bottom: 6px; }
.done-sub { font-size: 14px; color: var(--green-dim); margin-bottom: 10px; }
.done-divider { color: var(--green-dim); margin-bottom: 8px; }
.done-msg { font-size: 12px; color: #2a6a3a; }

/* ── Already voted ── */
.already-voted-msg { color: var(--green-dim); }
.voted-icon { font-size: 36px; color: var(--text-green); margin-bottom: 8px; }
.voted-sub { font-size: 12px; margin-top: 6px; }

/* ── Login required ── */
.lock-icon { font-size: 36px; margin-bottom: 8px; }
.login-req-title { font-family: 'Orbitron', monospace; font-size: 13px; color: var(--text-green); margin-bottom: 10px; }
.login-req-sub { font-size: 11px; color: var(--green-dim); margin-bottom: 4px; line-height: 1.5; }
.login-divider { color: var(--green-dim); margin: 10px 0; }
.login-options { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.login-opt-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px; border-radius: 6px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px; text-decoration: none;
  transition: .2s;
}
.google-btn { background: #1a3050; color: #c8e6fa; border: 1px solid #2a5080; }
.google-btn:hover { background: #2a4a70; }
.sms-btn { background: #1a3020; color: #b0efb0; border: 1px solid #2a6030; }
.sms-btn:hover { background: #2a5030; }

/* ── Keyboard ── */
.urna-keyboard {
  background: linear-gradient(180deg, #131e2b, #0d1620);
  padding: 12px 16px 22px;
  border-top: 1px solid var(--urna-edge);
}

.key-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}
.key-row-empty { height: 40px; }

.key {
  width: 70px; height: 44px;
  background: linear-gradient(180deg, var(--key-bg), #1e3040);
  border: 1px solid #3a5570;
  border-bottom: 3px solid var(--key-shadow);
  border-radius: 6px;
  color: #e8f4fd;
  font-family: 'Share Tech Mono', monospace;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: .1s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.key:hover { background: linear-gradient(180deg, var(--key-hover), #2a4a60); }
.key:active {
  transform: translateY(2px);
  border-bottom-width: 1px;
  background: #1e3040;
}

.key-wide { width: 70px; }

.key-green {
  background: linear-gradient(180deg, #00802e, #004d1c);
  border-color: #00b040; border-bottom-color: #002a0e;
  color: #fff;
  font-size: 13px;
  width: auto; padding: 0 16px;
}
.key-green:hover { background: linear-gradient(180deg, #00a03a, #006624); }

.key-orange {
  background: linear-gradient(180deg, #b34700, #7a2f00);
  border-color: #e05a00; border-bottom-color: #3d1700;
  color: #fff;
  font-size: 13px;
  width: auto; padding: 0 14px;
}
.key-orange:hover { background: linear-gradient(180deg, #d45500, #9a3a00); }

.key-white {
  background: linear-gradient(180deg, #d0d8e0, #a0aab5);
  border-color: #c0cdd8; border-bottom-color: #606870;
  color: #1a2535;
  font-size: 12px;
  width: auto; padding: 0 14px;
}
.key-white:hover { background: linear-gradient(180deg, #e0e8f0, #b0bbc8); }

.special-row { gap: 6px; }
.special-row .key { flex: 1 1 0 !important; width: 0 !important; min-width: 0 !important; padding: 0 2px !important; }

/* ── Beep flash ── */
.beep-flash {
  position: fixed;
  inset: 0;
  background: rgba(0,255,100,0.08);
  pointer-events: none;
  opacity: 0;
  z-index: 200;
  transition: opacity .05s;
}
.beep-flash.active { opacity: 1; }

/* ── Animations ── */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@keyframes confirmPop {
  0%   { transform: scale(0.8); opacity: 0; }
  60%  { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

.screen[data-active="true"] .confirmed-icon,
.screen[data-active="true"] .done-icon {
  animation: confirmPop .4s ease-out;
}

/* ── Responsive ── */
@media (max-height: 700px) {
  .urna-display { min-height: 200px; }
  .urna-display .display-content { padding: 12px; }
  .key { height: 38px; }
  .key-row-empty { height: 30px; }
}

@media (max-width: 360px) {
  .key { width: 60px; font-size: 14px; }
  .digit-box { width: 36px; height: 44px; font-size: 22px; }
}
