/* BUSCA MEDIEVAL — estilos da interface (autor: Hélvio Jorge) */
:root {
  --pergaminho: #f3e4c0;
  --pergaminho-escuro: #e2cc98;
  --tinta: #3b2612;
  --ouro: #e9c34a;
  --ouro-escuro: #a8791a;
  --madeira: #6b4423;
  --madeira-clara: #8d5a2f;
  --vermelho: #9c1f24;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #0d0906;
  font-family: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  color: var(--tinta);
}
body { display: flex; align-items: center; justify-content: center; }
/* a moldura ocupa o maior rectângulo 16:9 que cabe na janela; o palco (960×540) é escalado lá dentro */
#moldura {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  max-width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 40px rgba(0,0,0,0.8);
}
#palco {
  position: absolute; left: 0; top: 0;
  width: 960px; height: 540px;
  transform-origin: 0 0;
  overflow: hidden;
  background: #000;
  outline: none;
}
#tela { display: block; width: 960px; height: 540px; image-rendering: auto; }

.ecra {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column; align-items: center; justify-content: center;
}
.ecra.visivel { display: flex; }
.painel-ecra { background: rgba(10, 6, 3, 0.55); }

/* ---------- ecrã inicial ---------- */
#ecra-inicial { justify-content: flex-start; padding-top: 34px; }
.cabecalho-titulo {
  text-align: center;
  padding: 14px 46px 12px;
  background: linear-gradient(180deg, rgba(30,15,40,0.75), rgba(30,15,40,0.45));
  border: 3px solid var(--ouro-escuro);
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.6), inset 0 0 18px rgba(233,195,74,0.25);
}
.titulo {
  margin: 0;
  font-size: 70px; letter-spacing: 6px; line-height: 1.05;
  font-weight: bold;
  color: #ffd86b;
  background: linear-gradient(180deg, #fff3b0 0%, #ffd54f 45%, #c98a12 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 3px 0 #4a2a08) drop-shadow(0 0 10px rgba(255,200,80,0.35));
}
.autor {
  margin: 6px 0 0;
  font-size: 28px; font-weight: bold; letter-spacing: 1px;
  color: #fff8e1;
  text-shadow: 0 2px 0 #3b2612, 0 0 8px rgba(0,0,0,0.9);
}
.painel .autor { color: var(--vermelho); text-shadow: none; font-size: 24px; text-align: center; }
.menu { display: flex; flex-direction: column; gap: 9px; margin-top: 22px; width: 300px; }
.rodape {
  position: absolute; bottom: 8px; margin: 0;
  color: #f3e2b3; font-size: 14px; text-shadow: 0 1px 2px #000;
}

button {
  font-family: inherit; font-size: 20px; font-weight: bold;
  color: #fff4d6;
  background: linear-gradient(180deg, var(--madeira-clara), var(--madeira));
  border: 2px solid var(--ouro-escuro);
  border-radius: 8px;
  padding: 8px 18px;
  cursor: pointer;
  text-shadow: 0 1px 0 #2a1608;
  box-shadow: 0 3px 0 #2a1608, inset 0 1px 0 rgba(255,255,255,0.2);
  transition: transform 0.06s, filter 0.1s;
}
button:hover, button:focus-visible { filter: brightness(1.18); outline: none; border-color: var(--ouro); box-shadow: 0 3px 0 #2a1608, 0 0 0 3px rgba(255,215,90,0.55); }
button:active { transform: translateY(2px); box-shadow: 0 1px 0 #2a1608; }
.pequeno-btn { font-size: 15px; padding: 5px 12px; }

/* ---------- painéis ---------- */
.painel {
  background: linear-gradient(180deg, var(--pergaminho), var(--pergaminho-escuro));
  border: 4px solid var(--madeira);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.7), inset 0 0 30px rgba(120,80,20,0.25);
  padding: 18px 28px;
  width: 520px; max-height: 510px; overflow: auto;
}
.painel.largo { width: 860px; }
.painel h2 { margin: 0 0 10px; text-align: center; font-size: 30px; color: var(--vermelho); }
.painel h2.vitoria { font-size: 27px; color: #7a1a1a; }
.painel h3 { margin: 10px 0 6px; font-size: 19px; color: var(--madeira); }
.painel ul { margin: 0; padding-left: 20px; font-size: 15.5px; line-height: 1.4; }
.painel li { margin-bottom: 4px; }
.colunas { display: grid; grid-template-columns: 1fr 1.25fr; gap: 26px; }
.teclas { border-collapse: collapse; font-size: 15.5px; }
.teclas td { padding: 5px 6px; border-bottom: 1px dashed rgba(107,68,35,0.4); vertical-align: middle; }
kbd {
  display: inline-block; min-width: 22px; text-align: center;
  font-family: inherit; font-size: 13px; font-weight: bold;
  background: #fffaf0; border: 1px solid #8d6e63; border-bottom-width: 3px; border-radius: 4px;
  padding: 1px 5px;
}
.pequeno { font-size: 13.5px; color: #5a4028; margin: 6px 0; }
.botoes { display: flex; gap: 12px; justify-content: center; margin-top: 14px; }
.titulo-pequeno { text-align: center; font-size: 26px; font-weight: bold; letter-spacing: 4px; margin: 0; color: var(--madeira); }

fieldset { border: 2px solid rgba(107,68,35,0.5); border-radius: 8px; margin: 8px 0; padding: 8px 14px; }
legend { font-weight: bold; color: var(--madeira); padding: 0 6px; }
.linha { display: flex; align-items: center; gap: 10px; margin: 6px 0; font-size: 17px; }
input[type=range] { flex: 1; accent-color: var(--madeira); }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--madeira); }
input[type=text] {
  font-family: inherit; font-size: 16px; padding: 4px 8px; width: 170px;
  border: 2px solid var(--madeira); border-radius: 6px; background: #fffaf0;
}

.tabela-recordes { max-height: 330px; overflow: auto; }
#tabela-recordes { width: 100%; border-collapse: collapse; font-size: 15px; }
#tabela-recordes th { background: var(--madeira); color: #fff4d6; padding: 5px; position: sticky; top: 0; }
#tabela-recordes td { padding: 4px 6px; border-bottom: 1px solid rgba(107,68,35,0.3); text-align: center; }
#tabela-recordes tr.primeiro td { font-weight: bold; background: rgba(233,195,74,0.35); }
#tabela-recordes .vazio { padding: 20px; font-style: italic; }

.creditos { margin: 6px 0; font-size: 15px; }
.creditos dt { font-weight: bold; color: var(--madeira); margin-top: 6px; }
.creditos dd { margin: 0 0 0 16px; }
.pendente { color: #9c1f24; font-weight: bold; }

.estatisticas { margin: 8px auto; border-collapse: collapse; font-size: 18px; min-width: 330px; }
.estatisticas td { padding: 4px 10px; border-bottom: 1px dashed rgba(107,68,35,0.4); }
.estatisticas td:last-child { text-align: right; font-weight: bold; }
.estrelas-grandes { text-align: center; font-size: 44px; color: #f9a825; text-shadow: 0 2px 0 #7a4a00; letter-spacing: 8px; }
.destaque-recorde {
  text-align: center; font-size: 24px; font-weight: bold; margin: 4px 0;
  color: #b8860b; text-shadow: 0 0 8px rgba(255,215,0,0.7);
  animation: pulsar 0.9s ease-in-out infinite alternate;
}
@keyframes pulsar { from { transform: scale(1); } to { transform: scale(1.08); } }
.nome-recorde { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; font-size: 15px; margin-top: 6px; }
.estado-nome { min-width: 100px; }

/* ---------- controlos tácteis ---------- */
#toque { position: absolute; inset: 0; pointer-events: none; }
.t-btn {
  position: absolute; pointer-events: auto;
  width: 92px; height: 92px; border-radius: 50%;
  font-size: 34px; line-height: 1; padding: 0;
  color: #fff4d6; background: rgba(60,36,16,0.55);
  border: 3px solid rgba(233,195,74,0.75);
  box-shadow: none; text-shadow: 0 2px 2px #000;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.t-btn.activo { background: rgba(233,195,74,0.6); }
.t-esq { left: 24px; bottom: 24px; }
.t-dir { left: 134px; bottom: 24px; }
.t-espada { right: 134px; bottom: 24px; }
.t-saltar { right: 24px; bottom: 70px; width: 104px; height: 104px; }
.t-pausa { right: 20px; top: 76px; width: 60px; height: 60px; font-size: 20px; }
