/* Simulador de urna: feito para celular (retrato e paisagem). */
*, *::before, *::after { box-sizing: border-box; }
:root {
  --fundo: #2b2a28;
  --carcaca: #e4dfd3;
  --carcaca-esc: #cfc8b8;
  --moldura: #1d1d1c;
  --visor: #f7f7f5;
  --tinta: #111;
  --tecla: #151515;
  --verde: #1f9d3a;
  --verde-esc: #13732a;
  --laranja: #e9701a;
  --laranja-esc: #b8540d;
  --vermelho: #c8102e;
}
html, body { margin: 0; height: 100%; }
body {
  background: var(--fundo);
  color: var(--tinta);
  font-family: Arial, Helvetica, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
button { font-family: inherit; }
[hidden] { display: none !important; }

/* Faixa de prévia */
.previa {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  background: #ffd400; color: #000; font: bold 11px/20px Arial, sans-serif;
  text-align: center; letter-spacing: .04em; height: 20px;
}
body.com-previa .urna { padding-top: calc(20px + env(safe-area-inset-top)); }
body.com-previa .resultado { padding-top: calc(32px + env(safe-area-inset-top)); }

/* ---------- URNA ---------- */
.urna {
  height: 100vh; height: 100dvh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  grid-template-areas: "topo" "tela" "teclado";
  gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, var(--carcaca) 0%, var(--carcaca-esc) 100%);
  max-width: 560px; margin: 0 auto;
  overflow: hidden;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}
.topo {
  grid-area: topo;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 26px;
}
.topo-titulo { font-weight: bold; font-size: 15px; letter-spacing: .02em; color: #2d2b27; white-space: nowrap; }
.topo-etapa { font-size: 13px; color: #4a463e; white-space: nowrap; }
.topo-etapa b { color: #111; }

/* Visor */
.tela {
  grid-area: tela;
  container-type: inline-size;
  background: var(--moldura);
  border-radius: 10px;
  padding: 8px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,.6), 0 1px 0 rgba(255,255,255,.6);
}
.tela-voto, .tela-fim {
  background: var(--visor);
  border-radius: 3px;
  min-height: 76cqw; /* proporção da tela da urna; cresce se o conteúdo precisar */
  width: 100%;
  display: flex; flex-direction: column;
  padding: 3.2cqw 3.4cqw 2.4cqw;
  overflow: hidden;
}
.tv-corpo { flex: 1 0 auto; display: flex; gap: 2cqw; margin-bottom: 1.6cqw; }
.tv-info { flex: 1 1 auto; min-width: 0; }
.tv-seu { margin: 0; font-size: 3.5cqw; font-weight: bold; letter-spacing: .02em; }
.tv-cargo {
  margin: 3cqw 0 3.4cqw; font-size: 6.4cqw; font-weight: normal; text-align: center;
  line-height: 1.1; padding-right: 1cqw;
}
.tv-cargo small { display: block; font-size: 3.4cqw; margin-top: .6cqw; color: #333; }
.tv-linha { display: flex; align-items: baseline; gap: 1.6cqw; font-size: 4cqw; margin: 0 0 1.8cqw; min-width: 0; }
.tv-linha strong { font-weight: bold; overflow-wrap: anywhere; }
.tv-rot { flex: 0 0 auto; }
.tv-numero { align-items: center; margin-bottom: 3cqw; }
.digitos { display: inline-flex; gap: 1.1cqw; }
.digito {
  width: 6.8cqw; height: 8.6cqw;
  border: 1px solid #222;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 6.6cqw; font-weight: bold; background: #fff;
}
.digito.cursor { animation: pisca 1s steps(1) infinite; }
@keyframes pisca { 50% { background: #222; } }
.tv-extra { flex-direction: column; align-items: flex-start; gap: .6cqw; font-size: 3.4cqw; }
.tv-extra:empty { display: none; }
.tv-fotos { flex: 0 0 25cqw; display: flex; flex-direction: column; align-items: flex-end; gap: 1.4cqw; }
.tv-foto { margin: 0; width: 25cqw; text-align: center; }
.tv-foto img {
  width: 100%; aspect-ratio: 3 / 4; object-fit: cover; display: block;
  border: 1px solid #999; background: #ddd;
}
.tv-foto figcaption { font-size: 2.8cqw; margin-top: .6cqw; }
.tv-foto-vice { width: 15cqw; }
.tv-rodape {
  border-top: 1px solid #333; padding-top: 1.6cqw; font-size: 3.2cqw; line-height: 1.35;
}
.tv-rodape p { margin: 0; }
.tv-inst { padding-left: 3cqw; }
.t-verde { color: var(--verde-esc); }
.t-laranja { color: var(--laranja-esc); }
.oculto { visibility: hidden; }

.tela-fim { align-items: center; justify-content: center; position: relative; }
.fim { font-size: 30cqw; font-weight: bold; letter-spacing: .06em; line-height: 1; }
.votou { position: absolute; right: 4cqw; bottom: 3cqw; font-size: 3.6cqw; color: #555; letter-spacing: .1em; }

/* Teclado */
.teclado {
  grid-area: teclado;
  min-height: 0;
  background: #2a2927;
  border-radius: 12px;
  padding: 12px 14px 14px;
  display: grid;
  grid-template-rows: minmax(0, 4fr) minmax(0, 1.55fr);
  gap: 12px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 2px 0 rgba(0,0,0,.25);
}
.numeros {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: 8px 14px;
  min-height: 0;
  padding: 0 6%;
}
.tecla-0 { grid-column: 2; }
.tecla {
  background: linear-gradient(180deg, #2c2c2c, var(--tecla));
  color: #fff; border: 0; border-radius: 7px;
  font-size: clamp(20px, 6.4vw, 30px); font-weight: bold;
  box-shadow: 0 3px 0 #000, inset 0 1px 0 rgba(255,255,255,.18);
  min-height: 0; padding: 0;
  transition: transform .06s, box-shadow .06s, background .06s;
}
.tecla.apertada, .tecla:active, .tecla-acao:active, .tecla-acao.apertada {
  transform: translateY(3px); box-shadow: 0 0 0 #000, inset 0 1px 0 rgba(255,255,255,.1);
}
.tecla.apertada { background: #555; }
.acoes {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.25fr);
  gap: 10px;
  align-items: end;
  min-height: 0;
}
.tecla-acao {
  border: 0; border-radius: 7px; min-height: 0; padding: 0 2px;
  font-weight: bold; font-size: clamp(11px, 3.3vw, 15px); letter-spacing: .02em;
  height: 78%;
  box-shadow: 0 3px 0 rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.35);
  transition: transform .06s, box-shadow .06s;
}
.branco { background: #f4f4f1; color: #111; }
.corrige { background: var(--laranja); color: #111; }
.confirma-wrap { position: relative; height: 100%; display: flex; align-items: flex-end; }
.confirma { background: var(--verde); color: #111; width: 100%; height: 100%; font-size: clamp(12px, 3.6vw, 16px); }
.confirma.inativo { filter: saturate(.55) brightness(.85); }
.confirma.pulsando { animation: pulsa 1.15s ease-out infinite; }
@keyframes pulsa {
  0%   { box-shadow: 0 3px 0 rgba(0,0,0,.55), 0 0 0 0 rgba(64, 220, 100, .85); transform: scale(1); }
  45%  { transform: scale(1.06); }
  70%  { box-shadow: 0 3px 0 rgba(0,0,0,.55), 0 0 0 16px rgba(64, 220, 100, 0); }
  100% { box-shadow: 0 3px 0 rgba(0,0,0,.55), 0 0 0 0 rgba(64, 220, 100, 0); transform: scale(1); }
}
.dica {
  position: absolute; bottom: calc(100% + 10px); left: 50%; margin-left: -46px; width: 92px; text-align: center;
  background: #fff; color: #111; font-size: 12px; font-weight: bold;
  padding: 6px 9px; border-radius: 8px; white-space: nowrap;
  box-shadow: 0 3px 10px rgba(0,0,0,.35);
  opacity: 0; transform: translateY(4px); transition: opacity .25s, transform .25s;
  pointer-events: none;
}
.dica::after {
  content: ""; position: absolute; top: 100%; left: 50%; margin-left: -7px;
  border: 7px solid transparent; border-top-color: #fff;
}
.dica.visivel { opacity: 1; transform: none; animation: sobe 1.15s ease-in-out infinite; }
@keyframes sobe { 50% { transform: translateY(-3px); } }

.aviso {
  position: fixed; left: 50%; top: calc(64px + env(safe-area-inset-top)); z-index: 40;
  transform: translate(-50%, -12px); opacity: 0; pointer-events: none;
  background: #111; color: #fff; font-size: 14px; padding: 10px 14px; border-radius: 10px;
  max-width: calc(100% - 32px); text-align: center;
  transition: opacity .2s, transform .2s;
}
.aviso.visivel { opacity: 1; transform: translate(-50%, 0); }
.tremer { animation: treme .3s; }
@keyframes treme { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

/* Tela de início por cima da urna */
.inicio {
  position: fixed; inset: 0; z-index: 35;
  background: rgba(20, 19, 18, .72);
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.inicio-caixa {
  background: var(--carcaca); border-radius: 18px; padding: 26px 22px 24px;
  width: 100%; max-width: 360px; text-align: center; box-shadow: 0 16px 40px rgba(0,0,0,.45);
}
.inicio-caixa h1 { margin: 0 0 10px; font-size: 27px; line-height: 1.15; }
.inicio-caixa p { margin: 0 0 8px; font-size: 15px; line-height: 1.4; color: #333; }
.inicio-som { font-size: 13px !important; color: #555 !important; }
.bt-comecar {
  margin-top: 14px; width: 100%; border: 0; border-radius: 12px;
  background: var(--verde); color: #fff; font-size: 20px; font-weight: bold; letter-spacing: .04em;
  padding: 17px 12px; box-shadow: 0 4px 0 var(--verde-esc);
  animation: pulsa 1.15s ease-out infinite;
}
.legal { font-size: 10.5px !important; line-height: 1.35 !important; color: #6b675f !important; margin: 14px 0 0 !important; }
.legal:empty { display: none; }
.legal-escuro { color: #9d998f !important; }
.bt-comecar:disabled { animation: none; opacity: .8; }

/* Celular deitado: visor à esquerda e teclado à direita, como na urna real */
@media (orientation: landscape) and (max-height: 540px) {
  .urna {
    max-width: none;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "topo topo" "tela teclado";
    padding-left: calc(12px + env(safe-area-inset-left));
    padding-right: calc(12px + env(safe-area-inset-right));
  }
  .tela { align-self: stretch; min-height: 0; display: flex; flex-direction: column; }
  .tela-voto, .tela-fim { flex: 1 1 auto; min-height: 0; height: auto; }
  .tecla { font-size: clamp(16px, 4.5vh, 24px); }
  .tecla-acao { font-size: 12px; }
  .numeros { gap: 6px 10px; }
  .teclado { gap: 8px; padding: 10px; }
  .tv-fotos { flex-basis: 17cqw; gap: .8cqw; }
  .tv-foto { width: 17cqw; }
  .tv-foto-vice { width: 11cqw; }
  .tv-foto figcaption { font-size: 2.4cqw; }
  .tela-voto { padding: 2.4cqw 3cqw 1.8cqw; }
  .tv-cargo { font-size: 5.4cqw; margin: 1.6cqw 0 2cqw; }
  .tv-numero { margin-bottom: 1.8cqw; }
  .digito { width: 5.8cqw; height: 7.4cqw; font-size: 5.6cqw; }
  .tv-linha { font-size: 3.5cqw; margin-bottom: 1cqw; }
  .tv-extra { font-size: 3cqw; gap: .2cqw; }
  .tv-rodape { font-size: 2.8cqw; line-height: 1.25; padding-top: 1cqw; }
}

/* ---------- RESULTADO ---------- */
.resultado {
  position: fixed; inset: 0; z-index: 30;
  background: var(--fundo);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  animation: surge .35s ease-out;
}
@keyframes surge { from { opacity: 0; transform: translateY(12px); } }
.res-caixa { max-width: 480px; margin: 0 auto; color: #fff; text-align: center; }
.res-caixa h2 { font-size: 21px; margin: 4px 0 6px; line-height: 1.25; }
.res-sub { margin: 0 0 14px; font-size: 14px; color: #d9d6cf; line-height: 1.4; }
.res-cidade { position: relative; text-align: left; margin: 0 0 14px; }
.res-cidade label { display: block; font-size: 14px; font-weight: bold; margin-bottom: 6px; }
.res-cidade label span { font-weight: normal; color: #b9b5ab; }
.cidade-campo { position: relative; }
.cidade-campo input {
  width: 100%; font-size: 16px; padding: 13px 44px 13px 14px; border-radius: 12px;
  border: 2px solid #5a5650; background: #fff; color: #111; font-family: inherit;
}
.cidade-campo input:focus { outline: none; border-color: var(--verde); }
.cidade-campo input.escolhida { border-color: var(--verde); font-weight: bold; }
.cidade-limpar {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border: 0; border-radius: 50%; background: #e7e5df; color: #333; font-size: 22px; line-height: 1;
}
.cidade-lista {
  list-style: none; margin: 6px 0 0; padding: 4px; background: #fff; border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); max-height: 244px; overflow-y: auto;
}
.cidade-lista li button {
  width: 100%; text-align: left; border: 0; background: transparent; color: #111;
  font-size: 16px; padding: 11px 12px; border-radius: 8px;
}
.cidade-lista li button:active, .cidade-lista li button:focus { background: #e9f6ec; outline: none; }
.cidade-lista .vazio { color: #666; font-size: 14px; padding: 10px 12px; }
.res-card { display: flex; justify-content: center; }
.res-card img {
  width: auto; max-width: 100%; max-height: 52vh; max-height: 52dvh;
  border-radius: 10px; box-shadow: 0 8px 26px rgba(0,0,0,.5); display: block;
  -webkit-touch-callout: default; user-select: auto; -webkit-user-select: auto;
}
.res-dica { font-size: 12px; color: #b9b5ab; margin: 8px 0 12px; }
.res-botoes { display: grid; gap: 10px; }
.bt {
  border: 0; border-radius: 12px; font-size: 16px; font-weight: bold;
  padding: 15px 14px; width: 100%; cursor: pointer; line-height: 1.2;
}
.bt-principal { background: var(--verde); color: #fff; }
.bt:disabled { opacity: .6; }
.bt-zap { background: #25d366; color: #0b3d1e; }
.bt-sec { background: #fff; color: #111; }
.bt-link { background: transparent; color: #fff; text-decoration: underline; padding: 8px; font-weight: normal; }
.res-lembrete { font-size: 12px; color: #b9b5ab; margin: 14px 0 0; line-height: 1.4; }

/* ---------- COMPUTADOR ---------- */
.desktop { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.dk-caixa {
  background: var(--carcaca); border-radius: 18px; padding: 36px 40px; text-align: center;
  max-width: 440px; width: 100%; box-shadow: 0 20px 50px rgba(0,0,0,.4);
}
.dk-caixa h1 { margin: 0 0 12px; font-size: 30px; }
.dk-caixa p { margin: 6px 0; font-size: 16px; color: #333; }
.dk-qr { display: flex; justify-content: center; margin: 20px auto 14px; min-height: 220px; }
.dk-qr img, .dk-qr canvas { background: #fff; padding: 12px; border-radius: 8px; }
.dk-url { font-weight: bold; word-break: break-all; }

@media (prefers-reduced-motion: reduce) {
  .confirma.pulsando { animation-duration: 2s; }
  .dica.visivel { animation: none; }
}
