:root {
  --roxo-principal: #6d009f;
  --roxo-escuro: #4a006d;
  --verde: #00bc3f;
  --amarelo: #ffd100;
  --fundo: #f1f5f9;
  --texto: #1e293b;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--fundo);
  color: var(--texto);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

.header-campanha {
  text-align: center;
  margin-bottom: 20px;
  width: 100%;
  max-width: 480px;
}

.brand-badge {
  background: linear-gradient(135deg, var(--roxo-principal), var(--roxo-escuro));
  color: #ffffff;
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(109, 0, 159, 0.25);
  border-bottom: 4px solid var(--verde);
}

.brand-badge img.logo {
  max-height: 56px;
  margin-bottom: 8px;
}

.brand-badge h1 {
  font-size: 26px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.brand-badge .cargo {
  font-size: 13px;
  font-weight: 600;
  opacity: 0.9;
  margin-top: 2px;
}

.brand-badge .numero-container {
  margin-top: 6px;
  display: inline-block;
}

.brand-badge .numero {
  background: var(--amarelo);
  color: var(--roxo-principal);
  padding: 2px 14px;
  border-radius: 6px;
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 1px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.card {
  background: #ffffff;
  border-radius: 16px;
  padding: 20px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.08);
  border: 1px solid #e2e8f0;
  text-align: center;
}

p.instrucao {
  font-size: 14px;
  color: #475569;
  margin-bottom: 16px;
  font-weight: 500;
}

.moldura-selector-container {
  margin-bottom: 18px;
  text-align: left;
}

.moldura-selector-container label {
  font-size: 13px;
  font-weight: 700;
  color: var(--roxo-principal);
  display: block;
  margin-bottom: 8px;
}

.molduras-options {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.molduras-options::-webkit-scrollbar {
  height: 5px;
}
.molduras-options::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.moldura-option {
  flex: 1 0 92px;
  scroll-snap-align: start;
  border: 2px solid #cbd5e1;
  border-radius: 10px;
  padding: 10px 8px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.moldura-option:hover {
  border-color: var(--roxo-principal);
  background: #f1f5f9;
}

.moldura-option.selected {
  border-color: var(--roxo-principal);
  background: #f3e8ff;
  box-shadow: 0 0 0 2px rgba(109, 0, 159, 0.2);
}

.moldura-option img, .moldura-option .preview-placeholder {
  width: 50px;
  height: 50px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid #cbd5e1;
  background: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: var(--roxo-principal);
  font-size: 12px;
}

.moldura-option span.title {
  font-size: 12px;
  font-weight: 700;
  color: var(--texto);
  white-space: nowrap;
}

.button-group { display: flex; gap: 10px; margin-bottom: 16px; }

.btn-secondary {
  flex: 1;
  background: var(--verde);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  padding: 12px 8px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

input[type="file"] { display: none; }

.camera-container {
  display: none;
  position: relative;
  margin-bottom: 16px;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}

video {
  width: 100%;
  height: auto;
  display: block;
}
video.mirror {
  transform: scaleX(-1);
}

.btn-capture {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: #ef4444;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 20px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.btn-switch-camera {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0,0,0,0.5);
  color: white;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
}

.input-group { margin-bottom: 16px; text-align: left; }
label { font-size: 13px; font-weight: 700; color: var(--roxo-principal); display: block; margin-bottom: 6px; }

.zoom-control { display: flex; align-items: center; gap: 10px; }
input[type="range"] {
  flex: 1;
  accent-color: var(--roxo-principal);
  height: 6px;
}

.canvas-wrapper {
  position: relative;
  width: 100%;
  margin: 16px 0;
  border-radius: 12px;
  overflow: hidden;
  background: #e2e8f0;
  border: 2px solid #cbd5e1;
  touch-action: none;
}
canvas { width: 100%; height: auto; display: block; cursor: grab; touch-action: none; }
canvas:active { cursor: grabbing; }

.btn-primary {
  width: 100%;
  background: var(--roxo-principal);
  color: var(--amarelo);
  font-size: 16px;
  font-weight: 900;
  text-transform: uppercase;
  padding: 16px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.local-warning {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #991b1b;
  padding: 10px;
  font-size: 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  display: none;
  text-align: left;
}

.toast-erro {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #991b1b;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  z-index: 100000;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  max-width: 90vw;
  text-align: center;
}

.modal-result {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.92);
  z-index: 99999;
  padding: 20px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.modal-result img {
  max-width: 90%;
  max-height: 60vh;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.modal-result p {
  color: #ffffff;
  margin-top: 15px;
  font-size: 14px;
  text-align: center;
  font-weight: 600;
  line-height: 1.4;
}
.modal-close {
  margin-top: 15px;
  background: var(--verde);
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
}

.footer-legal {
  max-width: 480px;
  width: 100%;
  margin-top: 20px;
  padding: 12px;
  font-size: 10px;
  color: #64748b;
  text-align: center;
  border-top: 1px solid #cbd5e1;
  line-height: 1.5;
}
