/* Layout: um ecrã por pergunta, coluna central estreita, alvos de toque grandes.
   Cor: cacau + folha dourada da embalagem; 5 caras com cores semânticas próprias. */
:root {
  --bg: #FAF7F5;
  --surface: #FFFFFF;
  --ink: #2B1A12;
  --muted: #6D5950;
  --line: #E7DDD7;
  --accent: #6B3A22;
  --accent-ink: #FFFFFF;
  --gold: #B27C26;
  --sel: #F3E8E0;
  --warn-bg: #FFF4DC;
  --warn-ink: #6A4A00;
  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;
  --r: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1B1310; --surface: #261B16; --ink: #F5ECE6; --muted: #BDA99E; --line: #3C2D26;
    --accent: #E2AC7E; --accent-ink: #1B1310; --gold: #D9A64A; --sel: #34251E;
    --warn-bg: #3A2E14; --warn-ink: #F3D58B; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1B1310; --surface: #261B16; --ink: #F5ECE6; --muted: #BDA99E; --line: #3C2D26;
  --accent: #E2AC7E; --accent-ink: #1B1310; --gold: #D9A64A; --sel: #34251E;
  --warn-bg: #3A2E14; --warn-ink: #F3D58B; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 18px; line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.app { min-height: 100%; display: flex; flex-direction: column; }

/* Barra superior */
.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.top-row {
  max-width: 640px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px; min-height: 56px;
}
.brand { font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { display: block; font-family: var(--font-body); font-weight: 400; font-size: 13px; color: var(--muted); letter-spacing: 0; }
.back {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; flex: none;
}
.back svg { width: 20px; height: 20px; }
.lang { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; flex: none; }
.lang button { border: 0; background: transparent; padding: 8px 12px; font-size: 14px; font-weight: 700; cursor: pointer; color: var(--muted); min-height: 40px; }
.lang button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.progress { height: 4px; background: var(--line); }
.progress i { display: block; height: 100%; background: var(--gold); transition: width .3s ease; }

/* Conteúdo */
.main { flex: 1; width: 100%; max-width: 640px; margin: 0 auto; padding: 24px 16px 32px; display: flex; flex-direction: column; gap: 20px; }
.eyebrow { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--gold); font-weight: 700; display: flex; justify-content: space-between; gap: 12px; }
.eyebrow span:last-child { color: var(--muted); font-weight: 400; letter-spacing: .02em; text-transform: none; font-variant-numeric: tabular-nums; }
h1, h2 { font-family: var(--font-display); letter-spacing: -0.02em; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(32px, 8vw, 46px); line-height: 1.02; }
h2 { font-size: clamp(24px, 6vw, 30px); line-height: 1.15; font-weight: 650; }
.help { color: var(--muted); margin: -8px 0 0; font-size: 16px; }
.lead { font-size: 19px; margin: 0; max-width: 34em; }

/* Caras */
.faces { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.face {
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--r);
  padding: 12px 2px 10px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  cursor: pointer; transition: transform .12s ease, opacity .2s, border-color .2s;
  min-height: 124px; min-width: 0;
}
.face svg { width: min(58px, 13vw); height: auto; }
.face .lbl { font-size: 13px; line-height: 1.15; text-align: center; font-weight: 700; hyphens: auto; overflow-wrap: anywhere; }
.face:active { transform: scale(.96); }
.faces.has-sel .face:not(.on) { opacity: .45; }
.face.on { border-color: var(--ink); background: var(--sel); }
.na-btn {
  align-self: center; background: transparent; border: 1px dashed var(--line); border-radius: 999px;
  padding: 10px 18px; color: var(--muted); font-size: 15px; cursor: pointer; min-height: 44px;
}
.na-btn.on { border-style: solid; border-color: var(--ink); color: var(--ink); background: var(--sel); }

/* Grelha: em telemóvel, texto por cima e 5 caras por baixo; em ecrãs largos, lado a lado */
.minis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; justify-items: center; }
.legend { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 61px); z-index: 4; background: var(--bg); padding: 8px 0; border-bottom: 1px solid var(--line); }
.legend .lsp { display: none; }
.legend span { font-size: 11px; text-align: center; color: var(--muted); line-height: 1.1; }
.rows { display: flex; flex-direction: column; }
.row { padding: 12px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.row .t { font-size: 17px; line-height: 1.25; min-width: 0; font-weight: 700; }
.mini { width: 48px; height: 48px; border-radius: 50%; border: 2px solid transparent; background: transparent; padding: 2px; cursor: pointer; transition: opacity .2s, transform .12s; }
.mini svg { width: 100%; height: 100%; display: block; }
.row.has-sel .mini:not(.on) { opacity: .3; }
.mini.on { border-color: var(--ink); }
.mini:active { transform: scale(.92); }
.row .na-link { align-self: flex-start; background: none; border: 0; padding: 0; font-size: 14px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; min-height: 32px; }
.row .na-link.on { color: var(--ink); font-weight: 700; text-decoration: none; }
.row .na-link.on::before { content: "✓ "; }
@media (min-width: 640px) {
  .legend { display: grid; grid-template-columns: 1fr 270px; gap: 8px; align-items: end; }
  .legend .lsp { display: block; }
  .row { display: grid; grid-template-columns: 1fr 270px; gap: 4px 8px; align-items: center; }
  .row .t { font-weight: 400; }
  .row .na-link { grid-column: 1; justify-self: start; }
}

/* Opções */
.opts { display: grid; gap: 10px; }
.opts.c2 { grid-template-columns: 1fr 1fr; }
.opt {
  text-align: left; background: var(--surface); border: 2px solid var(--line); border-radius: var(--r);
  padding: 15px 16px; min-height: 58px; cursor: pointer; display: flex; align-items: center; gap: 12px;
  font-size: 18px; line-height: 1.25; transition: border-color .15s, background .15s;
}
.opt .box { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--muted); flex: none; display: grid; place-items: center; }
.opt.multi .box { border-radius: 6px; }
.opt.on { border-color: var(--ink); background: var(--sel); }
.opt.on .box { background: var(--ink); border-color: var(--ink); }
.opt.on .box::after { content: ""; width: 10px; height: 6px; border: 3px solid var(--bg); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.opt[disabled] { opacity: .45; cursor: not-allowed; }
.counter { font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; }

textarea, input[type="text"], input[type="password"] {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 2px solid var(--line); border-radius: var(--r); padding: 14px 16px;
}
textarea { min-height: 150px; resize: vertical; }
textarea:focus, input:focus { border-color: var(--ink); outline: none; }

/* Botões de navegação */
.actions { display: flex; gap: 12px; align-items: center; margin-top: auto; padding-top: 8px; flex-wrap: wrap; }
.btn {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px;
  padding: 16px 28px; font-weight: 700; font-size: 18px; cursor: pointer; min-height: 56px;
}
.btn.wide { flex: 1; }
.btn.ghost { background: transparent; color: var(--ink); border: 2px solid var(--line); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.skip { background: none; border: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 12px 6px; font-size: 16px; }

/* Ecrãs especiais */
.hero { display: flex; flex-direction: column; gap: 18px; padding-top: 8px; }
.kicker { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; color: var(--gold); text-transform: uppercase; letter-spacing: .08em; }
.facts { display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--muted); font-size: 15px; margin: 0; padding: 0; list-style: none; }
.facts li { display: flex; align-items: center; gap: 6px; }
.choose { display: grid; gap: 12px; }
.card-link {
  display: flex; align-items: center; gap: 16px; text-decoration: none; color: inherit;
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--r); padding: 18px;
}
.card-link:hover { border-color: var(--ink); }
.card-link strong { display: block; font-family: var(--font-display); font-size: 22px; letter-spacing: -0.01em; }
.card-link span { color: var(--muted); font-size: 15px; }
.card-link svg { width: 48px; height: 48px; flex: none; }
.staff { border-top: 1px solid var(--line); padding-top: 16px; display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 15px; }
.staff a { color: var(--muted); }
.notice { background: var(--warn-bg); color: var(--warn-ink); border-radius: 10px; padding: 10px 14px; font-size: 14px; }
.err { color: #C0392B; font-size: 15px; margin: 0; }
:root[data-theme="dark"] .err { color: #FF8A80; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .err { color: #FF8A80; } }
.thanks { align-items: center; text-align: center; justify-content: center; flex: 1; display: flex; flex-direction: column; gap: 16px; }
.thanks svg { width: 120px; height: 120px; animation: pop .5s ease both; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 12px 16px 20px; }
.pending { display: inline-block; background: var(--warn-bg); color: var(--warn-ink); border-radius: 999px; padding: 2px 10px; margin-left: 6px; }

.screen { animation: slide .22s ease both; }
@keyframes slide { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
.screen.backward { animation-name: slideb; }
@keyframes slideb { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .screen, .thanks svg, .progress i { animation: none !important; transition: none !important; } }

@media (max-width: 380px) {
  body { font-size: 17px; }
  .face { min-height: 112px; padding: 10px 1px 8px; }
  .face .lbl { font-size: 11.5px; }
  .faces { gap: 4px; }
  .mini { width: 44px; height: 44px; }
  .opts.c2 { grid-template-columns: 1fr; }
}
/* Tablets em modo quiosque */
@media (min-width: 900px) {
  body { font-size: 20px; }
  .main { max-width: 760px; }
  .top-row { max-width: 760px; }
  .face { min-height: 160px; }
  .face svg { width: 76px; }
  .face .lbl { font-size: 16px; }
}
