/* ONZE PRIME — estilos (mobile-first) */
:root {
  --papel: #F4EFE3;
  --branco: #FFFDF8;
  --tinta: #121A2E;
  --suave: #5C6477;
  --azul: #1E4FC2;
  --amarelo: #FFCB2D;
  --vermelho: #D8342B;
  --relva: #2B8A57;
  --relva-2: #237A4C;
  --linha: rgba(255, 255, 255, .5);
  --pos-gr: #A66A00;
  --pos-def: #1E4FC2;
  --pos-med: #1F7A4A;
  --pos-ata: #C92A22;
  --titulo: "Barlow Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --texto: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --raio: 12px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--papel);
  color: var(--tinta);
  font-family: var(--texto);
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
a.btn { cursor: pointer; }
button { background: none; border: 0; padding: 0; }
[hidden] { display: none !important; }
img { display: block; }

/* Altura a 100% (e não 100vh): cabe na área visível mesmo com as barras do browser no telemóvel. */
#app { min-height: 100%; display: flex; flex-direction: column; }
body.em-jogo #app { height: 100%; }
main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

/* ---------- Topo ---------- */
.topo {
  flex: 0 0 auto;
  height: 46px;
  padding-block: 0;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; align-items: center; justify-content: space-between;
  background: var(--papel);
}
.marca {
  font-family: var(--titulo); font-weight: 800; font-size: 26px; letter-spacing: .01em; line-height: 1;
  display: inline-flex; align-items: center; gap: 5px;
}
.marca span {
  background: var(--azul); color: #fff; padding: 2px 6px 3px; border-radius: 5px;
}
.topo-info { display: flex; align-items: center; gap: 10px; }
.ronda { font-family: var(--titulo); font-weight: 700; font-size: 17px; letter-spacing: .04em; }
.media {
  display: inline-flex; align-items: baseline; gap: 6px;
  background: var(--tinta); color: var(--papel);
  padding: 3px 9px 4px; border-radius: 8px;
}
.media small { font-family: var(--titulo); font-weight: 600; font-size: 11px; letter-spacing: .12em; opacity: .75; }
.media b { font-family: var(--titulo); font-weight: 800; font-size: 20px; min-width: 34px; text-align: right; color: var(--amarelo); }

/* Faixa de azulejo: assinatura visual da marca */
.azulejo {
  flex: 0 0 auto; height: 8px;
  border-top: 2px solid var(--tinta); border-bottom: 2px solid var(--tinta);
  box-sizing: content-box;
  background:
    linear-gradient(135deg, var(--azul) 25%, transparent 25%) -4px 0 / 8px 8px,
    linear-gradient(225deg, var(--azul) 25%, transparent 25%) -4px 0 / 8px 8px,
    linear-gradient(315deg, var(--azul) 25%, transparent 25%) 0 0 / 8px 8px,
    linear-gradient(45deg,  var(--azul) 25%, transparent 25%) 0 0 / 8px 8px,
    var(--branco);
}

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--titulo); font-weight: 700; font-size: 19px; letter-spacing: .04em; text-transform: uppercase;
  text-decoration: none;
  padding: 10px 18px; min-height: 46px;
  background: var(--branco); color: var(--tinta);
  border: 2px solid var(--tinta); border-radius: var(--raio);
  box-shadow: 0 3px 0 var(--tinta);
  transition: transform .08s ease, box-shadow .08s ease;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--tinta); }
.btn:focus-visible, .opcao:focus-visible, .marca:focus-visible, .vaga-vazia:focus-visible { outline: 3px solid var(--azul); outline-offset: 2px; }
.btn-primario { background: var(--amarelo); }
.btn-grande { font-size: 30px; font-weight: 800; padding: 12px 44px; min-height: 62px; }
.btn-fantasma { border-color: transparent; box-shadow: none; background: transparent; color: var(--suave); }
.btn[disabled] { opacity: .45; cursor: default; box-shadow: 0 3px 0 var(--tinta); transform: none; }

/* ---------- Início ---------- */
.inicio {
  flex: 1 1 auto;
  display: flex; flex-direction: column; align-items: center;
  padding-block: 28px 24px; text-align: center;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
  max-width: 520px; width: 100%; margin: 0 auto;
}
.hero {
  margin: 8px 0 0;
  font-family: var(--titulo); font-weight: 800; line-height: .86; letter-spacing: -.01em;
  font-size: clamp(84px, 27vw, 132px);
  display: flex; flex-direction: column; align-items: center;
}
.hero span {
  background: var(--azul); color: #fff; padding: 0 .12em .06em; border-radius: .09em;
  border: 3px solid var(--tinta); box-shadow: 0 5px 0 var(--tinta);
  transform: rotate(-2deg); margin-top: .03em;
}
.lema { margin: 26px 0 0; font-family: var(--titulo); font-weight: 700; font-size: clamp(18px, 5.6vw, 24px); letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; }
.recorde-inicio {
  margin-top: 16px; padding: 7px 14px;
  background: var(--tinta); color: var(--papel); border-radius: 999px;
  font-family: var(--titulo); font-weight: 600; font-size: 17px; letter-spacing: .05em; text-transform: uppercase;
}
.recorde-inicio b { color: var(--amarelo); font-weight: 800; font-size: 20px; }
.inicio-botoes { margin-top: 22px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.regras {
  margin: 30px 0 0; padding: 0; list-style: none; counter-reset: r;
  display: grid; gap: 10px; text-align: left; width: 100%;
}
.regras li {
  counter-increment: r; position: relative;
  padding: 10px 12px 10px 48px;
  background: var(--branco); border: 2px solid var(--tinta); border-radius: var(--raio);
  font-size: 15px; line-height: 1.35; color: #2B3350;
}
.regras li::before {
  content: counter(r); position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--tinta); color: var(--amarelo);
  font-family: var(--titulo); font-weight: 800; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
}
.regras b { color: var(--tinta); font-weight: 600; }
.mural { margin-top: 26px; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 12px; max-width: 420px; }
.mural img { width: 30px; height: 30px; object-fit: contain; }
.rodape { margin: 22px 0 0; font-size: 12px; color: var(--suave); line-height: 1.4; }

/* ---------- Jogo ---------- */
.jogo {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column; gap: 8px;
  padding-block: 8px 12px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  width: 100%; max-width: 560px; margin: 0 auto;
}
.progresso { flex: 0 0 auto; display: flex; gap: 3px; }
.progresso i { flex: 1; height: 5px; border-radius: 3px; background: rgba(18, 26, 46, .16); }
.progresso i.feito { background: var(--tinta); }
.progresso i.atual { background: var(--vermelho); }

.campo-wrap { flex: 1 1 auto; min-height: 236px; position: relative; }
.campo {
  position: absolute; inset: 0 0 3px 0;
  border: 2px solid var(--tinta); border-radius: 14px; box-shadow: 0 3px 0 var(--tinta);
  overflow: hidden;
  background: repeating-linear-gradient(180deg, var(--relva) 0 12.5%, var(--relva-2) 12.5% 25%);
  container-type: size;
}
.linhas { position: absolute; inset: 7px; border: 2px solid var(--linha); border-radius: 6px; pointer-events: none; }
.linhas i { position: absolute; display: block; }
.l-meio { left: 0; right: 0; top: 50%; height: 2px; margin-top: -1px; background: var(--linha); }
.l-circulo { left: 50%; top: 50%; width: 22%; aspect-ratio: 1; transform: translate(-50%, -50%); border: 2px solid var(--linha); border-radius: 50%; }
.l-area { left: 27%; right: 27%; height: 13%; border: 2px solid var(--linha); }
.l-cima { top: -2px; }
.l-baixo { bottom: -2px; }

.vaga { position: absolute; transform: translate(-50%, -50%); z-index: 1; }
.vaga-vazia {
  width: 42px; height: 42px; border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, .75);
  background: rgba(10, 40, 26, .22);
  color: #fff; font-family: var(--titulo); font-weight: 700; font-size: 14px; letter-spacing: .04em;
  display: flex; align-items: center; justify-content: center;
}
.vaga.alvo { z-index: 3; }
.vaga.alvo .vaga-vazia {
  background: var(--amarelo); color: var(--tinta); border: 2px solid var(--tinta);
  box-shadow: 0 2px 0 var(--tinta);
  animation: pulsar .9s ease-in-out infinite;
  cursor: pointer;
}
.ficha {
  width: clamp(68px, 21.5vw, 104px);
  width: clamp(68px, 23cqw, 122px);
  background: var(--branco); border: 2px solid var(--tinta); border-radius: 7px;
  box-shadow: 0 2px 0 var(--tinta);
  padding: 2px 5px 3px;
}
.ficha-topo { display: flex; align-items: center; gap: 3px; height: 17px; }
.ficha-topo img { width: 15px; height: 15px; object-fit: contain; flex: 0 0 auto; }
.ficha-ep { font-family: var(--titulo); font-weight: 600; font-size: 11px; color: var(--suave); letter-spacing: .02em; }
.ficha-ovr { margin-left: auto; font-family: var(--titulo); font-weight: 800; font-size: 16px; color: var(--vermelho); line-height: 1; }
.ficha-nome {
  font-family: var(--titulo); font-weight: 700; font-size: 13.5px; line-height: 1.08; text-transform: uppercase; letter-spacing: .01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vaga.nova .ficha { animation: entrar .26s cubic-bezier(.2, 1.5, .4, 1); }

/* ---------- Painel de draft ---------- */
.painel { flex: 0 0 auto; display: flex; flex-direction: column; gap: 7px; }
.sorteio {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px 7px 10px;
  background: var(--branco); border: 2px solid var(--tinta); border-radius: var(--raio); box-shadow: 0 3px 0 var(--tinta);
  position: relative; overflow: hidden;
}
.sorteio::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--cor-clube, var(--tinta)); }
.sorteio-emblema { width: 40px; height: 40px; object-fit: contain; margin-left: 4px; flex: 0 0 auto; }
.sorteio-texto { flex: 1 1 auto; min-width: 0; }
.sorteio-rotulo { font-family: var(--titulo); font-weight: 600; font-size: 11.5px; letter-spacing: .14em; color: var(--suave); text-transform: uppercase; line-height: 1.1; }
.sorteio-nome {
  font-family: var(--titulo); font-weight: 800; font-size: 25px; line-height: 1; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.btn-troca { flex: 0 0 auto; font-size: 15px; padding: 6px 10px; min-height: 40px; gap: 6px; box-shadow: 0 2px 0 var(--tinta); }
.btn-troca b { background: var(--tinta); color: var(--amarelo); border-radius: 5px; padding: 0 6px 1px; font-weight: 800; }
.btn-troca svg { width: 15px; height: 15px; }

.dica { margin: 0 2px; font-size: 12.5px; color: var(--suave); line-height: 1.2; min-height: 15px; }
.dica.ativa { color: var(--tinta); font-weight: 600; }

.opcoes { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.opcao {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 7px;
  padding: 5px 8px 6px 6px; min-height: 50px; text-align: left;
  background: var(--branco); border: 2px solid var(--tinta); border-radius: 10px; box-shadow: 0 2px 0 var(--tinta);
  transition: transform .08s ease, box-shadow .08s ease, background .1s ease;
}
.opcao:active { transform: translateY(2px); box-shadow: 0 0 0 var(--tinta); }
.opcao.sel { background: var(--amarelo); }
.opcao.fantasma { border-style: dashed; border-color: rgba(18, 26, 46, .25); box-shadow: none; background: transparent; }
.opcao.revelar { animation: revelar .22s ease both; }
.pos {
  min-width: 32px; padding: 3px 4px 4px; border-radius: 5px; text-align: center;
  font-family: var(--titulo); font-weight: 800; font-size: 13px; letter-spacing: .03em; color: #fff; line-height: 1;
}
.pos-GR { background: var(--pos-gr); }
.pos-DD, .pos-DC, .pos-DE { background: var(--pos-def); }
.pos-MDC, .pos-MC, .pos-MO { background: var(--pos-med); }
.pos-ED, .pos-EE, .pos-PL { background: var(--pos-ata); }
.op-nome { display: block; font-family: var(--titulo); font-weight: 700; font-size: 17px; line-height: 1.05; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.op-meta { display: block; font-size: 11.5px; color: var(--suave); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.opcao.sel .op-meta { color: #4A4220; }
.op-ovr { font-family: var(--titulo); font-weight: 800; font-size: 26px; line-height: 1; }

/* ---------- Resultado ---------- */
.resultado { display: flex; flex-direction: column; gap: 10px; animation: revelar .3s ease both; }
.res-cartao {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px;
  background: var(--tinta); color: var(--papel);
  border: 2px solid var(--tinta); border-radius: var(--raio); box-shadow: 0 3px 0 rgba(18, 26, 46, .35);
}
.res-num { font-family: var(--titulo); font-weight: 800; font-size: 74px; line-height: .86; color: var(--amarelo); letter-spacing: -.01em; }
.res-num span { font-size: .55em; }
.res-lado { min-width: 0; }
.res-rotulo { font-family: var(--titulo); font-weight: 600; font-size: 12px; letter-spacing: .16em; opacity: .7; }
.res-patamar { font-family: var(--titulo); font-weight: 800; font-size: 25px; line-height: 1.02; text-transform: uppercase; margin-top: 1px; }
.res-recorde { font-size: 13px; margin-top: 4px; opacity: .85; }
.res-recorde.novo { color: var(--amarelo); opacity: 1; font-weight: 600; }
.res-botoes { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.res-botoes .btn { white-space: nowrap; padding-left: 8px; padding-right: 8px; }

/* ---------- Modal de partilha ---------- */
.modal {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(18, 26, 46, .72);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-caixa {
  width: 100%; max-width: 380px; max-height: 100%; overflow: auto;
  background: var(--papel); border: 2px solid var(--tinta); border-radius: 16px; box-shadow: 0 5px 0 var(--tinta);
  padding: 12px; display: flex; flex-direction: column; gap: 12px;
}
.modal-caixa img { width: 100%; height: auto; border: 2px solid var(--tinta); border-radius: 10px; }
.modal-botoes { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.modal-botoes .btn { font-size: 17px; padding: 8px 10px; }
.modal-botoes .btn-primario, .modal-botoes .btn-fantasma { grid-column: 1 / -1; }
.modal-dica { margin: -4px 0 0; font-size: 12.5px; color: var(--suave); text-align: center; }

/* ---------- Animações ---------- */
@keyframes entrar { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes revelar { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pulsar { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Ecrãs baixos (ex.: iPhone SE com barras do browser) ---------- */
@media (max-height: 640px) {
  .topo { height: 40px; }
  .marca { font-size: 23px; }
  .jogo { gap: 6px; padding-block: 6px 8px; }
  .opcao { min-height: 44px; padding-top: 3px; padding-bottom: 4px; }
  .op-nome { font-size: 16px; }
  .op-ovr { font-size: 23px; }
  .sorteio { padding-top: 5px; padding-bottom: 5px; }
  .sorteio-emblema { width: 34px; height: 34px; }
  .sorteio-nome { font-size: 22px; }
  .vaga-vazia { width: 36px; height: 36px; font-size: 13px; }
  .ficha-nome { font-size: 12.5px; }
  .res-num { font-size: 60px; }
}
@media (max-width: 350px) {
  .op-nome { font-size: 15px; }
  .pos { min-width: 28px; font-size: 12px; }
  .ronda { font-size: 15px; }
}

/* ---------- Desktop: duas colunas, campo à esquerda ---------- */
@media (min-width: 900px) {
  .topo { height: 58px; padding-left: 28px; padding-right: 28px; }
  .marca { font-size: 32px; }
  .ronda { font-size: 21px; }
  .media b { font-size: 24px; }
  .jogo {
    max-width: 1080px;
    display: grid; grid-template-columns: minmax(0, 1fr) 410px; grid-template-rows: auto minmax(0, 1fr);
    column-gap: 32px; row-gap: 12px; padding-block: 18px 24px; padding-left: 28px; padding-right: 28px;
  }
  .progresso { grid-column: 1 / -1; }
  .progresso i { height: 6px; }
  .campo-wrap { min-height: 480px; max-width: 620px; width: 100%; justify-self: center; }
  .painel { gap: 12px; align-self: start; }
  .sorteio { padding: 12px 12px 12px 14px; }
  .sorteio-emblema { width: 56px; height: 56px; }
  .sorteio-nome { font-size: 32px; }
  .opcoes { gap: 10px; }
  .opcao { min-height: 60px; padding: 8px 10px 9px 8px; }
  .opcao:hover { background: #FFF3C4; }
  .op-nome { font-size: 19px; }
  .op-ovr { font-size: 30px; }
  .vaga-vazia { width: 54px; height: 54px; font-size: 17px; }
  .ficha { padding: 4px 7px 5px; }
  .ficha-topo { height: 22px; }
  .ficha-topo img { width: 20px; height: 20px; }
  .ficha-ep { font-size: 13px; }
  .ficha-ovr { font-size: 21px; }
  .ficha-nome { font-size: 17px; }
  .res-num { font-size: 96px; }
  .res-patamar { font-size: 30px; }
  .res-botoes { grid-template-columns: 1fr; }
  .dica { font-size: 14px; }
}
